GeoData.java 4.2 KB

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