Damage Alert Implementation (2th Stage)

1008-fix
DavivaD 2017-06-20 23:35:33 +02:00
parent 75d9f8573b
commit a29a4f93ac
6 changed files with 38 additions and 1 deletions

View File

@ -59,4 +59,11 @@ public:
//! Damage the object, with the given force. Returns true if the object has been fully destroyed (assuming the object is destroyable, of course). If force == infinity, destroy immediately (this is the default value)
/** NOTE: You should never assume that after this function exits, the object is destroyed, unless it returns true. Even if you specify force = infinity, if may still sometimes decide not to destroy the object. */
virtual bool DamageObject(DamageType type, float force = std::numeric_limits<float>::infinity(), CObject* killer = nullptr) = 0;
//! Set the status that means the object is currently taking damage
virtual void SetDamaging(bool damaging) = 0;
//! Is object currently taking damage?
virtual bool IsDamaging() = 0;
};

View File

@ -137,6 +137,7 @@ COldObject::COldObject(int id)
m_bVirusMode = false;
m_virusTime = 0.0f;
m_lastVirusParticle = 0.0f;
m_damaging = false;
m_dying = DeathType::Alive;
m_bFlat = false;
m_gunGoalV = 0.0f;
@ -387,6 +388,9 @@ bool COldObject::DamageObject(DamageType type, float force, CObject* killer)
float shield = GetShield();
shield -= loss;
SetShield(shield);
// Sending info about taking damage
SetDamaging(true);
}
else
{
@ -394,6 +398,7 @@ bool COldObject::DamageObject(DamageType type, float force, CObject* killer)
{
// Dead immediately
SetShield(0.0f);
SetDamaging(false);
}
}
dead = (GetShield() <= 0.0f);
@ -425,6 +430,9 @@ bool COldObject::DamageObject(DamageType type, float force, CObject* killer)
m_engine->GetPyroManager()->Create(Gfx::PT_SHOTT, this, loss);
}
/*if ( m_time < 2.0f && m_damaging == true ) SetDamaging(false);
m_time = 0.0f;*/ // TODO: Make DamageAlarm Icon Dissapear after 2 seconds
return false;
}
@ -440,6 +448,7 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
if (Implements(ObjectInterfaceType::Shielded))
{
SetShield(0.0f);
SetDamaging(false);
}
Gfx::PyroType pyroType = Gfx::PT_NULL;
@ -2652,6 +2661,15 @@ float COldObject::GetMagnifyDamage()
return m_magnifyDamage;
}
void COldObject::SetDamaging(bool damaging)
{
m_damaging = damaging;
}
bool COldObject::IsDamaging()
{
return m_damaging;
}
void COldObject::SetDying(DeathType deathType)
{

View File

@ -237,6 +237,9 @@ public:
void SetMagnifyDamage(float factor) override;
float GetMagnifyDamage() override;
void SetDamaging(bool damaging);
bool IsDamaging() override;
void SetDying(DeathType deathType) override;
DeathType GetDying() override;
bool IsDying() override;
@ -356,6 +359,7 @@ protected:
bool m_bSelectable; // selectable object
bool m_bCheckToken; // object with audited tokens
bool m_underground; // object active but undetectable
bool m_damaging;
DeathType m_dying;
bool m_bFlat;
bool m_bTrainer; // drive vehicle (without remote)

View File

@ -57,7 +57,8 @@ enum ControlState
STATE_FRAME = (1<<13), // framework highlighting
STATE_WARNING = (1<<14), // framework hatched yellow / black
STATE_VALUE = (1<<15), // displays the value
STATE_RUN = (1<<16) // running program
STATE_RUN = (1<<16), // running program
STATE_DAMAGE = (1<<17) // taking damage
};

View File

@ -109,6 +109,12 @@ void CShortcut::Draw()
zoom = 1.0f;
mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_state & STATE_DAMAGE )
{
icon = 59;
zoom = 0.8f;
mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_icon == 128+6 || m_icon == 128+7 || m_icon == 58 ) // pause or film?
{
icon = -1; // no bottom

View File

@ -247,6 +247,7 @@ bool CMainShort::UpdateShortcuts()
assert(m_shortcuts[i]->Implements(ObjectInterfaceType::Controllable));
pc->SetState(STATE_CHECK, dynamic_cast<CControllableObject*>(m_shortcuts[i])->GetSelect());
pc->SetState(STATE_RUN, m_shortcuts[i]->Implements(ObjectInterfaceType::Programmable) && dynamic_cast<CProgrammableObject*>(m_shortcuts[i])->IsProgram());
pc->SetState(STATE_DAMAGE, dynamic_cast<CDamageableObject*>(m_shortcuts[i])->IsDamaging());
}
}
return true;