本文整理汇总了C++中sp::getHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::getHealth方法的具体用法?C++ sp::getHealth怎么用?C++ sp::getHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::getHealth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createVehicleInfo
VehicleTileInfo ControlGenerator::createVehicleInfo(GameState &state, sp<Vehicle> v)
{
VehicleTileInfo t;
t.vehicle = v;
t.selected = UnitSelectionState::Unselected;
for (auto &veh : state.current_city->cityViewSelectedVehicles)
{
if (veh == v)
{
t.selected = (veh == state.current_city->cityViewSelectedVehicles.front())
? UnitSelectionState::FirstSelected
: UnitSelectionState::Selected;
break;
}
}
float maxHealth;
float currentHealth;
if (v->getShield() != 0)
{
maxHealth = v->getMaxShield();
currentHealth = v->getShield();
t.shield = true;
}
else
{
maxHealth = v->getMaxHealth();
currentHealth = v->getHealth();
t.shield = false;
}
t.healthProportion = currentHealth / maxHealth;
// Clamp passengers to 13 as anything beyond that gets the same icon
t.passengers = std::min(13, v->getPassengers());
// Faded if in other dimension or if haven't left dimension gate yet
t.faded = v->city != state.current_city || (!v->tileObject && !v->currentBuilding);
auto b = v->currentBuilding;
if (b)
{
if (b == v->homeBuilding)
{
t.state = CityUnitState::InBase;
}
else
{
t.state = CityUnitState::InBuilding;
}
}
else
{
t.state = CityUnitState::InMotion;
}
return t;
}
示例2: createAgentInfo
AgentInfo ControlGenerator::createAgentInfo(GameState &state, sp<Agent> a,
UnitSelectionState forcedSelectionState, bool forceFade)
{
AgentInfo i;
i.agent = a;
i.selected = UnitSelectionState::Unselected;
i.useRank = false;
i.state = CityUnitState::InMotion;
i.useState = false;
i.faded = false;
i.fatal = false;
i.psiIn = false;
i.psiOut = false;
i.stunProportion = 0.0f;
i.healthProportion = 0.0f;
i.shield = false;
if (!a)
{
return i;
}
// Rank only displayed on soldiers
if (a->type->role == AgentType::Role::Soldier)
{
i.useRank = true;
i.rank = a->rank;
}
// Check if this is not an special screen like AEquip
if (forcedSelectionState == UnitSelectionState::NA)
{
// Select according to battle state
if (a->unit)
{
for (auto &u : state.current_battle->battleViewSelectedUnits)
{
if (u->agent == a)
{
i.selected = (u == state.current_battle->battleViewSelectedUnits.front())
? UnitSelectionState::FirstSelected
: UnitSelectionState::Selected;
break;
}
}
}
// Select according to city state
else
{
for (auto &ag : state.current_city->cityViewSelectedAgents)
{
if (ag == a)
{
i.selected = (ag == state.current_city->cityViewSelectedAgents.front())
? UnitSelectionState::FirstSelected
: UnitSelectionState::Selected;
break;
}
}
}
}
else // This is a special screen
{
i.selected = forcedSelectionState;
if (!a->unit)
{
i.faded = forceFade;
}
}
// Set common agent state
i.shield = a->getMaxShield(state) > 0;
float maxHealth;
float currentHealth;
if (i.shield)
{
currentHealth = a->getShield(state);
maxHealth = a->getMaxShield(state);
}
else
{
currentHealth = a->getHealth();
maxHealth = a->getMaxHealth();
}
i.healthProportion = maxHealth == 0.0f ? 0.0f : currentHealth / maxHealth;
// Set state that is used in battle
if (a->unit)
{
// Stunned health
if (!i.shield)
{
float stunHealth = a->unit->stunDamage;
i.stunProportion = stunHealth / maxHealth;
i.stunProportion = clamp(i.stunProportion, 0.0f, i.healthProportion);
}
// Fatal wounds
i.fatal = a->unit->isFatallyWounded();
// Psi state
i.psiOut = a->unit->psiTarget != nullptr;
i.psiIn = !a->unit->psiAttackers.empty();
}
// Set state that is used in city
else
//.........这里部分代码省略.........