| 38 | } |
| 39 | |
| 40 | Maybe<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 | |
| 65 | LiquidLevel LiquidStore::take(float amount) { |
| 66 | if (source) |
nothing calls this directly
no test coverage detected