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