StaticObject.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.network.serverpackets;
  16. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  17. import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
  18. /**
  19. *
  20. *
  21. * @author KenM
  22. */
  23. public class StaticObject extends L2GameServerPacket
  24. {
  25. private final int _staticObjectId;
  26. private final int _objectId;
  27. private final int _type;
  28. private final boolean _isTargetable;
  29. private final int _meshIndex;
  30. private final boolean _isClosed;
  31. private final boolean _isEnemy;
  32. private final int _maxHp;
  33. private final int _currentHp;
  34. private final boolean _showHp;
  35. private final int _damageGrade;
  36. public StaticObject(L2StaticObjectInstance staticObject)
  37. {
  38. _staticObjectId = staticObject.getStaticObjectId();
  39. _objectId = staticObject.getObjectId();
  40. _type = 0;
  41. _isTargetable = true;
  42. _meshIndex = staticObject.getMeshIndex();
  43. _isClosed = false;
  44. _isEnemy = false;
  45. _maxHp = 0;
  46. _currentHp = 0;
  47. _showHp = false;
  48. _damageGrade = 0;
  49. }
  50. public StaticObject(L2DoorInstance door, boolean showHp)
  51. {
  52. _staticObjectId = door.getDoorId();
  53. _objectId = door.getObjectId();
  54. _type = 1;
  55. _isTargetable = true;
  56. _meshIndex = 1;
  57. _isClosed = !door.getOpen();
  58. _isEnemy = door.isEnemy();
  59. _maxHp = door.getMaxHp();
  60. _currentHp = (int) door.getCurrentHp();
  61. _showHp = door.getIsShowHp() || showHp;
  62. _damageGrade = door.getDamage();
  63. }
  64. @Override
  65. protected final void writeImpl()
  66. {
  67. writeC(0x9f);
  68. writeD(_staticObjectId);
  69. writeD(_objectId);
  70. writeD(_type);
  71. writeD(_isTargetable ? 1 : 0);
  72. writeD(_meshIndex);
  73. writeD(_isClosed ? 1 : 0);
  74. writeD(_isEnemy ? 1 : 0);
  75. writeD(_currentHp);
  76. writeD(_maxHp);
  77. writeD(_showHp ? 1 : 0);
  78. writeD(_damageGrade);
  79. }
  80. /* (non-Javadoc)
  81. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  82. */
  83. @Override
  84. public String getType()
  85. {
  86. return "[S] 9f StaticObject";
  87. }
  88. }