| 1357 | } |
| 1358 | |
| 1359 | void Vehicle::enterBuilding(GameState &state, StateRef<Building> b) |
| 1360 | { |
| 1361 | carriedByVehicle.clear(); |
| 1362 | crashed = false; |
| 1363 | if (this->currentBuilding) |
| 1364 | { |
| 1365 | LogError("Vehicle already in a building?"); |
| 1366 | return; |
| 1367 | } |
| 1368 | this->currentBuilding = b; |
| 1369 | b->currentVehicles.insert({&state, shared_from_this()}); |
| 1370 | if (carriedVehicle) |
| 1371 | { |
| 1372 | carriedVehicle->enterBuilding(state, b); |
| 1373 | carriedVehicle->processRecoveredVehicle(state); |
| 1374 | carriedVehicle.clear(); |
| 1375 | } |
| 1376 | |
| 1377 | removeFromMap(state); |
| 1378 | |
| 1379 | this->position = type->isGround() ? b->carEntranceLocation : *b->landingPadLocations.begin(); |
| 1380 | this->position += Vec3<float>{0.5f, 0.5f, 0.5f}; |
| 1381 | this->facing = 0.0f; |
| 1382 | this->goalFacing = 0.0f; |
| 1383 | this->ticksToTurn = 0; |
| 1384 | this->angularVelocity = 0.0f; |
| 1385 | // If spent some time outside then spend a unit of fuel |
| 1386 | if (fuelSpentTicks > 0 && currentBuilding == homeBuilding) |
| 1387 | { |
| 1388 | fuelSpentTicks = 0; |
| 1389 | auto engine = getEngine(); |
| 1390 | if (engine && engine->type->max_ammo > 0) |
| 1391 | { |
| 1392 | if (engine->ammo > 0) |
| 1393 | { |
| 1394 | engine->ammo--; |
| 1395 | } |
| 1396 | } |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | void Vehicle::setupMover() |
| 1401 | { |
no test coverage detected