| 80 | } |
| 81 | |
| 82 | size_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 | |
| 104 | Json ObjectDatabase::parseTouchDamage(String const& path, Json const& config) { |
| 105 | auto touchDamage = config.get("touchDamage", {}); |
no test coverage detected