diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp index 651ff719b..18bcbdd54 100644 --- a/Source/Engine/Particles/ParticleEffect.cpp +++ b/Source/Engine/Particles/ParticleEffect.cpp @@ -280,26 +280,18 @@ void ParticleEffect::UpdateSimulation(bool singleFrame) Particles::UpdateEffect(this); } -void ParticleEffect::Play(bool reset) +void ParticleEffect::Play() { - _play = true; _isPlaying = true; - - if (reset) - ResetSimulation(); - else - UpdateSimulation(true); } void ParticleEffect::Pause() { - _play = false; _isPlaying = false; } void ParticleEffect::Stop() { - _play = false; _isPlaying = false; ResetSimulation(); } @@ -424,9 +416,13 @@ void ParticleEffect::SetParametersOverrides(const Array& valu void ParticleEffect::Update() { - if (!_play) + if (!_isPlaying) + { + // Move update timer forward while paused for correct delta time after unpause + Instance.LastUpdateTime = (UseTimeScale ? Time::Update.Time : Time::Update.UnscaledTime).GetTotalSeconds(); return; - + } + // Skip if off-screen if (!UpdateWhenOffscreen && _lastMinDstSqr >= MAX_Real) return; @@ -448,16 +444,10 @@ void ParticleEffect::Update() void ParticleEffect::UpdateExecuteInEditor() { + // Auto-play in Editor if (!Editor::IsPlayMode) { - // Always Play in editor while not playing. - // Could be useful to have a GUI to change this state - if (!_play) - { - _play = true; - _isPlaying = true; - } - + _isPlaying = true; Update(); } } @@ -632,6 +622,7 @@ void ParticleEffect::Deserialize(DeserializeStream& stream, ISerializeModifier* const auto overridesMember = stream.FindMember("Overrides"); if (overridesMember != stream.MemberEnd()) { + // [Deprecated on 25.11.2018, expires on 25.11.2022] if (modifier->EngineBuild < 6197) { const auto& overrides = overridesMember->value; @@ -752,7 +743,7 @@ void ParticleEffect::OnEnable() if (PlayOnStart) Play(); - + // Base Actor::OnEnable(); } diff --git a/Source/Engine/Particles/ParticleEffect.h b/Source/Engine/Particles/ParticleEffect.h index 5a4bae771..bfee23a3b 100644 --- a/Source/Engine/Particles/ParticleEffect.h +++ b/Source/Engine/Particles/ParticleEffect.h @@ -184,7 +184,6 @@ private: uint32 _parametersVersion = 0; // Version number for _parameters to be in sync with Instance.ParametersVersion Array _parameters; // Cached for scripting API Array _parametersOverrides; // Cached parameter modifications to be applied to the parameters - bool _play = false; bool _isPlaying = false; public: @@ -353,8 +352,7 @@ public: /// /// Plays the simulation. /// - /// /// If true, the simulation will be reset - API_FUNCTION() void Play(bool reset = true); + API_FUNCTION() void Play(); /// /// Pauses the simulation.