IsEnded is only a getter

pyro-refactor
immibis 2021-07-04 12:21:19 +02:00
parent 02c5cb7aa7
commit ed9701545d
8 changed files with 28 additions and 23 deletions

View File

@ -219,14 +219,6 @@ Error CPyro::IsEnded()
// End of the pyrotechnic effect?
if ( m_progress < 1.0f ) return ERR_CONTINUE;
AfterEnd();
if ( m_lightRank != -1 )
{
m_lightMan->DeleteLight(m_lightRank);
m_lightRank = -1;
}
return ERR_STOP;
}

View File

@ -204,6 +204,8 @@ public:
void FallProgress(float rTime);
//! Indicates whether the fall is over
Error IsEnded() override;
//! Makes a sound and unlocks the object after fall is done
void AfterEnd() override;
bool EventProcess(const Event&) override;
};
@ -237,7 +239,7 @@ class CSpiderPyro : public CPyro
{
public:
CSpiderPyro(CObject *obj);
Error IsEnded() override;
bool EventProcess(const Event& event) override;
void AfterCreate() override;
};
@ -245,7 +247,7 @@ class CEggPyro : public CPyro
{
public:
CEggPyro(CObject *obj);
Error IsEnded() override;
bool EventProcess(const Event& event) override;
void AfterCreate() override;
};
@ -284,7 +286,7 @@ class CFragVPyro : public CPyro
{
public:
CFragVPyro(CObject *obj);
Error IsEnded() override;
bool EventProcess(const Event& event) override;
void AfterCreate() override;
};
@ -313,7 +315,7 @@ class CFragExploOrShotPyro : public CPyro
public:
CFragExploOrShotPyro(PyroType type, CObject *obj, float force = 1.0f);
void AfterCreate() override;
Error IsEnded() override;
bool EventProcess(const Event& event) override;
void UpdateEffect() override;
//! Starts the explosion of a vehicle

View File

@ -71,6 +71,7 @@ void Gfx::CPyroManager::EventProcess(const Event& event)
}
else
{
(*it)->AfterEnd();
(*it)->DeleteObject();
it = m_pyros.erase(it);
}

View File

@ -31,14 +31,15 @@ CEggPyro::CEggPyro(CObject *obj)
: CPyro(PT_OTHER, obj)
{}
Error CEggPyro::IsEnded() {
bool CEggPyro::EventProcess(const Event& event)
{
// Destroys the object that exploded.
//It should not be destroyed at the end of the Create,
//because it is sometimes the object itself that makes the Create:
// pyro->Create(PT_FRAGT, this);
DeleteObject(true, true);
return CPyro::IsEnded();
return CPyro::EventProcess(event);
}
void CEggPyro::AfterCreate()

View File

@ -176,12 +176,18 @@ Error CFallPyro::IsEnded()
Math::Vector pos = m_object->GetPosition();
if (pos.y > m_fallFloor) return ERR_CONTINUE;
m_sound->Play(SOUND_BOUM, pos);
m_object->SetLock(false); // usable again
return ERR_STOP;
}
void CFallPyro::AfterEnd()
{
if (m_object != nullptr)
{
m_sound->Play(SOUND_BOUM, m_object->GetPosition());
m_object->SetLock(false); // usable again
}
}
bool CFallPyro::EventProcess(const Event& event)
{
CPyro::EventProcess(event);

View File

@ -297,7 +297,8 @@ void CFragExploOrShotPyro::AfterCreate()
}
}
Error CFragExploOrShotPyro::IsEnded() {
bool CFragExploOrShotPyro::EventProcess(const Event& event)
{
// Destroys the object that exploded.
//It should not be destroyed at the end of the Create,
//because it is sometimes the object itself that makes the Create:
@ -309,7 +310,7 @@ Error CFragExploOrShotPyro::IsEnded() {
DeleteObject(true, true);
}
return CPyro::IsEnded();
return CPyro::EventProcess(event);
}
void CFragExploOrShotPyro::ExploStart()

View File

@ -32,14 +32,15 @@ CFragVPyro::CFragVPyro(CObject *obj)
: CPyro(PT_OTHER, obj)
{}
Error CFragVPyro::IsEnded() {
bool CFragVPyro::EventProcess(const Event& event)
{
// Destroys the object that exploded.
//It should not be destroyed at the end of the Create,
//because it is sometimes the object itself that makes the Create:
// pyro->Create(PT_FRAGT, this);
DeleteObject(true, true);
return CPyro::IsEnded();
return CPyro::EventProcess(event);
}
void CFragVPyro::AfterCreate()

View File

@ -37,14 +37,15 @@ CSpiderPyro::CSpiderPyro(CObject *obj)
: CPyro(PT_OTHER, obj)
{}
Error CSpiderPyro::IsEnded() {
bool CSpiderPyro::EventProcess(const Event& event)
{
// Destroys the object that exploded.
//It should not be destroyed at the end of the Create,
//because it is sometimes the object itself that makes the Create:
// pyro->Create(PT_FRAGT, this);
DeleteObject(true, true);
return CPyro::IsEnded();
return CPyro::EventProcess(event);
}
void CSpiderPyro::AfterCreate()