diff --git a/Engine.Core/Abstract/IBehaviourController.cs b/Engine.Core/Abstract/IBehaviourController.cs index bf5f195..f5e5ab9 100644 --- a/Engine.Core/Abstract/IBehaviourController.cs +++ b/Engine.Core/Abstract/IBehaviourController.cs @@ -65,6 +65,10 @@ public interface IBehaviourController : IAssignableGameObject /// Returns a list of all the matching s found in the . IList GetBehaviours(); + /// An implemented class or . + /// Fills the provided list parameter all the matching s found in the . + void GetBehaviours(List behaviours); + /// /// Removes the found in the . /// diff --git a/Engine.Core/BehaviourController.cs b/Engine.Core/BehaviourController.cs index 0a96572..ae65a2c 100644 --- a/Engine.Core/BehaviourController.cs +++ b/Engine.Core/BehaviourController.cs @@ -70,6 +70,18 @@ public class BehaviourController : IBehaviourController return behaviours ?? Enumerable.Empty().ToList(); } + public void GetBehaviours(List behaviors) + { + behaviors.Clear(); + foreach (var behaviourItem in behaviours) + { + if (behaviourItem is not T _) + continue; + + behaviours.Add(behaviourItem); + } + } + public void RemoveBehaviour(bool removeAll = false) where T : class, IBehaviour { for (int i = behaviours.Count; i >= 0; i--)