GeoData.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.util.Point3D;
  22. /**
  23. *
  24. * @author -Nemesiss-
  25. */
  26. public class GeoData
  27. {
  28. private static Logger _log = Logger.getLogger(GeoData.class.getName());
  29. private static GeoData _instance;
  30. public static GeoData getInstance()
  31. {
  32. if(_instance == null)
  33. {
  34. if (Config.GEODATA > 0)
  35. _instance = GeoEngine.getInstance();
  36. else
  37. {
  38. _instance = new GeoData();
  39. _log.info("Geodata Engine: Disabled.");
  40. }
  41. }
  42. return _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, int spawnid)
  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. /**
  103. * @param cha
  104. * @param target
  105. * @return True if cha can see target (LOS) and send usful info to PC
  106. */
  107. public boolean canSeeTargetDebug(L2PcInstance gm, L2Object target)
  108. {
  109. return true;
  110. }
  111. /**
  112. * @param x
  113. * @param y
  114. * @param z
  115. * @return Geo NSWE (0-15)
  116. */
  117. public short getNSWE(int x, int y, int z)
  118. {
  119. return 15;
  120. }
  121. /**
  122. * @param x
  123. * @param y
  124. * @param z
  125. * @param tx
  126. * @param ty
  127. * @param tz
  128. * @return Last Location (x,y,z) where player can walk - just befor wall
  129. */
  130. public Location moveCheck(int x, int y, int z, int tx, int ty, int tz)
  131. {
  132. return new Location(tx,ty,tz);
  133. }
  134. /**
  135. * @param gm
  136. * @param comment
  137. */
  138. public void addGeoDataBug(L2PcInstance gm, String comment)
  139. {
  140. //Do Nothing
  141. }
  142. public static void unloadGeodata(byte rx, byte ry)
  143. {
  144. }
  145. public static boolean loadGeodataFile(byte rx, byte ry)
  146. {
  147. return false;
  148. }
  149. public boolean hasGeo(int x, int y)
  150. {
  151. return false;
  152. }
  153. }