| 68 | } |
| 69 | |
| 70 | void LiquidWorld::setFlow(Vec2I const& location, CellularLiquidFlowCell<LiquidId> const& flow) { |
| 71 | if (flow.liquid) { |
| 72 | m_worldServer->setLiquid(location, *flow.liquid, flow.level, flow.pressure); |
| 73 | |
| 74 | auto const& tile = m_worldServer->getServerTile(location); |
| 75 | if (auto materialInteraction = m_materialDatabase->liquidMaterialInteraction(*flow.liquid, tile.background)) { |
| 76 | if (!materialInteraction->topOnly && tile.liquid.level >= materialInteraction->consumeLiquid) { |
| 77 | if (auto modifyTile = m_worldServer->modifyServerTile(location)) { |
| 78 | modifyTile->liquid.take(materialInteraction->consumeLiquid); |
| 79 | modifyTile->background = materialInteraction->transformTo; |
| 80 | m_worldServer->activateLiquidLocation(location); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | if (auto modInteraction = m_materialDatabase->liquidModInteraction(*flow.liquid, tile.backgroundMod)) { |
| 85 | if (!modInteraction->topOnly && tile.liquid.level >= modInteraction->consumeLiquid) { |
| 86 | if (auto modifyTile = m_worldServer->modifyServerTile(location)) { |
| 87 | modifyTile->liquid.take(modInteraction->consumeLiquid); |
| 88 | modifyTile->backgroundMod = modInteraction->transformTo; |
| 89 | m_worldServer->activateLiquidLocation(location); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | } else { |
| 94 | m_worldServer->setLiquid(location, EmptyLiquidId, 0.0f, 0.0f); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | void LiquidWorld::liquidInteraction(Vec2I const& a, LiquidId aLiquid, Vec2I const& b, LiquidId bLiquid) { |
| 99 | auto handleInteraction = [this](Vec2I const& target, Maybe<LiquidInteractionResult> interaction) { |
no test coverage detected