Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
cFireSimulator Class Reference

The fire simulator takes care of the fire blocks. More...

#include <FireSimulator.h>

Inheritance diagram for cFireSimulator:
Inheritance graph
[legend]
Collaboration diagram for cFireSimulator:
Collaboration graph
[legend]

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
cWorldm_World
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ cFireSimulator()

cFireSimulator::cFireSimulator ( cWorld a_World,
cIniFile a_IniFile 
)

Definition at line 68 of file FireSimulator.cpp.

Member Function Documentation

◆ AddBlock()

void cFireSimulator::AddBlock ( cChunk a_Chunk,
Vector3i  a_Position,
BLOCKTYPE  a_Block 
)
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.

◆ CanStartFireInBlock()

bool cFireSimulator::CanStartFireInBlock ( cChunk a_NearChunk,
Vector3i  a_RelPos 
)
private

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.

◆ DoesBurnForever()

bool cFireSimulator::DoesBurnForever ( BLOCKTYPE  a_BlockType)
static

Definition at line 228 of file FireSimulator.cpp.

◆ GetBurnStepTime()

int cFireSimulator::GetBurnStepTime ( cChunk a_Chunk,
Vector3i  a_RelPos 
)
private

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.

◆ IsAllowedBlock()

bool cFireSimulator::IsAllowedBlock ( BLOCKTYPE  a_BlockType)
staticprivate

Definition at line 171 of file FireSimulator.cpp.

◆ IsFuel()

bool cFireSimulator::IsFuel ( BLOCKTYPE  a_BlockType)
static

Definition at line 180 of file FireSimulator.cpp.

◆ RemoveFuelNeighbors()

void cFireSimulator::RemoveFuelNeighbors ( cChunk a_Chunk,
Vector3i  a_RelPos 
)
private

Removes all burnable blocks neighboring the specified block.

Definition at line 362 of file FireSimulator.cpp.

◆ SimulateChunk()

void cFireSimulator::SimulateChunk ( std::chrono::milliseconds  a_Dt,
int  a_ChunkX,
int  a_ChunkZ,
cChunk a_Chunk 
)
overrideprivatevirtual

Implements cSimulator.

Definition at line 82 of file FireSimulator.cpp.

◆ TrySpreadFire()

void cFireSimulator::TrySpreadFire ( cChunk a_Chunk,
Vector3i  a_RelPos 
)
private

Tries to spread fire to a neighborhood of the specified block.

Definition at line 316 of file FireSimulator.cpp.

Member Data Documentation

◆ m_BurnStepTimeFuel

unsigned cFireSimulator::m_BurnStepTimeFuel
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.

◆ m_BurnStepTimeNonfuel

unsigned cFireSimulator::m_BurnStepTimeNonfuel
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.

◆ m_Flammability

int cFireSimulator::m_Flammability
private

Chance [0..100000] of an adjacent fuel to catch fire on each tick.

Definition at line 41 of file FireSimulator.h.

◆ m_ReplaceFuelChance

int cFireSimulator::m_ReplaceFuelChance
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.


The documentation for this class was generated from the following files: