BREAKING CHANGE: renamed original Behaviour class to BehaviourInternal, and replaced it with BehaviourBase
Original Behaviour was using old methods for detecting entering/exiting universe, they are now all under the same hood and the original is kept for UniverseEntranceManager because it needs to enter the universe without itself. The internal behaviour kept under a subnamespace of "Core.Internal" for the purpose that it might come in handy for other use cases.
This commit is contained in:
@@ -2,7 +2,7 @@ using Engine.Core;
|
||||
|
||||
namespace Engine.Systems.Time;
|
||||
|
||||
public class Timer : Behaviour, IUpdate, ITimer
|
||||
public class Timer : Behaviour, IUpdate, IEnterUniverse, IExitUniverse, ITimer
|
||||
{
|
||||
public Event<IReadOnlyTimer> OnStarted { get; } = new();
|
||||
public Event<IReadOnlyTimer, IReadOnlyTimer.TimerDeltaArguments> OnDelta { get; } = new();
|
||||
@@ -67,7 +67,7 @@ public class Timer : Behaviour, IUpdate, ITimer
|
||||
Stop();
|
||||
}
|
||||
|
||||
protected override void OnEnteredUniverse(IUniverse universe)
|
||||
public void EnterUniverse(IUniverse universe)
|
||||
{
|
||||
if (!shouldBeTicking || State is TimerState.Ticking)
|
||||
return;
|
||||
@@ -78,7 +78,7 @@ public class Timer : Behaviour, IUpdate, ITimer
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
protected override void OnExitedUniverse(IUniverse universe)
|
||||
public void ExitUniverse(IUniverse universe)
|
||||
{
|
||||
if (!shouldBeTicking || State is not TimerState.Ticking)
|
||||
return;
|
||||
@@ -106,8 +106,10 @@ public class Timer : Behaviour, IUpdate, ITimer
|
||||
OnStarted?.Invoke(this);
|
||||
}
|
||||
|
||||
protected override void OnFinalize()
|
||||
protected override void FinalizeInternal()
|
||||
{
|
||||
base.FinalizeInternal();
|
||||
|
||||
StartTime = 0f;
|
||||
Remaining = 0f;
|
||||
State = TimerState.Idle;
|
||||
|
Reference in New Issue
Block a user