Use provider-native runtime access in menus
This commit is contained in:
parent
7a298cf95d
commit
3d48c762de
6 changed files with 98 additions and 52 deletions
|
|
@ -89,9 +89,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
() => _viewDirection,
|
||||
() => CurrentEntity);
|
||||
private AetheriaUnityObservedTargetQuery ObservedTargetQuery =>
|
||||
_observedTargetQuery ??= new AetheriaUnityObservedTargetQuery(
|
||||
() => ResolveDaemonObserver()?.Client,
|
||||
_observedEntityIndex);
|
||||
_observedTargetQuery ??= new AetheriaUnityObservedTargetQuery(_observedEntityIndex);
|
||||
private AetheriaUnityObservedFrameApplier ObservedFrameApplier =>
|
||||
_observedFrameApplier ??= new AetheriaUnityObservedFrameApplier(
|
||||
ResolveDaemonObserver,
|
||||
|
|
|
|||
|
|
@ -9,15 +9,11 @@ using GameCult.Mesh;
|
|||
|
||||
public sealed class AetheriaUnityObservedTargetQuery : IDisposable
|
||||
{
|
||||
private readonly Func<AetheriaClient> _resolveClient;
|
||||
private readonly AetheriaUnityObservedEntityIndex _entityIndex;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> _zoneContacts;
|
||||
|
||||
public AetheriaUnityObservedTargetQuery(
|
||||
Func<AetheriaClient> resolveClient,
|
||||
AetheriaUnityObservedEntityIndex entityIndex)
|
||||
public AetheriaUnityObservedTargetQuery(AetheriaUnityObservedEntityIndex entityIndex)
|
||||
{
|
||||
_resolveClient = resolveClient ?? (() => null);
|
||||
_entityIndex = entityIndex ?? throw new ArgumentNullException(nameof(entityIndex));
|
||||
}
|
||||
|
||||
|
|
@ -98,8 +94,8 @@ public sealed class AetheriaUnityObservedTargetQuery : IDisposable
|
|||
|
||||
try
|
||||
{
|
||||
_zoneContacts = _resolveClient()
|
||||
?.State.Reactive<AetheriaRuntimeZoneContactsDocument>();
|
||||
_zoneContacts = AetheriaUnityRuntimeClientProvider
|
||||
.Reactive<AetheriaRuntimeZoneContactsDocument>("unity-observed-target-query");
|
||||
return _zoneContacts?.Current;
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
|
|
@ -62,22 +62,51 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return ResolveClient(AetheriaUnityRuntimePaths.RuntimeStateFilePath, runtimeId);
|
||||
}
|
||||
|
||||
public static AetheriaClient RuntimeClient(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return ResolveClient(stateBoot, runtimeId);
|
||||
}
|
||||
|
||||
public static AetheriaClientState RuntimeState(string runtimeId = "")
|
||||
{
|
||||
return RuntimeClient(runtimeId).State;
|
||||
}
|
||||
|
||||
public static AetheriaClientState RuntimeState(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeClient(stateBoot, runtimeId).State;
|
||||
}
|
||||
|
||||
public static AetheriaControl Control(string runtimeId = "")
|
||||
{
|
||||
return RuntimeClient(runtimeId).Control;
|
||||
}
|
||||
|
||||
public static AetheriaControl Control(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
{
|
||||
return RuntimeClient(stateBoot, runtimeId).Control;
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(string runtimeId = "")
|
||||
where TDocument : class
|
||||
{
|
||||
return RuntimeState(runtimeId).Reactive<TDocument>();
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
string runtimeId = "")
|
||||
where TDocument : class
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).Reactive<TDocument>();
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
AetheriaRuntimeRtsViewportBounds viewport,
|
||||
string runtimeId = "")
|
||||
|
|
@ -86,6 +115,15 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return RuntimeState(runtimeId).Reactive<TDocument>(viewport);
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
AetheriaRuntimeRtsViewportBounds viewport,
|
||||
string runtimeId = "")
|
||||
where TDocument : class
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).Reactive<TDocument>(viewport);
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
int index,
|
||||
string runtimeId = "")
|
||||
|
|
@ -94,6 +132,15 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return RuntimeState(runtimeId).Reactive<TDocument>(index);
|
||||
}
|
||||
|
||||
public static CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
AetheriaRuntimeStateBootReport stateBoot,
|
||||
int index,
|
||||
string runtimeId = "")
|
||||
where TDocument : class
|
||||
{
|
||||
return RuntimeState(stateBoot, runtimeId).Reactive<TDocument>(index);
|
||||
}
|
||||
|
||||
public static AetheriaClient CurrentClientForStateFile(string stateFilePath)
|
||||
{
|
||||
foreach (var pair in RuntimeClients)
|
||||
|
|
|
|||
|
|
@ -343,7 +343,8 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
{
|
||||
try
|
||||
{
|
||||
var submitted = ResolveClient()
|
||||
var submitted = AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeClient(RequireLocalStateBoot(), "unity-input-screen")
|
||||
.Ui.InputSettingsAsync(command, body, "unity-input-screen")
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
|
@ -356,7 +357,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private AetheriaClient ResolveClient()
|
||||
private AetheriaRuntimeStateBootReport RequireLocalStateBoot()
|
||||
{
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory);
|
||||
if (!stateBoot.SupportsLocalStateFileRead || !stateBoot.StateFileExists)
|
||||
|
|
@ -371,7 +372,7 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
ClearClientCaches();
|
||||
}
|
||||
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(stateBoot, "unity-input-screen");
|
||||
return stateBoot;
|
||||
}
|
||||
|
||||
private void ClearClientCaches()
|
||||
|
|
@ -387,8 +388,10 @@ public class InputDisplayLayout : MonoBehaviour
|
|||
|
||||
try
|
||||
{
|
||||
_playerSettings = ResolveClient()
|
||||
.State.Reactive<AetheriaRuntimePlayerSettingsDocument>();
|
||||
_playerSettings = AetheriaUnityRuntimeClientProvider
|
||||
.Reactive<AetheriaRuntimePlayerSettingsDocument>(
|
||||
RequireLocalStateBoot(),
|
||||
"unity-input-screen");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -149,8 +149,9 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
try
|
||||
{
|
||||
_sectorMap ??= ResolveClient(stateBoot)
|
||||
.State.Reactive<AetheriaRuntimeSectorMapDocument>();
|
||||
PrepareDocumentAccess(stateBoot);
|
||||
_sectorMap ??= AetheriaUnityRuntimeClientProvider
|
||||
.Reactive<AetheriaRuntimeSectorMapDocument>(stateBoot, "unity-main-menu");
|
||||
return _sectorMap?.Current;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -167,8 +168,9 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
try
|
||||
{
|
||||
_playerSettings ??= ResolveClient(stateBoot)
|
||||
.State.Reactive<AetheriaRuntimePlayerSettingsDocument>();
|
||||
PrepareDocumentAccess(stateBoot);
|
||||
_playerSettings ??= AetheriaUnityRuntimeClientProvider
|
||||
.Reactive<AetheriaRuntimePlayerSettingsDocument>(stateBoot, "unity-main-menu");
|
||||
return _playerSettings?.Current;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -185,8 +187,9 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
try
|
||||
{
|
||||
_verseHostSettings ??= ResolveClient(stateBoot)
|
||||
.State.Reactive<AetheriaRuntimeVerseHostSettingsDocument>();
|
||||
PrepareDocumentAccess(stateBoot);
|
||||
_verseHostSettings ??= AetheriaUnityRuntimeClientProvider
|
||||
.Reactive<AetheriaRuntimeVerseHostSettingsDocument>(stateBoot, "unity-main-menu");
|
||||
return _verseHostSettings?.Current;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -424,7 +427,8 @@ public class MainMenu : MonoBehaviour
|
|||
|
||||
try
|
||||
{
|
||||
var submitted = ResolveClient(stateBoot)
|
||||
var submitted = AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeClient(stateBoot, "unity-main-menu")
|
||||
.Ui.SurfaceCommandAsync(request, "unity-main-menu")
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
|
@ -451,7 +455,7 @@ public class MainMenu : MonoBehaviour
|
|||
return true;
|
||||
}
|
||||
|
||||
private AetheriaClient ResolveClient(AetheriaRuntimeStateBootReport stateBoot)
|
||||
private void PrepareDocumentAccess(AetheriaRuntimeStateBootReport stateBoot)
|
||||
{
|
||||
var statePath = stateBoot.StateFilePath;
|
||||
if (!string.Equals(_clientStatePath, statePath, StringComparison.Ordinal))
|
||||
|
|
@ -459,8 +463,6 @@ public class MainMenu : MonoBehaviour
|
|||
_clientStatePath = statePath;
|
||||
ClearClientCaches();
|
||||
}
|
||||
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(stateBoot, "unity-main-menu");
|
||||
}
|
||||
|
||||
private void ClearClientCaches()
|
||||
|
|
|
|||
Loading…
Reference in a new issue