blob: 6c9a15a456454c0de2ef6a736c76f93ee7863719 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
#pragma once
#include "cBlockEntity.h"
#include "cEntity.h"
class cWindow;
/**
Base class for the behavior expected from a class that can handle UI windows for block entities.
*/
class cWindowOwner
{
public:
cWindowOwner() :
m_Window(NULL)
{
}
void CloseWindow(void)
{
m_Window = NULL;
}
void OpenWindow(cWindow * a_Window)
{
m_Window = a_Window;
}
cWindow * GetWindow(void) const
{
return m_Window;
}
/// Returns the block position at which the element owning the window is
virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) = 0;
private:
cWindow * m_Window;
} ;
/**
Window owner that is associated with a block entity (chest, furnace, ...)
*/
class cBlockEntityWindowOwner :
public cWindowOwner
{
public:
cBlockEntityWindowOwner(void) :
m_BlockEntity(NULL)
{
}
void SetBlockEntity(cBlockEntity * a_BlockEntity)
{
m_BlockEntity = a_BlockEntity;
}
virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
{
a_BlockX = m_BlockEntity->GetPosX();
a_BlockY = m_BlockEntity->GetPosY();
a_BlockZ = m_BlockEntity->GetPosZ();
}
private:
cBlockEntity * m_BlockEntity;
} ;
/**
Window owner that is associated with an entity (chest minecart)
*/
class cEntityWindowOwner :
public cWindowOwner
{
public:
cEntityWindowOwner(void) :
m_Entity(NULL)
{
}
void SetEntity(cEntity * a_Entity)
{
m_Entity = a_Entity;
}
virtual void GetBlockPos(int & a_BlockX, int & a_BlockY, int & a_BlockZ) override
{
a_BlockX = (int)(m_Entity->GetPosX());
a_BlockY = (int)(m_Entity->GetPosY());
a_BlockZ = (int)(m_Entity->GetPosZ());
}
private:
cEntity * m_Entity;
} ;
|