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

Method placementLevelConstraint

source/game/StarDungeonGenerator.cpp:637–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635 }
636
637 int Part::placementLevelConstraint() const {
638 Vec2I air = {0, size().y()};
639 Vec2I ground = {0, 0};
640 Vec2I liquid = {0, 0};
641 m_reader->forEachTile([&ground, &air, &liquid](Vec2I tilePos, Tile const& tile) -> bool {
642 for (auto const& rule : tile.rules) {
643 if (is<WorldGenMustContainSolidRule>(rule) && tilePos.y() > ground.y()) {
644 ground = tilePos;
645 }
646 if (is<WorldGenMustContainAirRule>(rule) && tilePos.y() < air.y()) {
647 air = tilePos;
648 }
649 if ((is<WorldGenMustContainLiquidRule>(rule) || is<WorldGenMustNotContainLiquidRule>(rule)) && tilePos.y() > liquid.y()) {
650 liquid = tilePos;
651 }
652 }
653 return false;
654 });
655 ground[1] = max(ground[1], liquid[1]);
656 if (air.y() < ground.y())
657 throw DungeonException::format(
658 "Invalid ground vs air contraint! Ground {} can't be above air {}"
659 " (try moving your 'require there be air here' anchors above any other 'require there be (something) here' anchors.)",
660 ground, air);
661 return air.y();
662 }
663
664 bool Part::ignoresPartMaximum() const {
665 for (size_t i = 0; i < m_rules.size(); i++)

Callers 1

generateMethod · 0.80

Calls 4

sizeFunction · 0.85
yMethod · 0.80
formatFunction · 0.50
forEachTileMethod · 0.45

Tested by

no test coverage detected