L2Object.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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;
  16. import com.l2jserver.Config;
  17. import com.l2jserver.gameserver.idfactory.IdFactory;
  18. import com.l2jserver.gameserver.instancemanager.InstanceManager;
  19. import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.actor.knownlist.ObjectKnownList;
  24. import com.l2jserver.gameserver.model.actor.poly.ObjectPoly;
  25. import com.l2jserver.gameserver.model.actor.position.ObjectPosition;
  26. import com.l2jserver.gameserver.model.entity.Instance;
  27. import com.l2jserver.gameserver.network.L2GameClient;
  28. import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
  29. import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
  30. /**
  31. * Mother class of all objects in the world wich ones is it possible
  32. * to interact (PC, NPC, Item...)<BR><BR>
  33. *
  34. * L2Object :<BR><BR>
  35. * <li>L2Character</li>
  36. * <li>L2ItemInstance</li>
  37. * <li>L2Potion</li>
  38. *
  39. */
  40. public abstract class L2Object
  41. {
  42. // =========================================================
  43. // Data Field
  44. private boolean _isVisible; // Object visibility
  45. private ObjectKnownList _knownList;
  46. private String _name;
  47. private int _objectId; // Object identifier
  48. private ObjectPoly _poly;
  49. private ObjectPosition _position;
  50. private int _instanceId = 0;
  51. private InstanceType _instanceType = null;
  52. // =========================================================
  53. // Constructor
  54. public L2Object(int objectId)
  55. {
  56. setInstanceType(InstanceType.L2Object);
  57. _objectId = objectId;
  58. initKnownList();
  59. initPosition();
  60. }
  61. public static enum InstanceType
  62. {
  63. L2Object(),
  64. L2Character(L2Object),
  65. L2Npc(L2Object, L2Character),
  66. L2Playable(L2Object, L2Character, L2Npc),
  67. L2Summon(L2Object, L2Character, L2Playable),
  68. L2Decoy(L2Object, L2Character),
  69. L2Trap(L2Object, L2Character),
  70. L2PcInstance(L2Object, L2Character, L2Playable),
  71. L2NpcInstance(L2Object, L2Character, L2Npc),
  72. L2MerchantInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  73. L2StaticObjectInstance(L2Object, L2Character),
  74. L2DoorInstance(L2Object, L2Character),
  75. L2EffectPointInstance(L2Object, L2Character, L2Npc),
  76. // Summons, Pets, Decoys and Traps
  77. L2SummonInstance(L2Object, L2Character, L2Playable, L2Summon),
  78. L2SiegeSummonInstance(L2Object, L2Character, L2Playable, L2Summon, L2SummonInstance),
  79. L2MerchantSummonInstance(L2Object, L2Character, L2Playable, L2Summon, L2SummonInstance),
  80. L2PetInstance(L2Object, L2Character, L2Playable, L2Summon),
  81. L2BabyPetInstance(L2Object, L2Character, L2Playable, L2Summon, L2PetInstance),
  82. L2DecoyInstance(L2Object, L2Character, L2Decoy),
  83. L2TrapInstance(L2Object, L2Character, L2Trap),
  84. // Attackable
  85. L2Attackable(L2Object, L2Character, L2Npc),
  86. L2GuardInstance(L2Object, L2Character, L2Npc, L2Attackable),
  87. L2MonsterInstance(L2Object, L2Character, L2Npc, L2Attackable),
  88. L2ChestInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  89. L2ControllableMobInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  90. L2FeedableBeastInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  91. L2TamedBeastInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance, L2FeedableBeastInstance),
  92. L2FriendlyMobInstance(L2Object, L2Character, L2Npc, L2Attackable),
  93. L2PenaltyMonsterInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  94. L2RiftInvaderInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  95. L2MinionInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  96. L2RaidBossInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  97. L2GrandBossInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance, L2RaidBossInstance),
  98. // FlyMobs
  99. L2FlyNpcInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  100. L2FlyMonsterInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  101. L2FlyMinionInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance, L2MinionInstance),
  102. L2FlyRaidBossInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance, L2RaidBossInstance),
  103. // Sepulchers
  104. L2SepulcherNpcInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  105. L2SepulcherMonsterInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  106. // Festival
  107. L2FestivalGiudeInstance(L2Object, L2Character, L2Npc),
  108. L2FestivalMonsterInstance(L2Object, L2Character, L2Npc, L2Attackable, L2MonsterInstance),
  109. // Ships and controllers
  110. L2BoatInstance(L2Object, L2Character),
  111. L2AirShipInstance(L2Object, L2Character),
  112. L2AirShipControllerInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  113. // Siege
  114. L2DefenderInstance(L2Object, L2Character, L2Npc, L2Attackable),
  115. L2ArtefactInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  116. L2ControlTowerInstance(L2Object, L2Character, L2Npc),
  117. L2FlameTowerInstance(L2Object, L2Character, L2Npc),
  118. L2SiegeFlagInstance(L2Object, L2Character, L2Npc),
  119. L2SiegeNpcInstance(L2Object, L2Character, L2Npc),
  120. // Fort Siege
  121. L2FortBallistaInstance(L2Object, L2Character, L2Npc),
  122. L2FortCommanderInstance(L2Object, L2Character, L2Npc, L2Attackable, L2DefenderInstance),
  123. // Castle NPCs
  124. L2CastleBlacksmithInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  125. L2CastleChamberlainInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  126. L2CastleMagicianInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  127. L2CastleTeleporterInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  128. L2CastleWarehouseInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  129. L2MercManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  130. // Fort NPCs
  131. L2FortEnvoyInstance(L2Object, L2Character, L2Npc),
  132. L2FortLogisticsInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  133. L2FortManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  134. L2FortSiegeNpcInstance(L2Object, L2Character, L2Npc),
  135. L2FortSupportCaptainInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  136. // Seven Signs
  137. L2CabaleBufferInstance(L2Object, L2Character, L2Npc),
  138. L2SignsPriestInstance(L2Object, L2Character, L2Npc),
  139. L2DawnPriestInstance(L2Object, L2Character, L2Npc, L2SignsPriestInstance),
  140. L2DuskPriestInstance(L2Object, L2Character, L2Npc, L2SignsPriestInstance),
  141. L2DungeonGatekeeperInstance(L2Object, L2Character, L2Npc),
  142. // City NPCs
  143. L2AdventurerInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  144. L2AuctioneerInstance(L2Object, L2Character, L2Npc),
  145. L2ClanHallManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  146. L2ClanTraderInstance(L2Object, L2Character, L2Npc),
  147. L2FameManagerInstance(L2Object, L2Character, L2Npc),
  148. L2FishermanInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  149. L2ManorManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  150. L2MercenaryManagerInstance(L2Object, L2Character, L2Npc),
  151. L2NpcWalkerInstance(L2Object, L2Character, L2Npc),
  152. L2ObservationInstance(L2Object, L2Character, L2Npc),
  153. L2OlympiadManagerInstance(L2Object, L2Character, L2Npc),
  154. L2PetManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  155. L2RaceManagerInstance(L2Object, L2Character, L2Npc),
  156. L2SymbolMakerInstance(L2Object, L2Character, L2Npc),
  157. L2TeleporterInstance(L2Object, L2Character, L2Npc),
  158. L2TownPetInstance(L2Object, L2Character, L2Npc),
  159. L2TrainerInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  160. L2TransformManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2MerchantInstance),
  161. L2VillageMasterInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  162. L2WarehouseInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  163. L2WyvernManagerInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  164. L2XmassTreeInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  165. // Doormens
  166. L2DoormenInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  167. L2CastleDoormenInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2DoormenInstance),
  168. L2FortDoormenInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2DoormenInstance),
  169. L2ClanHallDoormenInstance(L2Object, L2Character, L2Npc, L2NpcInstance, L2DoormenInstance),
  170. // Custom
  171. L2ClassMasterInstance(L2Object, L2Character, L2Npc, L2NpcInstance),
  172. L2NpcBufferInstance(L2Object, L2Character, L2Npc),
  173. L2TvTEventNpcInstance(L2Object, L2Character, L2Npc),
  174. L2WeddingManagerInstance(L2Object, L2Character, L2Npc);
  175. private final long _type;
  176. private InstanceType(InstanceType... parents)
  177. {
  178. long type = 1 << this.ordinal();
  179. if (type == 0)
  180. throw new Error("Too many instance types, failed to load " + this.name());
  181. for (InstanceType i : parents)
  182. type |= 1 << i.ordinal();
  183. _type = type;
  184. }
  185. public final boolean isType(InstanceType i)
  186. {
  187. return (_type & i._type) > 0;
  188. }
  189. }
  190. protected final void setInstanceType(InstanceType i)
  191. {
  192. _instanceType = i;
  193. }
  194. public final boolean isInstanceType(InstanceType i)
  195. {
  196. return _instanceType.isType(i);
  197. }
  198. // =========================================================
  199. // Event - Public
  200. public final void onAction(L2PcInstance player)
  201. {
  202. onAction(player, true);
  203. }
  204. public void onAction(L2PcInstance player, boolean interact)
  205. {
  206. player.sendPacket(ActionFailed.STATIC_PACKET);
  207. }
  208. @Deprecated
  209. public void onActionShift(L2GameClient client)
  210. {
  211. client.getActiveChar().sendPacket(ActionFailed.STATIC_PACKET);
  212. }
  213. public void onActionShift(L2PcInstance player)
  214. {
  215. player.sendPacket(ActionFailed.STATIC_PACKET);
  216. }
  217. public void onForcedAttack(L2PcInstance player)
  218. {
  219. player.sendPacket(ActionFailed.STATIC_PACKET);
  220. }
  221. /**
  222. * Do Nothing.<BR><BR>
  223. *
  224. * <B><U> Overridden in </U> :</B><BR><BR>
  225. * <li> L2GuardInstance : Set the home location of its L2GuardInstance </li>
  226. * <li> L2Attackable : Reset the Spoiled flag </li><BR><BR>
  227. *
  228. */
  229. public void onSpawn()
  230. {
  231. }
  232. // =========================================================
  233. // Position - Should remove to fully move to L2ObjectPosition
  234. public final void setXYZ(int x, int y, int z)
  235. {
  236. getPosition().setXYZ(x, y, z);
  237. }
  238. public final void setXYZInvisible(int x, int y, int z)
  239. {
  240. getPosition().setXYZInvisible(x, y, z);
  241. }
  242. public final int getX()
  243. {
  244. assert getPosition().getWorldRegion() != null || _isVisible;
  245. return getPosition().getX();
  246. }
  247. /**
  248. * @return The id of the instance zone the object is in - id 0 is global
  249. * since everything like dropped items, mobs, players can be in a instanciated area, it must be in l2object
  250. */
  251. public int getInstanceId()
  252. {
  253. return _instanceId;
  254. }
  255. /**
  256. * @param instanceId The id of the instance zone the object is in - id 0 is global
  257. */
  258. public void setInstanceId(int instanceId)
  259. {
  260. if (_instanceId == instanceId)
  261. return;
  262. Instance oldI = InstanceManager.getInstance().getInstance(_instanceId);
  263. Instance newI = InstanceManager.getInstance().getInstance(instanceId);
  264. if (newI == null)
  265. return;
  266. if (this instanceof L2PcInstance)
  267. {
  268. if (_instanceId > 0 && oldI != null)
  269. oldI.removePlayer(getObjectId());
  270. if (instanceId > 0)
  271. newI.addPlayer(getObjectId());
  272. if (((L2PcInstance)this).getPet() != null)
  273. ((L2PcInstance)this).getPet().setInstanceId(instanceId);
  274. }
  275. else if (this instanceof L2Npc)
  276. {
  277. if (_instanceId > 0 && oldI != null)
  278. oldI.removeNpc(((L2Npc)this));
  279. if (instanceId > 0)
  280. newI.addNpc(((L2Npc)this));
  281. }
  282. _instanceId = instanceId;
  283. // If we change it for visible objects, me must clear & revalidate knownlists
  284. if (_isVisible && _knownList != null)
  285. {
  286. if (this instanceof L2PcInstance)
  287. {
  288. // We don't want some ugly looking disappear/appear effects, so don't update
  289. // the knownlist here, but players usually enter instancezones through teleporting
  290. // and the teleport will do the revalidation for us.
  291. }
  292. else
  293. {
  294. decayMe();
  295. spawnMe();
  296. }
  297. }
  298. }
  299. public final int getY()
  300. {
  301. assert getPosition().getWorldRegion() != null || _isVisible;
  302. return getPosition().getY();
  303. }
  304. public final int getZ()
  305. {
  306. assert getPosition().getWorldRegion() != null || _isVisible;
  307. return getPosition().getZ();
  308. }
  309. // =========================================================
  310. // Method - Public
  311. /**
  312. * Remove a L2Object from the world.<BR><BR>
  313. *
  314. * <B><U> Actions</U> :</B><BR><BR>
  315. * <li>Remove the L2Object from the world</li><BR><BR>
  316. *
  317. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR>
  318. * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T SEND Server->Client packets to players</B></FONT><BR><BR>
  319. *
  320. * <B><U> Assert </U> :</B><BR><BR>
  321. * <li> _worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR><BR>
  322. *
  323. * <B><U> Example of use </U> :</B><BR><BR>
  324. * <li> Delete NPC/PC or Unsummon</li><BR><BR>
  325. *
  326. */
  327. public final void decayMe()
  328. {
  329. assert getPosition().getWorldRegion() != null;
  330. L2WorldRegion reg = getPosition().getWorldRegion();
  331. synchronized (this)
  332. {
  333. _isVisible = false;
  334. getPosition().setWorldRegion(null);
  335. }
  336. // this can synchronize on others instancies, so it's out of
  337. // synchronized, to avoid deadlocks
  338. // Remove the L2Object from the world
  339. L2World.getInstance().removeVisibleObject(this, reg);
  340. L2World.getInstance().removeObject(this);
  341. if (Config.SAVE_DROPPED_ITEM)
  342. ItemsOnGroundManager.getInstance().removeObject(this);
  343. }
  344. public void refreshID()
  345. {
  346. L2World.getInstance().removeObject(this);
  347. IdFactory.getInstance().releaseId(getObjectId());
  348. _objectId = IdFactory.getInstance().getNextId();
  349. }
  350. /**
  351. * Init the position of a L2Object spawn and add it in the world as a visible object.<BR><BR>
  352. *
  353. * <B><U> Actions</U> :</B><BR><BR>
  354. * <li>Set the x,y,z position of the L2Object spawn and update its _worldregion </li>
  355. * <li>Add the L2Object spawn in the _allobjects of L2World </li>
  356. * <li>Add the L2Object spawn to _visibleObjects of its L2WorldRegion</li>
  357. * <li>Add the L2Object spawn in the world as a <B>visible</B> object</li><BR><BR>
  358. *
  359. * <B><U> Assert </U> :</B><BR><BR>
  360. * <li> _worldRegion == null <I>(L2Object is invisible at the beginning)</I></li><BR><BR>
  361. *
  362. * <B><U> Example of use </U> :</B><BR><BR>
  363. * <li> Create Door</li>
  364. * <li> Spawn : Monster, Minion, CTs, Summon...</li><BR>
  365. *
  366. */
  367. public final void spawnMe()
  368. {
  369. assert getPosition().getWorldRegion() == null && getPosition().getWorldPosition().getX() != 0 && getPosition().getWorldPosition().getY() != 0 && getPosition().getWorldPosition().getZ() != 0;
  370. synchronized (this)
  371. {
  372. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  373. _isVisible = true;
  374. getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  375. // Add the L2Object spawn in the _allobjects of L2World
  376. L2World.getInstance().storeObject(this);
  377. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  378. getPosition().getWorldRegion().addVisibleObject(this);
  379. }
  380. // this can synchronize on others instancies, so it's out of
  381. // synchronized, to avoid deadlocks
  382. // Add the L2Object spawn in the world as a visible object
  383. L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());
  384. onSpawn();
  385. }
  386. public final void spawnMe(int x, int y, int z)
  387. {
  388. assert getPosition().getWorldRegion() == null;
  389. synchronized (this)
  390. {
  391. // Set the x,y,z position of the L2Object spawn and update its _worldregion
  392. _isVisible = true;
  393. if (x > L2World.MAP_MAX_X) x = L2World.MAP_MAX_X - 5000;
  394. if (x < L2World.MAP_MIN_X) x = L2World.MAP_MIN_X + 5000;
  395. if (y > L2World.MAP_MAX_Y) y = L2World.MAP_MAX_Y - 5000;
  396. if (y < L2World.MAP_MIN_Y) y = L2World.MAP_MIN_Y + 5000;
  397. getPosition().setWorldPosition(x, y ,z);
  398. getPosition().setWorldRegion(L2World.getInstance().getRegion(getPosition().getWorldPosition()));
  399. // Add the L2Object spawn in the _allobjects of L2World
  400. }
  401. L2World.getInstance().storeObject(this);
  402. // these can synchronize on others instancies, so they're out of
  403. // synchronized, to avoid deadlocks
  404. // Add the L2Object spawn to _visibleObjects and if necessary to _allplayers of its L2WorldRegion
  405. getPosition().getWorldRegion().addVisibleObject(this);
  406. // Add the L2Object spawn in the world as a visible object
  407. L2World.getInstance().addVisibleObject(this, getPosition().getWorldRegion());
  408. onSpawn();
  409. }
  410. public void toggleVisible()
  411. {
  412. if (isVisible())
  413. decayMe();
  414. else
  415. spawnMe();
  416. }
  417. // =========================================================
  418. // Method - Private
  419. // =========================================================
  420. // Property - Public
  421. public boolean isAttackable()
  422. {
  423. return false;
  424. }
  425. public abstract boolean isAutoAttackable(L2Character attacker);
  426. public boolean isMarker()
  427. {
  428. return false;
  429. }
  430. /**
  431. * Return the visibilty state of the L2Object. <BR><BR>
  432. *
  433. * <B><U> Concept</U> :</B><BR><BR>
  434. * A L2Object is visble if <B>__IsVisible</B>=true and <B>_worldregion</B>!=null <BR><BR>
  435. */
  436. public final boolean isVisible()
  437. {
  438. //return getPosition().getWorldRegion() != null && _IsVisible;
  439. return getPosition().getWorldRegion() != null;
  440. }
  441. public final void setIsVisible(boolean value)
  442. {
  443. _isVisible = value;
  444. if (!_isVisible) getPosition().setWorldRegion(null);
  445. }
  446. public ObjectKnownList getKnownList()
  447. {
  448. return _knownList;
  449. }
  450. /**
  451. * Initializes the KnownList of the L2Object,
  452. * is overwritten in classes that require a different knownlist Type.
  453. *
  454. * Removes the need for instanceof checks.
  455. */
  456. public void initKnownList()
  457. {
  458. _knownList = new ObjectKnownList(this);
  459. }
  460. public final void setKnownList(ObjectKnownList value)
  461. {
  462. _knownList = value;
  463. }
  464. public final String getName()
  465. {
  466. return _name;
  467. }
  468. public final void setName(String value)
  469. {
  470. _name = value;
  471. }
  472. public final int getObjectId()
  473. {
  474. return _objectId;
  475. }
  476. public final ObjectPoly getPoly()
  477. {
  478. if (_poly == null) _poly = new ObjectPoly(this);
  479. return _poly;
  480. }
  481. public ObjectPosition getPosition()
  482. {
  483. return _position;
  484. }
  485. /**
  486. * Initializes the Position class of the L2Object,
  487. * is overwritten in classes that require a different position Type.
  488. *
  489. * Removes the need for instanceof checks.
  490. */
  491. public void initPosition()
  492. {
  493. _position = new ObjectPosition(this);
  494. }
  495. public final void setObjectPosition(ObjectPosition value)
  496. {
  497. _position = value;
  498. }
  499. /**
  500. * returns reference to region this object is in
  501. */
  502. public L2WorldRegion getWorldRegion()
  503. {
  504. return getPosition().getWorldRegion();
  505. }
  506. public L2PcInstance getActingPlayer()
  507. {
  508. return null;
  509. }
  510. /**
  511. * Sends the Server->Client info packet for the object.<br><br>
  512. * Is Overridden in:
  513. * <li>L2AirShipInstance</li>
  514. * <li>L2BoatInstance</li>
  515. * <li>L2DoorInstance</li>
  516. * <li>L2PcInstance</li>
  517. * <li>L2StaticObjectInstance</li>
  518. * <li>L2Decoy</li>
  519. * <li>L2Npc</li>
  520. * <li>L2Summon</li>
  521. * <li>L2Trap</li>
  522. * <li>L2ItemInstance</li>
  523. */
  524. public void sendInfo(L2PcInstance activeChar)
  525. {
  526. }
  527. @Override
  528. public String toString()
  529. {
  530. return (getClass().getSimpleName() + ":"+getName()+"[" + getObjectId() + "]");
  531. }
  532. /**
  533. * Not Implemented.<BR><BR>
  534. *
  535. * <B><U> Overridden in </U> :</B><BR><BR>
  536. * <li> L2PcInstance</li><BR><BR>
  537. */
  538. public void sendPacket(L2GameServerPacket mov)
  539. {
  540. // default implementation
  541. }
  542. }