Cuberite
A lightweight, fast and extensible game server for Minecraft
FireSimulator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Simulator.h"
5 
6 
7 
8 
9 
18  public cSimulator
19 {
20 public:
21  cFireSimulator(cWorld & a_World, cIniFile & a_IniFile);
22  virtual ~cFireSimulator() override;
23 
24  virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
25  virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
26 
27  virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override;
28 
29  static bool IsFuel (BLOCKTYPE a_BlockType);
30  static bool DoesBurnForever(BLOCKTYPE a_BlockType);
31 
32 protected:
35 
38 
41 
44 
45 
46  virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
47 
49  int GetBurnStepTime(cChunk * a_Chunk, Vector3i a_RelPos);
50 
52  void TrySpreadFire(cChunk * a_Chunk, Vector3i a_RelPos);
53 
55  void RemoveFuelNeighbors(cChunk * a_Chunk, Vector3i a_RelPos);
56 
61  bool CanStartFireInBlock(cChunk * a_NearChunk, Vector3i a_RelPos);
62 } ;
63 
64 
65 
66 
67 
70 
71 
72 
73 
virtual void AddBlock(Vector3i a_Block, cChunk *a_Chunk) override
Called to simulate a new block.
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
int GetBurnStepTime(cChunk *a_Chunk, Vector3i a_RelPos)
Returns the time [msec] after which the specified fire block is stepped again; based on surrounding f...
virtual ~cFireSimulator() override
static bool DoesBurnForever(BLOCKTYPE a_BlockType)
int m_Flammability
Chance [0..100000] of an adjacent fuel to catch fire on each tick.
Definition: FireSimulator.h:40
virtual void Simulate(float a_Dt) override
Called in each tick, a_Dt is the time passed since the last tick, in msec.
Definition: FireSimulator.h:24
bool CanStartFireInBlock(cChunk *a_NearChunk, Vector3i a_RelPos)
Returns true if a fire can be started in the specified block, that is, it is an air block and has fue...
Definition: Chunk.h:49
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc...
Definition: Simulator.h:19
Definition: World.h:65
int m_ReplaceFuelChance
Chance [0..100000] of a fuel burning out being replaced by a new fire block instead of an air block...
Definition: FireSimulator.h:43
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override
Returns true if the specified block type is "interesting" for this simulator.
cCoordWithIntList cFireSimulatorChunkData
Stores individual fire blocks in the chunk; the int data is used as the time [msec] the fire takes to...
Definition: FireSimulator.h:69
std::list< cCoordWithInt > cCoordWithIntList
Definition: ChunkDef.h:668
void RemoveFuelNeighbors(cChunk *a_Chunk, Vector3i a_RelPos)
Removes all burnable blocks neighboring the specified block.
#define UNUSED
Definition: Globals.h:152
cFireSimulator(cWorld &a_World, cIniFile &a_IniFile)
unsigned m_BurnStepTimeFuel
Time (in msec) that a fire block takes to burn with a fuel block into the next step.
Definition: FireSimulator.h:34
The fire simulator takes care of the fire blocks.
Definition: FireSimulator.h:17
void TrySpreadFire(cChunk *a_Chunk, Vector3i a_RelPos)
Tries to spread fire to a neighborhood of the specified block.
unsigned m_BurnStepTimeNonfuel
Time (in msec) that a fire block takes to burn without a fuel block into the next step...
Definition: FireSimulator.h:37
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk) override
Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct acce...
static bool IsFuel(BLOCKTYPE a_BlockType)