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:
2025-10-22 16:50:19 +03:00
parent 2f32038f04
commit 988a6f67f2
23 changed files with 194 additions and 185 deletions

View File

@@ -2,7 +2,7 @@ using Engine.Core;
namespace Engine.Systems.Time;
public class Stopwatch : Behaviour, IUpdate, IStopwatch
public class Stopwatch : Behaviour, IUpdate, IEnterUniverse, IExitUniverse, IStopwatch
{
public Event<IReadOnlyStopwatch> OnStarted { get; } = new();
public Event<IReadOnlyStopwatch, IReadOnlyStopwatch.StopwatchDeltaArguments> OnDelta { get; } = new();
@@ -49,7 +49,7 @@ public class Stopwatch : Behaviour, IUpdate, IStopwatch
OnDelta?.Invoke(this, new(delta));
}
protected override void OnEnteredUniverse(IUniverse universe)
public void EnterUniverse(IUniverse universe)
{
if (!shouldBeTicking || State is TimerState.Ticking)
return;
@@ -60,7 +60,7 @@ public class Stopwatch : Behaviour, IUpdate, IStopwatch
StartStopwatch();
}
protected override void OnExitedUniverse(IUniverse universe)
public void ExitUniverse(IUniverse universe)
{
if (!shouldBeTicking || State is not TimerState.Ticking)
return;
@@ -88,8 +88,10 @@ public class Stopwatch : Behaviour, IUpdate, IStopwatch
OnStarted?.Invoke(this);
}
protected override void OnFinalize()
protected override void FinalizeInternal()
{
base.FinalizeInternal();
Time = 0f;
State = TimerState.Idle;
shouldBeTicking = false;