Item.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. void setDurability(float durability);
  28. virtual void tick();
  29. const ItemType* zItemType() const;
  30. int getTypeId() const;
  31. const BlockType* zPlacedBlockType() const;
  32. float getHp() const;
  33. float getDurability() const;
  34. bool isUsable() const;
  35. bool isEatable() const;
  36. bool isPlaceable() const;
  37. bool isEquippable() const;
  38. bool isSolid() const;
  39. float getMaxDurability() const;
  40. int getMaxStackSize() const;
  41. float getMaxHp() const;
  42. virtual bool canBeStackedWith(const Item* zItem) const;
  43. virtual void onPlaced();
  44. virtual Framework::Text getTooltipUIML() const;
  45. virtual void applyInventoryEffects(Entity* zTarget);
  46. virtual void removeInventoryEffects(Entity* zTarget);
  47. virtual void applyEquippedEffects(Entity* zTarget);
  48. virtual void removeEquippedEffects(Entity* zTarget);
  49. virtual void applyFoodEffects(Entity* zTarget);
  50. friend ItemType;
  51. };