From 23976aada77cf02a66e258ad6da62311fd75314f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 14:34:05 +0200 Subject: [PATCH 1/5] Ship mounts: delete EquipmentHardpoints and the plan's Equipment list The array's only reader was the dead SoundBank block in EntityInstance, which looked up a hardpoint transform and did nothing with it. ShipModPlan.Equipment, ShipModShips' assignment, the preview check, the FBX builder's HP.Equipment case and its smoke assertion all fed that one dead reader. An HP.Equipment node is now refused by the builder as an unknown hardpoint kind. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Editor/ShipModPreview.cs | 4 +--- Assets/Scripts/Editor/ShipPrefabAuthoring.cs | 8 +++----- Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs | 4 +--- Assets/Scripts/Gameplay/EntityInstance.cs | 11 ----------- Assets/Scripts/Gameplay/ShipModShips.cs | 1 - Assets/Scripts/ServerShared/ShipModPlan.cs | 3 --- docs/ship-collection-authoring.md | 6 ++---- tests/Aetheria.Shared.Tests/ShipModPlanTests.cs | 1 - 8 files changed, 7 insertions(+), 31 deletions(-) diff --git a/Assets/Scripts/Editor/ShipModPreview.cs b/Assets/Scripts/Editor/ShipModPreview.cs index 3cd6a05d0..44d419d92 100644 --- a/Assets/Scripts/Editor/ShipModPreview.cs +++ b/Assets/Scripts/Editor/ShipModPreview.cs @@ -53,7 +53,7 @@ public static class ShipModPreview var clone = UnityEngine.Object.Instantiate(ship.gameObject).GetComponent(); try { CheckShip(clone, plan, "clone"); } finally { UnityEngine.Object.DestroyImmediate(clone.gameObject); } - Debug.Log($"SHIP_MOD_ASSEMBLY_SMOKE equipment={plan.Equipment.Length} thrusters={plan.Thrusters.Length} " + + Debug.Log($"SHIP_MOD_ASSEMBLY_SMOKE thrusters={plan.Thrusters.Length} " + $"weapons={plan.Weapons.Length} radiators={plan.Radiators.Length}"); } @@ -64,8 +64,6 @@ public static class ShipModPreview Require(ship.HullColliders.Length == 1 && Inside(ship.HullColliders[0]) && ship.HullColliders[0].GetComponent() != null, "one hull collider with a MeshCollider"); Require(Inside(ship.MapIcon) && Inside(ship.Shield) && Inside(ship.TractorBeam), "map icon, shield and tractor inside the ship"); - Require(ship.EquipmentHardpoints.Select(node => node.name).SequenceEqual(plan.Equipment) && - ship.EquipmentHardpoints.All(Inside), "equipment hardpoints named by the plan"); Require(ship.ThrusterHardpoints.Select(node => node.name).SequenceEqual(plan.Thrusters) && ship.ThrusterHardpoints.All(node => Inside(node) && Inside(node.Emitter)), "thruster hardpoints with emitters"); Require(ship.RadiatorHardpoints.Select(node => node.name).SequenceEqual(plan.Radiators) && diff --git a/Assets/Scripts/Editor/ShipPrefabAuthoring.cs b/Assets/Scripts/Editor/ShipPrefabAuthoring.cs index 988fe15e7..8a419c6e0 100644 --- a/Assets/Scripts/Editor/ShipPrefabAuthoring.cs +++ b/Assets/Scripts/Editor/ShipPrefabAuthoring.cs @@ -92,7 +92,7 @@ public static class ShipPrefabAuthoring var combatLayer = LayerMask.NameToLayer("Combat"); if (minimapLayer < 0 || combatLayer < 0) throw new InvalidOperationException("Minimap or Combat layer is missing"); - var equipment = new List(); + var hardpoints = 0; var thrusters = new List(); var weapons = new List(); var radiators = new List(); @@ -106,10 +106,9 @@ public static class ShipPrefabAuthoring var parts = name.Split('.'); if (parts.Length != 3 || string.IsNullOrWhiteSpace(parts[2])) throw new InvalidOperationException($"Invalid hardpoint name {name}"); - equipment.Add(node); + hardpoints++; switch (parts[1]) { - case "Equipment": break; case "Thruster": var emitter = DirectChild(node, "Emitter")?.GetComponent(); if (emitter == null) throw new InvalidOperationException($"{name} needs an Emitter mesh child"); @@ -155,7 +154,7 @@ public static class ShipPrefabAuthoring name != "SHIP.Shield" && name != "SHIP.TractorBeam") throw new InvalidOperationException($"Unknown ship anchor {name}"); } - if (equipment.Count == 0) throw new InvalidOperationException("Ship has no HP.* hardpoints"); + if (hardpoints == 0) throw new InvalidOperationException("Ship has no HP.* hardpoints"); mapIcon.sharedMaterial = mapMaterial; mapIcon.gameObject.layer = minimapLayer; @@ -182,7 +181,6 @@ public static class ShipPrefabAuthoring ship.InvisibleMaterial = invisible; ship.Shield = shield; ship.HullColliders = new[] { hullSurface }; - ship.EquipmentHardpoints = equipment.ToArray(); ship.ThrusterHardpoints = thrusters.ToArray(); ship.WeaponHardpoints = weapons.ToArray(); ship.RadiatorHardpoints = radiators.ToArray(); diff --git a/Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs b/Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs index adda9ff7d..34f5abf83 100644 --- a/Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs +++ b/Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs @@ -23,13 +23,11 @@ public static class ShipPrefabAuthoringSmoke Child(weapon.gameObject, "Muzzle.0"); var radiator = Child(root, "HP.Radiator.Port"); Primitive(radiator.gameObject, "RadiatorMesh"); - Child(root, "HP.Equipment.Reactor"); Child(root, "Pivot.2.-90.90.-80.80.60"); ShipPrefabAuthoring.Configure(root); var ship = root.GetComponent(); - Require(ship != null && ship.EquipmentHardpoints.Length == 4, "equipment references"); - Require(ship.ThrusterHardpoints.Length == 1 && ship.ThrusterHardpoints[0].Emitter != null, "thruster emitter"); + Require(ship != null && ship.ThrusterHardpoints.Length == 1 && ship.ThrusterHardpoints[0].Emitter != null, "thruster emitter"); Require(ship.WeaponHardpoints.Length == 1 && ship.WeaponHardpoints[0].FiringPoint.Length == 2, "weapon muzzles"); Require(ship.WeaponHardpoints[0].FiringPoint[0].name == "Muzzle.0", "numeric muzzle order"); Require(ship.RadiatorHardpoints.Length == 1 && ship.RadiatorHardpoints[0].Mesh != null, "radiator mesh"); diff --git a/Assets/Scripts/Gameplay/EntityInstance.cs b/Assets/Scripts/Gameplay/EntityInstance.cs index f3d977c8c..af80d8c2d 100644 --- a/Assets/Scripts/Gameplay/EntityInstance.cs +++ b/Assets/Scripts/Gameplay/EntityInstance.cs @@ -20,7 +20,6 @@ public class EntityInstance : MonoBehaviour public ShieldManager Shield; public HullCollider[] HullColliders; - public Transform[] EquipmentHardpoints; public RadiatorHardpoint[] RadiatorHardpoints; public ThrusterHardpoint[] ThrusterHardpoints; public WeaponHardpoint[] WeaponHardpoints; @@ -241,16 +240,6 @@ public class EntityInstance : MonoBehaviour _constantWeaponManagers[data].StopFiring(item); } } - - var hp = Entity.Hardpoints[item.Position.x, item.Position.y]; - if (hp != null && item.Data.SoundBank != 0) - { - var hardpointTransform = EquipmentHardpoints.FirstOrDefault(x => x.name == hp.Transform); - if (hardpointTransform != null) - { - var hardpointGameObject = hardpointTransform.gameObject; - } - } } RadiatorMeshes = new Dictionary(); Barrels = new Dictionary(); diff --git a/Assets/Scripts/Gameplay/ShipModShips.cs b/Assets/Scripts/Gameplay/ShipModShips.cs index 26761ad11..9e06099c9 100644 --- a/Assets/Scripts/Gameplay/ShipModShips.cs +++ b/Assets/Scripts/Gameplay/ShipModShips.cs @@ -149,7 +149,6 @@ public static class ShipModShips instance.InvisibleMaterial = template.Invisible; instance.Shield = shield; instance.HullColliders = new[] { surface }; - instance.EquipmentHardpoints = plan.Equipment.Select(Node).ToArray(); instance.ThrusterHardpoints = thrusters; instance.WeaponHardpoints = weapons; instance.RadiatorHardpoints = radiators; diff --git a/Assets/Scripts/ServerShared/ShipModPlan.cs b/Assets/Scripts/ServerShared/ShipModPlan.cs index 6b696bcaa..787656a3e 100644 --- a/Assets/Scripts/ServerShared/ShipModPlan.cs +++ b/Assets/Scripts/ServerShared/ShipModPlan.cs @@ -10,8 +10,6 @@ public sealed class ShipModPlan public string HullCollider; public string Shield; public string Tractor; - // Every hull hardpoint's mount id, in hardpoint order: the anchor node each one is matched to by name. - public string[] Equipment; // Mount ids whose anchor (role thruster-emitter / radiator-mesh) is the emitter / mesh node itself. public string[] Thrusters; public string[] Radiators; @@ -53,7 +51,6 @@ public sealed class ShipModPlan HullCollider = Only("hull-collider"), Shield = Only("shield"), Tractor = Only("tractor"), - Equipment = hardpoints.Select(hardpoint => hardpoint.Transform).ToArray(), Thrusters = Mounts(HardpointType.Thruster), Radiators = Mounts(HardpointType.Radiator), Weapons = weapons diff --git a/docs/ship-collection-authoring.md b/docs/ship-collection-authoring.md index a92551ccd..198a083dc 100644 --- a/docs/ship-collection-authoring.md +++ b/docs/ship-collection-authoring.md @@ -44,13 +44,11 @@ reserved. IDs after a role prefix must be unique across the model. Other visual Muzzle.1 optional additional barrel HP.Radiator.Port empty; exact name copied to the catalog RadiatorMesh one mesh; temperature emission surface - HP.Equipment.Reactor empty; exact name copied to the catalog Pivot.0.-90.90.-80.80.60 optional empty parent of articulated mounts ``` -`HP.Equipment` covers sensors, reactor, shield, cargo, and other mounts without a special visual component. -`HP.Weapon` covers ballistic, energy, and launcher mounts; the catalog chooses which. Every `HP.*` becomes an -`EquipmentHardpoints` entry. Thruster, weapon, and radiator roles also get their matching components and arrays. +`HP.Weapon` covers ballistic, energy, and launcher mounts; the catalog chooses which. Only thrusters, weapons and +radiators are visible and get a node; internal hardpoints have none. Each role gets its matching component and array. `Muzzle.` children are sorted numerically; their transforms become `FiringPoint`. A weapon mount requires at least one. A `Pivot` name carries `Group.YawMin.YawMax.PitchMin.PitchMax.Speed` as signed integers in degrees and degrees per second. It gets `ArticulationPoint`; child mounts follow its transform. Pivots are diff --git a/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs b/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs index c98ff3a10..e44c60e83 100644 --- a/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs @@ -33,7 +33,6 @@ public sealed class ShipModPlanTests var plan = Plan(Rig()); Assert.Equal(("map", "collider", "shield", "tractor"), (plan.MapIcon, plan.HullCollider, plan.Shield, plan.Tractor)); - Assert.Equal(new[] { "thruster.port", "gun", "fin" }, plan.Equipment); Assert.Equal(new[] { "thruster.port" }, plan.Thrusters); Assert.Equal(new[] { "fin" }, plan.Radiators); var (mount, muzzles) = Assert.Single(plan.Weapons); From 976b7119054f10fcb76f29fe2c1121901918f779 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 14:39:08 +0200 Subject: [PATCH 2/5] Ship mounts: anchors only for visible hardpoints, every role rule in Validate ShipAuthoringStore.Validate now alone decides which hardpoints carry anchors and which role each plays. A thruster, radiator, energy, ballistic or launcher hardpoint needs an anchor of its mount id with role thruster-emitter, radiator-mesh or the new weapon-mount; every other hardpoint is internal and no anchor may take its id. A mount-role anchor must be a hardpoint's mount, a muzzle must hang off a weapon mount, and each weapon needs a muzzle; these checks move out of ShipModPlan.Build, which now only maps a validated pair to slots and throws nothing itself. 'articulation' stays in the vocabulary for pivots and is never a mount. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/ServerShared/ShipAuthoring.cs | 53 ++++-- Assets/Scripts/ServerShared/ShipModPlan.cs | 30 +--- .../ShipAuthoringTests.cs | 156 ++++++++++++++---- tests/Aetheria.Shared.Tests/ShipFixture.cs | 2 +- .../Aetheria.Shared.Tests/ShipModPlanTests.cs | 47 +----- .../ShipValidationTests.cs | 6 +- 6 files changed, 171 insertions(+), 123 deletions(-) diff --git a/Assets/Scripts/ServerShared/ShipAuthoring.cs b/Assets/Scripts/ServerShared/ShipAuthoring.cs index d7263fd42..837bcefc2 100644 --- a/Assets/Scripts/ServerShared/ShipAuthoring.cs +++ b/Assets/Scripts/ServerShared/ShipAuthoring.cs @@ -24,8 +24,8 @@ public sealed class ShipAnchor { // Stable semantic identity. HullData.Hardpoints[].Transform names this ID for mounts. [Key(0)] public string Id; - // One of: map-icon, hull-collider, shield, tractor, thruster-emitter, - // weapon-muzzle, radiator-mesh, or articulation. + // One of: map-icon, hull-collider, shield, tractor, thruster-emitter, weapon-mount, + // weapon-muzzle, radiator-mesh, or articulation (a pivot, never a mount). [Key(1)] public string Role; // Stable node ID in the compiled model, never a Blender display name. [Key(2)] public string ModelNodeId; @@ -53,9 +53,19 @@ public static class ShipAuthoringStore // ShipAnchor.Role's vocabulary. private static readonly HashSet Roles = new HashSet(StringComparer.Ordinal) { - "map-icon", "hull-collider", "shield", "tractor", "thruster-emitter", "weapon-muzzle", "radiator-mesh", "articulation" + "map-icon", "hull-collider", "shield", "tractor", "thruster-emitter", "weapon-mount", "weapon-muzzle", "radiator-mesh", + "articulation" }; + // The anchor role a visible hardpoint's mount plays, or null for an internal hardpoint, which has no anchor. + private static string MountRole(HardpointType type) => + type == HardpointType.Thruster ? "thruster-emitter" : + type == HardpointType.Radiator ? "radiator-mesh" : + IsWeapon(type) ? "weapon-mount" : null; + + public static bool IsWeapon(HardpointType type) => + type == HardpointType.Energy || type == HardpointType.Ballistic || type == HardpointType.Launcher; + public static CultCache Open(string path, bool writable = false) { var cache = new CultCache(); @@ -193,13 +203,13 @@ public static class ShipAuthoringStore if (anchors.Count(anchor => anchor.Role == role) != 1) throw new InvalidOperationException($"{ship.Id}: exactly one {role} anchor is required."); - var mounts = new HashSet(StringComparer.Ordinal); + var mounts = new Dictionary(StringComparer.Ordinal); var occupiedHardpointCells = new HashSet<(int x, int y)>(); foreach (var hardpoint in hull.Hardpoints ?? new List()) { - if (hardpoint == null || string.IsNullOrWhiteSpace(hardpoint.Transform) || - !mounts.Add(hardpoint.Transform)) + if (hardpoint == null || string.IsNullOrWhiteSpace(hardpoint.Transform) || mounts.ContainsKey(hardpoint.Transform)) throw new InvalidOperationException($"{ship.Id}: hardpoint IDs must be present and unique."); + mounts.Add(hardpoint.Transform, hardpoint); if (!Enum.IsDefined(typeof(HardpointType), hardpoint.Type)) throw new InvalidOperationException($"{ship.Id}: hardpoint {hardpoint.Transform} has an unknown type {(int)hardpoint.Type}."); if (!Enum.IsDefined(typeof(ItemRotation), hardpoint.Rotation)) @@ -219,19 +229,32 @@ public static class ShipAuthoringStore if (!occupiedHardpointCells.Add((x, y))) throw new InvalidOperationException($"{ship.Id}: hardpoint {hardpoint.Transform} overlaps another hardpoint."); } + // Only a hardpoint that shows on the model has a mount anchor, and its type fixes the role that anchor plays. var mountAnchor = anchors.FirstOrDefault(anchor => anchor.Id == hardpoint.Transform); - if (mountAnchor == null) - throw new InvalidOperationException($"{ship.Id}: hardpoint {hardpoint.Transform} has no model anchor."); - // A mount's anchor plays the mount, so its role is fixed by the hardpoint type; the structural roles (map-icon, - // hull-collider, shield, tractor, weapon-muzzle) name other nodes and never double as a mount. - var mountRole = hardpoint.Type == HardpointType.Thruster ? "thruster-emitter" : - hardpoint.Type == HardpointType.Radiator ? "radiator-mesh" : "articulation"; - if (mountAnchor.Role != mountRole) + var mountRole = MountRole(hardpoint.Type); + if (mountRole == null && mountAnchor != null) + throw new InvalidOperationException($"{ship.Id}: {hardpoint.Type} hardpoint {hardpoint.Transform} is internal, so no anchor may take its id."); + if (mountRole != null && mountAnchor == null) + throw new InvalidOperationException($"{ship.Id}: {hardpoint.Type} hardpoint {hardpoint.Transform} has no model anchor."); + if (mountRole != null && mountAnchor.Role != mountRole) throw new InvalidOperationException($"{ship.Id}: {hardpoint.Type} hardpoint {hardpoint.Transform} needs a {mountRole} anchor of that id."); } - foreach (var anchor in anchors.Where(anchor => !string.IsNullOrEmpty(anchor.ParentId))) - if (!mounts.Contains(anchor.ParentId)) + foreach (var anchor in anchors) + { + if (!string.IsNullOrEmpty(anchor.ParentId) && !mounts.ContainsKey(anchor.ParentId)) throw new InvalidOperationException($"{ship.Id}: anchor {anchor.Id} has unknown hardpoint parent {anchor.ParentId}."); + // A mount-role anchor is the mount of a hardpoint of its type, never a loose node. The hardpoint loop above has + // already refused one whose id names a hardpoint of another type, so here it only has to name a hardpoint. + if ((anchor.Role == "thruster-emitter" || anchor.Role == "radiator-mesh" || anchor.Role == "weapon-mount") && + !mounts.ContainsKey(anchor.Id)) + throw new InvalidOperationException($"{ship.Id}: {anchor.Role} anchor {anchor.Id} must be the mount of a hardpoint of its type."); + if (anchor.Role == "weapon-muzzle" && + (string.IsNullOrEmpty(anchor.ParentId) || !IsWeapon(mounts[anchor.ParentId].Type))) + throw new InvalidOperationException($"{ship.Id}: muzzle {anchor.Id} must be parented to a weapon hardpoint's mount."); + } + foreach (var hardpoint in mounts.Values.Where(hardpoint => IsWeapon(hardpoint.Type))) + if (!anchors.Any(anchor => anchor.Role == "weapon-muzzle" && anchor.ParentId == hardpoint.Transform)) + throw new InvalidOperationException($"{ship.Id}: weapon hardpoint {hardpoint.Transform} needs at least one muzzle anchor."); foreach (var line in ship.SchematicLines ?? new List()) { diff --git a/Assets/Scripts/ServerShared/ShipModPlan.cs b/Assets/Scripts/ServerShared/ShipModPlan.cs index 787656a3e..bb80647a1 100644 --- a/Assets/Scripts/ServerShared/ShipModPlan.cs +++ b/Assets/Scripts/ServerShared/ShipModPlan.cs @@ -13,37 +13,18 @@ public sealed class ShipModPlan // Mount ids whose anchor (role thruster-emitter / radiator-mesh) is the emitter / mesh node itself. public string[] Thrusters; public string[] Radiators; - // A weapon mount's muzzle anchors, by Order then id. + // Each weapon mount (role weapon-mount) and its muzzle anchors, by Order then id. public (string Mount, string[] Muzzles)[] Weapons; - // Anchors with role "articulation" become ordinary mount nodes: ArticulationPoint's limits are not authorable until - // pivots move onto HullData, so no ArticulationPoint is planned. + // Maps a pair Validate accepts; every rule about which anchor may play which part is Validate's, so this refuses nothing. public static ShipModPlan Build(HullData hull, ShipAuthoring visual) { ShipAuthoringStore.Validate(hull, visual); var hardpoints = hull.Hardpoints ?? new List(); - var byMount = hardpoints.ToDictionary(hardpoint => hardpoint.Transform, StringComparer.Ordinal); string Only(string wanted) => visual.Anchors.Single(anchor => anchor.Role == wanted).Id; - - foreach (var anchor in visual.Anchors.Where(anchor => anchor.Role == "thruster-emitter" || anchor.Role == "radiator-mesh")) - { - var wanted = anchor.Role == "thruster-emitter" ? HardpointType.Thruster : HardpointType.Radiator; - if (!byMount.ContainsKey(anchor.Id)) - throw new InvalidOperationException($"{visual.Id}: {anchor.Role} anchor {anchor.Id} must be a {wanted} hardpoint's mount."); - } string[] Mounts(HardpointType type) => hardpoints.Where(hardpoint => hardpoint.Type == type).Select(hardpoint => hardpoint.Transform).ToArray(); - var muzzles = visual.Anchors.Where(anchor => anchor.Role == "weapon-muzzle") .OrderBy(anchor => anchor.Order).ThenBy(anchor => anchor.Id, StringComparer.Ordinal).ToArray(); - foreach (var muzzle in muzzles) - if (string.IsNullOrEmpty(muzzle.ParentId) || !IsWeapon(byMount[muzzle.ParentId].Type)) - throw new InvalidOperationException($"{visual.Id}: muzzle {muzzle.Id} must be parented to a weapon hardpoint's mount."); - var weapons = hardpoints.Where(hardpoint => IsWeapon(hardpoint.Type)).Select(hardpoint => ( - hardpoint.Transform, - muzzles.Where(muzzle => muzzle.ParentId == hardpoint.Transform).Select(muzzle => muzzle.Id).ToArray())).ToArray(); - foreach (var (mount, ids) in weapons) - if (ids.Length == 0) - throw new InvalidOperationException($"{visual.Id}: weapon hardpoint {mount} needs at least one muzzle anchor."); return new ShipModPlan { @@ -53,10 +34,9 @@ public sealed class ShipModPlan Tractor = Only("tractor"), Thrusters = Mounts(HardpointType.Thruster), Radiators = Mounts(HardpointType.Radiator), - Weapons = weapons + Weapons = hardpoints.Where(hardpoint => ShipAuthoringStore.IsWeapon(hardpoint.Type)).Select(hardpoint => ( + hardpoint.Transform, + muzzles.Where(muzzle => muzzle.ParentId == hardpoint.Transform).Select(muzzle => muzzle.Id).ToArray())).ToArray() }; } - - private static bool IsWeapon(HardpointType type) => - type == HardpointType.Energy || type == HardpointType.Ballistic || type == HardpointType.Launcher; } diff --git a/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs b/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs index 2d6680933..349411ea2 100644 --- a/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs @@ -230,49 +230,137 @@ public sealed class ShipAuthoringTests Assert.Contains("records must be stored under", Assert.Throws(() => ShipAuthoringStore.Load(wrongVisualKey)).Message); } - // A mount's anchor plays the mount, so a structural anchor (the hull collider, the shield, a muzzle...) is never one. - // Interim ruling until an `equipment` role exists: a mount that is not a thruster or radiator is an articulation anchor. - [Theory] - [InlineData("map-icon", "map")] - [InlineData("hull-collider", "collider")] - [InlineData("shield", "shield")] - [InlineData("tractor", "tractor")] - [InlineData("weapon-muzzle", "muzzle")] - [InlineData("thruster-emitter", "emitter")] - [InlineData("radiator-mesh", "mesh")] - public void AStructuralAnchorCannotBeAnEquipmentMount(string role, string anchorId) + private static readonly string[] AllRoles = + { + "map-icon", "hull-collider", "shield", "tractor", "thruster-emitter", "weapon-mount", "weapon-muzzle", "radiator-mesh", "articulation" + }; + + // The fixture with its thruster swapped for one hardpoint of the given type at mount id "mount", and no anchor for it. + private static ShipParts WithOnly(HardpointType type) { var ship = Fixture(); - // The extra anchors exist so the role-count and parent checks pass; the Tool hardpoint then claims the anchor. - ship.Visual.Anchors.Add(new ShipAnchor { Id = "muzzle", Role = "weapon-muzzle", ModelNodeId = "muzzle", ParentId = "thruster.port" }); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "emitter", Role = "thruster-emitter", ModelNodeId = "emitter" }); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "mesh", Role = "radiator-mesh", ModelNodeId = "mesh" }); - ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Tool, Position = new int2(0, 0), Shape = new Shape(), Transform = anchorId }); + ship.Hull.Hardpoints.Clear(); + ship.Visual.Anchors.RemoveAll(anchor => anchor.Id == "thruster.port"); + ship.Hull.Hardpoints.Add(new HardpointData { Type = type, Position = new int2(0, 0), Shape = new Shape(), Transform = "mount" }); + return ship; + } - Assert.Contains($"Tool hardpoint {anchorId} needs a articulation anchor of that id", Assert.Throws(ship.Validate).Message); - ship = Fixture(); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "tool", Role = "articulation", ModelNodeId = "tool" }); - ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Tool, Position = new int2(0, 0), Shape = new Shape(), Transform = "tool" }); - ship.Validate(); + private static string Refusal(ShipParts ship) => Assert.Throws(ship.Validate).Message; + + // Mount anchors exist only for hardpoints that show on the model: weapons, radiators and thrusters. + [Theory] + [InlineData(HardpointType.Hull), InlineData(HardpointType.Tool), InlineData(HardpointType.Thermal), InlineData(HardpointType.WarpDrive), + InlineData(HardpointType.Reactor), InlineData(HardpointType.Shield), InlineData(HardpointType.Sensors), + InlineData(HardpointType.ControlModule), InlineData(HardpointType.AetherDrive)] + public void AnInternalHardpointCarriesNoAnchor(HardpointType type) + { + WithOnly(type).Validate(); + + // Any anchor taking the mount's id is refused, a mount role or not. (The four structural roles are one-of-a-kind, + // so they are covered by renaming the existing anchor.) + foreach (var role in AllRoles) + { + var ship = WithOnly(type); + var existing = ship.Visual.Anchors.FirstOrDefault(anchor => anchor.Role == role); + if (existing != null) existing.Id = "mount"; + else ship.Visual.Anchors.Add(new ShipAnchor { Id = "mount", Role = role, ModelNodeId = "mount" }); + Assert.Contains($"mod.skiff: {type} hardpoint mount is internal, so no anchor may take its id", Refusal(ship)); + } + } + + [Theory] + [InlineData(HardpointType.Thruster, "thruster-emitter")] + [InlineData(HardpointType.Radiator, "radiator-mesh")] + [InlineData(HardpointType.Energy, "weapon-mount")] + [InlineData(HardpointType.Ballistic, "weapon-mount")] + [InlineData(HardpointType.Launcher, "weapon-mount")] + public void EachVisibleHardpointNeedsItsRoleAnchor(HardpointType type, string wanted) + { + ShipParts Rig() + { + var ship = WithOnly(type); + if (ShipAuthoringStore.IsWeapon(type)) + ship.Visual.Anchors.Add(new ShipAnchor { Id = "mount.muzzle", Role = "weapon-muzzle", ModelNodeId = "muzzle", ParentId = "mount" }); + return ship; + } + + Assert.Contains($"mod.skiff: {type} hardpoint mount has no model anchor", Refusal(Rig())); + + // A structural anchor (the map icon, the collider...) whose id is the mount, or a mount anchor of the wrong role. + foreach (var role in AllRoles.Where(role => role != wanted)) + { + var ship = Rig(); + var existing = ship.Visual.Anchors.FirstOrDefault(anchor => anchor.Role == role); + if (existing != null) existing.Id = "mount"; + else ship.Visual.Anchors.Add(new ShipAnchor { Id = "mount", Role = role, ModelNodeId = "mount" }); + Assert.Contains($"mod.skiff: {type} hardpoint mount needs a {wanted} anchor of that id", Refusal(ship)); + } + + var valid = Rig(); + valid.Visual.Anchors.Add(new ShipAnchor { Id = "mount", Role = wanted, ModelNodeId = "mount" }); + valid.Validate(); + } + + // Called on Validate itself: a mount-role anchor is the mount of a hardpoint of its own type, never a loose node and + // never another type's mount. + [Theory] + [InlineData("thruster-emitter", HardpointType.Radiator)] + [InlineData("thruster-emitter", HardpointType.Energy)] + [InlineData("thruster-emitter", HardpointType.Reactor)] + [InlineData("radiator-mesh", HardpointType.Thruster)] + [InlineData("radiator-mesh", HardpointType.Launcher)] + [InlineData("radiator-mesh", HardpointType.Sensors)] + [InlineData("weapon-mount", HardpointType.Thruster)] + [InlineData("weapon-mount", HardpointType.Radiator)] + [InlineData("weapon-mount", HardpointType.Tool)] + public void AMountRoleAnchorMustBeAMountOfItsType(string role, HardpointType otherType) + { + string Refused(ShipParts ship) => + Assert.Throws(() => ShipAuthoringStore.Validate(ship.Hull, ship.Visual)).Message; + + var loose = Fixture(); + loose.Visual.Anchors.Add(new ShipAnchor { Id = "loose", Role = role, ModelNodeId = "loose" }); + Assert.Contains($"mod.skiff: {role} anchor loose must be the mount of a hardpoint of its type", Refused(loose)); + + // The anchor takes the id of a hardpoint of another type; whichever side the validator reads first, it refuses. + var other = WithOnly(otherType); + other.Visual.Anchors.Add(new ShipAnchor { Id = "mount", Role = role, ModelNodeId = "mount" }); + if (ShipAuthoringStore.IsWeapon(otherType)) + other.Visual.Anchors.Add(new ShipAnchor { Id = "mount.muzzle", Role = "weapon-muzzle", ModelNodeId = "muzzle", ParentId = "mount" }); + Assert.Contains($"mod.skiff: {otherType} hardpoint mount ", Refused(other)); } [Fact] - public void EveryHardpointTypeHasOneAnchorRoleForItsMount() + public void MuzzleRulesBelongToTheValidator() { - foreach (HardpointType type in Enum.GetValues(typeof(HardpointType))) + ShipParts Armed() { - var wanted = type == HardpointType.Thruster ? "thruster-emitter" : type == HardpointType.Radiator ? "radiator-mesh" : "articulation"; - foreach (var role in new[] { "articulation", "thruster-emitter", "radiator-mesh" }) - { - var ship = Fixture(); - ship.Hull.Hardpoints.Clear(); - ship.Visual.Anchors.RemoveAll(anchor => anchor.Id == "thruster.port"); - ship.Hull.Hardpoints.Add(new HardpointData { Type = type, Position = new int2(0, 0), Shape = new Shape(), Transform = "mount" }); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "mount", Role = role, ModelNodeId = "mount" }); - if (role == wanted) ship.Validate(); - else Assert.Contains($"{type} hardpoint mount needs a {wanted} anchor of that id", Assert.Throws(ship.Validate).Message); - } + var ship = Fixture(); + ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Energy, Position = new int2(0, 0), Shape = new Shape(), Transform = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "weapon-mount", ModelNodeId = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.b", Role = "weapon-muzzle", ModelNodeId = "gun-b", ParentId = "gun", Order = 0 }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.a", Role = "weapon-muzzle", ModelNodeId = "gun-a", ParentId = "gun", Order = 0 }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.z", Role = "weapon-muzzle", ModelNodeId = "gun-z", ParentId = "gun", Order = -1 }); + return ship; } + + var orphan = Armed(); + orphan.Visual.Anchors.Single(anchor => anchor.Id == "gun.z").ParentId = null; + Assert.Contains("mod.skiff: muzzle gun.z must be parented to a weapon hardpoint's mount", Refusal(orphan)); + + var onThruster = Armed(); + onThruster.Visual.Anchors.Single(anchor => anchor.Id == "gun.z").ParentId = "thruster.port"; + Assert.Contains("mod.skiff: muzzle gun.z must be parented to a weapon hardpoint's mount", Refusal(onThruster)); + + var unarmed = Armed(); + unarmed.Visual.Anchors.RemoveAll(anchor => anchor.Role == "weapon-muzzle"); + Assert.Contains("mod.skiff: weapon hardpoint gun needs at least one muzzle anchor", Refusal(unarmed)); + + // A valid pair plans without a refusal of the plan's own; muzzles by Order, then id ordinally. + var valid = Armed(); + var (mount, muzzles) = Assert.Single(ShipModPlan.Build(valid.Hull, valid.Visual).Weapons); + Assert.Equal("gun", mount); + Assert.Equal(new[] { "gun.z", "gun.a", "gun.b" }, muzzles); } internal static ShipParts Fixture() diff --git a/tests/Aetheria.Shared.Tests/ShipFixture.cs b/tests/Aetheria.Shared.Tests/ShipFixture.cs index eb4f5c01e..2e8d4994e 100644 --- a/tests/Aetheria.Shared.Tests/ShipFixture.cs +++ b/tests/Aetheria.Shared.Tests/ShipFixture.cs @@ -68,7 +68,7 @@ internal static class ShipFixture var ship = ShipAuthoringTests.Fixture(); // A playable rig: the fixture thruster plus one energy weapon mount on the hull's other cell, with its muzzle. ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Energy, Position = new int2(0, 0), Shape = new Shape(), Transform = "gun" }); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "articulation", ModelNodeId = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "weapon-mount", ModelNodeId = "gun" }); ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.muzzle", Role = "weapon-muzzle", ModelNodeId = "gun-muzzle", ParentId = "gun" }); tweak?.Invoke(ship); ship.WithId(id); diff --git a/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs b/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs index e44c60e83..6df76dc6b 100644 --- a/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipModPlanTests.cs @@ -17,7 +17,7 @@ public sealed class ShipModPlanTests ship.Hull.Hardpoints[0].Position = new int2(2, 0); ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Energy, Position = new int2(0, 0), Shape = new Shape(), Transform = "gun" }); ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Radiator, Position = new int2(1, 0), Shape = new Shape(), Transform = "fin" }); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "articulation", ModelNodeId = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "weapon-mount", ModelNodeId = "gun" }); ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.a", Role = "weapon-muzzle", ModelNodeId = "gun-a", ParentId = "gun", Order = 1 }); ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun.z", Role = "weapon-muzzle", ModelNodeId = "gun-z", ParentId = "gun", Order = 0 }); ship.Visual.Anchors.Add(new ShipAnchor { Id = "fin", Role = "radiator-mesh", ModelNodeId = "fin" }); @@ -40,31 +40,6 @@ public sealed class ShipModPlanTests Assert.Equal(new[] { "gun.z", "gun.a" }, muzzles); } - [Fact] - public void AThrusterOrRadiatorMountMustCarryItsRole() - { - var ship = Rig(); - ship.Visual.Anchors.Single(anchor => anchor.Id == "thruster.port").Role = "articulation"; - Assert.Contains("Thruster hardpoint thruster.port needs a thruster-emitter anchor", Refusal(ship)); - - ship = Rig(); - ship.Visual.Anchors.Single(anchor => anchor.Id == "fin").Role = "articulation"; - Assert.Contains("Radiator hardpoint fin needs a radiator-mesh anchor", Refusal(ship)); - } - - [Fact] - public void AnEmitterOrMeshAnchorMustBeItsHardpointsMount() - { - // A thruster-emitter anchor on a weapon mount, and a radiator-mesh anchor that is no mount at all. - var ship = Rig(); - ship.Visual.Anchors.Single(anchor => anchor.Id == "gun").Role = "thruster-emitter"; - Assert.Contains("Energy hardpoint gun needs a articulation anchor of that id", Refusal(ship)); - - ship = Rig(); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "loose", Role = "radiator-mesh", ModelNodeId = "loose" }); - Assert.Contains("radiator-mesh anchor loose must be a Radiator hardpoint's mount", Refusal(ship)); - } - // Equal Order falls back to the id, compared ordinally, whatever order the anchors were authored in. [Fact] public void MuzzlesOfEqualOrderAreTiedByIdOrdinally() @@ -78,22 +53,6 @@ public sealed class ShipModPlanTests Assert.Equal(new[] { "gun.z", "gun.B", "gun.a", "gun.b", "gun.c" }, Assert.Single(Plan(ship).Weapons).Muzzles); } - [Fact] - public void MuzzlesBelongToWeaponMountsAndEveryWeaponHasOne() - { - var ship = Rig(); - ship.Visual.Anchors.Single(anchor => anchor.Id == "gun.z").ParentId = null; - Assert.Contains("muzzle gun.z must be parented to a weapon hardpoint's mount", Refusal(ship)); - - ship = Rig(); - ship.Visual.Anchors.Single(anchor => anchor.Id == "gun.z").ParentId = "thruster.port"; - Assert.Contains("muzzle gun.z must be parented to a weapon hardpoint's mount", Refusal(ship)); - - ship = Rig(); - ship.Visual.Anchors.RemoveAll(anchor => anchor.Role == "weapon-muzzle"); - Assert.Contains("weapon hardpoint gun needs at least one muzzle anchor", Refusal(ship)); - } - [Theory] [InlineData(HardpointType.Energy)] [InlineData(HardpointType.Ballistic)] @@ -103,10 +62,6 @@ public sealed class ShipModPlanTests var ship = Rig(); ship.Hull.Hardpoints.Single(hardpoint => hardpoint.Transform == "gun").Type = type; Assert.Equal("gun", Assert.Single(Plan(ship).Weapons).Mount); - - // Any other type refuses the same muzzles. - ship.Hull.Hardpoints.Single(hardpoint => hardpoint.Transform == "gun").Type = HardpointType.Tool; - Assert.Contains("must be parented to a weapon hardpoint's mount", Refusal(ship)); } [Fact] diff --git a/tests/Aetheria.Shared.Tests/ShipValidationTests.cs b/tests/Aetheria.Shared.Tests/ShipValidationTests.cs index eb150939a..c67f3e6d3 100644 --- a/tests/Aetheria.Shared.Tests/ShipValidationTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipValidationTests.cs @@ -34,7 +34,7 @@ public sealed class ShipValidationTests ship.Hull.Hardpoints[0].Armor = 5; ship.Hull.Hardpoints[0].FiringArc = 360; ship.Hull.Hardpoints[0].Type = HardpointType.AetherDrive; - ship.Visual.Anchors.Single(anchor => anchor.Id == "thruster.port").Role = "articulation"; + ship.Visual.Anchors.RemoveAll(anchor => anchor.Id == "thruster.port"); ship.Hull.Hardpoints[0].Rotation = ItemRotation.Clockwise; ship.Validate(); } @@ -128,7 +128,9 @@ public sealed class ShipValidationTests public void AnAnchorMayNameItsHardpointAsParent() { var ship = ShipAuthoringTests.Fixture(); - ship.Visual.Anchors.Add(new ShipAnchor { Id = "muzzle", Role = "weapon-muzzle", ModelNodeId = "muzzle", ParentId = "thruster.port" }); + ship.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Ballistic, Position = new int2(0, 0), Shape = new Shape(), Transform = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "gun", Role = "weapon-mount", ModelNodeId = "gun" }); + ship.Visual.Anchors.Add(new ShipAnchor { Id = "muzzle", Role = "weapon-muzzle", ModelNodeId = "muzzle", ParentId = "gun" }); ship.Validate(); } From 95c0fa621b4b8fa1a921635254c409a32468a259 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 14:39:09 +0200 Subject: [PATCH 3/5] Ship mounts: a thruster's mesh is an unrendered emission surface Ruling thrusters-radiators-are-meshes: thruster and radiator mounts are meshes; the thruster's is not drawn and is the surface its exhaust emits from, the radiator's is drawn. The assembler already required a mesh for both; it now turns rendering off on the thruster emitter, and the preview smoke checks it. The authoring doc states the mount rules and the mesh rule. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Editor/ShipModPreview.cs | 3 ++- Assets/Scripts/Gameplay/ShipModShips.cs | 2 ++ docs/moddable-ship-authoring.md | 21 ++++++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Editor/ShipModPreview.cs b/Assets/Scripts/Editor/ShipModPreview.cs index 44d419d92..090917d9e 100644 --- a/Assets/Scripts/Editor/ShipModPreview.cs +++ b/Assets/Scripts/Editor/ShipModPreview.cs @@ -65,7 +65,8 @@ public static class ShipModPreview ship.HullColliders[0].GetComponent() != null, "one hull collider with a MeshCollider"); Require(Inside(ship.MapIcon) && Inside(ship.Shield) && Inside(ship.TractorBeam), "map icon, shield and tractor inside the ship"); Require(ship.ThrusterHardpoints.Select(node => node.name).SequenceEqual(plan.Thrusters) && - ship.ThrusterHardpoints.All(node => Inside(node) && Inside(node.Emitter)), "thruster hardpoints with emitters"); + ship.ThrusterHardpoints.All(node => Inside(node) && Inside(node.Emitter) && node.Emitter.forceRenderingOff), + "thruster hardpoints with unrendered emitter meshes"); Require(ship.RadiatorHardpoints.Select(node => node.name).SequenceEqual(plan.Radiators) && ship.RadiatorHardpoints.All(node => Inside(node) && Inside(node.Mesh)), "radiator hardpoints with meshes"); Require(ship.WeaponHardpoints.Select(node => node.name).SequenceEqual(plan.Weapons.Select(weapon => weapon.Mount)) && diff --git a/Assets/Scripts/Gameplay/ShipModShips.cs b/Assets/Scripts/Gameplay/ShipModShips.cs index 9e06099c9..d60dc2a8c 100644 --- a/Assets/Scripts/Gameplay/ShipModShips.cs +++ b/Assets/Scripts/Gameplay/ShipModShips.cs @@ -122,8 +122,10 @@ public static class ShipModShips var thrusters = plan.Thrusters.Select(id => { + // The thruster's mesh is its exhaust's emission surface, never drawn (ruling thrusters-radiators-are-meshes). var hardpoint = AddOrGet(Node(id).gameObject); hardpoint.Emitter = Renderer(id); + hardpoint.Emitter.forceRenderingOff = true; return hardpoint; }).ToArray(); var radiators = plan.Radiators.Select(id => diff --git a/docs/moddable-ship-authoring.md b/docs/moddable-ship-authoring.md index 5a69f06de..6072e1afb 100644 --- a/docs/moddable-ship-authoring.md +++ b/docs/moddable-ship-authoring.md @@ -161,13 +161,20 @@ import](https://github.com/Unity-Technologies/com.unity.cloud.gltfast/blob/main/ to read the package GLB asynchronously and map its stable node IDs to Unity transforms. It keeps a partially loaded object inactive and destroys it on failure. `ShipModShips` preloads one assembled, inactive prototype per hull -that names a `Visual`, at boot and before the game scene loads. `ShipModPlan` -decides which anchor fills which `ShipInstance` slot: the hull's hardpoint type -says what a mount is, and its anchor (id equal to the mount id) supplies the -node; a thruster mount needs a `thruster-emitter` anchor, a radiator mount a -`radiator-mesh` anchor, a weapon mount muzzle anchors parented to it. An -`articulation` anchor is an ordinary mount node until pivots move onto -`HullData`. The shared effects (shield, tractor beam, ping, explosion, map +that names a `Visual`, at boot and before the game scene loads. +`ShipAuthoringStore.Validate` owns which hardpoints carry anchors and which role +each anchor plays. Mount anchors exist only for hardpoints that show on the +model: weapons, radiators and thrusters. Each such hardpoint needs an anchor +whose id is its mount id: `thruster-emitter` for a thruster, `radiator-mesh` for +a radiator, `weapon-mount` for an energy, ballistic or launcher hardpoint. An +internal hardpoint (reactor, sensors, shield and the rest) has no anchor, and +an anchor taking its id is refused. A thruster's or radiator's anchor node is a +mesh: the thruster's is not rendered and is the surface its exhaust emits from, +the radiator's is rendered. A weapon mount is a point, and each one needs at +least one `weapon-muzzle` anchor whose `ParentId` is the weapon's mount id. +`articulation` is reserved for pivots and is never a mount; no pivot is +planned until pivots move onto `HullData`. `ShipModPlan` then maps the +validated pair to `ShipInstance` slots and refuses nothing itself. The shared effects (shield, tractor beam, ping, explosion, map and invisible materials) come from the Addressable `ShipModTemplate` prefab. `ZoneRenderer.LoadEntity` clones the prototype when the hull names a `Visual`. Gameplay reads a mod ship's records from the derived catalog; the package From da2a299baa0587244c3b0eff8ac1cb02237baf99 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 14:48:51 +0200 Subject: [PATCH 4/5] Ship mounts: hide the thruster emitter with the invisible material forceRenderingOff is not serialized, so the prototype's clone drew the emitter again; the preview smoke's clone check caught it. The emitter's materials become the template's invisible material, which survives Instantiate and which EntityInstance keeps as the renderer's own material. Co-Authored-By: Claude Opus 5.5 --- Assets/Scripts/Editor/ShipModPreview.cs | 3 ++- Assets/Scripts/Gameplay/ShipModShips.cs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Editor/ShipModPreview.cs b/Assets/Scripts/Editor/ShipModPreview.cs index 090917d9e..64f9ea6b7 100644 --- a/Assets/Scripts/Editor/ShipModPreview.cs +++ b/Assets/Scripts/Editor/ShipModPreview.cs @@ -65,7 +65,8 @@ public static class ShipModPreview ship.HullColliders[0].GetComponent() != null, "one hull collider with a MeshCollider"); Require(Inside(ship.MapIcon) && Inside(ship.Shield) && Inside(ship.TractorBeam), "map icon, shield and tractor inside the ship"); Require(ship.ThrusterHardpoints.Select(node => node.name).SequenceEqual(plan.Thrusters) && - ship.ThrusterHardpoints.All(node => Inside(node) && Inside(node.Emitter) && node.Emitter.forceRenderingOff), + ship.ThrusterHardpoints.All(node => Inside(node) && Inside(node.Emitter) && + node.Emitter.sharedMaterials.All(material => material == ship.InvisibleMaterial)), "thruster hardpoints with unrendered emitter meshes"); Require(ship.RadiatorHardpoints.Select(node => node.name).SequenceEqual(plan.Radiators) && ship.RadiatorHardpoints.All(node => Inside(node) && Inside(node.Mesh)), "radiator hardpoints with meshes"); diff --git a/Assets/Scripts/Gameplay/ShipModShips.cs b/Assets/Scripts/Gameplay/ShipModShips.cs index d60dc2a8c..354a1e4a6 100644 --- a/Assets/Scripts/Gameplay/ShipModShips.cs +++ b/Assets/Scripts/Gameplay/ShipModShips.cs @@ -123,9 +123,11 @@ public static class ShipModShips var thrusters = plan.Thrusters.Select(id => { // The thruster's mesh is its exhaust's emission surface, never drawn (ruling thrusters-radiators-are-meshes). + // The invisible material is serialized, so it survives the prototype's clone, and EntityInstance keeps it as + // this renderer's visible material; forceRenderingOff would not survive Instantiate. var hardpoint = AddOrGet(Node(id).gameObject); hardpoint.Emitter = Renderer(id); - hardpoint.Emitter.forceRenderingOff = true; + hardpoint.Emitter.sharedMaterials = Enumerable.Repeat(template.Invisible, hardpoint.Emitter.sharedMaterials.Length).ToArray(); return hardpoint; }).ToArray(); var radiators = plan.Radiators.Select(id => From 80de88f2674a4799c9d1256b3a89e7e23e42ccbf Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 3 Oct 2026 14:54:03 +0200 Subject: [PATCH 5/5] Ship mounts: each weapon needs a muzzle of its own Kills the Stryker survivor that armed every weapon with any muzzle on the ship (the && in the per-weapon muzzle check turned into ||): a second weapon mount with no muzzle is refused even when the first has one. Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs b/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs index 349411ea2..8855475ae 100644 --- a/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipAuthoringTests.cs @@ -356,6 +356,13 @@ public sealed class ShipAuthoringTests unarmed.Visual.Anchors.RemoveAll(anchor => anchor.Role == "weapon-muzzle"); Assert.Contains("mod.skiff: weapon hardpoint gun needs at least one muzzle anchor", Refusal(unarmed)); + // Each weapon needs a muzzle of its own: another weapon's muzzle does not arm it. + var second = Armed(); + second.Hull.Shape.Cells[0, 1] = true; + second.Hull.Hardpoints.Add(new HardpointData { Type = HardpointType.Launcher, Position = new int2(0, 1), Shape = new Shape(), Transform = "tube" }); + second.Visual.Anchors.Add(new ShipAnchor { Id = "tube", Role = "weapon-mount", ModelNodeId = "tube" }); + Assert.Contains("mod.skiff: weapon hardpoint tube needs at least one muzzle anchor", Refusal(second)); + // A valid pair plans without a refusal of the plan's own; muzzles by Order, then id ordinally. var valid = Armed(); var (mount, muzzles) = Assert.Single(ShipModPlan.Build(valid.Hull, valid.Visual).Weapons);