31 lines
782 B
C#
31 lines
782 B
C#
using System;
|
|
|
|
using Syntriax.Engine.Core.Abstract;
|
|
|
|
namespace Syntriax.Engine.Core;
|
|
|
|
public class ActiveBehaviourCollectorSorted<T> : ActiveBehaviourCollector<T> where T : class, IBehaviour
|
|
{
|
|
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)
|
|
{
|
|
if (SortBy is not null)
|
|
activeBehaviours.Sort(SortBy);
|
|
}
|
|
|
|
public ActiveBehaviourCollectorSorted() { }
|
|
public ActiveBehaviourCollectorSorted(IGameManager gameManager, Comparison<T> sortBy) : base(gameManager) => SortBy = sortBy;
|
|
}
|