Item.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include "Item.h"
  2. Item::Item(const ItemType* zType, const char* name)
  3. : ReferenceCounter(),
  4. zType(zType),
  5. zBlockType(0),
  6. damage(0),
  7. maxDamage(0),
  8. durability(1),
  9. maxDurability(1),
  10. eatable(0),
  11. placeable(0),
  12. equippable(0),
  13. solid(1),
  14. usable(0),
  15. maxStackSize(50),
  16. name(name)
  17. {}
  18. void Item::tick()
  19. {}
  20. const ItemType* Item::zItemType() const
  21. {
  22. return zType;
  23. }
  24. const BlockType* Item::zPlacedBlockType() const
  25. {
  26. return zBlockType;
  27. }
  28. float Item::getDamage() const
  29. {
  30. return damage;
  31. }
  32. float Item::getDurability() const
  33. {
  34. return durability;
  35. }
  36. bool Item::isUsable() const
  37. {
  38. return usable;
  39. }
  40. bool Item::isEatable() const
  41. {
  42. return eatable;
  43. }
  44. bool Item::isPlaceable() const
  45. {
  46. return placeable;
  47. }
  48. bool Item::isEquippable() const
  49. {
  50. return equippable;
  51. }
  52. bool Item::isSolid() const
  53. {
  54. return solid;
  55. }
  56. float Item::getMaxDurability() const
  57. {
  58. return maxDurability;
  59. }
  60. int Item::getMaxStackSize() const
  61. {
  62. return maxStackSize;
  63. }
  64. float Item::getMaxDamage() const
  65. {
  66. return maxDamage;
  67. }
  68. bool Item::canBeStackedWith(const Item* zItem) const
  69. {
  70. return zType == zItem->zType && damage == 0 &&
  71. zItem->damage == 0 &&
  72. durability == maxDurability &&
  73. zItem->durability == zItem->maxDurability &&
  74. maxDamage == zItem->maxDamage &&
  75. eatable == zItem->eatable &&
  76. placeable == zItem->placeable &&
  77. equippable == zItem->eatable &&
  78. solid == zItem->solid &&
  79. usable == zItem->usable &&
  80. maxStackSize == zItem->maxStackSize &&
  81. name.istGleich(zItem->name);
  82. }
  83. void Item::onPlaced()
  84. {
  85. damage = maxDamage;
  86. durability = 0;
  87. }
  88. void Item::applyInventoryEffects(Entity* zTarget)
  89. {}
  90. void Item::removeInventoryEffects(Entity* zTarget)
  91. {}
  92. void Item::applyEquippedEffects(Entity* zTarget)
  93. {}
  94. void Item::removeEquippedEffects(Entity* zTarget)
  95. {}
  96. void Item::applyFoodEffects(Entity* zTarget)
  97. {}