A standing order carries only goods its To station's installed recipes consume

Seeding read Drawable, which included the crew's table and every draw of every recipe; it now reads Consumed (recipe draws only, startable
or not). A crew-only good has no seeded leg; a hauler can no longer be handed a good no recipe at its To takes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-30 00:25:17 +01:00
commit d267a2d2b4
3 changed files with 12 additions and 11 deletions

View file

@ -42,7 +42,7 @@ public static class RegionLegs
foreach (var (zone, station, makes) in stations)
{
if (station.Faction == null) continue;
foreach (var good in StationWants.Drawable(station).Where(good => !makes.Contains(good)).OrderBy(good => good.Value, StringComparer.Ordinal))
foreach (var good in StationWants.Consumed(station).Where(good => !makes.Contains(good)).OrderBy(good => good.Value, StringComparer.Ordinal))
{
// The nearest producer of its own faction by jumps, then zone index, then entity order (the list's order: the first
// of equals wins).

View file

@ -80,20 +80,20 @@ public static class StationWants
}
}
private static HashSet<CultRecordKey> Drawn(Entity station) => Draws(station, startableOnly: true);
// Every good the station may draw: what its installed recipe facilities draw, startable or not (what a seeded haul leg may bring it, which
// does not wait for room), and what its crew eats. The one reader of what gear could use; Drawn is the startable part.
public static IReadOnlyCollection<CultRecordKey> Drawable(Entity station) => Draws(station, startableOnly: false);
// Every good the station's installed recipe facilities consume, startable or not: what a standing haul order may carry to it (a
// seeded leg waits on room and never writes an order for a good no installed recipe takes). The crew's table is not here: it is
// bought by sale, never hauled by a seeded leg. Drawn is the startable part.
public static IReadOnlyCollection<CultRecordKey> Consumed(Entity station) =>
FacilityRecipes(station).SelectMany(recipe => Production.Draws(station.ItemManager.ItemData, recipe)).ToHashSet();
// The goods its installed recipe facilities make: the set Allocation builds.
public static IReadOnlyCollection<CultRecordKey> Makes(Entity station) => FacilityRecipes(station).Select(recipe => recipe.Output.Key).ToHashSet();
private static HashSet<CultRecordKey> Draws(Entity station, bool startableOnly)
private static HashSet<CultRecordKey> Drawn(Entity station)
{
var catalog = station.ItemManager.ItemData;
var wants = new HashSet<CultRecordKey>();
foreach (var recipe in FacilityRecipes(station).Where(recipe => !startableOnly || CanStart(station, recipe)))
foreach (var recipe in FacilityRecipes(station).Where(recipe => CanStart(station, recipe)))
foreach (var draw in Production.Draws(catalog, recipe))
wants.Add(draw);
// What its crew eats: the table of every habitation unit that runs (the module defines what and how much it consumes).

View file

@ -44,6 +44,7 @@ public sealed partial class RunStartTests
Assert.Same(At(order.From.Key).Faction, At(order.To.Key).Faction);
Assert.Equal(order.Goods.Select(good => good.Key.Value).OrderBy(v => v, StringComparer.Ordinal), order.Goods.Select(good => good.Key.Value));
Assert.Empty(order.Goods.Select(good => good.Key).Intersect(StationWants.Makes(At(order.To.Key))));
Assert.Empty(order.Goods.Select(good => good.Key).Except(StationWants.Consumed(At(order.To.Key))));
}
var expectedGoods = 0;
for (var s = 0; s < stations.Length; s++)
@ -51,7 +52,7 @@ public sealed partial class RunStartTests
var (zone, station) = stations[s];
if (station.Faction == null) continue;
var makes = StationWants.Makes(station);
foreach (var good in StationWants.Drawable(station).Where(good => !makes.Contains(good)))
foreach (var good in StationWants.Consumed(station).Where(good => !makes.Contains(good)))
{
var producers = stations.Select((x, index) => (x.Zone, x.Station, index)).Where(x => x.Station != station && x.Station.Faction == station.Faction
&& StationWants.Makes(x.Station).Contains(good)).ToArray();
@ -63,8 +64,8 @@ public sealed partial class RunStartTests
}
}
Assert.Equal(expectedGoods, orders.Sum(order => order.Goods.Count));
// Seeds 1 to 97 hold the whole range the spec probed: dozens of orders, and legs that jump.
Assert.InRange(orders.Length, 20, 80);
// Seeds 1 to 97: a dozen to several dozen orders (a crew-only good has none), and legs that jump.
Assert.InRange(orders.Length, 10, 80);
}
}
}