Compound commodities stack: ICommodityStack owns interchangeability, one bay rule serves every stack
ICommodityStack (StacksWith, Split) on SimpleCommodity and CompoundCommodity; CompoundCommodity.Quantity at Key(13), CompoundCommodityData.MaxStack at Key(12), ItemManager.MaxStack. The bay's typed SimpleCommodity and CraftedItemInstance entries are private behind the ItemInstance dispatchers, Remove and TryTransferItem take ItemInstance with a quantity, EquippedCargoBay.Count serves CountItemsInCargo and the trade menu. Restore, pickup, prices, give and sale follow (sale absorbs for any stack: question compound-stack-sale-absorbs). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f0119a3599
commit
a30f3be50d
12 changed files with 213 additions and 200 deletions
|
|
@ -445,7 +445,7 @@ public class Zone
|
|||
if (floating == null || (floating.Holder != null && !ReferenceEquals(floating.Holder, taker))) return false;
|
||||
// The quantity is read before the store: a store that merges into a part-filled stack and spills the rest into a
|
||||
// new cell rewrites the item's Quantity.
|
||||
var stored = floating.Item is SimpleCommodity stack ? stack.Quantity : 1;
|
||||
var stored = floating.Item is ICommodityStack stack ? stack.Quantity : 1;
|
||||
if (!taker.CargoBays.Any(bay => bay.TryStore(floating.Item))) return false;
|
||||
FloatingItems.Remove(floating);
|
||||
CargoGained.OnNext(new CargoGain
|
||||
|
|
|
|||
Loading…
Reference in a new issue