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) | |
Public Member Functions inherited from cSimulator | |
cSimulator (cWorld &a_World) | |
virtual | ~cSimulator () |
Static Public Member Functions | |
static bool | DoesBurnForever (BLOCKTYPE a_BlockType) |
static bool | IsFuel (BLOCKTYPE a_BlockType) |
Static Public Member Functions inherited from cSimulator | |
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 offset position, excluding the old position. More... | |
Private Member Functions | |
virtual void | AddBlock (cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_Block) 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... | |
virtual void | SimulateChunk (std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk *a_Chunk) override |
void | TrySpreadFire (cChunk *a_Chunk, Vector3i a_RelPos) |
Tries to spread fire to a neighborhood of the specified block. More... | |
Static Private Member Functions | |
static bool | IsAllowedBlock (BLOCKTYPE a_BlockType) |
Private 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... | |
Additional Inherited Members | |
Static Public Attributes inherited from cSimulator | |
static constexpr std::array< Vector3i, 6 > | AdjacentOffsets |
Contains offsets for direct adjacents of any position. More... | |
Protected Member Functions inherited from cSimulator | |
virtual void | Simulate (float a_Dt) |
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. More... | |
virtual void | WakeUp (cChunk &a_Chunk, Vector3i a_Position, Vector3i a_Offset, BLOCKTYPE a_Block) |
Called to simulate a single block, synthesised by the simulator manager. 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 18 of file FireSimulator.h.
Definition at line 68 of file FireSimulator.cpp.
|
overrideprivatevirtual |
Called to simulate a new block.
Unlike WakeUp this function will perform minimal checking. It queues the block to be simulated as fast as possible, suitable for area wakeups.
Implements cSimulator.
Definition at line 237 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 411 of file FireSimulator.cpp.
|
static |
Definition at line 228 of file FireSimulator.cpp.
Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels.
Definition at line 272 of file FireSimulator.cpp.
|
staticprivate |
Definition at line 171 of file FireSimulator.cpp.
|
static |
Definition at line 180 of file FireSimulator.cpp.
Removes all burnable blocks neighboring the specified block.
Definition at line 362 of file FireSimulator.cpp.
|
overrideprivatevirtual |
Implements cSimulator.
Definition at line 82 of file FireSimulator.cpp.
Tries to spread fire to a neighborhood of the specified block.
Definition at line 316 of file FireSimulator.cpp.
|
private |
Time (in msec) that a fire block takes to burn with a fuel block into the next step.
Definition at line 35 of file FireSimulator.h.
|
private |
Time (in msec) that a fire block takes to burn without a fuel block into the next step.
Definition at line 38 of file FireSimulator.h.
|
private |
Chance [0..100000] of an adjacent fuel to catch fire on each tick.
Definition at line 41 of file FireSimulator.h.
|
private |
Chance [0..100000] of a fuel burning out being replaced by a new fire block instead of an air block.
Definition at line 44 of file FireSimulator.h.