DimensionalRiftRoom.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model;
  20. import java.awt.Polygon;
  21. import java.awt.Shape;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. import com.l2jserver.util.Rnd;
  25. /**
  26. * Dimensional Rift Room.
  27. * @author xban1x
  28. */
  29. public final class DimensionalRiftRoom
  30. {
  31. private final byte _type;
  32. private final byte _room;
  33. private final int _xMin;
  34. private final int _xMax;
  35. private final int _yMin;
  36. private final int _yMax;
  37. private final int _zMin;
  38. private final int _zMax;
  39. private final Location _teleportCoords;
  40. private final Shape _s;
  41. private final boolean _isBossRoom;
  42. private final List<L2Spawn> _roomSpawns = new ArrayList<>();
  43. private boolean _partyInside = false;
  44. public DimensionalRiftRoom(byte type, byte room, int xMin, int xMax, int yMin, int yMax, int zMin, int zMax, int xT, int yT, int zT, boolean isBossRoom)
  45. {
  46. _type = type;
  47. _room = room;
  48. _xMin = (xMin + 128);
  49. _xMax = (xMax - 128);
  50. _yMin = (yMin + 128);
  51. _yMax = (yMax - 128);
  52. _zMin = zMin;
  53. _zMax = zMax;
  54. _teleportCoords = new Location(xT, yT, zT);
  55. _isBossRoom = isBossRoom;
  56. _s = new Polygon(new int[]
  57. {
  58. xMin,
  59. xMax,
  60. xMax,
  61. xMin
  62. }, new int[]
  63. {
  64. yMin,
  65. yMin,
  66. yMax,
  67. yMax
  68. }, 4);
  69. }
  70. public byte getType()
  71. {
  72. return _type;
  73. }
  74. public byte getRoom()
  75. {
  76. return _room;
  77. }
  78. public int getRandomX()
  79. {
  80. return Rnd.get(_xMin, _xMax);
  81. }
  82. public int getRandomY()
  83. {
  84. return Rnd.get(_yMin, _yMax);
  85. }
  86. public Location getTeleportCoorinates()
  87. {
  88. return _teleportCoords;
  89. }
  90. public boolean checkIfInZone(int x, int y, int z)
  91. {
  92. return _s.contains(x, y) && (z >= _zMin) && (z <= _zMax);
  93. }
  94. public boolean isBossRoom()
  95. {
  96. return _isBossRoom;
  97. }
  98. public List<L2Spawn> getSpawns()
  99. {
  100. return _roomSpawns;
  101. }
  102. public void spawn()
  103. {
  104. for (L2Spawn spawn : _roomSpawns)
  105. {
  106. spawn.doSpawn();
  107. spawn.startRespawn();
  108. }
  109. }
  110. public DimensionalRiftRoom unspawn()
  111. {
  112. for (L2Spawn spawn : _roomSpawns)
  113. {
  114. spawn.stopRespawn();
  115. if (spawn.getLastSpawn() != null)
  116. {
  117. spawn.getLastSpawn().deleteMe();
  118. }
  119. }
  120. return this;
  121. }
  122. /**
  123. * Returns if party is inside the room.
  124. * @return {@code true} if there is a party inside, {@code false} otherwise
  125. */
  126. public boolean isPartyInside()
  127. {
  128. return _partyInside;
  129. }
  130. /**
  131. * Sets the party inside.
  132. * @param partyInside
  133. */
  134. public void setPartyInside(boolean partyInside)
  135. {
  136. _partyInside = partyInside;
  137. }
  138. }