Item.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. int itemTypeId;
  11. int blockTypeId;
  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
  15. // durability reaches 0
  16. float maxDurability;
  17. bool eatable;
  18. bool placeable;
  19. bool equippable;
  20. bool solid;
  21. bool usable;
  22. int maxStackSize;
  23. Framework::Text name;
  24. Item(int itemTypeId, const char* name);
  25. public:
  26. void setHp(float hp);
  27. virtual void tick();
  28. const ItemType* zItemType() const;
  29. int getTypeId() const;
  30. const BlockType* zPlacedBlockType() const;
  31. float getHp() const;
  32. float getDurability() const;
  33. bool isUsable() const;
  34. bool isEatable() const;
  35. bool isPlaceable() const;
  36. bool isEquippable() const;
  37. bool isSolid() const;
  38. float getMaxDurability() const;
  39. int getMaxStackSize() const;
  40. float getMaxHp() const;
  41. virtual bool canBeStackedWith(const Item* zItem) const;
  42. virtual void onPlaced();
  43. virtual Framework::Text getTooltipUIML() const;
  44. virtual void applyInventoryEffects(Entity* zTarget);
  45. virtual void removeInventoryEffects(Entity* zTarget);
  46. virtual void applyEquippedEffects(Entity* zTarget);
  47. virtual void removeEquippedEffects(Entity* zTarget);
  48. virtual void applyFoodEffects(Entity* zTarget);
  49. friend ItemType;
  50. };