OlympiadStadium.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model.olympiad;
  16. import java.util.List;
  17. import java.util.logging.Level;
  18. import java.util.logging.Logger;
  19. import com.l2jserver.gameserver.datatables.DoorTable;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.util.L2FastList;
  22. /**
  23. * @author GodKratos
  24. */
  25. class OlympiadStadium
  26. {
  27. private static final Logger _log = Logger.getLogger(OlympiadStadium.class.getName());
  28. private boolean _freeToUse = true;
  29. private static DoorTable _doorTable;
  30. private int[] _coords = new int[3];
  31. private int[] _doors = new int[2];
  32. private List<L2PcInstance> _spectators;
  33. public boolean isFreeToUse()
  34. {
  35. return _freeToUse;
  36. }
  37. public void setStadiaBusy()
  38. {
  39. _freeToUse = false;
  40. }
  41. public void setStadiaFree()
  42. {
  43. _freeToUse = true;
  44. }
  45. public int[] getCoordinates()
  46. {
  47. return _coords;
  48. }
  49. public int[] getDoorID()
  50. {
  51. return _doors;
  52. }
  53. public OlympiadStadium(int x, int y, int z, int d1, int d2)
  54. {
  55. _coords[0] = x;
  56. _coords[1] = y;
  57. _coords[2] = z;
  58. _doors[0] = d1;
  59. _doors[1] = d2;
  60. _spectators = new L2FastList<L2PcInstance>().shared();
  61. }
  62. public void openDoors()
  63. {
  64. _doorTable = DoorTable.getInstance();
  65. try
  66. {
  67. _doorTable.getDoor(getDoorID()[0]).openMe();
  68. _doorTable.getDoor(getDoorID()[1]).openMe();
  69. }
  70. catch (Exception e)
  71. {
  72. _log.log(Level.WARNING, "", e);
  73. }
  74. }
  75. public void closeDoors()
  76. {
  77. _doorTable = DoorTable.getInstance();
  78. try
  79. {
  80. _doorTable.getDoor(getDoorID()[0]).closeMe();
  81. _doorTable.getDoor(getDoorID()[1]).closeMe();
  82. }
  83. catch (Exception e)
  84. {
  85. _log.log(Level.WARNING, "", e);
  86. }
  87. }
  88. protected void addSpectator(int id, L2PcInstance spec, boolean storeCoords)
  89. {
  90. spec.enterOlympiadObserverMode(getCoordinates()[0] + 1200, getCoordinates()[1], getCoordinates()[2], id, storeCoords);
  91. _spectators.add(spec);
  92. }
  93. protected List<L2PcInstance> getSpectators()
  94. {
  95. return _spectators;
  96. }
  97. protected void removeSpectator(L2PcInstance spec)
  98. {
  99. if (_spectators != null && _spectators.contains(spec))
  100. _spectators.remove(spec);
  101. }
  102. }