From 5977924bf1fe3707b84612d213d876742a5971cc Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 14 Jun 2026 03:43:37 +0100 Subject: [PATCH] Use typed hull geometry in inventory panel --- .voidbot/state/aetheria.cc | Bin 60858 -> 61123 bytes Assets/Scripts/UI/Menu/InventoryPanel.cs | 88 +++++++++++++++-------- docs/aetheria-perfect-machine-map.md | 8 +++ 3 files changed, 66 insertions(+), 30 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 8e0a2eb0cc0f92812d20dab5084da077373d21c6..a2436357d044d3647bc7f2bfc27b2374f7be51fb 100644 GIT binary patch delta 1212 zcmah}OKTKC5O$LgjHuuf6a$5qfNo;ULnWdp#7Dr8U~&pM*gI1@)263;(%rLhb6LcT z;6ZeMf-mqCSUs4F1QFuRg9Kj@G)D!0fETN0b{3P1ry0KP`s%B%s(SfL` zh6YFaPxcKAoSu15I8cAvb}vT;2U0|}FSd~36xrU<-S+Knqo?C|qjr8wR!~}{tCLKk z0Q%>)+8b!@Lx3tmtE(W@0we|v*lLVEgozLkF*9fSo_K=s=yPGu78;F4iOS{(6S5dj zaA{FZPhQA|~MNJ2GA7voS%FluHKji4&11*=t49ocD!I$~sjA0Sv21OiQw!pl@l2qxCt zA~63Z^H6%#B8l{yDj`keDM2!P^tj0OVV82Q2C{V3tOLmwZHc3a*|pXGvkKAgenm}SgHyw zU5pr)PVBU1K8~YIiZH1a8E!e6Y`RJqvWjayxhl|eNs4eW{a#@ajx)&u)ZmeQNyJKm z{HDW7T6wXS);xupI!E2tGz6Kk|JpM;JwXKtVW?T=Ecl9s*NHPU;s~3kw8y|z8s$;v zMQhf}6kKB7T;FqQNT~F6ESs;}y6-&Fjfv$Oy9;CWrPZTHHWOtVkyF%vt{yHNY;?Z+ zv$KBf#ZbNQVc+cRmVm6n|L;dS*{#-OYnit=&-ZZc+}`FR(0^v;v1I`XhQ`F&g|=fa zt%|uf!t*8Xjop?vGSuyHZ_d)V|8ZAWSBt0qzWq@CYz$>j%lh}%IWpYed|Eo|D?d~V Y9Zb=QjoU3GeQ+ATH&(iG=v4pAUrC+6xc~qF delta 1002 zcmZvbId2nD5XZ5dpacPtqC^M@&=V8^5jF`9wjm9X!r_8L1PSEsd3Wr6;_Z8@ci1tF zMZpI^+t70s6d*S!9YRPPO&UM}(m)D60*Hp$!-{oM}ugehCpJADle2w7!oSbAPhB33KCF#OFNHTPFe6JH}-E$ zXBkZDAwsqZ=1JZHO^gp|b>k~(n||UjoiKVcJl>rqt`sd$2ID#*c!N5qKyyoo3!H0$ zk|g2MrJO7$Vq273(9#lBa#n4I0<9rd zczAQotX}_Cr~Y#qAvJ!_uByGc^U=?@hv!oT{ft3{vMoSqpM}mdXfY3v(lu!4Z#yP? zi|_vIj^-*8Q8zyv{r+@hJbSU(V(p=!O^i9zb3UKV_wKLn8SVeyY%y9Z?9Z%9c^<#< rWA=BIayk3NozeRrvhS_TCf=KycSh0%l}fa@xv%$Y^VR59OsV!4@LzEd diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index d00b32d20..f55cbe48f 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -63,6 +63,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler private Entity _displayedEntity; private EquippedCargoBay _displayedCargo; + private Shape _displayedHullShape; + private Shape _displayedHullInterior; private Texture2D _temperatureTexture; private RectTransform _firstRect; @@ -211,12 +213,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler MinTempLabel.text = ActionGameManager.RuntimePlayerSettings.FormatTemperature(_displayedEntity.MinTemp); MaxTempLabel.text = ActionGameManager.RuntimePlayerSettings.FormatTemperature(_displayedEntity.MaxTemp); } - var hullData = GameManager.ItemManager.GetData(_displayedEntity.Hull) as HullData; for(var x = 0; x < _temperatureTexture.width; x++) { for (var y = 0; y < _temperatureTexture.height; y++) { - if (hullData.Shape[int2(x-1, y-1)]) + if (_displayedHullShape[int2(x-1, y-1)]) { var temp = (_displayedEntity.Temperature[x - 1, y - 1] - _displayedEntity.MinTemp) / (_displayedEntity.MaxTemp-_displayedEntity.MinTemp); var color = TemperatureColor.GetPixelBilinear(TemperatureColorCurve.Evaluate(temp), 0); @@ -242,6 +243,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { _displayedCargo = null; _displayedEntity = null; + _displayedHullShape = null; + _displayedHullInterior = null; foreach(var empty in EmptyCells) Destroy(empty); @@ -291,27 +294,31 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler EditName.gameObject.SetActive(true); } - var hullData = GameManager.ItemManager.GetData(entity.Hull) as HullData; + if (!TryResolveTypedHullGeometry(entity.Hull, out _displayedHullShape, out _displayedHullInterior)) + { + Debug.LogError($"Cannot display inventory for {entity.Name}: missing typed hull geometry."); + return; + } if (FitToContent) { var gridRect = Grid.GetComponent(); var rect = gridRect.rect; - Grid.cellSize = Vector2.one * (int) min(rect.width / (hullData.Shape.Width + 1), rect.height / (hullData.Shape.Height + 1)); + Grid.cellSize = Vector2.one * (int) min(rect.width / (_displayedHullShape.Width + 1), rect.height / (_displayedHullShape.Height + 1)); } if(TemperatureDisplay) { _temperatureTexture = new Texture2D( - hullData.Shape.Width + 2, - hullData.Shape.Height + 2, + _displayedHullShape.Width + 2, + _displayedHullShape.Height + 2, TextureFormat.RGBA32, false, false); TemperatureDisplay.gameObject.SetActive(true); TemperatureDisplay.texture = _temperatureTexture; var tempRect = TemperatureDisplay.rectTransform; - tempRect.sizeDelta = Grid.cellSize * new Vector2(hullData.Shape.Width + 2, hullData.Shape.Height + 2); + tempRect.sizeDelta = Grid.cellSize * new Vector2(_displayedHullShape.Width + 2, _displayedHullShape.Height + 2); } if (Current) @@ -325,10 +332,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler Thermal.targetGraphic.color = thermal ? ToggleEnabledColor : ToggleDisabledColor; } - Grid.constraintCount = hullData.Shape.Width; - foreach (var v in hullData.Shape.AllCoordinates) + Grid.constraintCount = _displayedHullShape.Width; + foreach (var v in _displayedHullShape.AllCoordinates) { - if (!hullData.Shape[v]) + if (!_displayedHullShape[v]) { var empty = new GameObject("Empty Node", typeof(RectTransform)); empty.transform.SetParent(Grid.transform); @@ -363,7 +370,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler var item = entity.GearOccupancy[v.x, v.y]; if (item != null) { - var originalOccupancy = hullData.Shape.Inset(GetItemShape(item.EquippableItem), item.Position, item.EquippableItem.Rotation); + var originalOccupancy = _displayedHullShape.Inset(GetItemShape(item.EquippableItem), item.Position, item.EquippableItem.Rotation); _dragCells = originalOccupancy.Coordinates .Select(v1 => Instantiate(CellInstances[v1], DragParent, true).transform).ToArray(); foreach(var dragCell in _dragCells) @@ -417,7 +424,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { //foreach (var cell in _dragCells) cell.gameObject.SetActive(false); FakeItem = item; - FakeOccupancy = hullData.Shape.Inset(GetItemShape(item), placementPosition, item.Rotation); + FakeOccupancy = _displayedHullShape.Inset(GetItemShape(item), placementPosition, item.Rotation); RefreshCells(); GameManager.RegisterDragTarget(drag => { @@ -467,22 +474,22 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler var rect = cell.GetComponent(); var point = Rect.PointToNormalized(rect.rect, rect.InverseTransformPoint(data.position)); // Debug.Log($"Clicked at pos {data.position}, normalized {point}"); - if (hullData.Shape[int2(v.x - 1, v.y)] && point.x < ThermalToggleRegionSize) + if (_displayedHullShape[int2(v.x - 1, v.y)] && point.x < ThermalToggleRegionSize) { entity.HullConductivity[v.x - 1, v.y].x = !entity.HullConductivity[v.x - 1, v.y].x; RefreshCells(new []{v,int2(v.x - 1, v.y)}); } - if (hullData.Shape[int2(v.x + 1, v.y)] && point.x > 1 - ThermalToggleRegionSize) + if (_displayedHullShape[int2(v.x + 1, v.y)] && point.x > 1 - ThermalToggleRegionSize) { entity.HullConductivity[v.x, v.y].x = !entity.HullConductivity[v.x, v.y].x; RefreshCells(new []{v,int2(v.x + 1, v.y)}); } - if (hullData.Shape[int2(v.x, v.y - 1)] && point.y < ThermalToggleRegionSize) + if (_displayedHullShape[int2(v.x, v.y - 1)] && point.y < ThermalToggleRegionSize) { entity.HullConductivity[v.x, v.y - 1].y = !entity.HullConductivity[v.x, v.y - 1].y; RefreshCells(new []{v,int2(v.x, v.y - 1)}); } - if (hullData.Shape[int2(v.x, v.y + 1)] && point.y > 1 - ThermalToggleRegionSize) + if (_displayedHullShape[int2(v.x, v.y + 1)] && point.y > 1 - ThermalToggleRegionSize) { entity.HullConductivity[v.x, v.y].y = !entity.HullConductivity[v.x, v.y].y; RefreshCells(new []{v,int2(v.x, v.y + 1)}); @@ -694,10 +701,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { if(!CellInstances.ContainsKey(v)) continue; - var hullData = GameManager.ItemManager.GetData(_displayedEntity.Hull) as HullData; - var spriteIndex = 0; - var interior = hullData.InteriorCells[v]; + var interior = _displayedHullInterior[v]; var item = FakeOccupancy?[v]??false ? FakeItem : IgnoreOccupancy?[v]??false ? null : _displayedEntity.GearOccupancy[v.x, v.y]?.EquippableItem; var hardpoint = _displayedEntity.Hardpoints[v.x, v.y]; @@ -705,7 +710,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { var v2 = v + offset * (Flip ? -1 : 1); return !( - hullData.Shape[v2] && + _displayedHullShape[v2] && _displayedEntity.Hardpoints[v2.x, v2.y] == hardpoint && (FakeOccupancy?[v2]??false ? FakeItem : IgnoreOccupancy?[v2]??false ? null : _displayedEntity.GearOccupancy[v2.x, v2.y]?.EquippableItem) == item ); @@ -715,8 +720,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { var v2 = v + offset * (Flip ? -1 : 1); return !( - hullData.Shape[v2] && ( - !interior && !hullData.InteriorCells[v2] && _displayedEntity.Hardpoints[v2.x, v2.y] == null || + _displayedHullShape[v2] && ( + !interior && !_displayedHullInterior[v2] && _displayedEntity.Hardpoints[v2.x, v2.y] == null || interior && item != null && (FakeOccupancy?[v2]??false ? FakeItem : IgnoreOccupancy?[v2]??false ? null : _displayedEntity.GearOccupancy[v2.x, v2.y]?.EquippableItem) == item ) @@ -745,7 +750,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { bool ThermalMatch(int2 offset) { - if (!hullData.Shape[v + offset]) return false; + if (!_displayedHullShape[v + offset]) return false; var i = (offset.x, offset.y); return i switch { @@ -803,8 +808,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { if (_displayedEntity != null) { - var hullData = GameManager.ItemManager.GetData(_displayedEntity.Hull) as HullData; - var interior = hullData.InteriorCells[position]; + var interior = _displayedHullInterior[position]; var hardpoint = _displayedEntity.Hardpoints[position.x, position.y]; var item = (FakeOccupancy?[position] ?? false ? FakeItem : IgnoreOccupancy?[position] ?? false ? null : _displayedEntity.GearOccupancy[position.x, position.y]?.EquippableItem) as EquippableItem; @@ -881,16 +885,40 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler { var typedItem = FindTypedInventoryItem(item); if (typedItem != null && typedItem.ShapeCells.Count > 0) - return ToShape(typedItem); + return ToShape(typedItem.ShapeWidth, typedItem.ShapeHeight, typedItem.ShapeCells); return new Shape(1, 1); } - private static Shape ToShape(AetheriaRuntimeCatalogItem item) + private static bool TryResolveTypedHullGeometry(ItemInstance hull, out Shape hullShape, out Shape interiorShape) { - var shape = new Shape(Math.Max(item.ShapeWidth, 1), Math.Max(item.ShapeHeight, 1)); - foreach (var cell in item.ShapeCells) - shape[new int2(cell.X, cell.Y)] = true; + hullShape = null; + interiorShape = null; + var typedHull = FindTypedInventoryItem(hull); + if (typedHull == null || + typedHull.ShapeCells.Count == 0 || + typedHull.InteriorShapeCells.Count == 0 || + typedHull.ShapeWidth <= 0 || + typedHull.ShapeHeight <= 0 || + typedHull.InteriorShapeWidth <= 0 || + typedHull.InteriorShapeHeight <= 0) + { + return false; + } + + hullShape = ToShape(typedHull.ShapeWidth, typedHull.ShapeHeight, typedHull.ShapeCells); + interiorShape = ToShape(typedHull.InteriorShapeWidth, typedHull.InteriorShapeHeight, typedHull.InteriorShapeCells); + return true; + } + + private static Shape ToShape(int width, int height, IReadOnlyList cells) + { + var shape = new Shape(Math.Max(width, 1), Math.Max(height, 1)); + foreach (var cell in cells) + { + if (cell.X >= 0 && cell.Y >= 0 && cell.X < shape.Width && cell.Y < shape.Height) + shape[int2(cell.X, cell.Y)] = true; + } return shape; } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 30eea3129..d9ab1a4ef 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -170,6 +170,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. collision damage masks and weapon-barrel presentation setup; behavior effect prefabs still come from behavior DTOs until behavior construction/execution moves to typed payloads. + Inventory panel equipment-grid geometry, hull/interior cell drawing, + temperature overlay masking, thermal edge toggles, and entity cell tinting now + use typed hull shape/interior masks from the runtime catalog. Final equip, + cargo fit, and mutation acceptance still belong to the existing entity/cargo + simulation owners until those are rebuilt. 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 @@ -654,6 +659,9 @@ First Aetheria surfaces to publish: - 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: move `InventoryPanel` entity-grid hull shape/interior rendering and + thermal overlay masking onto typed catalog rows; legacy `HullData` no + longer supplies equipment-grid display geometry. - 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