feat: safe delegate invocation helper added
This commit is contained in:
@@ -36,7 +36,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
shouldBeTicking = false;
|
||||
|
||||
State = TimerState.Stopped;
|
||||
OnStopped?.Invoke(this);
|
||||
OnStopped?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
@@ -47,7 +47,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
double delta = GameManager.Time.DeltaSpan.TotalSeconds;
|
||||
|
||||
Time += delta;
|
||||
OnDelta?.Invoke(this, delta);
|
||||
OnDelta?.InvokeSafe(this, delta);
|
||||
}
|
||||
|
||||
protected override void OnEnteredHierarchy(IGameManager gameManager)
|
||||
@@ -72,13 +72,13 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
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 StartStopwatch()
|
||||
@@ -86,7 +86,7 @@ public class StopwatchBehaviour : Behaviour, IStopwatch
|
||||
hasStartedTickingBefore = true;
|
||||
|
||||
State = TimerState.Ticking;
|
||||
OnStarted?.Invoke(this);
|
||||
OnStarted?.InvokeSafe(this);
|
||||
}
|
||||
|
||||
protected override void OnFinalize()
|
||||
|
||||
Reference in New Issue
Block a user