Use reactive catalog in zone renderer

This commit is contained in:
Meta Vens 2026-06-28 09:16:15 +01:00
commit 3c37579153
2 changed files with 46 additions and 7 deletions

View file

@ -7278,6 +7278,30 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root)
string.Join(", ", missingSectorRendererSharedDocumentSymbols));
}
var zoneRenderer = File.ReadAllText(Path.Combine(
root,
"Assets",
"Scripts",
"Zone Display",
"ZoneRenderer.cs"));
var requiredZoneRendererSharedDocumentSymbols = new[]
{
"CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog",
"ResolveClient().Aetheria().ReactiveCatalog()",
"_catalog?.Dispose()",
"_catalog?.Current",
"private void OnDestroy()"
};
var missingZoneRendererSharedDocumentSymbols = requiredZoneRendererSharedDocumentSymbols
.Where(symbol => !zoneRenderer.Contains(symbol, StringComparison.Ordinal))
.ToArray();
if (missingZoneRendererSharedDocumentSymbols.Length > 0)
{
throw new InvalidOperationException(
"ZoneRenderer should bind catalog state through the managed reactive Aetheria catalog document with renderer lifetime disposal: " +
string.Join(", ", missingZoneRendererSharedDocumentSymbols));
}
var volumeCloudRenderer = File.ReadAllText(Path.Combine(
root,
"Assets",

View file

@ -7,6 +7,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cinemachine;
using GameCult.Mesh;
using GameCult.Aetheria.State.Verse;
using UnityEngine;
using UnityEngine.Serialization;
@ -118,7 +119,8 @@ public class ZoneRenderer : MonoBehaviour
Array.Empty<AetheriaRuntimeZoneRenderAsteroidBeltPose>();
private IReadOnlyList<AetheriaRuntimeBodySnapshotCommit> _zoneRenderBodies =
Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
private AetheriaRuntimeCatalogSnapshot _catalog;
private string _clientStatePath = "";
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
public Dictionary<int, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<int, (GameObject, CompassIcon)>();
private List<ItemPickup> _loot = new List<ItemPickup>();
@ -1006,7 +1008,7 @@ public class ZoneRenderer : MonoBehaviour
private void OnDestroy()
{
_catalog = null;
ClearClientCaches();
}
private float GetTerrainHeight(float2 position)
@ -1214,26 +1216,39 @@ public class ZoneRenderer : MonoBehaviour
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
{
if (_catalog != null)
return _catalog;
return _catalog.Current;
try
{
_catalog = ResolveClient().Aetheria().LatestCatalog();
_catalog = ResolveClient().Aetheria().ReactiveCatalog();
}
catch (Exception ex)
{
Debug.LogWarning($"Failed to read Aetheria runtime catalog for zone renderer: {ex.Message}");
Debug.LogWarning($"Failed to bind Aetheria runtime catalog for zone renderer: {ex.Message}");
}
return _catalog;
return _catalog?.Current;
}
private AetheriaClient ResolveClient()
{
var stateBoot = AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory);
if (!string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
{
_clientStatePath = stateBoot.StateFilePath;
ClearClientCaches();
}
return AetheriaUnityRuntimeClientProvider.ResolveClient(
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
stateBoot,
"unity-zone-renderer");
}
private void ClearClientCaches()
{
_catalog?.Dispose();
_catalog = null;
}
}