Add named current typed state accessors
This commit is contained in:
parent
67c1b3d689
commit
06a3f8dab2
4 changed files with 170 additions and 19 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
|
|
@ -28,7 +27,6 @@ public class ActionBarSlot : MonoBehaviour
|
|||
if (ReferenceEquals(binding, value))
|
||||
return;
|
||||
|
||||
binding?.Dispose();
|
||||
binding = value;
|
||||
if (binding == null)
|
||||
{
|
||||
|
|
@ -52,13 +50,12 @@ public class ActionBarSlot : MonoBehaviour
|
|||
|
||||
}
|
||||
|
||||
public abstract class ActionBarBinding : IDisposable
|
||||
public abstract class ActionBarBinding
|
||||
{
|
||||
public Entity Entity { get; }
|
||||
private readonly Func<AetheriaControl> _resolveControl;
|
||||
protected ActionBarSlot Slot { get; }
|
||||
protected GameSettings Settings { get; }
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
|
||||
public abstract void Activate();
|
||||
public abstract void Deactivate();
|
||||
public abstract void Update();
|
||||
|
|
@ -100,9 +97,10 @@ public abstract class ActionBarBinding : IDisposable
|
|||
{
|
||||
try
|
||||
{
|
||||
_catalog ??= AetheriaUnityRuntimeClientProvider
|
||||
.ReactiveCatalogSnapshot("unity-action-bar");
|
||||
return _catalog?.Current?.FindItem(item, x => x.ItemKey);
|
||||
return AetheriaUnityRuntimeClientProvider
|
||||
.RuntimeState()
|
||||
.CurrentCatalog()
|
||||
.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -110,12 +108,6 @@ public abstract class ActionBarBinding : IDisposable
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
_catalog?.Dispose();
|
||||
_catalog = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionBarConsumableBinding : ActionBarBinding
|
||||
|
|
|
|||
|
|
@ -188,6 +188,11 @@ public class DaemonRuntimeDocumentTests
|
|||
MaxX = 100,
|
||||
MaxY = 100
|
||||
};
|
||||
var currentCatalog = client.State.CurrentCatalog();
|
||||
var currentPlayerSettings = client.State.CurrentPlayerSettings();
|
||||
var currentFrame = client.State.CurrentDaemonFrame();
|
||||
var currentEntityState = client.State.CurrentEntityState();
|
||||
var currentObjectsViewport = client.State.CurrentObjectsViewport(viewport);
|
||||
var objectsViewport = ReadLatest(client.State.ObjectsViewport(viewport));
|
||||
var zoneDetails = ReadLatest(client.State.ZoneDetails(0));
|
||||
var inventory = ReadLatest(client.State.Inventory(0));
|
||||
|
|
@ -288,6 +293,11 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.AreEqual(AetheriaRuntimeCatalogSnapshot.SchemaId, client.State.Catalog.Sources.Last().SchemaId);
|
||||
Assert.GreaterOrEqual(catalog.Items.Count, 0);
|
||||
Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettings.Schema);
|
||||
Assert.AreSame(catalog, currentCatalog);
|
||||
Assert.AreEqual(playerSettings.Schema, currentPlayerSettings.Schema);
|
||||
Assert.AreEqual(latestFrame.FrameId, currentFrame.FrameId);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityState.EntityKey);
|
||||
Assert.AreEqual(objectsViewport.Schema, currentObjectsViewport.Schema);
|
||||
Assert.AreSame(catalog, catalogReactive.Current);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, daemonFrameReactive.Current.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.SoaView, daemonSoaViewReactive.Current.Schema);
|
||||
|
|
|
|||
Loading…
Reference in a new issue