fix: sorted collector behaviours not working properly as the last object
This commit is contained in:
parent
906edf096e
commit
33a452a62e
@ -6,7 +6,18 @@ namespace Syntriax.Engine.Core;
|
||||
|
||||
public class ActiveBehaviourCollectorSorted<T> : ActiveBehaviourCollector<T> where T : class, IBehaviour
|
||||
{
|
||||
public Comparison<T>? SortBy { get; set; } = null;
|
||||
private Comparison<T>? _sortBy = null;
|
||||
public Comparison<T>? SortBy
|
||||
{
|
||||
get => _sortBy;
|
||||
set
|
||||
{
|
||||
_sortBy = value;
|
||||
|
||||
if (value is not null)
|
||||
activeBehaviours.Sort(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBehaviourAdd(IBehaviour behaviour)
|
||||
{
|
||||
@ -15,5 +26,5 @@ public class ActiveBehaviourCollectorSorted<T> : ActiveBehaviourCollector<T> whe
|
||||
}
|
||||
|
||||
public ActiveBehaviourCollectorSorted() { }
|
||||
public ActiveBehaviourCollectorSorted(IGameManager gameManager) : base(gameManager) { }
|
||||
public ActiveBehaviourCollectorSorted(IGameManager gameManager, Comparison<T> sortBy) : base(gameManager) => SortBy = sortBy;
|
||||
}
|
||||
|
@ -6,7 +6,18 @@ namespace Syntriax.Engine.Core;
|
||||
|
||||
public class BehaviourCollectorSorted<T> : BehaviourCollector<T> where T : class
|
||||
{
|
||||
public Comparison<T>? SortBy { get; set; } = null;
|
||||
private Comparison<T>? _sortBy = null;
|
||||
public Comparison<T>? SortBy
|
||||
{
|
||||
get => _sortBy;
|
||||
set
|
||||
{
|
||||
_sortBy = value;
|
||||
|
||||
if (value is not null)
|
||||
behaviours.Sort(value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBehaviourAdd(IBehaviour behaviour)
|
||||
{
|
||||
@ -15,5 +26,5 @@ public class BehaviourCollectorSorted<T> : BehaviourCollector<T> where T : class
|
||||
}
|
||||
|
||||
public BehaviourCollectorSorted() { }
|
||||
public BehaviourCollectorSorted(IGameManager gameManager) : base(gameManager) { }
|
||||
public BehaviourCollectorSorted(IGameManager gameManager, Comparison<T> sortBy) : base(gameManager) => SortBy = sortBy;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user