L2Object.java 20 KB

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