GeoData.java 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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;
  16. import java.util.logging.Logger;
  17. import net.sf.l2j.Config;
  18. import net.sf.l2j.gameserver.model.L2Object;
  19. import net.sf.l2j.gameserver.model.Location;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.pathfinding.Node;
  22. import net.sf.l2j.util.Point3D;
  23. /**
  24. *
  25. * @author -Nemesiss-
  26. */
  27. public class GeoData
  28. {
  29. private static Logger _log = Logger.getLogger(GeoData.class.getName());
  30. private static GeoData _instance;
  31. public static GeoData getInstance()
  32. {
  33. if(_instance == null)
  34. {
  35. if (Config.GEODATA > 0)
  36. _instance = GeoEngine.getInstance();
  37. else
  38. {
  39. _instance = new GeoData();
  40. _log.info("Geodata Engine: Disabled.");
  41. }
  42. }
  43. return _instance;
  44. }
  45. // Public Methods
  46. /**
  47. * @param x
  48. * @param y
  49. * @return Geo Block Type
  50. */
  51. public short getType (int x, int y)
  52. {
  53. return 0;
  54. }
  55. /**
  56. * @param x
  57. * @param y
  58. * @param z
  59. * @return Nearles Z
  60. */
  61. public short getHeight(int x, int y, int z)
  62. {
  63. return (short)z;
  64. }
  65. /**
  66. * @param x
  67. * @param y
  68. * @param zmin
  69. * @param zmax
  70. * @param spawnid
  71. * @return
  72. */
  73. public short getSpawnHeight(int x, int y, int zmin, int zmax, int spawnid)
  74. {
  75. return (short)zmin;
  76. }
  77. /**
  78. * @param x
  79. * @param y
  80. * @return
  81. */
  82. public String geoPosition(int x, int y)
  83. {
  84. return "";
  85. }
  86. /**
  87. * @param cha
  88. * @param target
  89. * @return True if cha can see target (LOS)
  90. */
  91. public boolean canSeeTarget(L2Object cha, L2Object target)
  92. {
  93. //If geo is off do simple check :]
  94. //Don't allow casting on players on different dungeon lvls etc
  95. return (Math.abs(target.getZ() - cha.getZ()) < 1000);
  96. }
  97. public boolean canSeeTarget(L2Object cha, Point3D worldPosition)
  98. {
  99. //If geo is off do simple check :]
  100. //Don't allow casting on players on different dungeon lvls etc
  101. return Math.abs(worldPosition.getZ() - cha.getZ()) < 1000;
  102. }
  103. public boolean canSeeTarget(int x, int y, int z, int tx, int ty, int tz)
  104. {
  105. // If geo is off do simple check :]
  106. // Don't allow casting on players on different dungeon lvls etc
  107. return (Math.abs(z - tz) < 1000);
  108. }
  109. /**
  110. * @param cha
  111. * @param target
  112. * @return True if cha can see target (LOS) and send usful info to PC
  113. */
  114. public boolean canSeeTargetDebug(L2PcInstance gm, L2Object target)
  115. {
  116. return true;
  117. }
  118. /**
  119. * @param x
  120. * @param y
  121. * @param z
  122. * @return Geo NSWE (0-15)
  123. */
  124. public short getNSWE(int x, int y, int z)
  125. {
  126. return 15;
  127. }
  128. /**
  129. * @param x
  130. * @param y
  131. * @param z
  132. * @param tx
  133. * @param ty
  134. * @param tz
  135. * @return Last Location (x,y,z) where player can walk - just befor wall
  136. */
  137. public Location moveCheck(int x, int y, int z, int tx, int ty, int tz)
  138. {
  139. return new Location(tx,ty,tz);
  140. }
  141. public boolean canMoveFromToTarget(int x, int y, int z, int tx, int ty, int tz)
  142. {
  143. return true;
  144. }
  145. /**
  146. * @param gm
  147. * @param comment
  148. */
  149. public void addGeoDataBug(L2PcInstance gm, String comment)
  150. {
  151. //Do Nothing
  152. }
  153. public static void unloadGeodata(byte rx, byte ry)
  154. {
  155. }
  156. public static boolean loadGeodataFile(byte rx, byte ry)
  157. {
  158. return false;
  159. }
  160. public boolean hasGeo(int x, int y)
  161. {
  162. return false;
  163. }
  164. public Node[] getNeighbors(Node n)
  165. {
  166. return null;
  167. }
  168. }