MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / update

Method update

source/game/StarLiquidTypes.cpp:40–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40Maybe<LiquidNetUpdate> LiquidStore::update(LiquidId liquid, float level, float pressure) {
41 if (source) {
42 if (this->liquid != liquid)
43 return {};
44 level = max(level, this->level);
45 pressure = max(pressure, this->pressure);
46 }
47
48 if (level <= 0.0f) {
49 liquid = EmptyLiquidId;
50 pressure = 0.0f;
51 }
52
53 bool netUpdate = this->liquid != liquid || floatToByte(this->level, true) != floatToByte(level, true);
54
55 this->liquid = liquid;
56 this->level = level;
57 this->pressure = pressure;
58
59 if (netUpdate)
60 return LiquidNetUpdate{liquid, floatToByte(level)};
61 else
62 return {};
63}
64
65LiquidLevel LiquidStore::take(float amount) {
66 if (source)

Callers

nothing calls this directly

Calls 1

floatToByteFunction · 0.85

Tested by

no test coverage detected