| 63 | void Scenery::clearSupportedParts() { supportedParts.clear(); } |
| 64 | |
| 65 | bool Scenery::attachToSomething() |
| 66 | { |
| 67 | auto pos = tileObject->getOwningTile()->position; |
| 68 | supportHardness = -10; |
| 69 | auto &map = tileObject->map; |
| 70 | auto thisPtr = shared_from_this(); |
| 71 | |
| 72 | int startX = pos.x - 1; |
| 73 | int endX = pos.x + 1; |
| 74 | int startY = pos.y - 1; |
| 75 | int endY = pos.y + 1; |
| 76 | int startZ = pos.z - 1; |
| 77 | int endZ = pos.z; |
| 78 | for (int x = startX; x <= endX; x++) |
| 79 | { |
| 80 | for (int y = startY; y <= endY; y++) |
| 81 | { |
| 82 | for (int z = startZ; z <= endZ; z++) |
| 83 | { |
| 84 | if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y || z < 0 || |
| 85 | z >= map.size.z) |
| 86 | { |
| 87 | continue; |
| 88 | } |
| 89 | auto tile = map.getTile(x, y, z); |
| 90 | for (auto &o : tile->ownedObjects) |
| 91 | { |
| 92 | if (o->getType() == TileObject::Type::Scenery) |
| 93 | { |
| 94 | auto mp = std::static_pointer_cast<TileObjectScenery>(o)->getOwner(); |
| 95 | |
| 96 | if (mp == thisPtr || !mp->isAlive()) |
| 97 | { |
| 98 | continue; |
| 99 | } |
| 100 | mp->supportedParts.insert(currentPosition); |
| 101 | supportedBy.emplace_back(mp->currentPosition); |
| 102 | return true; |
| 103 | } |
| 104 | } |
| 105 | } // For every x and y and z |
| 106 | } |
| 107 | } |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | bool Scenery::findSupport(bool allowClinging) |
| 112 | { |
no test coverage detected