BuildThrustedShip fills extra hardpoint types before activation; the vent test fits a radiator through it
A ship cannot be equipped once active, so the radiator has to be fitted inside the one builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d577c64d8f
commit
b3b81007d5
2 changed files with 12 additions and 23 deletions
|
|
@ -123,22 +123,8 @@ public sealed class ConsumablesFirstSetTests
|
|||
|
||||
public Run()
|
||||
{
|
||||
Ship = RestoredHullsTests.BuildThrustedShip(Cache, "Djinni");
|
||||
Ship = RestoredHullsTests.BuildThrustedShip(Cache, "Djinni", HardpointType.Radiator);
|
||||
Zone = Ship.Zone;
|
||||
var hull = Cache.GetByName<HullData>("Djinni");
|
||||
// The first radiator hardpoint that takes a radiator design; a hull has several and not every pairing fits.
|
||||
var fitted = false;
|
||||
foreach (var hardpoint in hull.Hardpoints.Where(h => h.Type == HardpointType.Radiator).TakeWhile(_ => !fitted))
|
||||
foreach (var design in Cache.GetAll<GearData>().Where(g => hardpoint.IsFilledBy(g) && g.Behaviors.OfType<RadiatorData>().Any()))
|
||||
{
|
||||
var item = new EquippableItem
|
||||
{
|
||||
Data = Cache.RefOf<ItemData>(design), Durability = design.Durability,
|
||||
Lot = Ship.ItemManager.Lots.Add(new Lot { Design = Cache.RefOf<ItemData>(design), Origin = new Attributed(), Quality = .5f, Roles = new List<RoleFill>() })
|
||||
};
|
||||
if (fitted = Ship.TryEquip(item, hardpoint.Position)) break;
|
||||
}
|
||||
Assert.True(fitted, "no radiator fits the Djinni");
|
||||
Zone.Update(0f);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -268,9 +268,9 @@ public sealed class RestoredHullsTests
|
|||
}
|
||||
}
|
||||
|
||||
// A restored hull with every thruster hardpoint (and its reactor) filled, activated and warmed up: the
|
||||
// rotation thrusters the helm tests need. The caller owns the cache.
|
||||
internal static Ship BuildThrustedShip(CultCache cache, string name)
|
||||
// A restored hull with every thruster hardpoint (and its reactor, and the first hardpoint of each type in
|
||||
// alsoFill) filled, activated and warmed up: the rotation thrusters the helm tests need. The caller owns the cache.
|
||||
internal static Ship BuildThrustedShip(CultCache cache, string name, params HardpointType[] alsoFill)
|
||||
{
|
||||
var hull = cache.GetByName<HullData>(name);
|
||||
var thrusterDesigns = cache.GetAll<GearData>().Where(g => g.Hardpoint == HardpointType.Thruster).ToArray();
|
||||
|
|
@ -296,12 +296,15 @@ public sealed class RestoredHullsTests
|
|||
// some fitting thrusters produce thrust -- an artifact of which design TryEquip's own hardpoint search
|
||||
// happens to land on, not of the restored content. Every hull here also has a Reactor hardpoint; a real
|
||||
// ship always carries one, so this fixture should too.
|
||||
var reactorHardpoint = hull.Hardpoints.FirstOrDefault(h => h.Type == HardpointType.Reactor);
|
||||
if (reactorHardpoint != null)
|
||||
// Types named by the caller (a radiator, say) are filled the same way, one hardpoint each; a ship cannot be
|
||||
// equipped once it is active.
|
||||
foreach (var type in new[] { HardpointType.Reactor }.Concat(alsoFill))
|
||||
{
|
||||
var reactorDesign = cache.GetAll<GearData>().First(reactorHardpoint.IsFilledBy);
|
||||
var reactorItem = new EquippableItem { Data = cache.RefOf<ItemData>(reactorDesign), Durability = reactorDesign.Durability, Lot = lot++ };
|
||||
Assert.True(ship.TryEquip(reactorItem, reactorHardpoint.Position));
|
||||
var filled = hull.Hardpoints.FirstOrDefault(h => h.Type == type);
|
||||
if (filled == null) continue;
|
||||
var filler = cache.GetAll<GearData>().First(filled.IsFilledBy);
|
||||
var fillerItem = new EquippableItem { Data = cache.RefOf<ItemData>(filler), Durability = filler.Durability, Lot = lot++ };
|
||||
Assert.True(ship.TryEquip(fillerItem, filled.Position));
|
||||
}
|
||||
|
||||
zone.Entities.Add(ship);
|
||||
|
|
|
|||
Loading…
Reference in a new issue