Cuberite
A lightweight, fast and extensible game server for Minecraft
Simulator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 class cWorld;
5 class cChunk;
6 class cCuboid;
7 
8 
9 
10 
11 
20 {
21 public:
22  cSimulator(cWorld & a_World)
23  : m_World(a_World)
24  {
25  }
26 
27  virtual ~cSimulator() {}
28 
30  virtual void Simulate(float a_Dt) = 0;
31 
33  virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk)
34  {
35  UNUSED(a_Dt);
36  UNUSED(a_ChunkX);
37  UNUSED(a_ChunkZ);
38  UNUSED(a_Chunk);
39  }
40 
42  void WakeUp(Vector3i a_Block, cChunk * a_Chunk);
43 
49  void WakeUpArea(const cCuboid & a_Area);
50 
52  virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) = 0;
53 
54 protected:
55  friend class cChunk; // Calls AddBlock() in its WakeUpSimulators() function, to speed things up
56 
58  virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) = 0;
59 
61 } ;
62 
63 
64 
65 
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
virtual void AddBlock(Vector3i a_Block, cChunk *a_Chunk)=0
Called to simulate a new block.
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk)
Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct acce...
Definition: Simulator.h:33
void WakeUpArea(const cCuboid &a_Area)
Does the same processing as WakeUp, but for all blocks within the specified area. ...
Definition: Simulator.cpp:42
Definition: Chunk.h:49
cWorld & m_World
Definition: Simulator.h:60
virtual void Simulate(float a_Dt)=0
Called in each tick, a_Dt is the time passed since the last tick, in msec.
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc...
Definition: Simulator.h:19
Definition: World.h:65
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType)=0
Returns true if the specified block type is "interesting" for this simulator.
void WakeUp(Vector3i a_Block, cChunk *a_Chunk)
Called when a block changes.
Definition: Simulator.cpp:21
virtual ~cSimulator()
Definition: Simulator.h:27
Definition: Cuboid.h:9
#define UNUSED
Definition: Globals.h:152
cSimulator(cWorld &a_World)
Definition: Simulator.h:22