Every generated ship carries a tractor beam; AetherDb pickup-catalog turns the Tractor Beam into Pickup gear (group B, code)
GenerateShipLoadout equips one gear whose behaviours include PickupData after the shared outfitting (stations and turrets get none). The pickup-catalog command (retired in the next commit after apply) edits the existing Tractor Beam. PickupTests: two fixes found by group A's run (equip is refused once a ship is deployed, and the freeing tick takes one step). PickupGenerationTests needs the applied catalog and is red until the catalog commit; the catalog itself is not in this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e7a35135fe
commit
68430771f3
4 changed files with 119 additions and 12 deletions
|
|
@ -54,6 +54,7 @@ public class LoadoutGenerator
|
|||
var entity = new Ship(ItemManager, null, hull, ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
entity.Faction = Faction;
|
||||
OutfitEntity(entity);
|
||||
EquipPickup(entity);
|
||||
StockConsumables(entity, ShipConsumableChance, ShipConsumableUnits);
|
||||
return EntitySerializer.Pack(entity);
|
||||
}
|
||||
|
|
@ -287,6 +288,24 @@ public class LoadoutGenerator
|
|||
FillInterior(entity);
|
||||
}
|
||||
|
||||
// Every ship carries a tractor beam: picking up needs a pickup behaviour (scenarios ruling, "everyone gets tractor
|
||||
// beams"). It goes in after the shared outfitting, which stations and turrets also run and which adds none, into
|
||||
// whatever interior the hull has left; a hull with no cell for one cannot be generated.
|
||||
private void EquipPickup(Entity entity)
|
||||
{
|
||||
var emptyShape = entity.UnoccupiedSpace;
|
||||
var (product, design) = RandomProduct<GearData>(2, item =>
|
||||
item.Behaviors.Any(b => b is PickupData) &&
|
||||
item.Shape.FitsWithin(emptyShape, out _, out _), required: true);
|
||||
if (design == null) throw new InvalidLoadoutException("No compatible tractor beam found for ship!");
|
||||
|
||||
design.Shape.FitsWithin(emptyShape, out var rotation, out var position);
|
||||
var beam = ItemManager.CreateInstance(product) as EquippableItem;
|
||||
beam.Rotation = rotation;
|
||||
if (!entity.TryEquip(beam, position))
|
||||
throw new InvalidLoadoutException("Failed to equip selected tractor beam!");
|
||||
}
|
||||
|
||||
private void EquipHardpoints(Entity entity)
|
||||
{
|
||||
var hullData = ItemManager.GetData(entity.Hull) as HullData;
|
||||
|
|
|
|||
Loading…
Reference in a new issue