The quarters seat with the facilities through InstalledDesigns, one call site; the drain asks by Habitants.Size and pins the short-span count
EquipCrewQuarters and its filters are deleted (seating last protected nothing: the digest re-measure covers the stream). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bf8f6c679c
commit
67afbdc65f
3 changed files with 25 additions and 22 deletions
|
|
@ -161,8 +161,6 @@ public class LoadoutGenerator
|
|||
if (cargo.TryStore(instance)) stocked += cells;
|
||||
}
|
||||
|
||||
EquipCrewQuarters(entity, kind);
|
||||
|
||||
entity.CanTow = hullData.CanTow;
|
||||
|
||||
return EntitySerializer.Pack(entity) as OrbitalEntityPack;
|
||||
|
|
@ -379,31 +377,21 @@ public class LoadoutGenerator
|
|||
throw new InvalidLoadoutException("Failed to equip selected tractor beam!");
|
||||
}
|
||||
|
||||
// Installs the station kind's Facilities, largest shape first then by name (StationKinds.InstalledDesigns' order, which
|
||||
// FacilityRoomFaults counts rows in), each on a free Facility row that takes it. The brand is derived, never drawn: the station
|
||||
// faction's own product of the design, else the first by name. A facility is on no market, so the product need not be offered. Draws
|
||||
// nothing from Random.
|
||||
private void EquipFacilities(Entity entity, CultRecordRef<StationKindData> kind) =>
|
||||
Install(entity, kind, StationKinds.InstalledDesigns(ItemManager.ItemData, ItemManager.ItemData.Get(kind)).Where(design => !StationKinds.IsCrewQuarters(design)));
|
||||
|
||||
// Installs the Crew Quarters on the station's last Facility row, after every other draw of the loadout: making the unit takes a lot from
|
||||
// the item stream, and made last it moves no draw the station's own generation makes (the cargo bay it draws, the gear it stocks).
|
||||
// Installs what the station's kind installs (StationKinds.InstalledDesigns: its facilities, largest shape first then by name, then the
|
||||
// Crew Quarters; the order FacilityRoomFaults counts rows in), each on a free Facility row that takes it. The brand is derived, never
|
||||
// drawn: the station faction's own product of the design, else the first by name. A facility is on no market, so the product need not
|
||||
// be offered. Draws nothing from Random.
|
||||
//
|
||||
// CONJURE (ruling economy-is-never-faked): every station is handed a Crew Quarters here from a not-offered product that no facility
|
||||
// makes, as it is handed its kind's facilities. This is interim scaffolding, named so it is deleted and not forgotten: follow-up
|
||||
// conjuring-site-deletions removes it once habitat gear works (a gear-works facility making Crew Quarters) exist to supply the
|
||||
// station's quarters, and the installation then comes from that production.
|
||||
private void EquipCrewQuarters(Entity entity, CultRecordRef<StationKindData> kind)
|
||||
{
|
||||
var quarters = StationKinds.InstalledDesigns(ItemManager.ItemData, ItemManager.ItemData.Get(kind)).Where(StationKinds.IsCrewQuarters).ToArray();
|
||||
if (quarters.Length == 0) throw new InvalidLoadoutException("No crew quarters design in the catalog for station!");
|
||||
Install(entity, kind, quarters);
|
||||
}
|
||||
|
||||
private void Install(Entity entity, CultRecordRef<StationKindData> kind, IEnumerable<EquippableItemData> designs)
|
||||
private void EquipFacilities(Entity entity, CultRecordRef<StationKindData> kind)
|
||||
{
|
||||
var kindData = ItemManager.ItemData.Get(kind);
|
||||
var hullName = ItemManager.GetData(entity.Hull).Name;
|
||||
var designs = StationKinds.InstalledDesigns(ItemManager.ItemData, kindData);
|
||||
if (!designs.Any(StationKinds.IsCrewQuarters)) throw new InvalidLoadoutException("No crew quarters design in the catalog for station!");
|
||||
foreach (var design in designs)
|
||||
{
|
||||
var product = InstalledProduct(design);
|
||||
|
|
|
|||
|
|
@ -74,11 +74,26 @@ public sealed class EconomyDrainTests
|
|||
Assert.Equal(("Crew Quarters", 20, 120, 7200.0), (crew.Name, crew.Occupants, crew.Spans, crew.Seconds));
|
||||
// Twenty occupants over two hours at the drafted rates: Water 2.0, Oxygen 1.5 and Algae 1.0 per occupant hour.
|
||||
Assert.Equal(new[] { ("Algae", 40.0), ("Oxygen", 60.0), ("Water", 80.0) }, crew.Asked.OrderBy(kv => kv.Key, StringComparer.Ordinal).Select(kv => (kv.Key, Math.Round(kv.Value, 6))));
|
||||
Assert.True(crew.ShortSpans > crew.Spans / 2, $"short in {crew.ShortSpans} of {crew.Spans} spans");
|
||||
// Pinned: the first span owes no whole unit of any row (20 occupants x 2 Water an hour is 0.67 a span), every later one owes some
|
||||
// and the hold has none.
|
||||
Assert.Equal(119, crew.ShortSpans);
|
||||
Assert.Contains("crew Crew Quarters (20 occupants): per sim hour asked ", Printed(sample));
|
||||
}
|
||||
}
|
||||
|
||||
// What the crew asks reads its population: a quarters holding ten of its twenty asks half (the figure reads Habitants.Size, not Capacity).
|
||||
[Fact]
|
||||
public void TheCrewAsksForItsPopulationNotItsCapacity()
|
||||
{
|
||||
var sample = EconomyDrain.Run(Root, 1, 30, 2, Seed1.Value, demo =>
|
||||
{
|
||||
var quarters = demo.Processing.Equipment.Single(unit => unit.Behaviors.OfType<Habitation>().Any());
|
||||
quarters.EquippableItem.Habitants = new Habitants { Size = 10, Owed = new double[3] };
|
||||
});
|
||||
var crew = Assert.Single(Station(sample, "processing").Crew);
|
||||
Assert.Equal(new[] { ("Algae", 20.0), ("Oxygen", 30.0), ("Water", 40.0) }, crew.Asked.OrderBy(kv => kv.Key, StringComparer.Ordinal).Select(kv => (kv.Key, Math.Round(kv.Value, 6))));
|
||||
}
|
||||
|
||||
// A drain copy shares no object with the live station: EntitySerializer.Pack alone puts the live stacks in the pack, so a copy
|
||||
// made from it would move the original's units when it sells or takes (Soul s1, copy-isolation-unpinned).
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ public static class EconomyDrain
|
|||
|
||||
// The copy's facilities and crew quarters, each advanced through `seconds` of sim time in spans of RegionClock.Span by the off-screen
|
||||
// step the game ships (RegionClock.AdvanceInstalled), in equipment order. Returns the Stall each facility ended in; each sees the sim
|
||||
// time and the stalls after every span. With a tally, each span adds what the crew asked of the hold (occupants x rate x span) and
|
||||
// time and the stalls after every span. With a tally, each span adds what the crew asked of the hold (the unit's Habitants.Size, Capacity before its first step, x rate x span) and
|
||||
// whether a quarters' step went short (Habitation.Shortfall), indexed as Drain.Crew.
|
||||
public Stall[] Spans(Entity copy, double seconds, Action<double, Stall[]> each = null, IReadOnlyList<CrewDrain> tally = null)
|
||||
{
|
||||
|
|
@ -431,7 +431,7 @@ public static class EconomyDrain
|
|||
foreach (var row in data.Table)
|
||||
{
|
||||
var name = Name(Demo.Cache, row.Commodity.Key.Value);
|
||||
tally[c].Asked[name] = tally[c].Asked.GetValueOrDefault(name) + data.Capacity * row.PerOccupantHour * span / 3600;
|
||||
tally[c].Asked[name] = tally[c].Asked.GetValueOrDefault(name) + (crews[c].EquippableItem.Habitants?.Size ?? data.Capacity) * row.PerOccupantHour * span / 3600;
|
||||
}
|
||||
}
|
||||
at += span;
|
||||
|
|
|
|||
Loading…
Reference in a new issue