Use reactive loadout snapshot projector

This commit is contained in:
Meta Vens 2026-06-28 10:23:14 +01:00
commit 0f5befb056
4 changed files with 95 additions and 17 deletions

View file

@ -7592,6 +7592,7 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root
{
"public AetheriaRuntimeDaemonFrameDocument LatestDaemonFrame()",
"public AetheriaRuntimeDaemonSoaViewDocument LatestDaemonSoaView()",
"public AetheriaRuntimeReactiveLoadoutSnapshotProjector ReactiveLoadoutSnapshotProjector(",
"public AetheriaRuntimeLoadoutTemplatesDocument LatestLoadoutTemplates()",
"public AetheriaRuntimeStationRefitDocument LatestStationRefit()",
"public AetheriaRuntimeZoneRenderDocument LatestZoneRender()",
@ -16333,8 +16334,10 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root)
{
"RequestLoadoutTemplateSave(Entity entity)",
"TryResolveEntityRecordKey(entity, out var targetEntityKey)",
"AetheriaRuntimeLoadoutSnapshotProjector",
".ProjectLoadoutTemplateAsync(client.State, targetEntityKey)",
"AetheriaRuntimeReactiveLoadoutSnapshotProjector _loadoutSnapshotProjector",
"ResolveLoadoutSnapshotProjector().ProjectLoadoutTemplate(targetEntityKey)",
".ReactiveLoadoutSnapshotProjector()",
"_loadoutSnapshotProjector?.Dispose()",
".Ui.SaveLoadoutTemplateAsync(loadout, \"unity-inventory\")"
};
var missingInventoryPanelSymbols = requiredInventoryPanelSymbols
@ -16347,19 +16350,23 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root)
string.Join(", ", missingInventoryPanelSymbols));
}
if (inventoryPanel.Contains(".LoadoutTemplateAsync(", StringComparison.Ordinal))
if (inventoryPanel.Contains(".LoadoutTemplateAsync(", StringComparison.Ordinal) ||
inventoryPanel.Contains(".ProjectLoadoutTemplateAsync(client.State, targetEntityKey)", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"InventoryPanel still asks AetheriaClient for a document-specific loadout template helper instead of composing from managed typed state.");
"InventoryPanel still asks a one-shot compatibility helper for loadout templates instead of caching the managed reactive loadout projector.");
}
var requiredLoadoutSnapshotProjectorSymbols = new[]
{
"ProjectLoadoutTemplateAsync(",
"AetheriaClientState state",
"state.Daemon.LatestFrame.LatestAsync()",
"public sealed class AetheriaRuntimeReactiveLoadoutSnapshotProjector",
"state.Daemon.LatestFrame.ReactiveAsync(options)",
"public AetheriaRuntimeLoadoutTemplateCommit ProjectLoadoutTemplate(string entityKey)",
"ProjectLoadoutTemplate(",
"frame.Run ?? new AetheriaRuntimeRunCheckpointCommit()"
"frame.Run ?? new AetheriaRuntimeRunCheckpointCommit()",
"public void Dispose()"
};
var missingLoadoutSnapshotProjectorSymbols = requiredLoadoutSnapshotProjectorSymbols
.Where(symbol => !loadoutSnapshotProjector.Contains(symbol, StringComparison.Ordinal))
@ -16371,6 +16378,12 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root)
string.Join(", ", missingLoadoutSnapshotProjectorSymbols));
}
if (loadoutSnapshotProjector.Contains("state.Daemon.LatestFrame.LatestAsync()", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Loadout template save payloads still perform one-shot daemon frame reads instead of using a reactive typed frame document.");
}
var forbiddenActionSymbols = new[]
{
"AetheriaRuntimeStateCommitLog.QueueLoadoutTemplate",

View file

@ -108,6 +108,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
private CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument> _currentEntity;
private CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> _stationRefit;
private AetheriaClientReactiveDockingState _reactiveDockingState;
private AetheriaRuntimeReactiveLoadoutSnapshotProjector _loadoutSnapshotProjector;
private int _inventoryEntityIndex = -1;
private CultMeshReactiveDocument<AetheriaRuntimeInventoryDocument> _inventory;
private AetheriaRuntimeStationRefitEntityOption[] _dropdownStationRefitEntities =
@ -1084,10 +1085,7 @@ private void Update()
try
{
var client = ResolveClient();
var loadout = AetheriaRuntimeLoadoutSnapshotProjector
.ProjectLoadoutTemplateAsync(client.State, targetEntityKey)
.GetAwaiter()
.GetResult();
var loadout = ResolveLoadoutSnapshotProjector().ProjectLoadoutTemplate(targetEntityKey);
if (loadout?.RootEntity == null || string.IsNullOrWhiteSpace(loadout.RootEntity.Hull?.ItemKey ?? ""))
return;
@ -1497,6 +1495,7 @@ private void Update()
_currentEntity?.Dispose();
_stationRefit?.Dispose();
_reactiveDockingState?.Dispose();
_loadoutSnapshotProjector?.Dispose();
_observedDockingIndex?.Dispose();
_inventory?.Dispose();
_catalog = null;
@ -1504,6 +1503,7 @@ private void Update()
_currentEntity = null;
_stationRefit = null;
_reactiveDockingState = null;
_loadoutSnapshotProjector = null;
_observedDockingIndex = null;
_inventory = null;
_inventoryEntityIndex = -1;
@ -1548,6 +1548,17 @@ private void Update()
return _stationRefit?.Current;
}
private AetheriaRuntimeReactiveLoadoutSnapshotProjector ResolveLoadoutSnapshotProjector()
{
if (_loadoutSnapshotProjector != null)
return _loadoutSnapshotProjector;
_loadoutSnapshotProjector = ResolveClient()
.Aetheria()
.ReactiveLoadoutSnapshotProjector();
return _loadoutSnapshotProjector;
}
private AetheriaRuntimeInventoryDocument ResolveInventory(int entityIndex)
{
if (_inventory != null && _inventoryEntityIndex == entityIndex)

View file

@ -220,6 +220,18 @@ namespace GameCult.Aetheria.State.Verse
return LatestDaemonSoaViewAsync().ConfigureAwait(false).GetAwaiter().GetResult();
}
public Task<AetheriaRuntimeReactiveLoadoutSnapshotProjector> ReactiveLoadoutSnapshotProjectorAsync(
CultMeshReactiveDocumentOptions? options = null)
{
return AetheriaRuntimeReactiveLoadoutSnapshotProjector.CreateAsync(this, options);
}
public AetheriaRuntimeReactiveLoadoutSnapshotProjector ReactiveLoadoutSnapshotProjector(
CultMeshReactiveDocumentOptions? options = null)
{
return ReactiveLoadoutSnapshotProjectorAsync(options).ConfigureAwait(false).GetAwaiter().GetResult();
}
public Task<AetheriaRuntimeReactiveObservedDaemonState> ReactiveObservedDaemonAsync(
CultMeshReactiveDocumentOptions? options = null)
{

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GameCult.Mesh;
#nullable enable
@ -15,13 +16,10 @@ namespace GameCult.Aetheria.State.Verse
{
if (state == null) throw new ArgumentNullException(nameof(state));
var frame = await state.Daemon.LatestFrame.LatestAsync().ConfigureAwait(false);
if (frame == null)
return new AetheriaRuntimeLoadoutTemplateCommit();
return ProjectLoadoutTemplate(
frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(),
entityKey ?? "");
using var projector = await state
.ReactiveLoadoutSnapshotProjectorAsync()
.ConfigureAwait(false);
return projector.ProjectLoadoutTemplate(entityKey);
}
public static AetheriaRuntimeLoadoutTemplateCommit ProjectLoadoutTemplate(
@ -252,4 +250,48 @@ namespace GameCult.Aetheria.State.Verse
return zoneIndex >= 0 && entityIndex >= 0;
}
}
public sealed class AetheriaRuntimeReactiveLoadoutSnapshotProjector : IDisposable
{
private readonly CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> _frame;
private AetheriaRuntimeReactiveLoadoutSnapshotProjector(
CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> frame)
{
_frame = frame ?? throw new ArgumentNullException(nameof(frame));
}
public static async Task<AetheriaRuntimeReactiveLoadoutSnapshotProjector> CreateAsync(
AetheriaClientState state,
CultMeshReactiveDocumentOptions? options = null)
{
if (state == null) throw new ArgumentNullException(nameof(state));
var frame = await state.Daemon.LatestFrame.ReactiveAsync(options).ConfigureAwait(false);
return new AetheriaRuntimeReactiveLoadoutSnapshotProjector(frame);
}
public static AetheriaRuntimeReactiveLoadoutSnapshotProjector Create(
AetheriaClientState state,
CultMeshReactiveDocumentOptions? options = null)
{
return CreateAsync(state, options).ConfigureAwait(false).GetAwaiter().GetResult();
}
public AetheriaRuntimeLoadoutTemplateCommit ProjectLoadoutTemplate(string entityKey)
{
var frame = _frame.Current;
if (frame == null)
return new AetheriaRuntimeLoadoutTemplateCommit();
return AetheriaRuntimeLoadoutSnapshotProjector.ProjectLoadoutTemplate(
frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(),
entityKey ?? "");
}
public void Dispose()
{
_frame.Dispose();
}
}
}