Simplify changes from #924 and properly update after unpausing effect
This commit is contained in:
@@ -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<ParameterOverride>& 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();
|
||||
}
|
||||
|
||||
@@ -184,7 +184,6 @@ private:
|
||||
uint32 _parametersVersion = 0; // Version number for _parameters to be in sync with Instance.ParametersVersion
|
||||
Array<ParticleEffectParameter> _parameters; // Cached for scripting API
|
||||
Array<ParameterOverride> _parametersOverrides; // Cached parameter modifications to be applied to the parameters
|
||||
bool _play = false;
|
||||
bool _isPlaying = false;
|
||||
|
||||
public:
|
||||
@@ -353,8 +352,7 @@ public:
|
||||
/// <summary>
|
||||
/// Plays the simulation.
|
||||
/// </summary>
|
||||
/// /// <param name="reset">If true, the simulation will be reset</param>
|
||||
API_FUNCTION() void Play(bool reset = true);
|
||||
API_FUNCTION() void Play();
|
||||
|
||||
/// <summary>
|
||||
/// Pauses the simulation.
|
||||
|
||||
Reference in New Issue
Block a user