Centralize inventory state sessions

This commit is contained in:
Meta Vens 2026-06-28 14:25:08 +01:00
commit d6bee723ec
6 changed files with 195 additions and 47 deletions

View file

@ -206,12 +206,16 @@ public class DaemonRuntimeDocumentTests
var observed = client.State.LatestObservedDaemon();
var observedAuthoritativeFrame = client.State.LatestDaemonFrame();
using var catalogSession = client.State.ObserveCatalog();
using var daemonFrameSession = client.State.ObserveDaemonFrame();
using var sectorMapSession = client.State.ObserveSectorMap();
using var playerSettingsSession = client.State.Settings.ObservePlayer();
using var verseHostSettingsSession = client.State.Settings.ObserveVerseHost();
using var zoneContactsSession = client.State.ObserveZoneContacts();
using var currentZoneSession = client.State.Current.ObserveZone();
using var currentEntitySession = client.State.Current.ObserveEntity();
using var stationRefitSession = client.State.ObserveStationRefit();
using var zoneDetailsSession = client.State.Details.ObserveZone(0);
using var inventorySession = client.State.Details.ObserveInventory(0);
using var objectsViewportSession = client.State.Viewports.ObserveObjects(viewport);
using var renderSplatsViewportSession = client.State.Viewports.ObserveRenderSplats(viewport);
using var playerHud = client.State.ObservePlayerHud();

View file

@ -6,7 +6,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using GameCult.Mesh;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
@ -32,12 +31,12 @@ public class InventoryMenu : MonoBehaviour
private UIDocument _cargoItemDetailsSurfaceDocument;
private UIDocument _equippedItemDetailsSurfaceDocument;
private string _clientStatePath = "";
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
private CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _playerSettings;
private CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument> _currentEntity;
private CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> _stationRefit;
private AetheriaRuntimeCatalogSession _catalog;
private AetheriaRuntimePlayerSettingsSession _playerSettings;
private AetheriaRuntimeCurrentEntitySession _currentEntity;
private AetheriaRuntimeStationRefitSession _stationRefit;
private int _inventoryEntityIndex = -1;
private CultMeshReactiveDocument<AetheriaRuntimeInventoryDocument> _inventory;
private AetheriaRuntimeInventorySession _inventory;
private AetheriaUnityActionBarPresentation _actionBarPresentation;
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
private AetheriaUnityObservedDockingIndex _observedDockingIndex;
@ -831,7 +830,7 @@ public class InventoryMenu : MonoBehaviour
return true;
}
var refit = ResolveReactiveStationRefit();
var refit = ResolveStationRefitDocument();
var entityIndex = -1;
if (refit != null)
{
@ -960,7 +959,7 @@ public class InventoryMenu : MonoBehaviour
_currentEntity = ResolveClient()
.State
.Current
.ReactiveEntity();
.ObserveEntity();
}
catch (Exception ex)
{
@ -970,7 +969,7 @@ public class InventoryMenu : MonoBehaviour
return _currentEntity?.Current;
}
private AetheriaRuntimeStationRefitDocument ResolveReactiveStationRefit()
private AetheriaRuntimeStationRefitDocument ResolveStationRefitDocument()
{
if (_stationRefit != null)
return _stationRefit.Current;
@ -979,7 +978,7 @@ public class InventoryMenu : MonoBehaviour
{
_stationRefit = ResolveClient()
.State
.ReactiveStationRefit();
.ObserveStationRefit();
}
catch (Exception ex)
{
@ -999,7 +998,7 @@ public class InventoryMenu : MonoBehaviour
var nextInventory = ResolveClient()
.State
.Details
.ReactiveInventory(entityIndex);
.ObserveInventory(entityIndex);
_inventory?.Dispose();
_inventoryEntityIndex = entityIndex;
_inventory = nextInventory;
@ -1071,7 +1070,7 @@ public class InventoryMenu : MonoBehaviour
try
{
_catalog = ResolveClient().State.ReactiveCatalog();
_catalog = ResolveClient().State.ObserveCatalog();
}
catch (Exception ex)
{
@ -1091,7 +1090,7 @@ public class InventoryMenu : MonoBehaviour
_playerSettings = ResolveClient()
.State
.Settings
.ReactivePlayer();
.ObservePlayer();
}
catch (Exception ex)
{

View file

@ -7,7 +7,6 @@ using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using GameCult.Mesh;
using GameCult.Aetheria.EveRuntime;
using GameCult.Aetheria.State.Verse;
using GameCult.Eve.Surface;
@ -103,13 +102,13 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
private InventoryCell _clickCell;
private float _clickTime;
private string _clientStatePath = "";
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
private CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _playerSettings;
private CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument> _currentEntity;
private CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> _stationRefit;
private CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> _loadoutFrame;
private AetheriaRuntimeCatalogSession _catalog;
private AetheriaRuntimePlayerSettingsSession _playerSettings;
private AetheriaRuntimeCurrentEntitySession _currentEntity;
private AetheriaRuntimeStationRefitSession _stationRefit;
private AetheriaRuntimeDaemonFrameSession _loadoutFrame;
private int _inventoryEntityIndex = -1;
private CultMeshReactiveDocument<AetheriaRuntimeInventoryDocument> _inventory;
private AetheriaRuntimeInventorySession _inventory;
private AetheriaRuntimeStationRefitEntityOption[] _dropdownStationRefitEntities =
Array.Empty<AetheriaRuntimeStationRefitEntityOption>();
private AetheriaRuntimeStationLoadoutRestoreOption[] _dropdownStationRefitLoadouts =
@ -1243,7 +1242,7 @@ private void Update()
return true;
}
var refit = ResolveReactiveStationRefit();
var refit = ResolveStationRefitDocument();
var entityIndex = -1;
if (refit != null)
{
@ -1498,7 +1497,7 @@ private void Update()
_currentEntity = ResolveClient()
.State
.Current
.ReactiveEntity();
.ObserveEntity();
}
catch (Exception ex)
{
@ -1508,7 +1507,7 @@ private void Update()
return _currentEntity?.Current;
}
private AetheriaRuntimeStationRefitDocument ResolveReactiveStationRefit()
private AetheriaRuntimeStationRefitDocument ResolveStationRefitDocument()
{
if (_stationRefit != null)
return _stationRefit.Current;
@ -1517,7 +1516,7 @@ private void Update()
{
_stationRefit = ResolveClient()
.State
.ReactiveStationRefit();
.ObserveStationRefit();
}
catch (Exception ex)
{
@ -1544,7 +1543,7 @@ private void Update()
{
_loadoutFrame = ResolveClient()
.State
.ReactiveDaemonFrame();
.ObserveDaemonFrame();
}
catch (Exception ex)
{
@ -1564,7 +1563,7 @@ private void Update()
var nextInventory = ResolveClient()
.State
.Details
.ReactiveInventory(entityIndex);
.ObserveInventory(entityIndex);
_inventory?.Dispose();
_inventoryEntityIndex = entityIndex;
_inventory = nextInventory;
@ -1584,7 +1583,7 @@ private void Update()
try
{
_catalog = ResolveClient().State.ReactiveCatalog();
_catalog = ResolveClient().State.ObserveCatalog();
}
catch (Exception ex)
{
@ -1604,7 +1603,7 @@ private void Update()
_playerSettings = ResolveClient()
.State
.Settings
.ReactivePlayer();
.ObservePlayer();
}
catch (Exception ex)
{