Suggestions
This commit is contained in:
parent
d1814d2d67
commit
7ce09a9113
@ -20,12 +20,9 @@
|
|||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cBlockEntityWithItems :
|
class cBlockEntityWithItems :
|
||||||
public cBlockEntity
|
public cBlockEntity,
|
||||||
// tolua_end
|
public cItemGrid::cListener,
|
||||||
// tolua doesn't seem to support multiple inheritance?
|
public cBlockEntityWindowOwner
|
||||||
, public cItemGrid::cListener
|
|
||||||
, public cWindowOwner
|
|
||||||
// tolua_begin
|
|
||||||
{
|
{
|
||||||
typedef cBlockEntity super;
|
typedef cBlockEntity super;
|
||||||
|
|
||||||
@ -39,7 +36,8 @@ public:
|
|||||||
cWorld * a_World // Optional world to assign to the entity
|
cWorld * a_World // Optional world to assign to the entity
|
||||||
) :
|
) :
|
||||||
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
super(a_BlockType, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
||||||
m_Contents(a_ItemGridWidth, a_ItemGridHeight)
|
m_Contents(a_ItemGridWidth, a_ItemGridHeight),
|
||||||
|
cBlockEntityWindowOwner(this)
|
||||||
{
|
{
|
||||||
m_Contents.AddListener(*this);
|
m_Contents.AddListener(*this);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@
|
|||||||
|
|
||||||
|
|
||||||
cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
|
cEnderChestEntity::cEnderChestEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) :
|
||||||
super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World)
|
super(E_BLOCK_ENDER_CHEST, a_BlockX, a_BlockY, a_BlockZ, a_World),
|
||||||
|
cBlockEntityWindowOwner(this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// tolua_begin
|
// tolua_begin
|
||||||
class cEnderChestEntity :
|
class cEnderChestEntity :
|
||||||
public cBlockEntity,
|
public cBlockEntity,
|
||||||
public cWindowOwner
|
public cBlockEntityWindowOwner
|
||||||
{
|
{
|
||||||
typedef cBlockEntity super;
|
typedef cBlockEntity super;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Minecart.h"
|
#include "Minecart.h"
|
||||||
#include "../World.h"
|
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
@ -1107,7 +1106,8 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
|
|||||||
|
|
||||||
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
|
cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
|
||||||
super(mpChest, a_X, a_Y, a_Z),
|
super(mpChest, a_X, a_Y, a_Z),
|
||||||
m_Contents(ContentsWidth, ContentsHeight)
|
m_Contents(ContentsWidth, ContentsHeight),
|
||||||
|
cEntityWindowOwner(this)
|
||||||
{
|
{
|
||||||
m_Contents.AddListener(*this);
|
m_Contents.AddListener(*this);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
#include "World.h"
|
||||||
#include "../UI/WindowOwner.h"
|
#include "../UI/WindowOwner.h"
|
||||||
|
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ protected:
|
|||||||
class cMinecartWithChest :
|
class cMinecartWithChest :
|
||||||
public cMinecart,
|
public cMinecart,
|
||||||
public cItemGrid::cListener,
|
public cItemGrid::cListener,
|
||||||
public cWindowOwner
|
public cEntityWindowOwner
|
||||||
{
|
{
|
||||||
typedef cMinecart super;
|
typedef cMinecart super;
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../BlockEntities/BlockEntity.h"
|
#include "../BlockEntities/BlockEntity.h"
|
||||||
@ -16,12 +15,6 @@ for entities / players in motion to close their windows when they get too far aw
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// class cWindow;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Base class for the window owning
|
Base class for the window owning
|
||||||
*/
|
*/
|
||||||
@ -32,16 +25,16 @@ public:
|
|||||||
m_Window(NULL)
|
m_Window(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~cWindowOwner()
|
virtual ~cWindowOwner()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseWindow(void)
|
void CloseWindow(void)
|
||||||
{
|
{
|
||||||
m_Window = NULL;
|
m_Window = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenWindow(cWindow * a_Window)
|
void OpenWindow(cWindow * a_Window)
|
||||||
{
|
{
|
||||||
m_Window = a_Window;
|
m_Window = a_Window;
|
||||||
@ -52,7 +45,10 @@ public:
|
|||||||
{
|
{
|
||||||
return m_Window;
|
return m_Window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the block position at which the element owning the window is
|
||||||
|
virtual Vector3i GetBlockPos(void) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cWindow * m_Window;
|
cWindow * m_Window;
|
||||||
};
|
};
|
||||||
@ -60,3 +56,53 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Window owner that is associated with a block entity (chest, furnace, ...)
|
||||||
|
*/
|
||||||
|
class cBlockEntityWindowOwner :
|
||||||
|
public cWindowOwner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cBlockEntityWindowOwner(cBlockEntity * a_BlockEntity) :
|
||||||
|
m_BlockEntity(a_BlockEntity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Vector3i GetBlockPos(void) override
|
||||||
|
{
|
||||||
|
return Vector3i(m_BlockEntity->GetPosX(), m_BlockEntity->GetPosY(), m_BlockEntity->GetPosZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cBlockEntity * m_BlockEntity;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Window owner that is associated with an entity (chest minecart)
|
||||||
|
*/
|
||||||
|
class cEntityWindowOwner :
|
||||||
|
public cWindowOwner
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cEntityWindowOwner(cEntity * a_Entity) :
|
||||||
|
m_Entity(a_Entity)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Vector3i GetBlockPos(void) override
|
||||||
|
{
|
||||||
|
return m_Entity->GetPosition().Floor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cEntity * m_Entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user