2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Simulator.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-02 14:57:09 -05:00
|
|
|
/// Despite the class name, this simulator takes care of all blocks that fall when suspended in the air.
|
|
|
|
class cSandSimulator :
|
|
|
|
public cSimulator
|
2012-06-14 09:06:06 -04:00
|
|
|
{
|
|
|
|
public:
|
2013-03-02 14:57:09 -05:00
|
|
|
cSandSimulator(cWorld & a_World, cIniFile & a_IniFile);
|
|
|
|
|
|
|
|
// cSimulator overrides:
|
|
|
|
virtual void Simulate(float a_Dt) override {} // Unused in this simulator
|
|
|
|
virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override;
|
|
|
|
virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override;
|
|
|
|
|
|
|
|
/// Returns true if a falling-able block can start falling through the specified block type
|
|
|
|
static bool CanStartFallingThrough(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
/// Returns true if an already-falling block can pass through the specified block type (e. g. torch)
|
|
|
|
static bool CanContinueFallThrough(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
/// Returns true if the falling block rematerializing will replace the specified block type (e. g. tall grass)
|
|
|
|
static bool IsReplacedOnRematerialization(BLOCKTYPE a_BlockType);
|
|
|
|
|
|
|
|
/// Returns true if the specified block breaks falling blocks while they fall through it (e. g. halfslabs)
|
2013-03-03 03:40:37 -05:00
|
|
|
static bool DoesBreakFallingThrough(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
2013-03-02 14:57:09 -05:00
|
|
|
|
|
|
|
/** Called when a block finishes falling at the specified coords, either by insta-fall,
|
|
|
|
or through cFallingBlock entity.
|
|
|
|
It either rematerializes the block (a_FallingBlockType) at the specified coords, or creates a pickup,
|
|
|
|
based on the block currently present in the world at the dest specified coords
|
|
|
|
*/
|
|
|
|
static void FinishFalling(
|
|
|
|
cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ,
|
|
|
|
BLOCKTYPE a_FallingBlockType, NIBBLETYPE a_FallingBlockMeta
|
|
|
|
);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
protected:
|
2013-03-02 14:57:09 -05:00
|
|
|
bool m_IsInstantFall; // If set to true, blocks don't fall using cFallingBlock entity, but instantly instead
|
|
|
|
|
|
|
|
int m_TotalBlocks; // Total number of blocks currently in the queue for simulating
|
|
|
|
|
2013-02-28 02:42:45 -05:00
|
|
|
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
|
2013-03-02 14:57:09 -05:00
|
|
|
|
|
|
|
/// Performs the instant fall of the block - removes it from top, Finishes it at the bottom
|
|
|
|
void DoInstantFall(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
|
2012-06-14 09:06:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-02 14:57:09 -05:00
|
|
|
/// Per-chunk data for the simulator, specified individual chunks to simulate; Data is not used
|
|
|
|
typedef cCoordWithIntList cSandSimulatorChunkData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|