Skip to content

Commit

Permalink
Traktor: Minor cleanup in SpawnEffectEventInstance.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Feb 26, 2024
1 parent c782a56 commit 8e672f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 8 additions & 12 deletions code/Spray/SpawnEffectEventInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ SpawnEffectEventInstance::SpawnEffectEventInstance(
, m_world(world)
, m_sender(sender)
, m_Toffset(Toffset)
, m_effectComponent(effectComponent)
{
Transform T;
if (m_sender)
Expand All @@ -39,7 +38,7 @@ SpawnEffectEventInstance::SpawnEffectEventInstance(
T = m_Toffset;

m_effectEntity = new world::Entity();
m_effectEntity->setComponent(m_effectComponent);
m_effectEntity->setComponent(effectComponent);

if (m_spawnEffect->m_useRotation)
m_effectEntity->setTransform(T);
Expand Down Expand Up @@ -73,11 +72,10 @@ bool SpawnEffectEventInstance::update(const world::UpdateParams& update)
m_effectEntity->setTransform(Transform(T.translation()));
}

if (m_effectComponent->isFinished())
if (m_effectEntity->getComponent< EffectComponent >()->isFinished())
{
m_world->removeEntity(m_effectEntity);
safeDestroy(m_effectEntity);
m_effectComponent = nullptr;
return false;
}

Expand All @@ -86,19 +84,17 @@ bool SpawnEffectEventInstance::update(const world::UpdateParams& update)

void SpawnEffectEventInstance::cancel(world::Cancel when)
{
if (!m_effectEntity)
return;

if (when == world::Cancel::Immediate)
{
if (m_effectEntity)
{
m_world->removeEntity(m_effectEntity);
safeDestroy(m_effectEntity);
m_effectComponent = nullptr;
}
m_world->removeEntity(m_effectEntity);
safeDestroy(m_effectEntity);
}
else
{
if (m_effectComponent)
m_effectComponent->setLoopEnable(false);
m_effectEntity->getComponent< EffectComponent >()->setLoopEnable(false);
}
}

Expand Down
3 changes: 1 addition & 2 deletions code/Spray/SpawnEffectEventInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ class SpawnEffectEventInstance : public world::IEntityEventInstance
const SpawnEffectEvent* m_spawnEffect;
Ref< world::World > m_world;
Ref< world::Entity > m_sender;
Transform m_Toffset;
Ref< EffectComponent > m_effectComponent;
Ref< world::Entity > m_effectEntity;
Transform m_Toffset;
};

}

0 comments on commit 8e672f7

Please sign in to comment.