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

Method underAttack

game/state/city/building.cpp:975–995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

973}
974
975void Building::underAttack(GameState &state, StateRef<Organisation> attacker)
976{
977 if (owner->isRelatedTo(attacker) == Organisation::Relation::Hostile)
978 {
979 std::list<StateRef<Vehicle>> toLaunch;
980 for (auto v : currentVehicles)
981 {
982 toLaunch.push_back(v);
983 }
984 for (auto v : toLaunch)
985 {
986 v->setMission(state, VehicleMission::patrol(state, *v, true, 5));
987 }
988 if (timeOfLastAttackEvent + TICKS_ATTACK_EVENT_TIMEOUT < state.gameTime.getTicks())
989 {
990 timeOfLastAttackEvent = state.gameTime.getTicks();
991 fw().pushEvent(new GameBuildingEvent(GameEventType::BuildingAttacked,
992 {&state, shared_from_this()}, attacker));
993 }
994 }
995}
996
997void Building::collapse(GameState &state)
998{

Callers 1

handleCollisionMethod · 0.80

Calls 4

isRelatedToMethod · 0.80
getTicksMethod · 0.80
pushEventMethod · 0.80
setMissionMethod · 0.45

Tested by

no test coverage detected