69 int HowManyCanFit(
const cItem & a_ItemStack,
int a_BeginSlotNum,
int a_EndSlotNum,
bool a_ConsiderEmptySlots =
true);
77 char AddItem(
const cItem & a_ItemStack,
bool a_AllowNewStacks =
true);
171 bool DamageItem(
int a_SlotNum,
short a_Amount);
196 bool AddToBar(
cItem & a_Item,
const int a_Offset,
const int a_Size,
bool * a_bChangedSlots,
int a_Mode = 0);
This class represents the player's inventory The slots are divided into three areas:
char AddItem(const cItem &a_ItemStack, bool a_AllowNewStacks=true)
Adds as many items out of a_ItemStack as can fit.
const cItem & GetHotbarSlot(int a_HotBarSlotNum) const
Returns current item in a_ArmorSlotNum in hotbar slots.
bool LoadFromJson(Json::Value &a_Value)
void UpdateItems(void)
Update items (e.g.
const cItem & GetEquippedChestplate(void) const
cItemGrid & GetHotbarGrid(void)
Returns the cItemGrid object representing the hotbar slots.
virtual void OnSlotChanged(cItemGrid *a_ItemGrid, int a_SlotNum) override
Called whenever a slot changes.
cItemGrid m_InventorySlots
virtual ~cInventory() override
cInventory(cPlayer &a_Owner)
void CopyToItems(cItems &a_Items)
Copies the non-empty slots into a_ItemStacks; preserves the original a_Items contents.
static int ArmorSlotNumToEntityEquipmentID(short a_ArmorSlotNum)
Converts an armor slot number into the ID for the EntityEquipment packet.
bool HasItems(const cItem &a_ItemStack)
Returns true if there are at least as many items of type a_ItemStack as in a_ItemStack.
bool DamageEquippedItem(short a_Amount=1)
Adds the specified damage to the currently held item; deletes the item and returns true if the item b...
const cItem & GetArmorSlot(int a_ArmorSlotNum) const
Returns current item in a_ArmorSlotNum in armor slots.
char AddItems(cItems &a_ItemStackList, bool a_AllowNewStacks)
Same as AddItem, but works on an entire list of item stacks.
cItem * FindItem(const cItem &a_RecipeItem)
Finds an item based on ItemType and ItemDamage (<- defines the itemType, too)
void SetEquippedSlotNum(int a_SlotNum)
Sets equiped item to the a_SlotNum slot number.
void SaveToJson(Json::Value &a_Value)
const cItem & GetEquippedBoots(void) const
const cPlayer & GetOwner(void) const
Returns the player associated with this inventory (const version)
cItemGrid & GetInventoryGrid(void)
Returns the cItemGrid object representing the main inventory slots.
void SendSlot(int a_SlotNum)
Sends the slot contents to the owner.
cPlayer & GetOwner(void)
Returns the player associated with this inventory.
void SetSlot(int a_SlotNum, const cItem &a_Item)
Puts a_Item item in a_SlotNum slot number.
const cItem & GetSlot(int a_SlotNum) const
Returns current item in a_SlotNum slot.
void SendEquippedSlot()
Sends the equipped item slot to the client.
char ChangeSlotCount(int a_SlotNum, char a_AddToCount)
Adds (or subtracts, if a_AddToCount is negative) to the count of items in the specified slot.
bool AddToBar(cItem &a_Item, const int a_Offset, const int a_Size, bool *a_bChangedSlots, int a_Mode=0)
void SetShieldSlot(const cItem &a_Item)
Sets current item in shield slot.
int HowManyItems(const cItem &a_Item)
Returns the number of items of type a_Item that are stored.
const cItem & GetEquippedHelmet(void) const
void SetInventorySlot(int a_InventorySlotNum, const cItem &a_Item)
Puts a_Item item in a_InventorySlotNum slot number in inventory slots.
void Clear(void)
Removes all items from the entire inventory.
int ReplaceOneEquippedItem(const cItem &a_Item, bool a_TryOtherSlots=true)
Removes one item from the the current equipped item stack, and attempts to add the specified item sta...
bool DamageItem(int a_SlotNum, short a_Amount)
Adds the specified damage to the specified item; deletes the item and returns true if the item broke.
const cItem & GetInventorySlot(int a_InventorySlotNum) const
Returns current item in a_ArmorSlotNum in inventory slots.
void SetArmorSlot(int a_ArmorSlotNum, const cItem &a_Item)
Puts a_Item item in a_ArmorSlotNum slot number in armor slots.
int GetEquippedSlotNum(void)
Returns slot number of equiped item.
void SetHotbarSlot(int a_HotBarSlotNum, const cItem &a_Item)
Puts a_Item item in a_HotBarSlotNum slot number in hotbar slots.
const cItemGrid * GetGridForSlotNum(int a_SlotNum, int &a_GridSlotNum) const
Returns the ItemGrid and the (grid-local) slot number for a (global) slot number; return nullptr for ...
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful,...
const cItem & GetEquippedItem(void) const
Returns current equiped item.
int HowManyCanFit(const cItem &a_ItemStack, bool a_ConsiderEmptySlots=true)
Returns number of items out of a_ItemStack that can fit in the storage.
int RemoveItem(const cItem &a_ItemStack)
Removes the specified item from the inventory, as many as possible, up to a_ItemStack....
const cItem & GetShieldSlot() const
Returns current item in shield slot.
cItemGrid & GetArmorGrid(void)
Returns the cItemGrid object representing the armor slots.
void SetEquippedItem(const cItem &a_Item)
Sets current item in the equipped hotbar slot.
const cItem & GetEquippedLeggings(void) const
This class bridges a vector of cItem for safe access via Lua.
const cItem & GetSlot(int a_X, int a_Y) const
This class is used as a callback for when a slot changes.