feat: safe delegate invocation helper added
This commit is contained in:
@@ -51,7 +51,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
shouldBeTicking = false;
|
||||
|
||||
State = TimerState.Stopped;
|
||||
OnStopped?.Invoke(this);
|
||||
OnStopped?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
@@ -62,7 +62,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
double delta = GameManager.Time.DeltaSpan.TotalSeconds;
|
||||
|
||||
Remaining -= delta;
|
||||
OnDelta?.Invoke(this, delta);
|
||||
OnDelta?.InvokeSafe(this, delta);
|
||||
|
||||
if (Remaining <= .0f)
|
||||
Stop();
|
||||
@@ -90,13 +90,13 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
public virtual void Pause()
|
||||
{
|
||||
State = TimerState.Paused;
|
||||
OnPaused?.Invoke(this);
|
||||
OnPaused?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
public virtual void Resume()
|
||||
{
|
||||
State = TimerState.Ticking;
|
||||
OnResumed?.Invoke(this);
|
||||
OnResumed?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
private void StartTimer()
|
||||
@@ -104,7 +104,7 @@ public class TimerBehaviour : Behaviour, ITimer
|
||||
hasStartedTickingBefore = true;
|
||||
|
||||
State = TimerState.Ticking;
|
||||
OnStarted?.Invoke(this);
|
||||
OnStarted?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
protected override void OnFinalize()
|
||||
|
||||
Reference in New Issue
Block a user