Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected 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)
 
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
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 17 of file FireSimulator.h.

Constructor & Destructor Documentation

cFireSimulator::cFireSimulator ( cWorld a_World,
cIniFile a_IniFile 
)

Definition at line 76 of file FireSimulator.cpp.

cFireSimulator::~cFireSimulator ( )
overridevirtual

Definition at line 90 of file FireSimulator.cpp.

Member Function Documentation

void cFireSimulator::AddBlock ( Vector3i  a_Block,
cChunk a_Chunk 
)
overrideprotectedvirtual

Called to simulate a new block.

Implements cSimulator.

Definition at line 240 of file FireSimulator.cpp.

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

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.

bool cFireSimulator::DoesBurnForever ( BLOCKTYPE  a_BlockType)
static

Definition at line 231 of file FireSimulator.cpp.

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

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.

bool cFireSimulator::IsAllowedBlock ( BLOCKTYPE  a_BlockType)
overridevirtual

Returns true if the specified block type is "interesting" for this simulator.

Implements cSimulator.

Definition at line 174 of file FireSimulator.cpp.

bool cFireSimulator::IsFuel ( BLOCKTYPE  a_BlockType)
static

Definition at line 183 of file FireSimulator.cpp.

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

Removes all burnable blocks neighboring the specified block.

Definition at line 366 of file FireSimulator.cpp.

virtual void cFireSimulator::Simulate ( float  a_Dt)
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.

void cFireSimulator::SimulateChunk ( std::chrono::milliseconds  a_Dt,
int  a_ChunkX,
int  a_ChunkZ,
cChunk a_Chunk 
)
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.

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

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

Definition at line 320 of file FireSimulator.cpp.

Member Data Documentation

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

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

int cFireSimulator::m_Flammability
protected

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

Definition at line 40 of file FireSimulator.h.

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


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