2012-06-14 09:06:06 -04:00
|
|
|
#pragma once
|
|
|
|
|
2013-05-28 15:12:47 -04:00
|
|
|
#include "../BlockEntities/BlockEntity.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../Entities/Entity.h"
|
2012-09-23 13:19:34 -04:00
|
|
|
#include "Window.h"
|
2012-09-20 09:25:54 -04:00
|
|
|
|
|
|
|
/*
|
2014-07-17 16:50:58 -04:00
|
|
|
Being a descendant of cWindowOwner means that the class can own one window. That window can be
|
2012-09-20 09:25:54 -04:00
|
|
|
queried, opened by other players, closed by players and finally destroyed.
|
|
|
|
Also, a cWindowOwner can be queried for the block coords where the window is displayed. That will be used
|
|
|
|
for entities / players in motion to close their windows when they get too far away from the window "source".
|
|
|
|
*/
|
2012-08-06 16:10:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2012-08-06 16:10:16 -04:00
|
|
|
/**
|
2012-09-20 09:25:54 -04:00
|
|
|
Base class for the window owning
|
2012-08-06 16:10:16 -04:00
|
|
|
*/
|
2012-06-14 09:06:06 -04:00
|
|
|
class cWindowOwner
|
|
|
|
{
|
|
|
|
public:
|
2012-08-07 08:05:35 -04:00
|
|
|
cWindowOwner() :
|
|
|
|
m_Window(NULL)
|
|
|
|
{
|
|
|
|
}
|
2014-09-27 14:19:28 -04:00
|
|
|
|
2014-03-28 16:35:45 -04:00
|
|
|
virtual ~cWindowOwner()
|
|
|
|
{
|
|
|
|
}
|
2014-09-27 14:19:28 -04:00
|
|
|
|
2012-08-07 08:05:35 -04:00
|
|
|
void CloseWindow(void)
|
|
|
|
{
|
|
|
|
m_Window = NULL;
|
|
|
|
}
|
2014-09-27 14:19:28 -04:00
|
|
|
|
2012-08-07 08:05:35 -04:00
|
|
|
void OpenWindow(cWindow * a_Window)
|
|
|
|
{
|
|
|
|
m_Window = a_Window;
|
2012-09-20 09:25:54 -04:00
|
|
|
m_Window->SetOwner(this);
|
2012-08-07 08:05:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
cWindow * GetWindow(void) const
|
|
|
|
{
|
|
|
|
return m_Window;
|
|
|
|
}
|
2014-09-27 14:19:28 -04:00
|
|
|
|
|
|
|
/// Returns the block position at which the element owning the window is
|
|
|
|
virtual Vector3i GetBlockPos(void) = 0;
|
|
|
|
|
2012-08-07 08:05:35 -04:00
|
|
|
private:
|
|
|
|
cWindow * m_Window;
|
2014-09-12 18:18:02 -04:00
|
|
|
};
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-27 14:19:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|