17 lines
961 B
C#
17 lines
961 B
C#
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<UniverseObject>(args);
|
|
|
|
public static T GetRequiredUniverseObject<T>(this IUniverse universe) where T : class
|
|
=> universe.GetUniverseObject<T>() ?? throw new UniverseObjectNotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} object of type {typeof(T).FullName}");
|
|
|
|
public static T FindRequiredBehaviour<T>(this IUniverse universe) where T : class
|
|
=> universe.FindBehaviour<T>() ?? throw new BehaviourNotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} with {nameof(IBehaviour)} of type {typeof(T).FullName}");
|
|
}
|