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

Method createAgentInfo

game/ui/components/controlgenerator.cpp:391–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391AgentInfo ControlGenerator::createAgentInfo(GameState &state, sp<Agent> a,
392 UnitSelectionState forcedSelectionState, bool forceFade)
393{
394 AgentInfo i;
395
396 i.agent = a;
397 i.selected = UnitSelectionState::Unselected;
398 i.useRank = false;
399 i.state = CityUnitState::InMotion;
400 i.useState = false;
401 i.faded = false;
402 i.fatal = false;
403 i.psiIn = false;
404 i.psiOut = false;
405 i.stunProportion = 0.0f;
406 i.healthProportion = 0.0f;
407 i.shield = false;
408 if (!a)
409 {
410 return i;
411 }
412 // Rank only displayed on soldiers
413 if (a->type->role == AgentType::Role::Soldier)
414 {
415 i.useRank = true;
416 i.rank = a->rank;
417 }
418 // Check if this is not an special screen like AEquip
419 if (forcedSelectionState == UnitSelectionState::NA)
420 {
421 // Select according to battle state
422 if (a->unit)
423 {
424 for (auto &u : state.current_battle->battleViewSelectedUnits)
425 {
426 if (u->agent == a)
427 {
428 i.selected = (u == state.current_battle->battleViewSelectedUnits.front())
429 ? UnitSelectionState::FirstSelected
430 : UnitSelectionState::Selected;
431 break;
432 }
433 }
434 }
435 // Select according to city state
436 else
437 {
438 for (auto &ag : state.current_city->cityViewSelectedAgents)
439 {
440 if (ag == a)
441 {
442 i.selected = (ag == state.current_city->cityViewSelectedAgents.front())
443 ? UnitSelectionState::FirstSelected
444 : UnitSelectionState::Selected;
445 break;
446 }
447 }
448 }

Callers

nothing calls this directly

Calls 7

clampFunction · 0.85
isFatallyWoundedMethod · 0.80
emptyMethod · 0.80
getMaxShieldMethod · 0.45
getShieldMethod · 0.45
getHealthMethod · 0.45
getMaxHealthMethod · 0.45

Tested by

no test coverage detected