refactor(runtime): own interaction transactions
Move use throttling, appraisal identity, queued interactions, and exact post-arrival pickup state beneath RuntimeActionState. Keep App as the picker, movement, transport, and retained-presentation adapter while preserving retail send and UseDone ordering. Add reset, disposal, GUID-reuse, callback-reentrancy, and transport-failure coverage. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
be73bccf5a
commit
f5f7b4177f
31 changed files with 1365 additions and 432 deletions
|
|
@ -153,7 +153,7 @@ public sealed class CursorFeedbackControllerTests
|
|||
var objects = SeedTargetObjects();
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -190,7 +190,7 @@ public sealed class CursorFeedbackControllerTests
|
|||
objects.Get(Source)!.TargetType = (uint)ItemType.Misc; // a tool that targets items
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -230,7 +230,7 @@ public sealed class CursorFeedbackControllerTests
|
|||
var objects = SeedTargetObjects();
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -260,7 +260,7 @@ public sealed class CursorFeedbackControllerTests
|
|||
var objects = SeedTargetObjects();
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using AcDream.App.UI;
|
||||
using AcDream.Core.Combat;
|
||||
using AcDream.Core.Items;
|
||||
using AcDream.Runtime.Gameplay;
|
||||
|
||||
namespace AcDream.App.Tests.UI;
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ public sealed class ItemInteractionControllerTests
|
|||
public readonly CombatState Combat = new();
|
||||
public readonly StackSplitQuantityState SplitQuantity = new();
|
||||
public readonly InventoryTransactionState SharedTransactions;
|
||||
public readonly RuntimeInteractionTransactionState RuntimeTransactions;
|
||||
public uint SelectedObject;
|
||||
public bool NonCombatMode;
|
||||
public bool DragOnPlayerOpensSecureTrade = true;
|
||||
|
|
@ -56,10 +58,12 @@ public sealed class ItemInteractionControllerTests
|
|||
});
|
||||
Objects.MoveItem(Pack, Player, 0);
|
||||
SharedTransactions = new InventoryTransactionState(Objects);
|
||||
RuntimeTransactions = new RuntimeInteractionTransactionState(
|
||||
SharedTransactions);
|
||||
|
||||
Controller = new ItemInteractionController(
|
||||
Objects,
|
||||
SharedTransactions,
|
||||
RuntimeTransactions,
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: requestUse is null ? Uses.Add : null,
|
||||
|
|
@ -338,10 +342,12 @@ public sealed class ItemInteractionControllerTests
|
|||
var objects = new ClientObjectTable();
|
||||
using var transactions =
|
||||
new InventoryTransactionState(new ClientObjectTable());
|
||||
using var runtimeTransactions =
|
||||
new RuntimeInteractionTransactionState(transactions);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => new ItemInteractionController(
|
||||
objects,
|
||||
transactions,
|
||||
runtimeTransactions,
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -858,7 +858,7 @@ public sealed class AppraisalUiControllerTests
|
|||
List<uint> sent)
|
||||
=> new(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => 0x50000002u,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public sealed class ExternalContainerControllerTests
|
|||
|
||||
Interaction = new ItemInteractionController(
|
||||
Objects,
|
||||
new InventoryTransactionState(Objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(Objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: Uses.Add,
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ public class InventoryControllerTests
|
|||
var appraisals = new List<uint>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -546,7 +546,7 @@ public class InventoryControllerTests
|
|||
objects.Get(0xA)!.Useability = 0x000A0008u;
|
||||
var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -716,7 +716,7 @@ public class InventoryControllerTests
|
|||
var pickups = new List<(uint item, uint container, int placement)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -762,7 +762,7 @@ public class InventoryControllerTests
|
|||
var eventOrder = new List<(string Kind, uint Item, ulong Token)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -815,7 +815,7 @@ public class InventoryControllerTests
|
|||
var eventOrder = new List<(string Kind, uint Item)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -874,7 +874,7 @@ public class InventoryControllerTests
|
|||
var messages = new List<string>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -944,7 +944,7 @@ public class InventoryControllerTests
|
|||
var messages = new List<string>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -1008,7 +1008,7 @@ public class InventoryControllerTests
|
|||
var merges = new List<(uint Source, uint Target, uint Amount)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -1069,7 +1069,7 @@ public class InventoryControllerTests
|
|||
var splits = new List<(uint Item, uint Container, uint Placement, uint Amount)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -1117,7 +1117,7 @@ public class InventoryControllerTests
|
|||
var puts = new List<(uint Item, uint Container, int Placement)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -1158,7 +1158,7 @@ public class InventoryControllerTests
|
|||
SeedContained(objects, loot, chest, slot: 0, type: ItemType.Misc);
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
@ -1198,7 +1198,7 @@ public class InventoryControllerTests
|
|||
SeedContained(objects, loot, chest, slot: 0, type: ItemType.Misc);
|
||||
using var interaction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class PaperdollControllerTests
|
|||
{
|
||||
var itemInteraction = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
() => Player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ public class ToolbarControllerTests
|
|||
var useWithTarget = new List<(uint Source, uint Target)>();
|
||||
var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => player,
|
||||
sendUse: null,
|
||||
|
|
@ -332,7 +332,7 @@ public class ToolbarControllerTests
|
|||
var directPuts = new List<(uint Item, uint Container, int Placement)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => player,
|
||||
sendUse: null,
|
||||
|
|
@ -382,7 +382,7 @@ public class ToolbarControllerTests
|
|||
var messages = new List<string>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => player,
|
||||
sendUse: null,
|
||||
|
|
@ -512,7 +512,7 @@ public class ToolbarControllerTests
|
|||
uint selected = item;
|
||||
var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
() => player,
|
||||
sendUse: uses.Add,
|
||||
|
|
@ -571,7 +571,7 @@ public class ToolbarControllerTests
|
|||
var selection = new SelectionState();
|
||||
using var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
() => player,
|
||||
sendUse: null,
|
||||
|
|
@ -637,7 +637,7 @@ public class ToolbarControllerTests
|
|||
var wields = new List<(uint Item, uint Location)>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
() => player,
|
||||
sendUse: null,
|
||||
|
|
@ -804,7 +804,7 @@ public class ToolbarControllerTests
|
|||
var appraisals = new List<uint>();
|
||||
using var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => player,
|
||||
sendUse: null,
|
||||
|
|
@ -854,7 +854,7 @@ public class ToolbarControllerTests
|
|||
uint sentTarget = 0;
|
||||
var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
() => player,
|
||||
sendUse: null,
|
||||
|
|
@ -897,7 +897,7 @@ public class ToolbarControllerTests
|
|||
repo.MoveItem(item, pack, 0);
|
||||
var interaction = new ItemInteractionController(
|
||||
repo,
|
||||
new InventoryTransactionState(repo),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(repo)),
|
||||
new InteractionState(),
|
||||
() => player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public sealed class RetailItemConfirmationControllerTests
|
|||
var uses = new List<uint>();
|
||||
var items = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: uses.Add,
|
||||
|
|
@ -54,7 +54,7 @@ public sealed class RetailItemConfirmationControllerTests
|
|||
var uses = new List<uint>();
|
||||
var items = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: uses.Add,
|
||||
|
|
@ -84,7 +84,7 @@ public sealed class RetailItemConfirmationControllerTests
|
|||
var messages = new List<string>();
|
||||
var items = new ItemInteractionController(
|
||||
objects,
|
||||
new InventoryTransactionState(objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: uses.Add,
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public sealed class RetailUiInteractionFlowTests
|
|||
{
|
||||
var interaction = new ItemInteractionController(
|
||||
Objects,
|
||||
new InventoryTransactionState(Objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(Objects)),
|
||||
new InteractionState(),
|
||||
playerGuid: () => Player,
|
||||
sendUse: Uses.Add,
|
||||
|
|
@ -199,7 +199,7 @@ public sealed class RetailUiInteractionFlowTests
|
|||
{
|
||||
itemInteraction ??= new ItemInteractionController(
|
||||
Objects,
|
||||
new InventoryTransactionState(Objects),
|
||||
new AcDream.Runtime.Gameplay.RuntimeInteractionTransactionState(new InventoryTransactionState(Objects)),
|
||||
new InteractionState(),
|
||||
() => Player,
|
||||
sendUse: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue