Cuberite
A lightweight, fast and extensible game server for Minecraft
Simulator.cpp
Go to the documentation of this file.
1 
2 #include "Globals.h"
3 
4 #include "Simulator.h"
5 #include "../Chunk.h"
6 #include "../World.h"
7 
8 
9 
10 
11 
12 std::array<Vector3i, 5> cSimulator::GetLinkedOffsets(const Vector3i Offset)
13 {
14  if (Offset.x == -1)
15  {
16  return
17  {
18  {
19  { -2, 0, 0 },
20  { -1, -1, 0 },
21  { -1, 1, 0 },
22  { -1, 0, -1 },
23  { -1, 0, 1 }
24  }
25  };
26  }
27  else if (Offset.x == 1)
28  {
29  return
30  {
31  {
32  { 2, 0, 0 },
33  { 1, -1, 0 },
34  { 1, 1, 0 },
35  { 1, 0, -1 },
36  { 1, 0, 1 }
37  }
38  };
39  }
40  else if (Offset.y == -1)
41  {
42  return
43  {
44  {
45  { 0, -2, 0 },
46  { -1, -1, 0 },
47  { 1, -1, 0 },
48  { 0, -1, -1 },
49  { 0, -1, 1 }
50  }
51  };
52  }
53  else if (Offset.y == 1)
54  {
55  return
56  {
57  {
58  { 0, 2, 0 },
59  { -1, 1, 0 },
60  { 1, 1, 0 },
61  { 0, 1, -1 },
62  { 0, 1, 1 }
63  }
64  };
65  }
66  else if (Offset.z == -1)
67  {
68  return
69  {
70  {
71  { 0, 0, -2 },
72  { -1, 0, -1 },
73  { 1, 0, -1 },
74  { 0, -1, -1 },
75  { 0, 1, -1 }
76  }
77  };
78  }
79 
80  return
81  {
82  {
83  { 0, 0, 2 },
84  { -1, 0, 1 },
85  { 1, 0, 1 },
86  { 0, -1, 1 },
87  { 0, 1, 1 }
88  }
89  };
90 }
91 
92 
93 
94 
95 
96 void cSimulator::Simulate(float a_Dt)
97 {
98  UNUSED(a_Dt);
99 }
100 
101 
102 
103 
104 
105 void cSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
106 {
107  ASSERT(a_Chunk.IsValid());
108 
109  AddBlock(a_Chunk, a_Position, a_Block);
110 }
111 
112 
113 
114 
115 
116 void cSimulator::WakeUp(cChunk & a_Chunk, Vector3i a_Position, Vector3i a_Offset, BLOCKTYPE a_Block)
117 {
118  ASSERT(a_Chunk.IsValid());
119 
120  WakeUp(a_Chunk, a_Position, a_Block);
121 }
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
#define ASSERT(x)
Definition: Globals.h:276
#define UNUSED
Definition: Globals.h:72
Definition: Chunk.h:36
bool IsValid(void) const
Returns true iff the chunk block data is valid (loaded / generated)
Definition: Chunk.h:58
virtual void Simulate(float a_Dt)
Definition: Simulator.cpp:96
virtual void WakeUp(cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)
Called to simulate a single new block, typically as a result of a single block break or change.
Definition: Simulator.cpp:105
static std::array< Vector3i, 5 > GetLinkedOffsets(Vector3i Offset)
For a given offset from a position, return the offsets that represent the adjacents of the newly offs...
Definition: Simulator.cpp:12
virtual void AddBlock(cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block)=0
Called to simulate a new block.
T x
Definition: Vector3.h:17
T y
Definition: Vector3.h:17
T z
Definition: Vector3.h:17