L2SpawnZone.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.zone;
  16. import java.util.List;
  17. import javolution.util.FastList;
  18. import com.l2jserver.gameserver.model.Location;
  19. import com.l2jserver.util.Rnd;
  20. /**
  21. * Abstract zone with spawn locations
  22. * @author DS
  23. *
  24. */
  25. public abstract class L2SpawnZone extends L2ZoneType
  26. {
  27. private List<Location> _spawnLocs = null;
  28. private List<Location> _chaoticSpawnLocs = null;
  29. public L2SpawnZone(int id)
  30. {
  31. super(id);
  32. }
  33. public final void addSpawn(int x, int y, int z)
  34. {
  35. if (_spawnLocs == null)
  36. _spawnLocs = new FastList<Location>();
  37. _spawnLocs.add(new Location(x, y, z));
  38. }
  39. public final void addChaoticSpawn(int x, int y, int z)
  40. {
  41. if (_chaoticSpawnLocs == null)
  42. _chaoticSpawnLocs = new FastList<Location>();
  43. _chaoticSpawnLocs.add(new Location(x, y, z));
  44. }
  45. public Location getSpawnLoc()
  46. {
  47. return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
  48. }
  49. public Location getChaoticSpawnLoc()
  50. {
  51. if (_chaoticSpawnLocs != null)
  52. return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
  53. else
  54. return getSpawnLoc();
  55. }
  56. }