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

Method levelMove

source/base/StarCellularLiquid.hpp:412–437  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410
411template <typename LiquidId>
412void LiquidCellEngine<LiquidId>::levelMove() {
413 for (auto const& selfCell : m_currentActiveCells) {
414 if (!selfCell->liquid)
415 continue;
416
417 auto belowCell = adjacentCell(selfCell, Adjacency::Bottom);
418 if (belowCell)
419 transferLevel(min(1.0f - belowCell->level, selfCell->level), *selfCell, *belowCell, false);
420
421 setLevel(selfCell->level * (1.0f - m_cellWorld->drainLevel(selfCell->position)), *selfCell);
422
423 auto lateralMove = [&](Adjacency adjacency) {
424 auto targetCell = adjacentCell(selfCell, adjacency);
425 if (targetCell)
426 transferLevel((selfCell->level - targetCell->level) * m_engineParameters.lateralMoveFactor, *selfCell, *targetCell, false);
427 };
428
429 if (m_random.randb()) {
430 lateralMove(Adjacency::Left);
431 lateralMove(Adjacency::Right);
432 } else {
433 lateralMove(Adjacency::Right);
434 lateralMove(Adjacency::Left);
435 }
436 }
437}
438
439template <typename LiquidId>
440void LiquidCellEngine<LiquidId>::findInteractions() {

Callers

nothing calls this directly

Calls 2

randbMethod · 0.80
drainLevelMethod · 0.45

Tested by

no test coverage detected