2
0

DimensionalRiftRoom.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /*
  2. * Copyright (C) 2004-2014 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 javolution.util.FastList;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  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 int[] _teleportCoords;
  40. private final Shape _s;
  41. private final boolean _isBossRoom;
  42. private final FastList<L2Spawn> _roomSpawns;
  43. protected final FastList<L2Npc> _roomMobs;
  44. private boolean _partyInside = false;
  45. 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)
  46. {
  47. _type = type;
  48. _room = room;
  49. _xMin = (xMin + 128);
  50. _xMax = (xMax - 128);
  51. _yMin = (yMin + 128);
  52. _yMax = (yMax - 128);
  53. _zMin = zMin;
  54. _zMax = zMax;
  55. _teleportCoords = new int[]
  56. {
  57. xT,
  58. yT,
  59. zT
  60. };
  61. _isBossRoom = isBossRoom;
  62. _roomSpawns = new FastList<>();
  63. _roomMobs = new FastList<>();
  64. _s = new Polygon(new int[]
  65. {
  66. xMin,
  67. xMax,
  68. xMax,
  69. xMin
  70. }, new int[]
  71. {
  72. yMin,
  73. yMin,
  74. yMax,
  75. yMax
  76. }, 4);
  77. }
  78. public byte getType()
  79. {
  80. return _type;
  81. }
  82. public byte getRoom()
  83. {
  84. return _room;
  85. }
  86. public int getRandomX()
  87. {
  88. return Rnd.get(_xMin, _xMax);
  89. }
  90. public int getRandomY()
  91. {
  92. return Rnd.get(_yMin, _yMax);
  93. }
  94. public int[] getTeleportCoorinates()
  95. {
  96. return _teleportCoords;
  97. }
  98. public boolean checkIfInZone(int x, int y, int z)
  99. {
  100. return _s.contains(x, y) && (z >= _zMin) && (z <= _zMax);
  101. }
  102. public boolean isBossRoom()
  103. {
  104. return _isBossRoom;
  105. }
  106. public FastList<L2Spawn> getSpawns()
  107. {
  108. return _roomSpawns;
  109. }
  110. public void spawn()
  111. {
  112. for (L2Spawn spawn : _roomSpawns)
  113. {
  114. spawn.doSpawn();
  115. spawn.startRespawn();
  116. }
  117. }
  118. public DimensionalRiftRoom unspawn()
  119. {
  120. for (L2Spawn spawn : _roomSpawns)
  121. {
  122. spawn.stopRespawn();
  123. if (spawn.getLastSpawn() != null)
  124. {
  125. spawn.getLastSpawn().deleteMe();
  126. }
  127. }
  128. return this;
  129. }
  130. /**
  131. * Returns if party is inside the room.
  132. * @return {@code true} if there is a party inside, {@code false} otherwise
  133. */
  134. public boolean isPartyInside()
  135. {
  136. return _partyInside;
  137. }
  138. /**
  139. * Sets the party inside.
  140. * @param partyInside
  141. */
  142. public void setPartyInside(boolean partyInside)
  143. {
  144. _partyInside = partyInside;
  145. }
  146. }