diff --git a/Engine.Core/CoroutineManager.cs b/Engine.Core/CoroutineManager.cs index 511f755..8ec9e22 100644 --- a/Engine.Core/CoroutineManager.cs +++ b/Engine.Core/CoroutineManager.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; namespace Syntriax.Engine.Core; -public class CoroutineManager : UniverseObject +public class CoroutineManager : Behaviour { private readonly List enumerators = []; @@ -18,12 +18,12 @@ public class CoroutineManager : UniverseObject enumerators.Remove(enumerator); } - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { universe.OnUpdate.AddListener(OnUpdate); } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { universe.OnUpdate.RemoveListener(OnUpdate); } diff --git a/Engine.Core/Systems/DrawManager.cs b/Engine.Core/Systems/DrawManager.cs index 64c320a..cd7fef0 100644 --- a/Engine.Core/Systems/DrawManager.cs +++ b/Engine.Core/Systems/DrawManager.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Syntriax.Engine.Core; -public class DrawManager : UniverseObject +public class DrawManager : Behaviour { // We use Descending order because draw calls are running from last to first private static Comparer SortByDescendingPriority() => Comparer.Create((x, y) => y.Priority.CompareTo(x.Priority)); @@ -29,7 +29,7 @@ public class DrawManager : UniverseObject postDrawEntities[i].PostDraw(); } - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { preDrawEntities.Assign(universe); drawEntities.Assign(universe); @@ -40,7 +40,7 @@ public class DrawManager : UniverseObject universe.OnPostDraw.AddListener(OnPostDraw); } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { preDrawEntities.Unassign(); drawEntities.Unassign(); diff --git a/Engine.Core/Systems/UpdateManager.cs b/Engine.Core/Systems/UpdateManager.cs index 87bf73b..dcf8070 100644 --- a/Engine.Core/Systems/UpdateManager.cs +++ b/Engine.Core/Systems/UpdateManager.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; namespace Syntriax.Engine.Core; -public class UpdateManager : UniverseObject +public class UpdateManager : Behaviour { // We use Ascending order because draw calls are running from last to first private static Comparer SortByAscendingPriority() => Comparer.Create((x, y) => x.Priority.CompareTo(y.Priority)); @@ -14,7 +14,7 @@ public class UpdateManager : UniverseObject private readonly List toCallFirstFrameUpdates = new(32); - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { firstFrameUpdates.Assign(universe); preUpdateEntities.Assign(universe); @@ -26,7 +26,7 @@ public class UpdateManager : UniverseObject universe.OnPostUpdate.AddListener(OnPostUpdate); } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { firstFrameUpdates.Unassign(); preUpdateEntities.Unassign(); diff --git a/Engine.Physics2D/PhysicsCoroutineManager.cs b/Engine.Physics2D/PhysicsCoroutineManager.cs index e5d47c1..8403594 100644 --- a/Engine.Physics2D/PhysicsCoroutineManager.cs +++ b/Engine.Physics2D/PhysicsCoroutineManager.cs @@ -5,7 +5,7 @@ using Syntriax.Engine.Core; namespace Syntriax.Engine.Physics2D; -public class PhysicsCoroutineManager : UniverseObject +public class PhysicsCoroutineManager : Behaviour { private readonly Event.EventHandler delegateOnUpdate = null!; @@ -23,9 +23,9 @@ public class PhysicsCoroutineManager : UniverseObject enumerators.Remove(enumerator); } - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { - physicsEngine = universe.GetUniverseObject(); + physicsEngine = universe.FindRequiredBehaviour(); if (physicsEngine is IPhysicsEngine2D foundPhysicsEngine) foundPhysicsEngine.OnPhysicsStep.RemoveListener(OnPhysicsStep); else @@ -44,11 +44,11 @@ public class PhysicsCoroutineManager : UniverseObject } } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { if (physicsEngine is IPhysicsEngine2D existingPhysicsEngine) existingPhysicsEngine.OnPhysicsStep.RemoveListener(OnPhysicsStep); - universe.OnUpdate.RemoveListener(OnUpdate); + universe.OnUpdate.RemoveListener(delegateOnUpdate); } private void OnUpdate(IUniverse sender, IUniverse.UpdateArguments args) @@ -56,11 +56,11 @@ public class PhysicsCoroutineManager : UniverseObject if (Universe is not IUniverse universe) return; - physicsEngine = universe.GetUniverseObject(); + physicsEngine = universe.FindRequiredBehaviour(); if (physicsEngine is IPhysicsEngine2D foundPhysicsEngine) { foundPhysicsEngine.OnPhysicsStep.AddListener(OnPhysicsStep); - universe.OnUpdate.RemoveListener(OnUpdate); + universe.OnUpdate.RemoveListener(delegateOnUpdate); } } diff --git a/Engine.Physics2D/PhysicsEngine2D.cs b/Engine.Physics2D/PhysicsEngine2D.cs index 040aabb..a5a3b18 100644 --- a/Engine.Physics2D/PhysicsEngine2D.cs +++ b/Engine.Physics2D/PhysicsEngine2D.cs @@ -4,7 +4,7 @@ using Syntriax.Engine.Core; namespace Syntriax.Engine.Physics2D; -public class PhysicsEngine2D : UniverseObject, IPhysicsEngine2D +public class PhysicsEngine2D : Behaviour, IPhysicsEngine2D { public Event OnPhysicsIteration { get; } = new(); public Event OnPhysicsStep { get; } = new(); @@ -174,7 +174,7 @@ public class PhysicsEngine2D : UniverseObject, IPhysicsEngine2D rigidBody.Transform.Rotation += rigidBody.AngularVelocity * intervalDeltaTime; } - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { physicsPreUpdateCollector.Assign(universe); physicsUpdateCollector.Assign(universe); @@ -185,7 +185,7 @@ public class PhysicsEngine2D : UniverseObject, IPhysicsEngine2D universe.OnPreUpdate.AddListener(OnEnginePreUpdate); } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { physicsPreUpdateCollector.Unassign(); physicsUpdateCollector.Unassign(); diff --git a/Engine.Systems/Tween/TweenManager.cs b/Engine.Systems/Tween/TweenManager.cs index a35ffa0..4c0b599 100644 --- a/Engine.Systems/Tween/TweenManager.cs +++ b/Engine.Systems/Tween/TweenManager.cs @@ -5,7 +5,7 @@ using Syntriax.Engine.Core; namespace Syntriax.Engine.Systems.Tween; -public class TweenManager : UniverseObject, ITweenManager +public class TweenManager : Behaviour, ITweenManager { private CoroutineManager coroutineManager = null!; @@ -73,12 +73,12 @@ public class TweenManager : UniverseObject, ITweenManager Return((Tween)tween); } - protected override void OnEnteringUniverse(IUniverse universe) + protected override void OnEnteredUniverse(IUniverse universe) { - coroutineManager = universe.GetRequiredUniverseObject(); + coroutineManager = universe.FindRequiredBehaviour(); } - protected override void OnExitingUniverse(IUniverse universe) + protected override void OnExitedUniverse(IUniverse universe) { coroutineManager = null!; }