diff --git a/Engine.Core/BehaviourController.cs b/Engine.Core/BehaviourController.cs index 98d4585..582276b 100644 --- a/Engine.Core/BehaviourController.cs +++ b/Engine.Core/BehaviourController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Linq; using Syntriax.Engine.Core.Abstract; @@ -55,17 +56,17 @@ public class BehaviourController : IBehaviourController public IList GetBehaviours() { - IList behaviours = new List(); + List? behaviours = null; foreach (var behaviourItem in this.behaviours) { if (behaviourItem is not T behaviour) continue; - behaviours ??= new List(); + behaviours ??= []; behaviours.Add(behaviour); } - return behaviours; + return behaviours ?? Enumerable.Empty().ToList(); } public void RemoveBehaviour(bool removeAll = false) where T : class, IBehaviour