2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Item.h"
|
2012-08-11 07:51:32 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
namespace Json
|
|
|
|
{
|
|
|
|
class Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
class cClientHandle;
|
|
|
|
class cPlayer;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
class cInventory // tolua_export
|
|
|
|
{ // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
2012-09-20 09:25:54 -04:00
|
|
|
cInventory(cPlayer & a_Owner);
|
2012-06-14 09:06:06 -04:00
|
|
|
~cInventory();
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void Clear(); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
cItem* GetSlotsForType( int a_Type );
|
|
|
|
int GetSlotCountForType( int a_Type );
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
bool AddItem( cItem & a_Item ); // tolua_export
|
|
|
|
bool AddItemAnyAmount( cItem & a_Item ); // tolua_export
|
|
|
|
bool RemoveItem( cItem & a_Item ); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
void SaveToJson(Json::Value & a_Value);
|
|
|
|
bool LoadFromJson(Json::Value & a_Value);
|
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
void SendWholeInventory(cClientHandle & a_Client);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
cItem * GetSlot(int a_SlotNum ); // tolua_export
|
2012-09-20 09:25:54 -04:00
|
|
|
cItem * GetSlots(void) { return m_Slots; }
|
|
|
|
const cItem * GetSlots(void) const { return m_Slots; }
|
2013-01-11 23:46:01 -05:00
|
|
|
cItem * GetFromHotBar(int a_HotBarSlotNum); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
cItem & GetEquippedItem(void); // tolua_export
|
2012-08-24 03:58:26 -04:00
|
|
|
const cItem & GetEquippedItem(void) const;
|
2013-01-11 23:46:01 -05:00
|
|
|
void SetEquippedSlot(int a_SlotNum); // tolua_export
|
|
|
|
short GetEquippedSlot(void) { return m_EquippedSlot; } // tolua_export
|
2012-12-21 06:02:31 -05:00
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
const cItem & GetEquippedHelmet (void) const { return m_Slots[c_ArmorOffset]; }
|
|
|
|
const cItem & GetEquippedChestplate(void) const { return m_Slots[c_ArmorOffset + 1]; }
|
|
|
|
const cItem & GetEquippedLeggings (void) const { return m_Slots[c_ArmorOffset + 2]; }
|
|
|
|
const cItem & GetEquippedBoots (void) const { return m_Slots[c_ArmorOffset + 3]; }
|
|
|
|
// tolua_end
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
void SendSlot( int a_SlotNum ); // tolua_export
|
2012-08-11 15:54:57 -04:00
|
|
|
|
|
|
|
/// Returns how many items of the specified type would fit into the slot range specified
|
2012-08-19 07:51:17 -04:00
|
|
|
int HowManyCanFit(short a_ItemType, short a_ItemDamage, int a_BeginSlot, int a_EndSlot);
|
2012-08-11 15:54:57 -04:00
|
|
|
|
|
|
|
/// Moves items, fitting them into the slot range specified, up to a_Count items. Returns the number of items moved
|
2012-08-19 07:51:17 -04:00
|
|
|
int MoveItem(short a_ItemType, short a_ItemDamage, int a_Count, int a_BeginSlot, int a_EndSlot);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
cItem m_Slots[c_NumSlots];
|
|
|
|
|
|
|
|
cItem * m_MainSlots;
|
|
|
|
cItem * m_CraftSlots;
|
|
|
|
cItem * m_ArmorSlots;
|
|
|
|
cItem * m_HotSlots;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
cItem * m_EquippedItem;
|
2012-06-14 09:06:06 -04:00
|
|
|
short m_EquippedSlot;
|
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
cPlayer & m_Owner;
|
2013-01-11 23:46:01 -05:00
|
|
|
}; // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|