From 4f6643b00ff317563ed2684934b9741852b4d746 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 16 Jun 2026 01:59:18 +0100 Subject: [PATCH] Route inventory transfers through checkpoints --- .voidbot/state/aetheria.cc | Bin 142533 -> 142922 bytes Aetheria.State.Verify/Program.cs | 74 +++++++++++++++++ Assets/Scripts/Gameplay/ActionGameManager.cs | 82 +++++++++++++++++++ Assets/Scripts/UI/Menu/InventoryMenu.cs | 40 +++++---- Assets/Scripts/UI/Menu/InventoryPanel.cs | 2 + docs/aetheria-perfect-machine-map.md | 12 ++- 6 files changed, 193 insertions(+), 17 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 7aa175586f2e718d308933078d24c4cc7b7e1ace..c152c0d3abea8df1facac34243ab151901dcf3d8 100644 GIT binary patch delta 1284 zcma)6O=uKJ6t-K1L@^OG8dldl1Hlcf|(;l@M56ka!6!QmLt#sZDoPTR%w# zRs$|%PYVeR_Q}IyR1A9%a)`>pvantj1ar*d!K1JT@#@Lf-Ek(9T)b7idi8zZd-c_O zxz+XWo35w7yS>G!e7-bVER7U$`9g7e#pw%Qx=TGf!y|?0=~?%5X!pw_9r0)r+>>F~ zfdTi-k@evN&{&x=jvOK=AJnq<`@Mh+>#VeCyjtL`G6ROhAcq~gjPG`X=B6N)@ z5ON-fp4Ct%J_|h31S5e;-{%HQgMlySSneV92>1VUdZ#ebfkTO^%k%7(<$;epZQOvE z28cxoo)mTDk@G?WH_T5ElUy#qPTZIrgO!zWTv!G( zO;FO}x*jeUj&GNNk4#zmSPeX_H&T9t-`lAjMQnQ_P#mqn=NQz8&*M^2y}(CHU=yfz z;hHLjhw~i0Kt!ZZxyO3eh@cIruCtncv#)=BIDhZ(iMtOJt8GnbX%%IqGDAqkNqFnd zK-f!qN~KET$4czANwm<^ws}`)xu`x$Z>11F?1p%IyFYwY>>iJum81I0k?1a@QsjI< z#~l6DIeepZJ@%YpE#H2Ze633Svp#D}C6}$iTDfWNl{&GDAX+)$4h@theVU4%_s{N*gW{#>Ph{rL{r~^~ delta 937 zcmYjQF>4f25OyzTNJwFk$Tfs+F3>d{suvNXZMcey5VEqeBXTEydOJ5-?oQ7yey>UMQ5aV zsy@5&%sIIAt?;A^%$}*|fEtLqz?tdOIWSZ_QaJSV-VW~Di z6M80%{yC+#sl0Im6yYzYej}DvgapD;2tt~OTq~615*k`Xq^%&+KuG~e1%Z++(%@nc z7+ByZ*H9uOmCI!3(IQv{o-k2>39ONi>q2QT7Oep;HV7jg?H$IDA5CiHVc^DkolJ$N zbrnK-x6Kk8m;?$vXbK8E18WIfr53tL55GbQp!C31(pVk4Ou%X)rBNr)Al+0tMCsB^ z=B}Qn`-1d^j0n~-h{-@xs}O7wkq1$ii7}Sg6JKpp)`*!EmA96p;bQyil21VQqCmL9 z!a~=qiOhy<_miO3N#~+9g~(n4LXeAw`K9aq=9*YH(WP>}!m<=L0rG@pepiK&2+)pY z8MrDAJht7km!M;rUT!*Y*hd2w=c=5}ZO+P6&yn>>3j|I}rZ1PAvG(^%v5hss@&en- z))+sZbT>x!+zLrq8Xg5?`}gVX(JyqvCzI&uTzFP&SYUVQv(Tzy zNcjo$liwkVAc~DIWDEArWdpUB9)0DMMwJYb$~z9tSNaAu&Cb5D&ckKr`AFyensaY| zX?m$PHCM0C&D1Nk)3ue?7F*m?>YVkRN$2ruxwBe!Hcxamh4bQ5_A3r-{Tvw0is9mH zWol~c&p;^+j}<=W&>%z8wcaNhOc%!sw|85o^VZ+vg$H}B`S !actionGameManager.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (missingCommits.Length > 0) + { + throw new InvalidOperationException( + "Inventory transfer no longer has complete gameplay-owned checkpoint commit primitives: " + + string.Join(", ", missingCommits)); + } + + var inventoryMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryMenu.cs"); + var inventoryMenu = File.Exists(inventoryMenuPath) + ? File.ReadAllText(inventoryMenuPath) + : throw new InvalidOperationException("Cannot verify inventory transfer authority; InventoryMenu.cs is missing."); + + var forbiddenSymbols = new[] + { + ".DropItem(", + ".CargoBay.Remove(", + ".TryUnequip(" + }; + + var hits = File.ReadLines(inventoryMenuPath) + .Select((line, index) => new { LineNumber = index + 1, Line = line }) + .Where(line => forbiddenSymbols.Any(symbol => line.Line.Contains(symbol, StringComparison.Ordinal))) + .Select(line => $"{Path.GetRelativePath(root, inventoryMenuPath)}:{line.LineNumber}: {line.Line.Trim()}") + .ToArray(); + + if (hits.Length > 0) + { + throw new InvalidOperationException( + "InventoryMenu double-click transfer still owns direct inventory mutation: " + + string.Join("; ", hits)); + } + + var requiredUiCalls = new[] + { + "GameManager.CommitCargoItemTransfer", + "GameManager.CommitCargoItemEquip", + "GameManager.CommitEquippedItemStore" + }; + + var missingUiCalls = requiredUiCalls + .Where(symbol => !inventoryMenu.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + + if (missingUiCalls.Length > 0) + { + throw new InvalidOperationException( + "InventoryMenu no longer routes double-click transfers through ActionGameManager: " + + string.Join(", ", missingUiCalls)); + } +} + static string ExtractMethodBody(string source, string methodName) { var signature = "private void " + methodName + "()"; diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 8c51d2153..99c33b95a 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -1455,6 +1455,88 @@ public class ActionGameManager : MonoBehaviour return true; } + public bool CommitCargoItemTransfer(EquippedCargoBay origin, EquippedCargoBay destination, ItemInstance item) + { + if (origin == null || + destination == null || + item == null || + origin == destination || + !origin.Cargo.ContainsKey(item) || + !destination.TryFindSpace(item)) + { + return false; + } + + if (item is SimpleCommodity commodity) + { + var quantity = commodity.Quantity; + var transferItem = new SimpleCommodity + { + Reference = commodity.Reference, + Quantity = quantity, + Rotation = commodity.Rotation + }; + + if (!destination.TryStore(transferItem)) + return false; + + origin.Remove(commodity, quantity); + QueueRunCheckpoint("cargo-item-transfer"); + return true; + } + + if (!destination.TryStore(item)) + return false; + + origin.Remove(item); + QueueRunCheckpoint("cargo-item-transfer"); + return true; + } + + public bool CommitCargoItemEquip(EquippedCargoBay origin, Entity destination, EquippableItem item) + { + if (origin == null || + destination == null || + item == null || + !origin.Cargo.ContainsKey(item) || + !destination.TryFindSpace(item, out _)) + { + return false; + } + + if (!destination.TryEquip(item)) + return false; + + origin.Remove(item); + QueueRunCheckpoint("cargo-item-equip"); + return true; + } + + public bool CommitEquippedItemStore(Entity origin, EquippedItem equippedItem, EquippedCargoBay destination) + { + if (origin == null || + equippedItem?.EquippableItem == null || + destination == null || + !origin.Equipment.Contains(equippedItem) || + !destination.TryFindSpace(equippedItem.EquippableItem)) + { + return false; + } + + var item = origin.TryUnequip(equippedItem); + if (item == null) + return false; + + if (!destination.TryStore(item)) + { + origin.TryEquip(item, equippedItem.Position); + return false; + } + + QueueRunCheckpoint("equipped-item-store"); + return true; + } + public void CommitEquippedItemOverrideShutdown(EquippedItem item, bool enabled) { if (item?.EquippableItem == null) diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index 18d1c1022..b3055326e 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -88,11 +88,9 @@ public class InventoryMenu : MonoBehaviour if (e.clickCount == 2) { var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0]; - if (otherPanel.CanDropItem(item)) + if (CommitCargoItemTransfer(cargoEvent.CargoBay, otherPanel, item)) { - otherPanel.DropItem(item); // TODO: SFX: Equip - cargoEvent.CargoBay.Remove(item); panel.RefreshCells(); otherPanel.RefreshCells(); } @@ -122,20 +120,11 @@ public class InventoryMenu : MonoBehaviour if (e.clickCount == 2) { var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0]; - if (otherPanel.CanDropItem(item.EquippableItem)) + if (CommitEquippedItemTransfer(entityEvent.Entity, item, otherPanel)) { - if (!entityEvent.Entity.Active) - { - if (entityEvent.Entity.TryUnequip(item) != null) - { - otherPanel.DropItem(item.EquippableItem); - // TODO: SFX: Unequip - panel.RefreshCells(); - otherPanel.RefreshCells(); - } - // else - // TODO: SFX: Fail - } + // TODO: SFX: Unequip + panel.RefreshCells(); + otherPanel.RefreshCells(); // else // TODO: SFX: Fail } @@ -170,6 +159,25 @@ public class InventoryMenu : MonoBehaviour } } + private bool CommitCargoItemTransfer(EquippedCargoBay origin, InventoryPanel destination, ItemInstance item) + { + if (destination.DisplayedEntity != null && item is EquippableItem equippableItem) + return GameManager.CommitCargoItemEquip(origin, destination.DisplayedEntity, equippableItem); + + if (destination.DisplayedCargo != null) + return GameManager.CommitCargoItemTransfer(origin, destination.DisplayedCargo, item); + + return false; + } + + private bool CommitEquippedItemTransfer(Entity origin, EquippedItem item, InventoryPanel destination) + { + if (destination.DisplayedCargo != null) + return GameManager.CommitEquippedItemStore(origin, item, destination.DisplayedCargo); + + return false; + } + void Update() { // if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null) diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index 6a87542f7..417e1a8d4 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -98,6 +98,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler public InventoryPanelTarget Target => _displayedEntity != null ? InventoryPanelTarget.Equipment : _displayedCargo != null ? InventoryPanelTarget.Cargo : InventoryPanelTarget.None; + public Entity DisplayedEntity => _displayedEntity; + public EquippedCargoBay DisplayedCargo => _displayedCargo; private void Start() { diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 949277752..6593efd84 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1389,6 +1389,13 @@ First Aetheria surfaces to publish: remains a uGUI control for now, but it no longer adds/removes items or weapons from `Entity.WeaponGroups` directly; gameplay owns the membership mutation and typed checkpoint. + - Done: route inventory double-click transfer through gameplay-owned + checkpoint commits. `InventoryMenu` no longer drops items, removes cargo, + or unequips gear directly for the double-click path; it asks + `ActionGameManager` to commit cargo-to-cargo, cargo-to-equipment, or + equipment-to-cargo movement and then refreshes display. The deeper + `InventoryPanel` drag/drop path still has direct mutation and is the next + inventory cut. - Replace the next concrete uGUI screen with an Eve-owned surface. - Move the staged packages into the Eve repo once its worktree is clean, then import them back into Aetheria from Eve instead of carrying a local copy. @@ -1710,7 +1717,10 @@ conductivity changes follow the same rule: UI requests the toggle, gameplay owns the grid mutation and checkpoint. Entity renames follow the same rule: UI collects text, gameplay owns the name mutation and checkpoint. Weapon group assignment follows the same rule: UI requests membership, gameplay owns the -group mutation and checkpoint. Any +group mutation and checkpoint. Inventory double-click transfer follows the same +rule: UI requests cargo/equipment movement, gameplay owns the move and queues +the checkpoint. Drag/drop inventory placement is not pure yet and should be cut +through the same commit primitive family next. Any predicate that still needs legacy DTO objects must earn that dependency by using behavior objects or simulation-only methods that typed facets do not yet expose.