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

Method findValidOrientation

source/game/StarObjectDatabase.cpp:82–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82size_t ObjectConfig::findValidOrientation(World const* world, Vec2I const& position, Maybe<Direction> directionAffinity) const {
83 // If we are given a direction affinity, try and find an orientation with a
84 // matching affinity *first*
85 if (directionAffinity) {
86 for (size_t i = 0; i < orientations.size(); ++i) {
87 if (!orientations[i]->directionAffinity || *directionAffinity != *orientations[i]->directionAffinity)
88 continue;
89
90 if (orientations[i]->placementValid(world, position) && orientations[i]->anchorsValid(world, position))
91 return i;
92 }
93 }
94
95 // Then, fallback and try and find any valid affinity
96 for (size_t i = 0; i < orientations.size(); ++i) {
97 if (orientations[i]->placementValid(world, position) && orientations[i]->anchorsValid(world, position))
98 return i;
99 }
100
101 return NPos;
102}
103
104Json ObjectDatabase::parseTouchDamage(String const& path, Json const& config) {
105 auto touchDamage = config.get("touchDamage", {});

Callers 3

updateOrientationMethod · 0.80
canPlaceObjectMethod · 0.80
cursorHintDrawablesMethod · 0.80

Calls 3

placementValidMethod · 0.80
anchorsValidMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected