Item.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 void applyInventoryEffects(Entity* zTarget);
  42. virtual void removeInventoryEffects(Entity* zTarget);
  43. virtual void applyEquippedEffects(Entity* zTarget);
  44. virtual void removeEquippedEffects(Entity* zTarget);
  45. virtual void applyFoodEffects(Entity* zTarget);
  46. friend ItemType;
  47. };