OlympiadStadium.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 net.sf.l2j.gameserver.model.olympiad;
  16. import net.sf.l2j.gameserver.datatables.DoorTable;
  17. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  18. import net.sf.l2j.util.L2FastList;
  19. /**
  20. * @author GodKratos
  21. */
  22. class OlympiadStadium
  23. {
  24. private boolean _freeToUse = true;
  25. private static DoorTable _doorTable;
  26. private int[] _coords = new int[3];
  27. private int[] _doors = new int[2];
  28. private L2FastList<L2PcInstance> _spectators;
  29. public boolean isFreeToUse()
  30. {
  31. return _freeToUse;
  32. }
  33. public void setStadiaBusy()
  34. {
  35. _freeToUse = false;
  36. }
  37. public void setStadiaFree()
  38. {
  39. _freeToUse = true;
  40. }
  41. public int[] getCoordinates()
  42. {
  43. return _coords;
  44. }
  45. public int[] getDoorID()
  46. {
  47. return _doors;
  48. }
  49. public OlympiadStadium(int x, int y, int z, int d1, int d2)
  50. {
  51. _coords[0] = x;
  52. _coords[1] = y;
  53. _coords[2] = z;
  54. _doors[0] = d1;
  55. _doors[1] = d2;
  56. _spectators = new L2FastList<L2PcInstance>();
  57. }
  58. public void openDoors()
  59. {
  60. _doorTable = DoorTable.getInstance();
  61. try
  62. {
  63. _doorTable.getDoor(getDoorID()[0]).openMe();
  64. _doorTable.getDoor(getDoorID()[1]).openMe();
  65. }
  66. catch (Exception e)
  67. {
  68. }
  69. }
  70. public void closeDoors()
  71. {
  72. _doorTable = DoorTable.getInstance();
  73. try
  74. {
  75. _doorTable.getDoor(getDoorID()[0]).closeMe();
  76. _doorTable.getDoor(getDoorID()[1]).closeMe();
  77. }
  78. catch (Exception e)
  79. {
  80. }
  81. }
  82. protected void addSpectator(int id, L2PcInstance spec, boolean storeCoords)
  83. {
  84. spec.enterOlympiadObserverMode(getCoordinates()[0] + 1200, getCoordinates()[1], getCoordinates()[2], id, storeCoords);
  85. _spectators.add(spec);
  86. }
  87. protected L2FastList<L2PcInstance> getSpectators()
  88. {
  89. return _spectators;
  90. }
  91. protected void removeSpectator(L2PcInstance spec)
  92. {
  93. if (_spectators != null && _spectators.contains(spec))
  94. _spectators.remove(spec);
  95. }
  96. }