blob: b5c5d4afceef382e81e6c308a9e55cff5c34a56f (
plain)
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
51
52
53
54
55
56
|
#pragma once
#include "StarMathCommon.hpp"
namespace Star {
typedef uint8_t LiquidId;
LiquidId const EmptyLiquidId = 0;
struct LiquidLevel {
LiquidLevel();
LiquidLevel(LiquidId liquid, float level);
LiquidLevel take(float amount);
LiquidId liquid;
float level;
};
struct LiquidNetUpdate {
LiquidId liquid;
uint8_t level;
LiquidLevel liquidLevel() const;
};
struct LiquidStore : LiquidLevel {
// Returns a LiquidStore of the given liquid
static LiquidStore filled(LiquidId liquid, float level, Maybe<float> pressure = {});
// Returns a LiquidStore source liquid block
static LiquidStore endless(LiquidId liquid, float pressure);
LiquidStore();
LiquidStore(LiquidId liquid, float level, float pressure, bool source);
LiquidNetUpdate netUpdate() const;
Maybe<LiquidNetUpdate> update(LiquidId liquid, float level, float pressure);
LiquidLevel take(float amount);
float pressure;
bool source;
};
inline LiquidLevel::LiquidLevel()
: liquid(EmptyLiquidId), level(0.0f) {}
inline LiquidLevel::LiquidLevel(LiquidId liquid, float level)
: liquid(liquid), level(level) {}
inline LiquidLevel LiquidNetUpdate::liquidLevel() const {
return LiquidLevel{liquid, byteToFloat(level)};
}
}
|