refactor(runtime): expose canonical gameplay state
Move character options and movement skills into the Runtime-owned character graph, expose borrowed inventory, character, and social views, and route retained UI state commands through generation-gated typed Runtime contracts. Preserve the existing synchronous wire path while deleting the App-owned option and skill mirrors and extending normalized parity checkpoints. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
parent
9d0d9b07e0
commit
dcb61efb5a
34 changed files with 2076 additions and 103 deletions
|
|
@ -12,6 +12,7 @@ namespace AcDream.Core.Items;
|
|||
public sealed class ItemManaState
|
||||
{
|
||||
private readonly ConcurrentDictionary<uint, float> _manaByGuid = new();
|
||||
private long _revision;
|
||||
|
||||
/// <summary>Fires for every valid or invalid query response.</summary>
|
||||
public event Action<uint /*guid*/, float /*fraction*/, bool /*valid*/>? ItemManaChanged;
|
||||
|
|
@ -20,6 +21,11 @@ public sealed class ItemManaState
|
|||
_manaByGuid.TryGetValue(guid, out float percent) ? percent : 0f;
|
||||
|
||||
public bool HasMana(uint guid) => _manaByGuid.ContainsKey(guid);
|
||||
public int Count => _manaByGuid.Count;
|
||||
public long Revision => Interlocked.Read(ref _revision);
|
||||
|
||||
public bool TryGetManaPercent(uint guid, out float fraction) =>
|
||||
_manaByGuid.TryGetValue(guid, out fraction);
|
||||
|
||||
public void OnQueryItemManaResponse(uint itemGuid, float manaPercent, bool valid)
|
||||
{
|
||||
|
|
@ -28,8 +34,13 @@ public sealed class ItemManaState
|
|||
else
|
||||
_manaByGuid.TryRemove(itemGuid, out _);
|
||||
|
||||
Interlocked.Increment(ref _revision);
|
||||
ItemManaChanged?.Invoke(itemGuid, manaPercent, valid);
|
||||
}
|
||||
|
||||
public void Clear() => _manaByGuid.Clear();
|
||||
public void Clear()
|
||||
{
|
||||
_manaByGuid.Clear();
|
||||
Interlocked.Increment(ref _revision);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue