MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / enterBuilding

Method enterBuilding

game/state/city/vehicle.cpp:1359–1398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359void 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
1400void Vehicle::setupMover()
1401{

Callers 13

startMethod · 0.45
updateCargoMethod · 0.45
startMethod · 0.45
getServiceDestinationMethod · 0.45
createVehicleMethod · 0.45
placeVehicleMethod · 0.45
updateLocationMethod · 0.45
loadBattleBuildingFunction · 0.45
goToBattleMethod · 0.45

Calls 5

insertMethod · 0.80
isGroundMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected