From 142e98a646e3ad00c6f352a8bcfed9bbf3150244 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 03:37:27 +0100 Subject: [PATCH] Use typed hull shapes in entity instances --- .voidbot/state/aetheria.cc | Bin 60616 -> 60858 bytes Assets/Scripts/Gameplay/EntityInstance.cs | 56 +++++++++++++++++----- docs/aetheria-perfect-machine-map.md | 7 +++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 81194be958002a90521140a2161f633b8f2d09e4..8e0a2eb0cc0f92812d20dab5084da077373d21c6 100644 GIT binary patch delta 1093 zcmZuw&ubGw6gG)f1Ja_{N?Ry{2vuy;)@qX0YyHuKR;^G72%T_!5ijtD>iH#2;ZR!CrFX|UP!MGxx4-&YdiV03!D(}e5Q_G>u{gmk0TQf5c zDn2Zp$ElI9+cy=O~eAnkpw9T z;s}d6WIiHWp-upDgqYw!M(u=zXe3KG4wHs=k-D@DG5sjA3e*#Pbg4#tA8>9^frquF z0$L=ZM6kZYc$v&9aIaF1$$sWCD5KUXR0EaF81+tPRuyp5V*BwzRB{YTC9o7(0-IJC zDvA1)=#q@Ox|D}RGBH!|Rlz zCLM+_x{i?MZaes6390`T delta 902 zcmZ8gy=xRf6!-4r^e_Yheg=z&O$v|mg2|aPqzFXuK!{jg<=pPu+rinHWoGu`VR2xs zh-_(Np`;BgHmOt)VrLbM#zIpD6#oO?e&jq;&CHwk-uyn^Y=5il>{Yfl%cq(*=i80e zV*ICaA^uo?TFcL^X7@$uT&yaOi-Z;>ER^@3C37dQCZpA^l6W7biyAecwA>CM)M#kS zELRew+JMNQ0Xq!Q1wRrZP4HL`wAwI@H;!OD_*$B|GjS6#>lGSNU^<_1;CV+;Xx$w)+7LG$%LWDIEhH8#>GSg0wzg%!5lPo=tUNcgR+BT zC>fGm`D@1*u*mvKr`Gw*K%fSxkgCvvSTdpd@zmk$= cells) + { + var shape = new Shape(width, height); + foreach (var cell in cells) + { + if (cell.X >= 0 && cell.Y >= 0 && cell.X < width && cell.Y < height) + shape[int2(cell.X, cell.Y)] = true; + } + + return shape; + } + public CompassIcon CompassIcon { get; set; } public Dictionary Barrels { get; private set; } public Dictionary BarrelIndices { get; private set; } @@ -162,7 +183,15 @@ public class EntityInstance : MonoBehaviour LocalSpace.SetParent(transform.parent); Entity = entity; ZoneRenderer = zoneRenderer; - var hullData = entity.ItemManager.GetData(entity.Hull) as HullData; + var typedHull = FindTypedHull(entity.Hull); + if (typedHull == null || typedHull.ShapeWidth <= 0 || typedHull.ShapeHeight <= 0 || typedHull.ShapeCells.Count == 0) + { + Debug.LogError($"Cannot bind entity instance for {entity.Name}: missing typed hull shape."); + return; + } + + var hullShape = ToShape(typedHull.ShapeWidth, typedHull.ShapeHeight, typedHull.ShapeCells); + var typedHardpoints = typedHull.Hardpoints.ToArray(); if(Shield) Shield.Entity = entity; @@ -260,7 +289,7 @@ public class EntityInstance : MonoBehaviour } } } - foreach (var hp in hullData.Hardpoints) + foreach (var hp in Entity.Hardpoints.Cast().Where(hp => hp != null).Distinct()) { if(hp.Type == HardpointType.Ballistic || hp.Type == HardpointType.Energy || hp.Type == HardpointType.Launcher) { @@ -276,7 +305,7 @@ public class EntityInstance : MonoBehaviour void DamageSchematic(float damage, Shape hitShape) { foreach (var v in hitShape.Coordinates) - hitShape[v] = hitShape[v] && hullData.Shape[v]; + hitShape[v] = hitShape[v] && hullShape[v]; float hullDamage = 0; var damagePerCell = damage / hitShape.Coordinates.Length; @@ -316,12 +345,12 @@ public class EntityInstance : MonoBehaviour { collider.Splash.Subscribe(splash => { - var hitShape = new Shape(hullData.Shape.Width, hullData.Shape.Height); - foreach (var v in hullData.Shape.Coordinates) + var hitShape = new Shape(hullShape.Width, hullShape.Height); + foreach (var v in hullShape.Coordinates) { var localHitDirection = transform.InverseTransformDirection(splash.Direction); var direction = normalize(float2(localHitDirection.x, localHitDirection.z)); - var cellDot = dot(normalize(v - hullData.Shape.CenterOfMass), direction); + var cellDot = dot(normalize(v - hullShape.CenterOfMass), direction); if (cellDot < 0) hitShape[v] = true; } DamageSchematic(splash.Damage, hitShape); @@ -332,18 +361,18 @@ public class EntityInstance : MonoBehaviour Entity.IncomingHit.OnNext(hit.Source); var hardpointIndex = (int) hit.TexCoord.x - 1; - var hitShape = new Shape(hullData.Shape.Width, hullData.Shape.Height); + var hitShape = new Shape(hullShape.Width, hullShape.Height); // U coordinate between 0-1 indicates a hit that didn't land directly on a hardpoint // Find the 2D position of the hit scaled to the schematic float2 hitPos = float2.zero; - if (hardpointIndex < 0 || hardpointIndex >= hullData.Hardpoints.Count) + if (hardpointIndex < 0 || hardpointIndex >= typedHardpoints.Length) { - hitPos = float2(hit.TexCoord.x * hullData.Shape.Width, hit.TexCoord.y * hullData.Shape.Height); + hitPos = float2(hit.TexCoord.x * hullShape.Width, hit.TexCoord.y * hullShape.Height); // Search all schematic border cells for the cell which is closest to the hit position var hitCell = int2(-1); var distance = float.MaxValue; - foreach (var v in hullData.Shape.Coordinates) + foreach (var v in hullShape.Coordinates) { var cellDist = lengthsq(hitPos - v); if (cellDist < distance) @@ -359,10 +388,11 @@ public class EntityInstance : MonoBehaviour else { // Collider UV coordinates starting with 1 correspond to hardpoint index - var hardpoint = hullData.Hardpoints[hardpointIndex]; + var hardpoint = typedHardpoints[hardpointIndex]; // Obtain the hull coordinates of all cells occupied by the hardpoint - var hardpointCells = hullData.Shape.Inset(hardpoint.Shape, hardpoint.Position); + var hardpointShape = ToShape(hardpoint.ShapeWidth, hardpoint.ShapeHeight, hardpoint.ShapeCells); + var hardpointCells = hullShape.Inset(hardpointShape, int2(hardpoint.PositionX, hardpoint.PositionY)); hitPos = hardpointCells.CenterOfMass; foreach (var v in hardpointCells.Coordinates) hitShape[v] = true; @@ -382,7 +412,7 @@ public class EntityInstance : MonoBehaviour // March a ray through the ship from the hit position var penetrationPoint = hitPos; var penetrationDistance = 0f; - while (penetrationDistance < hit.Penetration && hullData.Shape[int2(penetrationPoint)]) + while (penetrationDistance < hit.Penetration && hullShape[int2(penetrationPoint)]) { penetrationDistance += .5f; hitShape[int2(penetrationPoint)] = true; diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index f530a4ce4..30eea3129 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -166,6 +166,10 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. Zone entity scene instantiation also reads typed hull prefab paths and hull classifications from the runtime catalog; missing typed hull prefab rows fail loudly instead of asking legacy `HullData` to choose the scene prefab. + Entity scene instances use typed hull shape cells and typed hardpoint rows for + collision damage masks and weapon-barrel presentation setup; behavior effect + prefabs still come from behavior DTOs until behavior construction/execution + moves to typed payloads. The item properties panel also reads typed catalog title names, descriptions, manufacturer, base mass, max durability, thermal bounds, and thermal performance curve keys for basic item presentation without hydrating legacy @@ -647,6 +651,9 @@ First Aetheria surfaces to publish: - Done: import typed hull prefab paths and move `ZoneRenderer` entity scene instantiation onto typed hull rows; legacy `HullData` no longer chooses zone entity prefabs or station compass classification. + - Done: move `EntityInstance` hull shape and hardpoint presentation/damage + masks onto typed catalog rows; legacy `HullData` no longer supplies hull + shape or hardpoint lists to scene entity instances. - Done: delete the console `give` command instead of preserving a debug operator path that hydrated typed item rows back into legacy item DTOs. - Done: delete `ItemManager.GetCatalogEntries` after all live callers