GeoData.java 4.2 KB

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