refactor: IBehaviourController.TryGetBehaviour to Extension Method

This commit is contained in:
2024-11-24 11:34:36 +03:00
parent 1b3f40be5f
commit 4416f64287
4 changed files with 47 additions and 15 deletions

View File

@@ -10,7 +10,7 @@ public static class BehaviourExtensions
public static T? FindBehaviour<T>(this IEnumerable<IGameObject> gameObjects) where T : class
{
foreach (IGameObject gameObject in gameObjects)
if (gameObject.BehaviourController.TryGetBehaviour(out T? behaviour))
if (gameObject.BehaviourController.GetBehaviour<T>() is T behaviour)
return behaviour;
return default;