fix: IBehaviour.GetBehaviours<T>(List)

This commit is contained in:
Syntriax 2024-11-13 15:30:22 +03:00
parent 1b3b999a95
commit 4d59dcb9ab
2 changed files with 6 additions and 6 deletions

View File

@ -75,8 +75,8 @@ public interface IBehaviourController : IInitialize, IAssignableGameObject, IEnu
/// Gets all <see cref="IBehaviour"/>s of the specified type and stores them in the provided list.
/// </summary>
/// <typeparam name="T">The type of <see cref="IBehaviour"/>s to get.</typeparam>
/// <param name="behaviours">The list to store the <see cref="IBehaviour"/>s.</param>
void GetBehaviours<T>(List<T> behaviours);
/// <param name="results">The list to store the <see cref="IBehaviour"/>s.</param>
void GetBehaviours<T>(IList<T> results);
/// <summary>
/// Removes <see cref="IBehaviour"/>s of the specified type from the <see cref="IBehaviourController"/>.

View File

@ -95,15 +95,15 @@ public class BehaviourController : IBehaviourController
return behaviours ?? Enumerable.Empty<T>().ToList();
}
public void GetBehaviours<T>(List<T> behaviors)
public void GetBehaviours<T>(IList<T> results)
{
behaviors.Clear();
results.Clear();
foreach (var behaviourItem in behaviours)
{
if (behaviourItem is not T _)
if (behaviourItem is not T behaviour)
continue;
behaviours.Add(behaviourItem);
results.Add(behaviour);
}
}