StaticObject.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  21. import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
  22. /**
  23. * @author KenM
  24. */
  25. public class StaticObject extends L2GameServerPacket
  26. {
  27. private final int _staticObjectId;
  28. private final int _objectId;
  29. private final int _type;
  30. private final boolean _isTargetable;
  31. private final int _meshIndex;
  32. private final boolean _isClosed;
  33. private final boolean _isEnemy;
  34. private final int _maxHp;
  35. private final int _currentHp;
  36. private final boolean _showHp;
  37. private final int _damageGrade;
  38. public StaticObject(L2StaticObjectInstance staticObject)
  39. {
  40. _staticObjectId = staticObject.getId();
  41. _objectId = staticObject.getObjectId();
  42. _type = 0;
  43. _isTargetable = true;
  44. _meshIndex = staticObject.getMeshIndex();
  45. _isClosed = false;
  46. _isEnemy = false;
  47. _maxHp = 0;
  48. _currentHp = 0;
  49. _showHp = false;
  50. _damageGrade = 0;
  51. }
  52. public StaticObject(L2DoorInstance door, boolean targetable)
  53. {
  54. _staticObjectId = door.getId();
  55. _objectId = door.getObjectId();
  56. _type = 1;
  57. _isTargetable = door.isTargetable() || targetable;
  58. _meshIndex = door.getMeshIndex();
  59. _isClosed = !door.getOpen();
  60. _isEnemy = door.isEnemy();
  61. _maxHp = door.getMaxHp();
  62. _currentHp = (int) door.getCurrentHp();
  63. _showHp = door.getIsShowHp();
  64. _damageGrade = door.getDamage();
  65. }
  66. @Override
  67. protected final void writeImpl()
  68. {
  69. writeC(0x9f);
  70. writeD(_staticObjectId);
  71. writeD(_objectId);
  72. writeD(_type);
  73. writeD(_isTargetable ? 1 : 0);
  74. writeD(_meshIndex);
  75. writeD(_isClosed ? 1 : 0);
  76. writeD(_isEnemy ? 1 : 0);
  77. writeD(_currentHp);
  78. writeD(_maxHp);
  79. writeD(_showHp ? 1 : 0);
  80. writeD(_damageGrade);
  81. }
  82. }