Add the lot ledger and mint every crafted instance through it

Quality, Ingredients and Product leave CraftedItemInstance; a unit now
carries only a LotId into the run-scoped ProvenanceLedger. ItemManager
gains the one lot-minting path (CreateLot/CreateInstance(int)), GetLot,
and Brand(), which derives a maker and product from provenance instead
of a stored field. RunSave persists the ledger pruned to what the saved
zones' entities still reach; the live ledger is never pruned, so a
floor pickup collected after a save still resolves. CopyBuild is gone:
matching hardpoints now share the same lot instead of copying values.
PropertiesPanel shows the derived brand where the design's manufacturer
used to be. AetherDb's census flags duplicate (maker, design) products
and its save command checks every crafted instance's lot against a real
run store.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-17 04:16:23 +02:00
commit 415f8e1152
13 changed files with 305 additions and 92 deletions

View file

@ -215,9 +215,10 @@ public class LoadoutGenerator
if (entry.design == null) ItemManager.Log($"No compatible item found for entity {Enum.GetName(typeof(HardpointType), hardpoint.Type)} hardpoint!");
else
{
var item = ItemManager.CreateInstance(entry.product) as EquippableItem;
// Matching hardpoints carry matching units: the same brand, workmanship, and parts
if (previousItem != null) CopyBuild(previousItem.EquippableItem, item);
// Matching hardpoints carry matching units: same lot
var item = (previousItem != null
? ItemManager.CreateInstance(previousItem.EquippableItem.Lot)
: ItemManager.CreateInstance(entry.product)) as EquippableItem;
if (!entity.TryEquip(item))
{
throw new InvalidLoadoutException($"Failed to equip selected {Enum.GetName(typeof(HardpointType), hardpoint.Type)}!");
@ -259,14 +260,6 @@ public class LoadoutGenerator
throw new InvalidLoadoutException("Failed to equip selected capacitor!");
}
// A second unit off the same line: same workmanship and the same parts, not a fresh roll.
private static void CopyBuild(CraftedItemInstance from, CraftedItemInstance to)
{
to.Quality = from.Quality;
to.Ingredients = from.Ingredients?
.Select(fill => new RoleFill { Role = fill.Role, Quality = fill.Quality })
.ToList() ?? new List<RoleFill>();
}
}
public class InvalidLoadoutException : Exception