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

Method die

game/state/city/base.cpp:80–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void Base::die(GameState &state, bool collapse)
81{
82 fw().pushEvent(new GameSomethingDiedEvent(
83 GameEventType::BaseDestroyed, name,
84 collapse ? /*by collapsing building*/ "" : "byEnemyForces", building->crewQuarters));
85 for (auto &b : building->city->buildings)
86 {
87 for (auto &c : b.second->cargo)
88 {
89 if (c.destination == building)
90 {
91 c.refund(state, {&state, b.first});
92 }
93 }
94 }
95 for (auto &v : state.vehicles)
96 {
97 for (auto &c : v.second->cargo)
98 {
99 if (c.destination == building)
100 {
101 // This is base transfer in progress
102 if (c.originalOwner == c.destination->owner)
103 {
104 // Re-route to another base
105 for (auto &b : state.player_bases)
106 {
107 if (b.second->building == building)
108 {
109 continue;
110 }
111 c.destination = b.second->building;
112 break;
113 }
114 }
115 else
116 {
117 c.refund(state, nullptr);
118 }
119 }
120 }
121 }
122 for (auto a : building->currentAgents)
123 {
124 a->die(state, true);
125 }
126 for (auto v : building->currentVehicles)
127 {
128 v->die(state, true);
129 }
130 building->base.clear();
131 building->owner = state.getGovernment();
132 building->collapse(state);
133 building.clear();
134
135 state.player_bases.erase(Base::getId(state, shared_from_this()));
136 state.current_base.clear();
137 if (state.player_bases.empty())

Callers 12

alienMovementMethod · 0.45
buildingPartChangeMethod · 0.45
updateMethod · 0.45
startMethod · 0.45
updateMethod · 0.45
eventOccurredMethod · 0.45
executeOrdersMethod · 0.45
executeOrdersMethod · 0.45
orderDropMethod · 0.45
handleMouseDownMethod · 0.45
handleGameStateEventMethod · 0.45

Calls 7

pushEventMethod · 0.80
refundMethod · 0.80
getGovernmentMethod · 0.80
emptyMethod · 0.80
clearMethod · 0.45
collapseMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected