feat: safe delegate invocation helper added

This commit is contained in:
2025-04-13 19:08:47 +03:00
parent 00f7b1aaab
commit 58eb373c79
21 changed files with 116 additions and 91 deletions

View File

@@ -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()