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

Method setFlow

source/game/StarWorldGeneration.cpp:70–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void 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
98void LiquidWorld::liquidInteraction(Vec2I const& a, LiquidId aLiquid, Vec2I const& b, LiquidId bLiquid) {
99 auto handleInteraction = [this](Vec2I const& target, Maybe<LiquidInteractionResult> interaction) {

Callers 1

finishMethod · 0.80

Calls 6

modifyServerTileMethod · 0.80
liquidModInteractionMethod · 0.80
setLiquidMethod · 0.45
takeMethod · 0.45

Tested by

no test coverage detected