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 <noreply@anthropic.com>
This commit is contained in:
parent
b04828abd4
commit
60bd14337d
2 changed files with 5 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue