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

Method createControl

game/ui/general/transactioncontrol.cpp:187–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187sp<TransactionControl> TransactionControl::createControl(GameState &state, StateRef<Agent> agent,
188 int indexLeft, int indexRight)
189{
190 // The agent or agent's vehicle should be on a base
191 auto currentBuilding =
192 agent->currentVehicle ? agent->currentVehicle->currentBuilding : agent->currentBuilding;
193 if (!currentBuilding || !currentBuilding->base)
194 {
195 return nullptr;
196 }
197
198 std::vector<int> initialStock;
199 // Fill out stock
200 {
201 initialStock.resize(9);
202 // Stock of agents always zero on all bases except where it belongs
203 int baseIndex = 0;
204 for (auto &b : state.player_bases)
205 {
206 if (b.first == agent->homeBuilding->base.id)
207 {
208 initialStock[baseIndex] = 1;
209 break;
210 }
211 baseIndex++;
212 }
213 }
214
215 Type type;
216 switch (agent->type->role)
217 {
218 case AgentType::Role::BioChemist:
219 type = Type::BioChemist;
220 break;
221 case AgentType::Role::Engineer:
222 type = Type::Engineer;
223 break;
224 case AgentType::Role::Physicist:
225 type = Type::Physicist;
226 break;
227 case AgentType::Role::Soldier:
228 type = Type::Soldier;
229 break;
230 default:
231 LogError("Unknown type of agent %s.", agent.id);
232 return nullptr;
233 }
234
235 int price = 0;
236 int storeSpace = 0;
237 bool isAmmo = false;
238 bool isBio = false;
239 bool isPerson = true;
240 bool researched = true;
241 auto manufacturer = agent->owner;
242 bool manufacturerHostile = false;
243 bool manufacturerUnavailable = false;
244

Callers

nothing calls this directly

Calls 14

trFunction · 0.85
formatFunction · 0.85
satisfiedMethod · 0.80
endMethod · 0.80
getWeekMethod · 0.80
canPurchaseFromMethod · 0.80
getPlayerMethod · 0.80
setInitialStockMethod · 0.80
setLeftIndexMethod · 0.80
setRightIndexMethod · 0.80
setMinimumMethod · 0.80
setMaximumMethod · 0.80

Tested by

no test coverage detected