diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index dc9b0e614..167ac6e6a 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index 5388e6aa9..6be495120 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -6,6 +6,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using GameCult.Aetheria.State.Unity; using UnityEngine; using UniRx; using UniRx.Triggers; @@ -27,7 +28,7 @@ public class InventoryMenu : MonoBehaviour private int2 _selectedPosition; private InventoryPanel _selectedPanel; private ItemInstance _selectedItem; - private ItemData _selectedItemData; + private int2[] _selectedCells; // private List _backgroundSubscriptions; // private ItemInstance _dragItem; @@ -100,29 +101,15 @@ public class InventoryMenu : MonoBehaviour } else { - if (_selectedPanel != null) - { - if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition)) - { - foreach (var v in _selectedItemData.Shape.Coordinates) - { - var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition; - _selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2); - } - } - } + ClearSelectedCellHighlight(); _selectedPanel = panel; _selectedPosition = cargoEvent.Position; PropertiesPanel.Inspect(item); _selectedPanel = panel; _selectedPosition = cargoEvent.CargoBay.Cargo[item]; _selectedItem = item; - _selectedItemData = GameManager.ItemManager.GetData(item); - foreach (var v in _selectedItemData.Shape.Coordinates) - { - var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition; - _selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true); - } + _selectedCells = GetSelectedCells(item, _selectedPosition); + ApplySelectedCellHighlight(); // TODO: SFX: Success } } @@ -155,28 +142,14 @@ public class InventoryMenu : MonoBehaviour } else { - if (_selectedPanel != null) - { - if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition)) - { - foreach (var v in _selectedItemData.Shape.Coordinates) - { - var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition; - _selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2); - } - } - } + ClearSelectedCellHighlight(); PropertiesPanel.Inspect(item); _selectedPanel = panel; _selectedPosition = item.Position; _selectedItem = item.EquippableItem; - _selectedItemData = GameManager.ItemManager.GetData(item.EquippableItem); - foreach (var v in _selectedItemData.Shape.Coordinates) - { - var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition; - _selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true); - } + _selectedCells = GetSelectedCells(item.EquippableItem, _selectedPosition); + ApplySelectedCellHighlight(); // TODO: SFX: Success } } @@ -208,4 +181,64 @@ public class InventoryMenu : MonoBehaviour // _dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 3) % 4); // } } + + private void ClearSelectedCellHighlight() + { + if (_selectedPanel == null || _selectedCells == null) return; + + foreach (var v in _selectedCells) + { + if (_selectedPanel.CellInstances.ContainsKey(v)) + _selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v); + } + } + + private void ApplySelectedCellHighlight() + { + if (_selectedPanel == null || _selectedCells == null) return; + + foreach (var v in _selectedCells) + { + if (_selectedPanel.CellInstances.ContainsKey(v)) + _selectedPanel.CellInstances[v].Icon.color = _selectedPanel.GetColor(v, true); + } + } + + private int2[] GetSelectedCells(ItemInstance item, int2 position) + { + var typedItem = FindTypedInventoryItem(item); + if (typedItem != null && typedItem.ShapeCells.Count > 0) + { + return typedItem.ShapeCells + .Select(cell => RotateTypedShapeCell(cell, typedItem, item.Rotation) + position) + .ToArray(); + } + + var shape = GameManager.ItemManager.GetData(item).Shape; + return shape.Coordinates + .Select(cell => shape.Rotate(cell, item.Rotation) + position) + .ToArray(); + } + + private static AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item) + { + var itemId = item?.Data?.ItemId ?? Guid.Empty; + return itemId == Guid.Empty + ? null + : ActionGameManager.RuntimeCatalog?.FindItemByLegacyId(itemId.ToString("D")); + } + + private static int2 RotateTypedShapeCell( + AetheriaRuntimeShapeCell cell, + AetheriaRuntimeCatalogItem item, + ItemRotation rotation) + { + return rotation switch + { + ItemRotation.Clockwise => new int2(cell.Y, item.ShapeWidth - 1 - cell.X), + ItemRotation.Reversed => new int2(item.ShapeWidth - 1 - cell.X, item.ShapeHeight - 1 - cell.Y), + ItemRotation.CounterClockwise => new int2(item.ShapeHeight - 1 - cell.Y, cell.X), + _ => new int2(cell.X, cell.Y) + }; + } } diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index ae87a8d38..be3f4bfbb 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -148,7 +148,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. The item properties panel also reads typed catalog description, manufacturer, and base mass for item presentation before hydrating legacy DTOs for behavior reflection, thermal curves, and durability math that have not yet moved to - typed behavior surfaces. + typed behavior surfaces. Inventory selection highlighting now uses typed item + shape cells for UI tint geometry before falling back to legacy `ItemData.Shape`. - `Galaxy` generation no longer accepts a runtime item catalog reader or `ItemManager`. Sector and tutorial generation receive the package-owned typed runtime catalog. `Galaxy` projects typed corporation v2 records into temporary legacy