Cache managed runtime clients by runtime id

This commit is contained in:
Meta Vens 2026-06-28 02:39:41 +01:00
commit 5d03a64ddb
4 changed files with 64 additions and 79 deletions

View file

@ -2,7 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
@ -46,7 +45,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
private float _sectorBackgroundDepth;
private float _sectorCameraDepth;
private UIDocument _zoneDetailsSurfaceDocument;
private AetheriaClient _client;
private string _clientStatePath = "";
private AetheriaRuntimeCatalogSnapshot _catalog;
private AetheriaRuntimePlayerSettingsDocument _playerSettings;
@ -275,31 +273,18 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
private AetheriaClient ResolveClient()
{
var gameDataDirectory = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "GameData"));
var stateBoot = AetheriaRuntimeStateBoot.Inspect(gameDataDirectory);
if (_client != null && string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
return _client;
var stateBoot = AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory);
if (!string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
{
_clientStatePath = stateBoot.StateFilePath;
ClearClientCaches();
}
DisposeClient();
_client = AetheriaClient
.OpenLocalAsync(
gameDataDirectory,
"unity-sector-renderer",
"local",
pullOnOpen: true)
.GetAwaiter()
.GetResult();
_clientStatePath = stateBoot.StateFilePath;
_catalog = null;
_playerSettings = null;
return _client;
return AetheriaUnityRuntimeClientProvider.ResolveClient(stateBoot, "unity-sector-renderer");
}
private void DisposeClient()
private void ClearClientCaches()
{
_client?.Dispose();
_client = null;
_clientStatePath = "";
_catalog = null;
_playerSettings = null;
}
@ -350,8 +335,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
private void OnDestroy()
{
DisposeClient();
if (_zoneDetailsSurfaceDocument != null)
{
AetheriaEveUnitySurfaceHost.DestroyDocument(_zoneDetailsSurfaceDocument);