refactor(runtime): own magic and player state

Move the coupled Spellbook and LocalPlayerState into one Runtime-owned character graph, route content, live-session, retained UI, reset, and shutdown through that exact owner, and delete the duplicate desired-component snapshot from inventory state. Preserve synchronous retail update and reset ordering while adding independent-instance and retryable-failure coverage.

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-26 08:39:02 +02:00
parent d362172620
commit d02a12ceac
16 changed files with 418 additions and 96 deletions

View file

@ -13,22 +13,17 @@ public sealed class RuntimeInventoryStateTests
using var inventory = new RuntimeInventoryState(entities);
IReadOnlyList<ShortcutEntry> shortcuts =
[new ShortcutEntry(2, 0x50000001u, 0u)];
IReadOnlyList<(uint Id, uint Amount)> components =
[(0x68000001u, 12u)];
inventory.ExternalContainers.RequestOpen(0x70000001u);
inventory.ExternalContainers.ApplyViewContents(0x70000001u);
inventory.ItemMana.OnQueryItemManaResponse(0x50000001u, 0.75f, true);
inventory.Shortcuts.Replace(shortcuts);
inventory.DesiredComponents.Replace(components);
Assert.Same(entities.Objects, inventory.Objects);
Assert.Equal(0x70000001u, inventory.ExternalContainers.CurrentContainerId);
Assert.Equal(0.75f, inventory.ItemMana.GetManaPercent(0x50000001u));
Assert.Same(shortcuts, inventory.Shortcuts.Items);
Assert.Same(components, inventory.DesiredComponents.Items);
Assert.Equal(1, inventory.Shortcuts.Revision);
Assert.Equal(1, inventory.DesiredComponents.Revision);
}
[Fact]
@ -40,7 +35,6 @@ public sealed class RuntimeInventoryStateTests
inventory.ExternalContainers.ApplyViewContents(0x70000001u);
inventory.ItemMana.OnQueryItemManaResponse(0x50000001u, 0.75f, true);
inventory.Shortcuts.Replace([new ShortcutEntry(1, 2u, 3u)]);
inventory.DesiredComponents.Replace([(4u, 5u)]);
inventory.Transactions.IncrementBusyCount();
inventory.ResetExternalContainer();
@ -56,7 +50,6 @@ public sealed class RuntimeInventoryStateTests
Assert.Equal(0, inventory.Transactions.BusyCount);
Assert.False(inventory.ItemMana.HasMana(0x50000001u));
Assert.Empty(inventory.Shortcuts.Items);
Assert.Empty(inventory.DesiredComponents.Items);
}
[Fact]
@ -86,7 +79,6 @@ public sealed class RuntimeInventoryStateTests
inventory.ExternalContainers.ApplyViewContents(0x70000001u);
inventory.ItemMana.OnQueryItemManaResponse(0x50000001u, 0.5f, true);
inventory.Shortcuts.Replace([new ShortcutEntry(1, 2u, 3u)]);
inventory.DesiredComponents.Replace([(4u, 5u)]);
inventory.Dispose();
inventory.Dispose();
@ -96,7 +88,6 @@ public sealed class RuntimeInventoryStateTests
Assert.Equal(0u, inventory.ExternalContainers.CurrentContainerId);
Assert.False(inventory.ItemMana.HasMana(0x50000001u));
Assert.Empty(inventory.Shortcuts.Items);
Assert.Empty(inventory.DesiredComponents.Items);
}
[Fact]