L2ZoneForm.java 2.0 KB

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