refactor: renamed behaviour collectors from sorted to ordered
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Engine.Core;
|
||||
|
||||
public class ActiveBehaviourCollectorSorted<T> : ActiveBehaviourCollector<T> where T : class, IBehaviour
|
||||
public class ActiveBehaviourCollectorOrdered<T> : ActiveBehaviourCollector<T> where T : class, IBehaviour
|
||||
{
|
||||
private readonly Event<IBehaviour, IBehaviour.PriorityChangedArguments>.EventHandler delegateOnPriorityChanged = null!;
|
||||
|
||||
@@ -53,15 +53,10 @@ public class ActiveBehaviourCollectorSorted<T> : ActiveBehaviourCollector<T> whe
|
||||
AddBehaviour(behaviour);
|
||||
}
|
||||
|
||||
public ActiveBehaviourCollectorSorted()
|
||||
public ActiveBehaviourCollectorOrdered() => delegateOnPriorityChanged = OnPriorityChanged;
|
||||
public ActiveBehaviourCollectorOrdered(IUniverse universe, Comparison<T> sortBy) : base(universe)
|
||||
{
|
||||
delegateOnPriorityChanged = OnPriorityChanged;
|
||||
}
|
||||
|
||||
public ActiveBehaviourCollectorSorted(IUniverse universe, Comparison<T> sortBy) : base(universe)
|
||||
{
|
||||
delegateOnPriorityChanged = OnPriorityChanged;
|
||||
|
||||
SortBy = Comparer<T>.Create(sortBy);
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Engine.Core;
|
||||
|
||||
public class BehaviourCollectorSorted<T> : BehaviourCollector<T> where T : class
|
||||
public class BehaviourCollectorOrdered<T> : BehaviourCollector<T> where T : class
|
||||
{
|
||||
private readonly Event<IBehaviour, IBehaviour.PriorityChangedArguments>.EventHandler delegateOnPriorityChanged = null!;
|
||||
|
||||
@@ -53,15 +53,10 @@ public class BehaviourCollectorSorted<T> : BehaviourCollector<T> where T : class
|
||||
AddBehaviour(behaviour);
|
||||
}
|
||||
|
||||
public BehaviourCollectorSorted()
|
||||
public BehaviourCollectorOrdered() => delegateOnPriorityChanged = OnPriorityChanged;
|
||||
public BehaviourCollectorOrdered(IUniverse universe, Comparison<T> sortBy) : base(universe)
|
||||
{
|
||||
delegateOnPriorityChanged = OnPriorityChanged;
|
||||
}
|
||||
|
||||
public BehaviourCollectorSorted(IUniverse universe, Comparison<T> sortBy) : base(universe)
|
||||
{
|
||||
delegateOnPriorityChanged = OnPriorityChanged;
|
||||
|
||||
SortBy = Comparer<T>.Create(sortBy);
|
||||
}
|
||||
}
|
@@ -7,9 +7,9 @@ public class DrawManager : Behaviour
|
||||
// We use Descending order because draw calls are running from last to first
|
||||
private static Comparer<IBehaviour> SortByDescendingPriority() => Comparer<IBehaviour>.Create((x, y) => y.Priority.CompareTo(x.Priority));
|
||||
|
||||
private readonly ActiveBehaviourCollectorSorted<IPreDraw> preDrawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorSorted<IDraw> drawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorSorted<IPostDraw> postDrawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IPreDraw> preDrawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IDraw> drawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IPostDraw> postDrawEntities = new() { SortBy = SortByDescendingPriority() };
|
||||
|
||||
private void OnPreDraw(IUniverse sender)
|
||||
{
|
||||
|
@@ -7,8 +7,8 @@ public class UniverseEntranceManager : Behaviour
|
||||
// We use Ascending order because we are using reverse for loop to call them
|
||||
private static Comparer<IBehaviour> SortByAscendingPriority() => Comparer<IBehaviour>.Create((x, y) => x.Priority.CompareTo(y.Priority));
|
||||
|
||||
private readonly ActiveBehaviourCollectorSorted<IEnterUniverse> enterUniverses = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorSorted<IExitUniverse> exitUniverses = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IEnterUniverse> enterUniverses = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IExitUniverse> exitUniverses = new() { SortBy = SortByAscendingPriority() };
|
||||
|
||||
private readonly List<IEnterUniverse> toCallEnterUniverses = new(32);
|
||||
private readonly List<IExitUniverse> toCallExitUniverses = new(32);
|
||||
|
@@ -8,11 +8,11 @@ public class UpdateManager : Behaviour
|
||||
// We use Ascending order because we are using reverse for loop to call them
|
||||
private static Comparer<IBehaviour> SortByAscendingPriority() => Comparer<IBehaviour>.Create((x, y) => x.Priority.CompareTo(y.Priority));
|
||||
|
||||
private readonly ActiveBehaviourCollectorSorted<IFirstFrameUpdate> firstFrameUpdates = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IFirstFrameUpdate> firstFrameUpdates = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollector<ILastFrameUpdate> lastFrameUpdates = new();
|
||||
private readonly ActiveBehaviourCollectorSorted<IPreUpdate> preUpdateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorSorted<IUpdate> updateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorSorted<IPostUpdate> postUpdateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IPreUpdate> preUpdateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IUpdate> updateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
private readonly ActiveBehaviourCollectorOrdered<IPostUpdate> postUpdateEntities = new() { SortBy = SortByAscendingPriority() };
|
||||
|
||||
private readonly List<IFirstFrameUpdate> toCallFirstFrameUpdates = new(32);
|
||||
|
||||
|
Reference in New Issue
Block a user