Development Merge 2025.04.01 #1
@ -14,12 +14,12 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
|||||||
public event IBehaviourCollector<T>.CollectedEventHandler? OnCollected = null;
|
public event IBehaviourCollector<T>.CollectedEventHandler? OnCollected = null;
|
||||||
public event IBehaviourCollector<T>.RemovedEventHandler? OnRemoved = null;
|
public event IBehaviourCollector<T>.RemovedEventHandler? OnRemoved = null;
|
||||||
|
|
||||||
protected readonly List<T> _behaviours = new(32);
|
protected readonly List<T> behaviours = new(32);
|
||||||
|
|
||||||
public IReadOnlyList<T> Behaviours => _behaviours;
|
public IReadOnlyList<T> Behaviours => behaviours;
|
||||||
public IGameManager GameManager { get; private set; } = null!;
|
public IGameManager GameManager { get; private set; } = null!;
|
||||||
|
|
||||||
public T this[Index index] => _behaviours[index];
|
public T this[Index index] => behaviours[index];
|
||||||
|
|
||||||
public BehaviourCollector() { }
|
public BehaviourCollector() { }
|
||||||
public BehaviourCollector(IGameManager gameManager) => Assign(gameManager);
|
public BehaviourCollector(IGameManager gameManager) => Assign(gameManager);
|
||||||
@ -48,7 +48,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
|||||||
if (behaviour is not T tBehaviour)
|
if (behaviour is not T tBehaviour)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_behaviours.Add(tBehaviour);
|
behaviours.Add(tBehaviour);
|
||||||
OnBehaviourAdd(behaviour);
|
OnBehaviourAdd(behaviour);
|
||||||
OnCollected?.Invoke(this, tBehaviour);
|
OnCollected?.Invoke(this, tBehaviour);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
|||||||
if (behaviour is not T tBehaviour)
|
if (behaviour is not T tBehaviour)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_behaviours.Remove(tBehaviour))
|
if (!behaviours.Remove(tBehaviour))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OnBehaviourRemove(behaviour);
|
OnBehaviourRemove(behaviour);
|
||||||
@ -99,6 +99,6 @@ public class BehaviourCollector<T> : IBehaviourCollector<T> where T : class
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator() => _behaviours.GetEnumerator();
|
public IEnumerator<T> GetEnumerator() => behaviours.GetEnumerator();
|
||||||
IEnumerator IEnumerable.GetEnumerator() => _behaviours.GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => behaviours.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class BehaviourCollectorSorted<T> : BehaviourCollector<T> where T : class
|
|||||||
protected override void OnBehaviourAdd(IBehaviour behaviour)
|
protected override void OnBehaviourAdd(IBehaviour behaviour)
|
||||||
{
|
{
|
||||||
if (SortBy is not null)
|
if (SortBy is not null)
|
||||||
_behaviours.Sort(SortBy);
|
behaviours.Sort(SortBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BehaviourCollectorSorted() { }
|
public BehaviourCollectorSorted() { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user