This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View file

@ -0,0 +1,59 @@
#ifndef STAR_LIQUID_TYPES_HPP
#define STAR_LIQUID_TYPES_HPP
#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)};
}
}
#endif