summaryrefslogtreecommitdiffstats
path: root/source/Inventory.h
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-24 00:09:57 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-09-24 00:09:57 +0200
commitecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26 (patch)
tree898e37fe747f0fdcefeb88f833557fd45db3347c /source/Inventory.h
parentSource files cleanup: ChunkDataSerializer is Protocol-related (diff)
downloadcuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.gz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.bz2
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.lz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.xz
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.tar.zst
cuberite-ecfe6ab65bd1fc2c7f5733fe6ef4e6ddaac44a26.zip
Diffstat (limited to 'source/Inventory.h')
-rw-r--r--source/Inventory.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/source/Inventory.h b/source/Inventory.h
new file mode 100644
index 000000000..1dd22deec
--- /dev/null
+++ b/source/Inventory.h
@@ -0,0 +1,88 @@
+
+#pragma once
+
+#include "Item.h"
+
+
+
+
+
+namespace Json
+{
+ class Value;
+};
+
+class cClientHandle;
+class cPlayer;
+
+
+
+
+
+class cInventory //tolua_export
+{ //tolua_export
+public:
+ cInventory(cPlayer & a_Owner);
+ ~cInventory();
+
+ void Clear(); //tolua_export
+
+ cItem* GetSlotsForType( int a_Type );
+ int GetSlotCountForType( int a_Type );
+
+ bool AddItem( cItem & a_Item ); //tolua_export
+ bool RemoveItem( cItem & a_Item ); //tolua_export
+
+ void SaveToJson(Json::Value & a_Value);
+ bool LoadFromJson(Json::Value & a_Value);
+
+ void SendWholeInventory(cClientHandle & a_Client);
+
+ cItem * GetSlot(int a_SlotNum ); //tolua_export
+ cItem * GetSlots(void) { return m_Slots; }
+ const cItem * GetSlots(void) const { return m_Slots; }
+ cItem * GetFromHotBar(int a_HotBarSlotNum); //tolua_export
+
+ cItem & GetEquippedItem(void); //tolua_export
+ const cItem & GetEquippedItem(void) const;
+ void SetEquippedSlot(int a_SlotNum); //tolua_export
+ short GetEquippedSlot(void) { return m_EquippedSlot; } //tolua_export
+
+ void SendSlot( int a_SlotNum ); //tolua_export
+
+ /// Returns how many items of the specified type would fit into the slot range specified
+ int HowManyCanFit(short a_ItemType, short a_ItemDamage, int a_BeginSlot, int a_EndSlot);
+
+ /// Moves items, fitting them into the slot range specified, up to a_Count items. Returns the number of items moved
+ int MoveItem(short a_ItemType, short a_ItemDamage, int a_Count, int a_BeginSlot, int a_EndSlot);
+
+ static const unsigned int c_NumSlots = 45;
+ static const unsigned int c_MainSlots = 27;
+ static const unsigned int c_HotSlots = 9;
+ static const unsigned int c_CraftSlots = 4;
+ static const unsigned int c_ArmorSlots = 4;
+
+ static const unsigned int c_CraftOffset = 0;
+ static const unsigned int c_ArmorOffset = 5;
+ static const unsigned int c_MainOffset = 9;
+ static const unsigned int c_HotOffset = 36;
+
+protected:
+ bool AddToBar( cItem & a_Item, const int a_Offset, const int a_Size, bool* a_bChangedSlots, int a_Mode = 0 );
+
+ cItem m_Slots[c_NumSlots];
+
+ cItem * m_MainSlots;
+ cItem * m_CraftSlots;
+ cItem * m_ArmorSlots;
+ cItem * m_HotSlots;
+
+ cItem * m_EquippedItem;
+ short m_EquippedSlot;
+
+ cPlayer & m_Owner;
+}; //tolua_export
+
+
+
+