FireControl.Extract stamps every mined stack with the Extracted lot of its zone, belt and ore

Extracted gains Body at key 2. ItemManager.ExtractedLot finds or mints the lot; its
(zone, belt, ore) index is derived from the ledger at construction and never saved.
SavedGame roots skip null items and Lot 0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-13 03:03:25 +00:00
commit df67c875e3
4 changed files with 34 additions and 3 deletions

View file

@ -25,6 +25,11 @@ public class ItemManager
public CultCache ItemData { get; }
public ProvenanceLedger Lots { get; }
// (zone index, belt, commodity) -> the Extracted lot minted for it. Derived from Lots at construction and on mint,
// never persisted: a reload rebuilds it from the ledger, so the same source finds the same lot.
private readonly Dictionary<(int, CultRecordKey, CultRecordKey), int> _extracted =
new Dictionary<(int, CultRecordKey, CultRecordKey), int>();
public GameplaySettings GameplaySettings { get; }
public ItemManager(uint seed, CultCache itemData, ProvenanceLedger lots, GameplaySettings settings, Action<string> logger)
@ -33,6 +38,9 @@ public class ItemManager
Random = new Random(seed);
ItemData = itemData;
Lots = lots;
foreach (var (id, lot) in lots.Lots)
if (lot.Origin is Extracted extracted)
_extracted[(extracted.Zone, extracted.Body.Key, extracted.Commodity.Key)] = id;
GameplaySettings = settings;
_logger = logger;
}
@ -181,6 +189,24 @@ public class ItemManager
return Lots.Add(lot);
}
// Mining Cut 5b: the lot of every unit mined from one commodity in one belt of one zone, found or minted. Unbranded
// (Product unset) and unworked (Quality 1, no roles). FireControl.Extract is the only caller.
public int ExtractedLot(int zone, CultRecordKey belt, SimpleCommodityData commodity)
{
var key = (zone, belt, ItemData.RefOf<ItemData>(commodity).Key);
if (_extracted.TryGetValue(key, out var found)) return found;
var id = Lots.Add(new Lot
{
Design = ItemData.RefOf<ItemData>(commodity),
Origin = new Extracted
{
Zone = zone, Body = new CultRecordRef<BodyData>(belt), Commodity = ItemData.RefOf(commodity)
},
Quality = 1
});
return _extracted[key] = id;
}
// The one writer of a crafted instance's Data: copied from the lot's design, never independently set.
public CraftedItemInstance CreateInstance(int lot)
{