Cuberite
A lightweight, fast and extensible game server for Minecraft
FluidSimulator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "Simulator.h"
5 
6 
7 class cWorld;
8 
9 
11 {
18  NONE
19 };
20 
21 
22 
23 
24 
28 {
29 public:
30  virtual ~cFluidSimulatorData() {}
31 };
32 
33 
34 
35 
36 
38  public cSimulator
39 {
40  using Super = cSimulator;
41 
42 public:
43 
44  cFluidSimulator(cWorld & a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid);
45 
47  virtual Vector3f GetFlowingDirection(Vector3i a_Pos);
48 
50  virtual cFluidSimulatorData * CreateChunkData(void) = 0;
51 
52  bool IsFluidBlock (BLOCKTYPE a_BlockType) const { return (a_BlockType == m_FluidBlock); }
53  bool IsStationaryFluidBlock(BLOCKTYPE a_BlockType) const { return (a_BlockType == m_StationaryFluidBlock); }
54  bool IsAnyFluidBlock (BLOCKTYPE a_BlockType) const { return ((a_BlockType == m_FluidBlock) || (a_BlockType == m_StationaryFluidBlock)); }
55 
56  static bool CanWashAway(BLOCKTYPE a_BlockType);
57 
58  bool IsSolidBlock (BLOCKTYPE a_BlockType);
59  bool IsPassableForFluid(BLOCKTYPE a_BlockType);
60 
62  bool IsHigherMeta(NIBBLETYPE a_Meta1, NIBBLETYPE a_Meta2);
63 
64 protected:
65 
66  bool IsAllowedBlock(BLOCKTYPE a_BlockType);
67 
68  BLOCKTYPE m_FluidBlock; // The fluid block type that needs simulating
69  BLOCKTYPE m_StationaryFluidBlock; // The fluid block type that indicates no simulation is needed
70 };
71 
72 
73 
74 
75 
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:44
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
Direction
@ Y_MINUS
@ Z_PLUS
@ Y_PLUS
@ X_MINUS
@ NONE
@ Z_MINUS
@ X_PLUS
This is a base class for all fluid simulator data classes.
virtual ~cFluidSimulatorData()
bool IsHigherMeta(NIBBLETYPE a_Meta1, NIBBLETYPE a_Meta2)
Returns true if a_Meta1 is a higher fluid than a_Meta2.
bool IsSolidBlock(BLOCKTYPE a_BlockType)
BLOCKTYPE m_StationaryFluidBlock
virtual cFluidSimulatorData * CreateChunkData(void)=0
Creates a ChunkData object for the simulator to use.
bool IsStationaryFluidBlock(BLOCKTYPE a_BlockType) const
static bool CanWashAway(BLOCKTYPE a_BlockType)
bool IsAllowedBlock(BLOCKTYPE a_BlockType)
cFluidSimulator(cWorld &a_World, BLOCKTYPE a_Fluid, BLOCKTYPE a_StationaryFluid)
BLOCKTYPE m_FluidBlock
bool IsAnyFluidBlock(BLOCKTYPE a_BlockType) const
bool IsFluidBlock(BLOCKTYPE a_BlockType) const
virtual Vector3f GetFlowingDirection(Vector3i a_Pos)
Returns a unit vector in the direction the fluid is flowing or a zero-vector if not flowing.
bool IsPassableForFluid(BLOCKTYPE a_BlockType)
Base class for all block-based physics simulators (such as fluid, fire, falling blocks etc....
Definition: Simulator.h:22
cSimulator(cWorld &a_World)
Definition: Simulator.h:25
Definition: World.h:53