L2ZoneForm.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.zone;
  20. import com.l2jserver.gameserver.idfactory.IdFactory;
  21. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  22. import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
  23. /**
  24. * Abstract base class for any zone form
  25. * @author durgus
  26. */
  27. public abstract class L2ZoneForm
  28. {
  29. protected static final int STEP = 10;
  30. public abstract boolean isInsideZone(int x, int y, int z);
  31. public abstract boolean intersectsRectangle(int x1, int x2, int y1, int y2);
  32. public abstract double getDistanceToZone(int x, int y);
  33. public abstract int getLowZ(); // Support for the ability to extract the z coordinates of zones.
  34. public abstract int getHighZ(); // New fishing patch makes use of that to get the Z for the hook
  35. // landing coordinates.
  36. protected boolean lineSegmentsIntersect(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
  37. {
  38. return java.awt.geom.Line2D.linesIntersect(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
  39. }
  40. public abstract void visualizeZone(int z);
  41. protected final void dropDebugItem(int itemId, int num, int x, int y, int z)
  42. {
  43. L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), itemId);
  44. item.setCount(num);
  45. item.spawnMe(x, y, z + 5);
  46. ZoneManager.getInstance().getDebugItems().add(item);
  47. }
  48. public abstract int[] getRandomPoint();
  49. }