17 lines
1012 B
C#
17 lines
1012 B
C#
using Syntriax.Engine.Core.Abstract;
|
|
using Syntriax.Engine.Core.Exceptions;
|
|
|
|
namespace Syntriax.Engine.Core;
|
|
|
|
public static class GameManagerExtensions
|
|
{
|
|
public static IHierarchyObject InstantiateHierarchyObject(this IGameManager gameManager, params object?[]? args)
|
|
=> gameManager.InstantiateHierarchyObject<HierarchyObject>(args);
|
|
|
|
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}");
|
|
|
|
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}");
|
|
}
|