26 lines
565 B
C#
26 lines
565 B
C#
using System;
|
|
|
|
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);
|
|
}
|
|
}
|