2026-03-26 10:49:41 +08:00
|
|
|
namespace AlicizaX
|
|
|
|
|
{
|
|
|
|
|
public readonly struct ServiceContext
|
|
|
|
|
{
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceContext(ServiceWorld world, ServiceScope scope)
|
2026-03-26 10:49:41 +08:00
|
|
|
{
|
|
|
|
|
World = world;
|
|
|
|
|
Scope = scope;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceWorld World { get; }
|
2026-03-26 10:49:41 +08:00
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceScope Scope { get; }
|
2026-03-31 17:25:20 +08:00
|
|
|
|
|
|
|
|
|
2026-03-26 10:49:41 +08:00
|
|
|
public T Require<T>() where T : class, IService
|
|
|
|
|
=> World.Require<T>(Scope);
|
|
|
|
|
|
|
|
|
|
public bool TryGet<T>(out T service) where T : class, IService
|
|
|
|
|
=> World.TryGet(Scope, out service);
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceScope EnsureScene(int order = ServiceDomainOrder.Scene)
|
2026-03-31 17:25:20 +08:00
|
|
|
=> World.EnsureScene(order);
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal bool TryGetScene(out ServiceScope scope)
|
2026-03-31 17:25:20 +08:00
|
|
|
=> World.TryGetScene(out scope);
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceScope ResetScene(int order = ServiceDomainOrder.Scene)
|
2026-03-31 17:25:20 +08:00
|
|
|
=> World.ResetScene(order);
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal ServiceScope EnsureGameplay(int order = ServiceDomainOrder.Gameplay)
|
2026-03-31 17:25:20 +08:00
|
|
|
=> World.EnsureGameplay(order);
|
|
|
|
|
|
2026-04-20 13:46:44 +08:00
|
|
|
internal bool TryGetGameplay(out ServiceScope scope)
|
2026-03-31 17:25:20 +08:00
|
|
|
=> World.TryGetGameplay(out scope);
|
|
|
|
|
|
|
|
|
|
public T RequireApp<T>() where T : class, IService
|
2026-04-20 13:46:44 +08:00
|
|
|
=> World.App.Require<T>();
|
2026-03-26 10:49:41 +08:00
|
|
|
|
2026-03-31 17:25:20 +08:00
|
|
|
public T RequireScene<T>() where T : class, IService
|
2026-04-20 13:46:44 +08:00
|
|
|
=> World.Scene.Require<T>();
|
2026-03-26 10:49:41 +08:00
|
|
|
|
2026-03-31 17:25:20 +08:00
|
|
|
public T RequireGameplay<T>() where T : class, IService
|
2026-04-20 13:46:44 +08:00
|
|
|
=> World.Gameplay.Require<T>();
|
2026-03-26 10:49:41 +08:00
|
|
|
}
|
|
|
|
|
}
|