using System; using Syntriax.Engine.Core.Abstract; namespace Syntriax.Engine.Core; public class BehaviourCollectorSorted : BehaviourCollector where T : class { private Comparison? _sortBy = null; public Comparison? SortBy { get => _sortBy; set { _sortBy = value; if (value is not null) behaviours.Sort(value); } } protected override void OnBehaviourAdd(IBehaviour behaviour) { if (SortBy is not null) behaviours.Sort(SortBy); } public BehaviourCollectorSorted() { } public BehaviourCollectorSorted(IGameManager gameManager, Comparison sortBy) : base(gameManager) => SortBy = sortBy; }