refactor: switched from universe objects to behaviours on all managers like update, draw & physics etc.
This commit is contained in:
@@ -5,7 +5,7 @@ using Syntriax.Engine.Core;
|
||||
|
||||
namespace Syntriax.Engine.Physics2D;
|
||||
|
||||
public class PhysicsCoroutineManager : UniverseObject
|
||||
public class PhysicsCoroutineManager : Behaviour
|
||||
{
|
||||
private readonly Event<IUniverse, IUniverse.UpdateArguments>.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<IPhysicsEngine2D>();
|
||||
physicsEngine = universe.FindRequiredBehaviour<IPhysicsEngine2D>();
|
||||
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<IPhysicsEngine2D>();
|
||||
physicsEngine = universe.FindRequiredBehaviour<IPhysicsEngine2D>();
|
||||
if (physicsEngine is IPhysicsEngine2D foundPhysicsEngine)
|
||||
{
|
||||
foundPhysicsEngine.OnPhysicsStep.AddListener(OnPhysicsStep);
|
||||
universe.OnUpdate.RemoveListener(OnUpdate);
|
||||
universe.OnUpdate.RemoveListener(delegateOnUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user