Route Unity shell state reads through Verse client

This commit is contained in:
Meta Vens 2026-06-22 14:23:24 +01:00
commit a1f5c385af
4 changed files with 116 additions and 14 deletions

View file

@ -79,6 +79,9 @@ public class ActionGameManager : MonoBehaviour
public static string RuntimeStateFilePath =>
_runtimeStateFilePath ??= AetheriaRuntimeStateBoot.Inspect(GameDataDirectory).StateFilePath;
private static AetheriaRuntimeVerseClient _runtimeVerseClient;
private static string _runtimeVerseClientStatePath;
private static RuntimePlayerSettings _runtimePlayerSettings;
public static RuntimePlayerSettings RuntimePlayerSettings
{
@ -160,7 +163,10 @@ public class ActionGameManager : MonoBehaviour
var settings = CreateDefaultRuntimePlayerSettings();
try
{
var stored = AetheriaRuntimeStateReader.ReadPlayerSettings(RuntimeStateFilePath);
var stored = ResolveRuntimeVerseClient(RuntimeStateFilePath)
.GetPlayerSettingsAsync()
.GetAwaiter()
.GetResult();
if (stored == null)
return settings;
@ -223,7 +229,10 @@ public class ActionGameManager : MonoBehaviour
{
try
{
var loadouts = AetheriaRuntimeStateReader.ReadLoadoutTemplates(stateFilePath);
var loadouts = ResolveRuntimeVerseClient(stateFilePath)
.GetLoadoutTemplatesAsync()
.GetAwaiter()
.GetResult();
_observedLoadoutTemplates.Clear();
_observedLoadoutTemplates.AddRange(loadouts);
@ -2016,6 +2025,7 @@ public class ActionGameManager : MonoBehaviour
private void OnDisable()
{
Input.Dispose();
DisposeRuntimeVerseClient();
}
void Start()
@ -2038,7 +2048,7 @@ public class ActionGameManager : MonoBehaviour
$"Aetheria runtime state file is missing at {stateBoot.StateFilePath}; gameplay requires an authoritative daemon mirror.");
}
RuntimeCatalog = AetheriaRuntimeStateReader.OpenRuntimeCatalog(stateBoot.StateFilePath);
RuntimeCatalog = ResolveRuntimeVerseClient(stateBoot.StateFilePath).OpenRuntimeCatalog();
Debug.Log($"Aetheria runtime catalog: {RuntimeCatalog.Items.Count} items, {RuntimeCatalog.Corporations.Count} corporations, {RuntimeCatalog.NameFiles.Count} name files");
if (RuntimeCatalog == null)
@ -2232,6 +2242,30 @@ public class ActionGameManager : MonoBehaviour
_endDragCallback = null;
}
private static AetheriaRuntimeVerseClient ResolveRuntimeVerseClient(string stateFilePath)
{
if (_runtimeVerseClient != null &&
string.Equals(_runtimeVerseClientStatePath, stateFilePath, StringComparison.Ordinal))
{
return _runtimeVerseClient;
}
DisposeRuntimeVerseClient();
_runtimeVerseClient = AetheriaRuntimeVerseClient
.OpenAsync(stateFilePath, "unity-action-game", startServer: false, pullOnOpen: true)
.GetAwaiter()
.GetResult();
_runtimeVerseClientStatePath = stateFilePath;
return _runtimeVerseClient;
}
private static void DisposeRuntimeVerseClient()
{
_runtimeVerseClient?.Dispose();
_runtimeVerseClient = null;
_runtimeVerseClientStatePath = null;
}
public bool HasDragTarget => _endDragCallback != null;
public void EndDrag()

View file

@ -165,14 +165,17 @@ public class MainMenu : MonoBehaviour
}
}
private static AetheriaRuntimePlayerSettingsSnapshot LatestPlayerSettings(AetheriaRuntimeStateBootReport stateBoot)
private AetheriaRuntimePlayerSettingsSnapshot LatestPlayerSettings(AetheriaRuntimeStateBootReport stateBoot)
{
if (!stateBoot.SupportsLocalStateFileRead || !stateBoot.StateFileExists)
return null;
try
{
return AetheriaRuntimeStateReader.ReadPlayerSettings(stateBoot.StateFilePath);
return ResolveVerseClient(stateBoot)
.GetPlayerSettingsAsync()
.GetAwaiter()
.GetResult();
}
catch (Exception ex)
{
@ -181,14 +184,17 @@ public class MainMenu : MonoBehaviour
}
}
private static AetheriaRuntimeVerseHostSettingsSnapshot LatestVerseHostSettings(AetheriaRuntimeStateBootReport stateBoot)
private AetheriaRuntimeVerseHostSettingsSnapshot LatestVerseHostSettings(AetheriaRuntimeStateBootReport stateBoot)
{
if (!stateBoot.SupportsLocalStateFileRead || !stateBoot.StateFileExists)
return null;
try
{
return AetheriaRuntimeStateReader.ReadVerseHostSettings(stateBoot.StateFilePath);
return ResolveVerseClient(stateBoot)
.GetVerseHostSettingsAsync()
.GetAwaiter()
.GetResult();
}
catch (Exception ex)
{