feat: Find & FindRequired for general type search

This commit is contained in:
2025-05-25 12:59:37 +03:00
parent bcce427376
commit 114fa82b9d
5 changed files with 46 additions and 16 deletions

View File

@@ -12,4 +12,7 @@ public static class UniverseExtensions
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}");
public static T FindRequired<T>(this IUniverse universe) where T : class
=> universe.Find<T>() ?? throw new NotFoundException($"{universe.GetType().FullName}({universe.Id}) does not contain any {nameof(IUniverseObject)} or {nameof(IBehaviour)} of type {typeof(T).FullName}");
}