L2Object.java 20 KB

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