feat: IGameManager.FindRequiredBehaviour extension method added
This commit is contained in:
parent
2e2306c5bb
commit
9e4c74ed1d
@ -9,11 +9,8 @@ public static class GameManagerExtensions
|
||||
=> gameManager.InstantiateHierarchyObject<HierarchyObject>(args);
|
||||
|
||||
public static T GetRequiredHierarchyObject<T>(this IGameManager gameManager) where T : class
|
||||
{
|
||||
foreach (IHierarchyObject hierarchyObject in gameManager)
|
||||
if (hierarchyObject is T @object)
|
||||
return @object;
|
||||
=> gameManager.GetHierarchyObject<T>() ?? throw new HierarchyObjectNotFoundException($"{gameManager.GetType().FullName}({gameManager.Id}) does not contain any {nameof(IHierarchyObject)} object of type {typeof(T).FullName}");
|
||||
|
||||
throw new HierarchyObjectNotFoundException($"{gameManager.GetType().FullName}({gameManager.Id}) does not contain any {typeof(T).FullName}");
|
||||
}
|
||||
public static T FindRequiredBehaviour<T>(this IGameManager gameManager) where T : class
|
||||
=> gameManager.FindBehaviour<T>() ?? throw new BehaviourNotFoundException($"{gameManager.GetType().FullName}({gameManager.Id}) does not contain any {nameof(IHierarchyObject)} with {nameof(IBehaviour)} of type {typeof(T).FullName}");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user