Item.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "ItemType.h"
  3. #include "Reader.h"
  4. class ItemType;
  5. class BlockType;
  6. class StoneToolItemType;
  7. class Item : public virtual Framework::ReferenceCounter
  8. {
  9. protected:
  10. const ItemType* zType;
  11. const BlockType* zBlockType;
  12. float hp; // an item will be removed once its hp reaches 0
  13. float maxHp;
  14. float durability; // an item will break into another item once its durability reaches 0
  15. float maxDurability;
  16. bool eatable;
  17. bool placeable;
  18. bool equippable;
  19. bool solid;
  20. bool usable;
  21. int maxStackSize;
  22. Framework::Text name;
  23. Item(const ItemType* zType, const char* name);
  24. public:
  25. void setHp(float hp);
  26. virtual void tick();
  27. const ItemType* zItemType() const;
  28. const BlockType* zPlacedBlockType() const;
  29. float getHp() const;
  30. float getDurability() const;
  31. bool isUsable() const;
  32. bool isEatable() const;
  33. bool isPlaceable() const;
  34. bool isEquippable() const;
  35. bool isSolid() const;
  36. float getMaxDurability() const;
  37. int getMaxStackSize() const;
  38. float getMaxHp() const;
  39. virtual bool canBeStackedWith(const Item* zItem) const;
  40. virtual void onPlaced();
  41. virtual Framework::Text getTooltipUIML() const;
  42. virtual void applyInventoryEffects(Entity* zTarget);
  43. virtual void removeInventoryEffects(Entity* zTarget);
  44. virtual void applyEquippedEffects(Entity* zTarget);
  45. virtual void removeEquippedEffects(Entity* zTarget);
  46. virtual void applyFoodEffects(Entity* zTarget);
  47. friend ItemType;
  48. };