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

Method updateCargo

game/state/city/vehicle.cpp:2326–2371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2324}
2325
2326void Vehicle::updateCargo(GameState &state)
2327{
2328 if (crashed || falling)
2329 {
2330 return;
2331 }
2332 // Cannot order to ferry if aggressive and in city
2333 if (!currentBuilding && attackMode == AttackMode::Aggressive)
2334 {
2335 return;
2336 }
2337 // Already ferrying
2338 if (!missions.empty() && missions.back().type == VehicleMission::MissionType::OfferService)
2339 {
2340 return;
2341 }
2342 // See if need to ferry
2343 bool needFerry = false;
2344 for (auto &c : cargo)
2345 {
2346 // Either this is non-combat loot, or this loot belongs to this building
2347 // Don't keep trying to ferry combat loot to other building as we're NOT going to move
2348 // when we check it in getServiceDestination method!
2349 if (c.originalOwner || c.destination == currentBuilding)
2350 {
2351 needFerry = true;
2352 break;
2353 }
2354 }
2355 if (!needFerry)
2356 {
2357 for (auto &a : currentAgents)
2358 {
2359 if (!a->missions.empty() &&
2360 a->missions.front().type == AgentMission::MissionType::AwaitPickup)
2361 {
2362 needFerry = true;
2363 break;
2364 }
2365 }
2366 }
2367 if (needFerry)
2368 {
2369 setMission(state, VehicleMission::offerService(state, *this));
2370 }
2371}
2372
2373void Vehicle::updateSprite(GameState &state [[maybe_unused]])
2374{

Callers 2

updateEndOfSecondMethod · 0.45

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected