From 60bd14337dc2dfd31363f89b836458198db0dd93 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 27 Nov 2026 19:09:19 +0100 Subject: [PATCH] Give and ItemUsage count a stack's units, not a compound unit as a crafted item A compound commodity is a CraftedItemInstance, so a give order for a compound stack was clamped to one unit and an item use removed the whole stack. Both now read ICommodityStack. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs | 6 ++---- Assets/Scripts/ServerShared/Pilot.cs | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs b/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs index e8c5e7dd0..29de67727 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs @@ -45,10 +45,8 @@ public class ItemUsage : Behavior if (cargo == null) return false; var item = cargo.ItemsOfType[_data.Item.Key][0]; - if (item is SimpleCommodity simpleCommodity) - cargo.Remove(simpleCommodity, 1); - if (item is CraftedItemInstance craftedItemInstance) - cargo.Remove(craftedItemInstance); + // One unit of a stack, or the unit itself. + cargo.Remove(item, 1); return true; } diff --git a/Assets/Scripts/ServerShared/Pilot.cs b/Assets/Scripts/ServerShared/Pilot.cs index 0ef20f96c..e0f51078c 100644 --- a/Assets/Scripts/ServerShared/Pilot.cs +++ b/Assets/Scripts/ServerShared/Pilot.cs @@ -79,13 +79,13 @@ public sealed class PilotCommand public void ToggleHeatsinks() => HeatsinkToggles++; public void ToggleShield() => ShieldToggles++; public void Ping() => Pings++; - // Offers goods from this entity's hold to a ship alongside (ruling transfer-is-give-only): the quantity of a commodity, - // or the one crafted instance. It replaces any give under way. A give of nothing, or of less than one, is ignored, and + // Offers goods from this entity's hold to a ship alongside (ruling transfer-is-give-only): the quantity of a commodity + // stack, or the one unit. It replaces any give under way. A give of nothing, or of less than one, is ignored, and // so is one to oneself when applied. The last give or stop in a step wins. public void Give(Entity receiver, ItemInstance item, int quantity) { if (receiver == null || item == null) return; - var count = item is CraftedItemInstance ? 1 : quantity; + var count = item is ICommodityStack ? quantity : 1; if (count < 1) return; GiveVerb = (receiver, item, count); }