From b3b81007d5d31051464b20031c418ff30728fcea Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 10 Oct 2026 07:59:13 +0200 Subject: [PATCH] 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 --- .../ConsumablesFirstSetTests.cs | 16 +--------------- .../RestoredHullsTests.cs | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs b/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs index ee50a6f88..cac9267f8 100644 --- a/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs +++ b/tests/Aetheria.Shared.Tests/ConsumablesFirstSetTests.cs @@ -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("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().Where(g => hardpoint.IsFilledBy(g) && g.Behaviors.OfType().Any())) - { - var item = new EquippableItem - { - Data = Cache.RefOf(design), Durability = design.Durability, - Lot = Ship.ItemManager.Lots.Add(new Lot { Design = Cache.RefOf(design), Origin = new Attributed(), Quality = .5f, Roles = new List() }) - }; - if (fitted = Ship.TryEquip(item, hardpoint.Position)) break; - } - Assert.True(fitted, "no radiator fits the Djinni"); Zone.Update(0f); } diff --git a/tests/Aetheria.Shared.Tests/RestoredHullsTests.cs b/tests/Aetheria.Shared.Tests/RestoredHullsTests.cs index b5622b268..fe043ddae 100644 --- a/tests/Aetheria.Shared.Tests/RestoredHullsTests.cs +++ b/tests/Aetheria.Shared.Tests/RestoredHullsTests.cs @@ -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(name); var thrusterDesigns = cache.GetAll().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().First(reactorHardpoint.IsFilledBy); - var reactorItem = new EquippableItem { Data = cache.RefOf(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().First(filled.IsFilledBy); + var fillerItem = new EquippableItem { Data = cache.RefOf(filler), Durability = filler.Durability, Lot = lot++ }; + Assert.True(ship.TryEquip(fillerItem, filled.Position)); } zone.Entities.Add(ship);