本文整理汇总了C++中Entity::GetHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetHealth方法的具体用法?C++ Entity::GetHealth怎么用?C++ Entity::GetHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetHealth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCollision
void LaserBeam::OnCollision(ICollidable *other)
{
Entity *entity = (Entity*)other;
Damage_t damage;
damage.damage = entity->GetHealth();
if (entity->IsPlayer())
{
damage.damage = 1;
}
damage.direction = Vector2D(-1, 0);
damage.inflictor = GetOwner();
if (GetOwner() != nullptr)
{
damage.statsInflictorName = GetOwner()->GetEntityClassName();
damage.statsInflictorClass = GetOwner()->GetEntityResourceClass();
}
damage.statsWeaponName = GetEntityClassName();
damage.statsWeaponClass = GetEntityResourceClass();
entity->TakeDamage(damage);
Vector2D laserCenter = GetOrigin();
laserCenter.x = entity->GetOrigin().x;
GetGameContext()->GetParticleRoot()->CreateParticles("laser_cannon_hit", laserCenter, Vector2D(-1, 0));
}
示例2: DrawESP
void hud::DrawESP()
{
surface->SetFont(ui::font_hud);
surface->SetTextColor(0xff, 0xff, 0xff, 0xff);
Entity *lp = LocalPlayer();
int maxent = globals->maxclients();
for (int i = 1; i <= ents->GetMaxEntities(); ++i)
{
Entity *ent = ents->GetEntity(i);
if (ent == nullptr || ent == lp)
continue;
if (ent->IsDormant())
continue;
if (1 && i <= maxent)
{
if (!ent->IsAlive())
continue;
int x0, y0, x1, y1;
if (!MakeBox(ent, x0, y0, x1, y1))
continue;
surface->SetColor(0x00, 0x00, 0x00, 0x7f);
surface->DrawOutlinedRect(x0 - 1, y0 - 1, x1 + 1, y1 + 1);
surface->DrawOutlinedRect(x0 + 1, y0 + 1, x1 - 1, y1 - 1);
if (1) // menu.ESP.health
surface->DrawFilledRect(x0 - 4, y0 - 1, x0 - 1, y1 + 1);
#if defined(L4D) || defined(L4D2)
switch (ent->GetTeam())
{
case 2:
case 4:
surface->SetColor(0x46, 0x78, 0xff, 0xff);
break;
case 3:
surface->SetColor(0x96, 0x00, 0xe1, 0xff);
break;
}
#else
switch (ent->GetTeam())
{
case TEAM_RED:
surface->SetColor(0xff, 0x64, 0x64, 0xff);
break;
case TEAM_BLU:
surface->SetColor(0x46, 0x78, 0xff, 0xff);
break;
}
#endif
surface->DrawOutlinedRect(x0, y0, x1, y1);
if (1) // menu.ESP.health
{
if (ent->GetHealth() <= ent->GetMaxHealth())
{
if (ent->GetHealth() <= (ent->GetMaxHealth() / 4))
surface->SetColor(0xff, 0x00, 0x00, 0xff);
else
surface->SetColor(0x00, 0xff, 0x00, 0xff);
}
surface->DrawFilledRect(x0 - 3, y1 - Min<int>(y1 - y0, (float)(y1 - y0) * ((float)ent->GetHealth() / (float)ent->GetMaxHealth()) + 0.5f), x0 - 1, y1);
}
if (1) // menu.ESP.name
{
player_info info;
engine->GetPlayerInfo(i, info);
int length = 0;
const wchar_t *text = tounicode(info.name, length);
int tw, th;
surface->GetTextSize(ui::font_hud, text, tw, th);
surface->SetTextPos((x0 + x1 - tw) / 2, y0 - th);
surface->DrawText(text, length, 0);
}
if (1) // menu.ESP.weapon
{
Entity *weapon = ent->GetActiveWeapon();
if (weapon)
{
const char *classname = weapon->GetClass();
#ifndef GMOD
if (qstrlen(classname) > 6)
{
//.........这里部分代码省略.........