Facility runs its recipes: Production.Advance is the one cycle rule, Facility.Execute ticks it per zone step
The consumable constructor and the runs-nothing comment go. FacilityRun rides the installed unit (EquippableItem key 14); the run list is derived from RecipeData.Facility through Recipes.RunOn; EntityHold is the on-screen hold over the entity's bays. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
a7f91ba8de
commit
47ed8c071f
5 changed files with 234 additions and 9 deletions
|
|
@ -1,9 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
// The facility gear a station carries to run recipes: a GearData of HardpointType Facility whose Behaviors hold one of these. The type
|
||||
// says where it mounts (a hull's Facility rows), this says it runs recipes. It holds no field of its own: which recipes a facility
|
||||
// runs is derived from RecipeData.Facility, so no list is stored here.
|
||||
// runs is derived from RecipeData.Facility, so no list is stored here. A facility is installed gear, never a consumable's effect.
|
||||
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class FacilityData : BehaviorData
|
||||
{
|
||||
|
|
@ -13,15 +14,32 @@ public class FacilityData : BehaviorData
|
|||
}
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new Facility(this, item);
|
||||
throw new System.InvalidOperationException($"{item.Data.Name} cannot carry a facility: a facility is installed gear, never a consumable effect.");
|
||||
}
|
||||
}
|
||||
|
||||
// The installed facility that will run its recipes (ruling demand-consumed-inputs-processed-by-facilities). It runs nothing until
|
||||
// follow-up facility-production: LoadoutGenerator.EquipFacilities seats it on a station's Facility row, and it is priced and carried,
|
||||
// and that is all.
|
||||
// The installed facility (ruling demand-consumed-inputs-processed-by-facilities). It ticks once per zone step, from EquippedItem.Update
|
||||
// while the item is active, and on screen only; an unloaded zone is frozen and the strategic tick (target r3 cut 8) calls the same
|
||||
// Production.Advance for what is off screen. Its recipes are the run list of its design, fixed for a run because the catalog is.
|
||||
public class Facility : Behavior
|
||||
{
|
||||
public Facility(FacilityData data, EquippedItem item) : base(data, item) { }
|
||||
public Facility(FacilityData data, ConsumableItemEffect item) : base(data, item) { }
|
||||
private readonly IReadOnlyList<RecipeData> _runList;
|
||||
private EntityHold _hold;
|
||||
|
||||
// Why the facility advanced no further this step: derived by Advance every step, never stored on the unit.
|
||||
public Stall Stall { get; private set; }
|
||||
|
||||
public Facility(FacilityData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_runList = Production.RunList(ItemManager.ItemData, Item.EquippableItem.Data.Key);
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
_hold ??= new EntityHold(Entity);
|
||||
var (run, stall) = Production.Advance(ItemManager.ItemData, _runList, Item.EquippableItem.Run, dt, _hold);
|
||||
Item.EquippableItem.Run = run;
|
||||
Stall = stall;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue