|
@@ -32,6 +32,7 @@
|
|
|
#include "../Urho2D/ParticleEmitter2D.h"
|
|
#include "../Urho2D/ParticleEmitter2D.h"
|
|
|
#include "../Urho2D/Renderer2D.h"
|
|
#include "../Urho2D/Renderer2D.h"
|
|
|
#include "../Urho2D/Sprite2D.h"
|
|
#include "../Urho2D/Sprite2D.h"
|
|
|
|
|
+#include "../Urho2D/Urho2DEvents.h"
|
|
|
|
|
|
|
|
#include "../DebugNew.h"
|
|
#include "../DebugNew.h"
|
|
|
|
|
|
|
@@ -262,11 +263,6 @@ void ParticleEmitter2D::UpdateMaterial()
|
|
|
sourceBatches_[0].material_ = 0;
|
|
sourceBatches_[0].material_ = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-URHO3D_EVENT(E_PARTICLESEND, ParticlesEnd) {
|
|
|
|
|
-}
|
|
|
|
|
-URHO3D_EVENT(E_PARTICLESDURATION, ParticlesDuration) {
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void ParticleEmitter2D::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
|
|
void ParticleEmitter2D::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
|
|
|
{
|
|
{
|
|
|
using namespace ScenePostUpdate;
|
|
using namespace ScenePostUpdate;
|
|
@@ -274,10 +270,31 @@ void ParticleEmitter2D::HandleScenePostUpdate(StringHash eventType, VariantMap&
|
|
|
bool emitting = emissionTime_ > 0.0f;
|
|
bool emitting = emissionTime_ > 0.0f;
|
|
|
float timeStep = eventData[P_TIMESTEP].GetFloat();
|
|
float timeStep = eventData[P_TIMESTEP].GetFloat();
|
|
|
Update(timeStep);
|
|
Update(timeStep);
|
|
|
|
|
+
|
|
|
if (emitting && emissionTime_ == 0.0f)
|
|
if (emitting && emissionTime_ == 0.0f)
|
|
|
- SendEvent(E_PARTICLESDURATION); // emitting particles stoped
|
|
|
|
|
- if (hasParticles && 0 == numParticles_)
|
|
|
|
|
- SendEvent(E_PARTICLESEND); // all particles over
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ // Make a weak pointer to self to check for destruction during event handling
|
|
|
|
|
+ WeakPtr<ParticleEmitter2D> self(this);
|
|
|
|
|
+ using namespace ParticlesDuration;
|
|
|
|
|
+
|
|
|
|
|
+ VariantMap& eventData = GetEventDataMap();
|
|
|
|
|
+ eventData[P_NODE] = node_;
|
|
|
|
|
+ eventData[P_EFFECT] = effect_;
|
|
|
|
|
+ SendEvent(E_PARTICLESDURATION, eventData); // Emitting particles stopped
|
|
|
|
|
+
|
|
|
|
|
+ if (self.Expired())
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (hasParticles && numParticles_ == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ using namespace ParticlesEnd;
|
|
|
|
|
+
|
|
|
|
|
+ VariantMap& eventData = GetEventDataMap();
|
|
|
|
|
+ eventData[P_NODE] = node_;
|
|
|
|
|
+ eventData[P_EFFECT] = effect_;
|
|
|
|
|
+
|
|
|
|
|
+ SendEvent(E_PARTICLESEND, eventData); // All particles over
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ParticleEmitter2D::Update(float timeStep)
|
|
void ParticleEmitter2D::Update(float timeStep)
|