Bind decides every GLB-structure fact of a mod ship once

ReadNodeIds' HasMesh is now BuildsMesh: no skin, mesh index inside meshes,
at least one primitive, POSITION and triangle mode on each. Assemble's
shield-radii throw is deleted (Bind's PositiveScale is the judge). The FBX
thruster emitter takes Hide, with a smoke Require. Unity-only edits are
not compiled in this Body.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-13 06:08:44 +00:00
commit b66d4f89ab
5 changed files with 35 additions and 15 deletions

View file

@ -112,6 +112,7 @@ public static class ShipPrefabAuthoring
case "Thruster":
var emitter = DirectChild(node, "Emitter")?.GetComponent<MeshRenderer>();
if (emitter == null) throw new InvalidOperationException($"{name} needs an Emitter mesh child");
ShipModShips.Hide(emitter, invisible);
AddOrGet<ThrusterHardpoint>(node.gameObject).Emitter = emitter;
thrusters.Add(node.GetComponent<ThrusterHardpoint>());
break;

View file

@ -28,6 +28,8 @@ public static class ShipPrefabAuthoringSmoke
ShipPrefabAuthoring.Configure(root);
var ship = root.GetComponent<ShipInstance>();
Require(ship != null && ship.ThrusterHardpoints.Length == 1 && ship.ThrusterHardpoints[0].Emitter != null, "thruster emitter");
Require(Array.TrueForAll(ship.ThrusterHardpoints[0].Emitter.sharedMaterials, material => material == ship.InvisibleMaterial),
"thruster emitter drawn with the invisible material only");
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");

View file

@ -6,9 +6,10 @@ using GameCult.Caching;
using UnityEngine;
using Object = UnityEngine.Object;
// Mod ships in the running game. Compose decides which mod hulls exist; Preload builds a prototype for each, keyed by the
// hull's record key, into an inactive assembled copy that Instantiate clones synchronously, so LoadEntity never loads async.
// A composed hull Preload cannot build is an import fault: Loading faults with ImportFault, naming every such hull's package.
// Mod ships in the running game. Compose (Bind) is the one verdict on whether a mod hull exists, from the package's files;
// Preload only builds a prototype for each, keyed by the hull's record key, into an inactive assembled copy that Instantiate
// clones synchronously, so LoadEntity never loads async. ImportFault reports what the Unity importer made of a composed hull:
// a composed hull Preload cannot build is an import fault: Loading faults with ImportFault, naming every such hull's package.
// The prototypes are cache-only: rebuilt every boot from the catalog, the mod GLBs and the template.
public static class ShipModShips
{
@ -101,6 +102,7 @@ public static class ShipModShips
node.name = id;
return node;
}
// An importer report, not a verdict: Bind has already judged the file.
MeshRenderer Renderer(string id)
{
var found = Node(id).GetComponentInChildren<MeshRenderer>(true);
@ -130,9 +132,6 @@ public static class ShipModShips
var surface = AddOrGet<HullCollider>(hullNode.gameObject);
var shieldMarker = Node(plan.Shield);
var scale = shieldMarker.localScale;
if (!(scale.x > 0 && scale.y > 0 && scale.z > 0))
throw new InvalidOperationException($"{ship.Id}: the shield anchor scale must have three positive radii.");
var shield = Object.Instantiate(template.Shield.GetComponent<ShieldManager>(), shieldMarker, false);
Reset(shield.transform);
AddOrGet<ShieldEnvelope>(shield.gameObject);

View file

@ -251,14 +251,15 @@ public static class ShipModCatalog
foreach (var anchor in ship.Anchors)
if (!modelNodes.ContainsKey(anchor.ModelNodeId))
throw new InvalidOperationException($"{ship.Id}: model has no node with aetheria.id={anchor.ModelNodeId} for anchor {anchor.Id}.");
// Assemble reads a renderer or collider mesh from these anchors' nodes and refuses without one, and reads the shield
// node's scale as three positive radii (ruling thrusters-radiators-are-meshes). These refusals stand in for Assemble's
// throws, so a package Compose includes is one the importer's assembler can build; the exhaust emission surface and
// the glowing radiator are meshes by that same ruling. A weapon mount and a tractor may be empties.
// Assemble reads a renderer or collider mesh from these anchors' nodes, and the shield node's scale as three positive
// radii (ruling thrusters-radiators-are-meshes). These refusals cover everything the package's files say about whether
// the importer can build a node (skin, dangling or empty mesh, not only "names a mesh") and are Assemble's only judge,
// so a package Compose includes is one the importer's assembler can build; the exhaust emission surface and the
// glowing radiator are meshes by that same ruling. A weapon mount and a tractor may be empties.
foreach (var anchor in ship.Anchors)
if ((anchor.Role == "thruster-emitter" || anchor.Role == "radiator-mesh" || anchor.Role == "map-icon" || anchor.Role == "hull-collider") &&
!modelNodes[anchor.ModelNodeId].HasMesh)
throw new InvalidOperationException($"{ship.Id}: {anchor.Role} anchor {anchor.Id} needs a mesh, but model node {anchor.ModelNodeId} has none.");
throw new InvalidOperationException($"{ship.Id}: {anchor.Role} anchor {anchor.Id} needs a mesh, but model node {anchor.ModelNodeId} has none the importer can build.");
foreach (var anchor in ship.Anchors)
if (anchor.Role == "shield" && !modelNodes[anchor.ModelNodeId].PositiveScale)
throw new InvalidOperationException($"{ship.Id}: shield anchor {anchor.Id} needs three positive scale radii on model node {anchor.ModelNodeId}, with no matrix.");
@ -309,7 +310,23 @@ public static class ShipModCatalog
private static bool PositiveScale(JObject node) =>
node["matrix"] == null && (node["scale"] == null || node["scale"].Select(component => (double)component).All(component => component > 0));
// GLB is the xenos asset boundary. Only its node extras, whether each node names a mesh, and its nearest identified ancestor's node index
// A mesh the importer builds as a plain mesh node: no skin (glTFast makes a skinned node a SkinnedMeshRenderer, which
// Assemble's MeshRenderer/MeshFilter reads cannot see), a mesh index inside meshes, at least one primitive, and every
// primitive with POSITION and a mode absent or 4 (triangles). Geometry accessors and buffers are not read.
private static bool BuildsMesh(JObject json, JObject node)
{
if (node["skin"] != null && node["skin"].Type != JTokenType.Null) return false;
var meshes = json["meshes"] as JArray;
if (node["mesh"] == null || node["mesh"].Type != JTokenType.Integer || meshes == null) return false;
var index = (long)node["mesh"];
if (index < 0 || index >= meshes.Count) return false;
var primitives = (meshes[(int)index] as JObject)?["primitives"] as JArray;
return primitives != null && primitives.Count > 0 && primitives.All(primitive =>
primitive is JObject p && p["attributes"]?["POSITION"] != null &&
(p["mode"] == null || (p["mode"].Type == JTokenType.Integer && (int)p["mode"] == 4)));
}
// GLB is the xenos asset boundary. Only its node extras, whether each node carries a mesh the importer builds as a plain mesh node, and its nearest identified ancestor's node index
// (-1 for none) are read here, plus whether the node's scale is three positive radii with no matrix; geometry belongs to the runtime importer.
public static Dictionary<string, (uint Index, bool HasMesh, int Parent, bool PositiveScale)> ReadNodeIds(string path)
{
@ -333,7 +350,7 @@ public static class ShipModCatalog
{
var id = (string)node["extras"]?["aetheria.id"];
if (string.IsNullOrEmpty(id)) { index++; continue; }
if (!ids.TryAdd(id, (index, node["mesh"] != null && node["mesh"].Type != JTokenType.Null, IdentifiedAncestor(parents, nodes, (int)index), PositiveScale(node))))
if (!ids.TryAdd(id, (index, BuildsMesh(json, node), IdentifiedAncestor(parents, nodes, (int)index), PositiveScale(node))))
throw new InvalidOperationException($"{path}: duplicate GLB node aetheria.id={id}.");
index++;
}