2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
// BlockEntityWithItems.h
|
|
|
|
|
|
|
|
// Declares the cBlockEntityWithItems class representing a common ancestor for all block entities that have an ItemGrid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockEntity.h"
|
|
|
|
#include "../ItemGrid.h"
|
2014-02-12 17:01:22 -05:00
|
|
|
#include "../UI/WindowOwner.h"
|
2014-09-26 13:13:19 -04:00
|
|
|
#include "World.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
class cBlockEntityWithItems :
|
2014-09-27 14:19:28 -04:00
|
|
|
public cBlockEntity,
|
2015-03-19 16:26:38 -04:00
|
|
|
// tolua_end
|
2014-09-27 14:19:28 -04:00
|
|
|
public cItemGrid::cListener,
|
2015-03-19 16:26:38 -04:00
|
|
|
// tolua_begin
|
2014-09-27 14:19:28 -04:00
|
|
|
public cBlockEntityWindowOwner
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2017-06-15 09:32:33 -04:00
|
|
|
typedef cBlockEntity Super;
|
2014-10-19 06:46:25 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-11-27 16:42:08 -05:00
|
|
|
BLOCKENTITY_PROTODEF(cBlockEntityWithItems)
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2017-06-15 09:32:33 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
cBlockEntityWithItems(
|
|
|
|
BLOCKTYPE a_BlockType, // Type of the block that the entity represents
|
2017-06-15 09:32:33 -04:00
|
|
|
NIBBLETYPE a_BlockMeta, // Meta of the block that the entity represents
|
2013-07-29 07:13:03 -04:00
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, // Position of the block entity
|
|
|
|
int a_ItemGridWidth, int a_ItemGridHeight, // Dimensions of the ItemGrid
|
|
|
|
cWorld * a_World // Optional world to assign to the entity
|
2017-06-15 09:32:33 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
// cBlockEntity overrides:
|
|
|
|
virtual void Destroy(void) override;
|
|
|
|
virtual void CopyFrom(const cBlockEntity & a_Src) override;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// tolua_begin
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
const cItem & GetSlot(int a_SlotNum) const { return m_Contents.GetSlot(a_SlotNum); }
|
|
|
|
const cItem & GetSlot(int a_X, int a_Y) const { return m_Contents.GetSlot(a_X, a_Y); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
void SetSlot(int a_SlotNum, const cItem & a_Item) { m_Contents.SetSlot(a_SlotNum, a_Item); }
|
|
|
|
void SetSlot(int a_X, int a_Y, const cItem & a_Item) { m_Contents.SetSlot(a_X, a_Y, a_Item); }
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Returns the ItemGrid used for storing the contents */
|
2013-07-29 07:13:03 -04:00
|
|
|
cItemGrid & GetContents(void) { return m_Contents; }
|
|
|
|
|
|
|
|
// tolua_end
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Const version of the GetContents() function for C++ type-safety */
|
2013-07-29 07:13:03 -04:00
|
|
|
const cItemGrid & GetContents(void) const { return m_Contents; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
cItemGrid m_Contents;
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
// cItemGrid::cListener overrides:
|
2017-06-15 09:32:33 -04:00
|
|
|
virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) override;
|
2013-07-29 07:13:03 -04:00
|
|
|
} ; // tolua_export
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|