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 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-03 14:48:51 +02:00
commit da2a299baa
2 changed files with 5 additions and 2 deletions

View file

@ -65,7 +65,8 @@ public static class ShipModPreview
ship.HullColliders[0].GetComponent<MeshCollider>() != 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");

View file

@ -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<ThrusterHardpoint>(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 =>