Cuberite
A lightweight, fast and extensible game server for Minecraft
|
The fire simulator takes care of the fire blocks. More...
#include <FireSimulator.h>
Public Member Functions | |
cFireSimulator (cWorld &a_World, cIniFile &a_IniFile) | |
virtual bool | IsAllowedBlock (BLOCKTYPE a_BlockType) override |
Returns true if the specified block type is "interesting" for this simulator. More... | |
virtual void | Simulate (float a_Dt) override |
Called in each tick, a_Dt is the time passed since the last tick, in msec. More... | |
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 access to chunk data available. More... | |
virtual | ~cFireSimulator () override |
Public Member Functions inherited from cSimulator | |
cSimulator (cWorld &a_World) | |
void | WakeUp (Vector3i a_Block, cChunk *a_Chunk) |
Called when a block changes. More... | |
void | WakeUpArea (const cCuboid &a_Area) |
Does the same processing as WakeUp, but for all blocks within the specified area. More... | |
virtual | ~cSimulator () |
Static Public Member Functions | |
static bool | DoesBurnForever (BLOCKTYPE a_BlockType) |
static bool | IsFuel (BLOCKTYPE a_BlockType) |
Protected Member Functions | |
virtual void | AddBlock (Vector3i a_Block, cChunk *a_Chunk) override |
Called to simulate a new block. More... | |
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 fuel next to it. More... | |
int | GetBurnStepTime (cChunk *a_Chunk, Vector3i a_RelPos) |
Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels. More... | |
void | RemoveFuelNeighbors (cChunk *a_Chunk, Vector3i a_RelPos) |
Removes all burnable blocks neighboring the specified block. More... | |
void | TrySpreadFire (cChunk *a_Chunk, Vector3i a_RelPos) |
Tries to spread fire to a neighborhood of the specified block. More... | |
Protected Attributes | |
unsigned | m_BurnStepTimeFuel |
Time (in msec) that a fire block takes to burn with a fuel block into the next step. More... | |
unsigned | m_BurnStepTimeNonfuel |
Time (in msec) that a fire block takes to burn without a fuel block into the next step. More... | |
int | m_Flammability |
Chance [0..100000] of an adjacent fuel to catch fire on each tick. More... | |
int | m_ReplaceFuelChance |
Chance [0..100000] of a fuel burning out being replaced by a new fire block instead of an air block. More... | |
Protected Attributes inherited from cSimulator | |
cWorld & | m_World |
The fire simulator takes care of the fire blocks.
It periodically increases their meta ("steps") until they "burn out"; it also supports the forever burning netherrack. Each individual fire block gets stored in per-chunk data; that list is then used for fast retrieval. The data value associated with each coord is used as the number of msec that the fire takes until it progresses to the next step (blockmeta++). This value is updated if a neighbor is changed. The simulator reads its parameters from the ini file given to the constructor.
Definition at line 17 of file FireSimulator.h.
Definition at line 76 of file FireSimulator.cpp.
|
overridevirtual |
Definition at line 90 of file FireSimulator.cpp.
Called to simulate a new block.
Implements cSimulator.
Definition at line 240 of file FireSimulator.cpp.
Returns true if a fire can be started in the specified block, that is, it is an air block and has fuel next to it.
Note that a_NearChunk may be a chunk neighbor to the block specified! The coords are relative to a_NearChunk but not necessarily in it.
Definition at line 408 of file FireSimulator.cpp.
|
static |
Definition at line 231 of file FireSimulator.cpp.
Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels.
Definition at line 274 of file FireSimulator.cpp.
|
overridevirtual |
Returns true if the specified block type is "interesting" for this simulator.
Implements cSimulator.
Definition at line 174 of file FireSimulator.cpp.
|
static |
Definition at line 183 of file FireSimulator.cpp.
Removes all burnable blocks neighboring the specified block.
Definition at line 366 of file FireSimulator.cpp.
|
inlineoverridevirtual |
Called in each tick, a_Dt is the time passed since the last tick, in msec.
Implements cSimulator.
Definition at line 24 of file FireSimulator.h.
|
overridevirtual |
Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available.
Reimplemented from cSimulator.
Definition at line 98 of file FireSimulator.cpp.
Tries to spread fire to a neighborhood of the specified block.
Definition at line 320 of file FireSimulator.cpp.
|
protected |
Time (in msec) that a fire block takes to burn with a fuel block into the next step.
Definition at line 34 of file FireSimulator.h.
|
protected |
Time (in msec) that a fire block takes to burn without a fuel block into the next step.
Definition at line 37 of file FireSimulator.h.
|
protected |
Chance [0..100000] of an adjacent fuel to catch fire on each tick.
Definition at line 40 of file FireSimulator.h.
|
protected |
Chance [0..100000] of a fuel burning out being replaced by a new fire block instead of an air block.
Definition at line 43 of file FireSimulator.h.