| 109 | } |
| 110 | |
| 111 | bool Scenery::findSupport(bool allowClinging) |
| 112 | { |
| 113 | auto pos = tileObject->getOwningTile()->position; |
| 114 | supportHardness = 1; |
| 115 | if (pos.z <= 1) |
| 116 | { |
| 117 | return true; |
| 118 | } |
| 119 | auto &map = tileObject->map; |
| 120 | auto thisPtr = shared_from_this(); |
| 121 | |
| 122 | // Forward lookup for adding increments |
| 123 | static const std::map<int, Vec2<int>> intToVec = { |
| 124 | {0, {0, -1}}, {1, {1, 0}}, {2, {0, 1}}, {3, {-1, 0}}}; |
| 125 | // Forward lookup for connection/hill checking |
| 126 | static const std::map<Vec2<int>, int> vecToIntForward = { |
| 127 | {{0, -1}, 0}, {{1, 0}, 1}, {{0, 1}, 2}, {{-1, 0}, 3}}; |
| 128 | // Reverse lookup for connection checking |
| 129 | static const std::map<Vec2<int>, int> vecToIntBack = { |
| 130 | {{0, -1}, 2}, {{1, 0}, 3}, {{0, 1}, 0}, {{-1, 0}, 1}}; |
| 131 | |
| 132 | // Scenery gets supported in a different way than battle map parts |
| 133 | // |
| 134 | // - When first checked it finds what supports it in a generous way |
| 135 | // and remembers it |
| 136 | // - Then, for the remainder of its life, it will only accept support |
| 137 | // from that location, and nothing else. |
| 138 | // - This means that, for example, hanging building part will be supported by adjacent part |
| 139 | // However if it was originally supported by the part below, it won't re-support when |
| 140 | // part below dies, but will come crashing down |
| 141 | // - However, roads and tubes are an exception and will try to re-establish their "supportedby" |
| 142 | |
| 143 | // Scenery gets (hard) support in the following way: |
| 144 | // |
| 145 | // - The only way to hard-support is by having non-road/tube below |
| 146 | // - Only tubes can be supported on tubes this way |
| 147 | // (in this case tube looking for support must have a downward connection) |
| 148 | // - Only WalkMode::None Road can give support this way |
| 149 | // - Only non-WalkMode::Into General can give support this way |
| 150 | // - The exception is that tube can be supported by tube below if connected |
| 151 | // |
| 152 | // (following conditions provide "soft" support) |
| 153 | // |
| 154 | // - If allowClinging is true |
| 155 | // - General/Wall/Junk can cling to one adjacent "hard" supported General/Wall |
| 156 | // - General/Wall/Junk can cling to two adjacent "soft" supported General/Wall/Junk |
| 157 | // - General can cling to one General above it |
| 158 | // - General can cling to two Generals adjacent, one above one below on same side (xy) |
| 159 | // - Wall can cling to two adjacent Walls below it |
| 160 | // - People tube can cling onto adjacent "hard" General, adhering to its direction |
| 161 | // |
| 162 | // Finally, can be supported if it has established support lines |
| 163 | // on both sides that connect to an object providing support (any kind) |
| 164 | // - Object "shoots" a line in both directions and as long as there is an object on every tile |
| 165 | // the line continues, and if an object providing hard support is reached, |
| 166 | // then "soft" support can be attained |
| 167 | // |
| 168 |
no test coverage detected