blob: 7a5967235e11c5ab8f8ab21673b9396928f59448 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// DelayedFluidSimulator.h
// Interfaces to the cDelayedFluidSimulator class representing a fluid simulator that has a configurable delay
// before simulating a block. Each tick it takes a consecutive delay "slot" and simulates only blocks in that slot.
#pragma once
#include "FluidSimulator.h"
class cDelayedFluidSimulator :
public cFluidSimulator
{
typedef cFluidSimulator super;
public:
cDelayedFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid, int a_TickDelay);
virtual ~cDelayedFluidSimulator();
// cSimulator overrides:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
virtual void Simulate(float a_Dt) override;
protected:
typedef std::vector<Vector3i> CoordsArray;
int m_TickDelay; // Count of the m_Slots array
CoordsArray * m_Slots; // Slots, one for each delay tick
int m_CurrentSlotNum; // Index into m_Slots[] where to insert new blocks
/*
Slots:
| 0 | 1 | ... | m_CurrentSlotNum | m_CurrentSlotNum + 1 | ... | m_TickDelay - 1 |
adding blocks here ^ | ^ simulating here
*/
/// Called from Simulate() to simulate each block in one slot of blocks. Descendants override this method to provide custom simulation.
virtual void SimulateBlock(int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
} ;
|