Use +infinity instead of -1 for immediate object destruction
parent
275e792a81
commit
a644fc107d
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include "object/object_interface_type.h"
|
#include "object/object_interface_type.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
enum class DamageType
|
enum class DamageType
|
||||||
{
|
{
|
||||||
Fire = 1, //!< fire damage (AlienSpider or Shooter), burns on destruction
|
Fire = 1, //!< fire damage (AlienSpider or Shooter), burns on destruction
|
||||||
|
@ -48,7 +50,7 @@ public:
|
||||||
virtual ~CDamageableObject()
|
virtual ~CDamageableObject()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Damage the object, with the given force. Returns true if the object has been fully destroyed (assuming the object is destroyable, of course). force < 0 => destroy immediately (default), force == 0 => default damage values
|
//! Damage the object, with the given force. Returns true if the object has been fully destroyed (assuming the object is destroyable, of course). force == infinity => destroy immediately (default), force == 0 => default damage values
|
||||||
// NOTE: You should never assume that after this function exits, the object is destroyed, unless it returns true. Even if you specify force = -1, if may still sometimes decide not to destroy the object.
|
// 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 = -1.0f) = 0;
|
virtual bool DamageObject(DamageType type, float force = std::numeric_limits<float>::infinity()) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -366,7 +366,7 @@ bool COldObject::DamageObject(DamageType type, float force)
|
||||||
if (Implements(ObjectInterfaceType::Shielded))
|
if (Implements(ObjectInterfaceType::Shielded))
|
||||||
{
|
{
|
||||||
float magnifyDamage = m_magnifyDamage * m_main->GetGlobalMagnifyDamage();
|
float magnifyDamage = m_magnifyDamage * m_main->GetGlobalMagnifyDamage();
|
||||||
if (force >= 0)
|
if (force != std::numeric_limits<float>::infinity())
|
||||||
{
|
{
|
||||||
// Calculate the shield lost by the explosion
|
// Calculate the shield lost by the explosion
|
||||||
if ( force == 0.0f ) // use default?
|
if ( force == 0.0f ) // use default?
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
|
|
||||||
void Simplify() override;
|
void Simplify() override;
|
||||||
|
|
||||||
bool DamageObject(DamageType type, float force = -1.0f) override;
|
bool DamageObject(DamageType type, float force = std::numeric_limits<float>::infinity()) override;
|
||||||
void DestroyObject(DestructionType type) override;
|
void DestroyObject(DestructionType type) override;
|
||||||
|
|
||||||
bool EventProcess(const Event& event) override;
|
bool EventProcess(const Event& event) override;
|
||||||
|
|
Loading…
Reference in New Issue