| 209 | } |
| 210 | |
| 211 | void Base::startingBase(GameState &state) |
| 212 | { |
| 213 | while (!tryToPlaceInitialFacilities(state, *this)) |
| 214 | { |
| 215 | LogInfo("Failed to place facilities, trying again"); |
| 216 | // Cleanup the partially-placed base |
| 217 | for (int y = 0; y < this->SIZE; y++) |
| 218 | { |
| 219 | for (int x = 0; x < this->SIZE; x++) |
| 220 | { |
| 221 | this->destroyFacility(state, {x, y}); |
| 222 | } |
| 223 | } |
| 224 | // There always must be a single 'access lift' base module even if everything else has been |
| 225 | // removed |
| 226 | if (this->facilities.size() > 1) |
| 227 | { |
| 228 | LogError("Failed to cleanup facilities after unsuccessful random place"); |
| 229 | } |
| 230 | if (this->facilities.empty()) |
| 231 | { |
| 232 | LogError("No access lift after facility cleanup after unsuccessful random place"); |
| 233 | } |
| 234 | if (this->facilities[0]->type->fixed != true) |
| 235 | { |
| 236 | LogError("Remaining facility after cleanup not an access lift?"); |
| 237 | } |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | Base::BuildError Base::canBuildFacility(StateRef<FacilityType> type, Vec2<int> pos, bool free) const |
| 242 | { |
no test coverage detected