12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
- #include "ItemType.h"
- #include "Reader.h"
- class ItemType;
- class BlockType;
- class StoneToolItemType;
- class Item : public virtual Framework::ReferenceCounter
- {
- protected:
- int itemTypeId;
- int blockTypeId;
- float hp; // an item will be removed once its hp reaches 0
- float maxHp;
- float durability; // an item will break into another item once its
- // durability reaches 0
- float maxDurability;
- bool eatable;
- bool placeable;
- bool equippable;
- bool solid;
- bool usable;
- int maxStackSize;
- Framework::Text name;
- std::function<void(Entity*)> foodEffect;
- Item(int itemTypeId, const char* name);
- public:
- void setHp(float hp);
- void setDurability(float durability);
- virtual void tick();
- void setFoodEffect(std::function<void(Entity*)> foodEffect);
- const ItemType* zItemType() const;
- int getTypeId() const;
- const BlockType* zPlacedBlockType() const;
- float getHp() const;
- float getDurability() const;
- bool isUsable() const;
- bool isEatable() const;
- bool isPlaceable() const;
- bool isEquippable() const;
- bool isSolid() const;
- float getMaxDurability() const;
- int getMaxStackSize() const;
- float getMaxHp() const;
- virtual bool canBeStackedWith(const Item* zItem) const;
- virtual bool canBePlacedAt(int dimensionId, Framework::Vec3<int> worldPos) const;
- virtual void onPlaced();
- virtual Framework::Text getTooltipUIML() const;
- virtual void applyInventoryEffects(Entity* zTarget);
- virtual void removeInventoryEffects(Entity* zTarget);
- virtual void applyEquippedEffects(Entity* zTarget);
- virtual void removeEquippedEffects(Entity* zTarget);
- virtual void applyFoodEffects(Entity* zTarget);
- friend ItemType;
- };
|