diff --git a/Assets/Resources/Aetheria.inputactions b/Assets/Resources/Aetheria.inputactions index c5e3153a6..86044799b 100644 --- a/Assets/Resources/Aetheria.inputactions +++ b/Assets/Resources/Aetheria.inputactions @@ -68,6 +68,15 @@ "interactions": "", "initialStateCheck": false }, + { + "name": "Cycle Target Item", + "type": "Button", + "id": "3f9a2f0a-6e3f-4a53-9f5e-1a9c1e6d9f7b", + "expectedControlType": "Button", + "processors": "", + "interactions": "", + "initialStateCheck": false + }, { "name": "Toggle Heatsinks", "type": "Button", @@ -307,6 +316,17 @@ "isComposite": false, "isPartOfComposite": false }, + { + "name": "", + "id": "8c2d5e77-4b18-4f0b-9a2e-6d3f7c1a5e90", + "path": "/j", + "interactions": "", + "processors": "", + "groups": "Keyboard&Mouse", + "action": "Cycle Target Item", + "isComposite": false, + "isPartOfComposite": false + }, { "name": "", "id": "71ac6088-1e18-4810-86be-1179918dd4a2", diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 491fb93c5..903bf2054 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -400,7 +400,27 @@ public class ActionGameManager : MonoBehaviour var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value); CurrentEntity.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length]; }; - + + // Cut 2 (docs/fire-control-cut.md): cycles the aim point among the current target's revealed + // subsystems -- decides nothing itself, only calls the one writer (TrySelectTargetItem), same + // predicate (FireControl.IsRevealed) the AI path uses. No generated typed accessor exists for this + // action yet (it was hand-authored into Aetheria.inputactions rather than regenerated through the + // Unity Input Actions editor, unavailable here), so it is looked up by name instead of through + // Input.Player. + Input.asset.FindAction("Player/Cycle Target Item").performed += context => + { + var target = CurrentEntity.Target.Value; + if (target == null) return; + var revealed = target.Equipment.Where(x => FireControl.IsRevealed(CurrentEntity, x)).ToArray(); + if (revealed.Length == 0) + { + CurrentEntity.TrySelectTargetItem(null); + return; + } + var currentItemIndex = Array.IndexOf(revealed, CurrentEntity.ResolvedTargetItem); + CurrentEntity.TrySelectTargetItem(revealed[(currentItemIndex + 1) % revealed.Length]); + }; + #endregion diff --git a/Assets/Scripts/UI/HUD/SchematicDisplay.cs b/Assets/Scripts/UI/HUD/SchematicDisplay.cs index 65c3b1f7f..e2eb764f7 100644 --- a/Assets/Scripts/UI/HUD/SchematicDisplay.cs +++ b/Assets/Scripts/UI/HUD/SchematicDisplay.cs @@ -106,8 +106,11 @@ public class SchematicDisplay : MonoBehaviour CargoTemperatureLabel.text = "N/A"; } + // Cut 2 (docs/fire-control-cut.md): an enemy schematic shows only what `player` has actually + // resolved (FireControl.IsRevealed) -- the same predicate the selection writer and the AI use. The + // player's own schematic is unfiltered; there is nothing to reveal about your own ship. _schematicItems = entity.Equipment - .Where(x => x.Behaviors.Any(b => b.Data is WeaponData)) + .Where(x => x.Behaviors.Any(b => b.Data is WeaponData) && (!_enemy || FireControl.IsRevealed(player, x))) .Select(x => new SchematicDisplayItem { Item = x, @@ -201,6 +204,13 @@ public class SchematicDisplay : MonoBehaviour // DistanceLabel.text = $"{(int)length(_entity.Position - _player.Position)}"; // } + // Cut 2 (docs/fire-control-cut.md): marks whichever row is the player's current aim point. + // Re-checked every frame (not just on ShowShip) because ResolvedTargetItem can drop on its own + // as info decays, with no event to hook. + if (_enemy && _schematicItems != null) + foreach (var x in _schematicItems) + x.ListElement.SetSelected(x.Item == _player.ResolvedTargetItem); + if(VisibilityLabel) VisibilityLabel.text = ((int)_entity.Visibility).ToString(); diff --git a/Assets/Scripts/UI/HUD/SchematicListElement.cs b/Assets/Scripts/UI/HUD/SchematicListElement.cs index 8b6829379..5603e927e 100644 --- a/Assets/Scripts/UI/HUD/SchematicListElement.cs +++ b/Assets/Scripts/UI/HUD/SchematicListElement.cs @@ -15,8 +15,18 @@ public class SchematicListElement : MonoBehaviour public RectTransform CooldownFill; public RectTransform HeatFill; + // Cut 2 (docs/fire-control-cut.md): marks this row as the current aim point (Entity.ResolvedTargetItem) + // on an enemy schematic. Unassigned in a prefab that has not been wired up in the Unity editor yet + // (unavailable in this pass) -- SetSelected below is a no-op until then, not a null reference. + public GameObject SelectedIndicator; + private List _iconInstances = new List(); + public void SetSelected(bool selected) + { + if (SelectedIndicator != null) SelectedIndicator.SetActive(selected); + } + public void ShowWeapon(WeaponItemData weapon) { foreach(var prototype in _iconInstances) prototype.ReturnToPool();