1
0
cuberite-2a/src/Simulator/FireSimulator.h
Mattes D 01b8ed5295
Pulled the BlockID and BlockInfo headers from Globals.h. (#4591)
The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change)
The BlockInfo.h file was removed from Globals.h (main change)
The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics)
The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor)
Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header.
That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified.
eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values
2020-04-03 08:57:01 +02:00

75 lines
2.6 KiB
C++

#pragma once
#include "Simulator.h"
#include "../IniFile.h"
/** 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.
*/
class cFireSimulator :
public cSimulator
{
public:
cFireSimulator(cWorld & a_World, cIniFile & a_IniFile);
virtual ~cFireSimulator() override;
virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used
virtual void SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override;
static bool IsFuel (BLOCKTYPE a_BlockType);
static bool DoesBurnForever(BLOCKTYPE a_BlockType);
protected:
/** Time (in msec) that a fire block takes to burn with a fuel block into the next step */
unsigned m_BurnStepTimeFuel;
/** Time (in msec) that a fire block takes to burn without a fuel block into the next step */
unsigned m_BurnStepTimeNonfuel;
/** Chance [0..100000] of an adjacent fuel to catch fire on each tick */
int m_Flammability;
/** Chance [0..100000] of a fuel burning out being replaced by a new fire block instead of an air block */
int m_ReplaceFuelChance;
virtual void AddBlock(Vector3i a_Block, cChunk * a_Chunk) override;
/** Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels */
int GetBurnStepTime(cChunk * a_Chunk, Vector3i a_RelPos);
/** Tries to spread fire to a neighborhood of the specified block */
void TrySpreadFire(cChunk * a_Chunk, Vector3i a_RelPos);
/** Removes all burnable blocks neighboring the specified block */
void RemoveFuelNeighbors(cChunk * a_Chunk, 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.
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. */
bool CanStartFireInBlock(cChunk * a_NearChunk, Vector3i a_RelPos);
} ;
/** Stores individual fire blocks in the chunk; the int data is used as the time [msec] the fire takes to step to another stage (blockmeta++) */
typedef cCoordWithIntList cFireSimulatorChunkData;