using Syntriax.Engine.Core.Abstract; using Syntriax.Engine.Core.Exceptions; namespace Syntriax.Engine.Core; public static class UniverseExtensions { public static IUniverseObject InstantiateUniverseObject(this IUniverse universe, params object?[]? args) => universe.InstantiateUniverseObject(args); public static T GetRequiredUniverseObject(this IUniverse universe) where T : class => universe.GetUniverseObject() ?? throw new UniverseObjectNotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} object of type {typeof(T).FullName}"); public static T FindRequiredBehaviour(this IUniverse universe) where T : class => universe.FindBehaviour() ?? throw new BehaviourNotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} with {nameof(IBehaviour)} of type {typeof(T).FullName}"); }