Eliminate burn pyro types (PT_BURNO/T)

pyro-refactor
immibis 2021-07-04 12:41:16 +02:00
parent ed9701545d
commit 272f80faf9
4 changed files with 16 additions and 25 deletions

View File

@ -292,8 +292,9 @@ public:
class CBurnPyro : public CPyro
{
bool m_organicBurn;
public:
CBurnPyro(PyroType type, CObject *obj);
CBurnPyro(CObject *obj);
void AfterCreate() override;
void UpdateEffect() override;

View File

@ -48,8 +48,6 @@ enum PyroType
PT_SHOTW = 12, //! < hit under water (TODO: check if unused)
// Other subclasses
PT_BURNT = 14, //! < burning of technical object
PT_BURNO = 15, //! < burning of organic object
PT_WIN = 22, //! < fireworks
PT_LOST = 23, //! < black smoke

View File

@ -32,25 +32,28 @@
using namespace Gfx;
CBurnPyro::CBurnPyro(PyroType type, CObject *obj)
: CPyro(type, obj)
CBurnPyro::CBurnPyro(CObject *obj)
: CPyro(PT_OTHER, obj)
, m_organicBurn(obj->GetType() == OBJECT_MOTHER ||
obj->GetType() == OBJECT_ANT ||
obj->GetType() == OBJECT_SPIDER ||
obj->GetType() == OBJECT_BEE ||
obj->GetType() == OBJECT_WORM ||
obj->GetType() == OBJECT_BULLET)
{}
void CBurnPyro::AfterCreate()
{
assert( m_type == PT_BURNT || m_type == PT_BURNO );
m_soundChannel = m_sound->Play(SOUND_BURN, m_pos, 1.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, 12.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.0f, 5.0f, SOPER_STOP);
if ( m_type == PT_BURNO )
if (m_organicBurn)
{
m_sound->Play(SOUND_DEADi, m_pos);
m_sound->Play(SOUND_DEADi, m_engine->GetEyePt());
}
if ( m_type == PT_BURNT )
else
{
BurnStart();
}
@ -108,7 +111,7 @@ void CBurnPyro::UpdateEffect()
m_particle->CreateParticle(pos, speed, dim, PARTISMOKE3, 4.0f);
}
if ( m_type == PT_BURNT )
if ( !m_organicBurn )
{
BurnProgress();
}
@ -699,7 +702,7 @@ void CBurnPyro::AfterEnd()
if (m_object == nullptr)
return;
if (m_type == PT_BURNO) // organic object is burning?
if (m_organicBurn) // organic object is burning?
{
DeleteObject(true, true); // removes the insect
return;

View File

@ -552,24 +552,13 @@ void COldObject::DestroyObject(DestructionType type, CObject* killer)
}
else if ( type == DestructionType::Burn ) // burning?
{
if ( m_type == OBJECT_MOTHER ||
m_type == OBJECT_ANT ||
m_type == OBJECT_SPIDER ||
m_type == OBJECT_BEE ||
m_type == OBJECT_WORM ||
m_type == OBJECT_BULLET )
{
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CBurnPyro>(Gfx::PT_BURNO, this));
SetDying(DeathType::Burning);
m_main->NotifyObjectDestroyed(this);
}
else if ( m_type == OBJECT_HUMAN )
if ( m_type == OBJECT_HUMAN )
{
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CDeadGPyro>(this));
}
else
{
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CBurnPyro>(Gfx::PT_BURNT, this));
m_engine->GetPyroManager()->Create(MakeUnique<Gfx::CBurnPyro>(this));
SetDying(DeathType::Burning);
m_main->NotifyObjectDestroyed(this);
}