Wire subsystem selection and reveal into player input and the HUD
A new "Cycle Target Item" action (hand-authored into Aetheria.inputactions; no Unity editor here to regenerate AetheriaInput.cs, so ActionGameManager looks it up by name through Input.asset.FindAction instead of a typed accessor) cycles the local player's aim point among the current target's revealed items via TrySelectTargetItem. SchematicDisplay's enemy view now filters to what FireControl.IsRevealed actually resolves for the viewer, and marks whichever row is the current ResolvedTargetItem through a new SchematicListElement.SelectedIndicator (unwired in any prefab yet -- a no-op until an editor pass assigns one). Presentation only; decides nothing. Unverified here -- Unity batchmode is unavailable in this environment. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
52a18efcdc
commit
04c0943fa0
4 changed files with 62 additions and 2 deletions
|
|
@ -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": "<Keyboard>/j",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard&Mouse",
|
||||
"action": "Cycle Target Item",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "71ac6088-1e18-4810-86be-1179918dd4a2",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Prototype> _iconInstances = new List<Prototype>();
|
||||
|
||||
public void SetSelected(bool selected)
|
||||
{
|
||||
if (SelectedIndicator != null) SelectedIndicator.SetActive(selected);
|
||||
}
|
||||
|
||||
public void ShowWeapon(WeaponItemData weapon)
|
||||
{
|
||||
foreach(var prototype in _iconInstances) prototype.ReturnToPool();
|
||||
|
|
|
|||
Loading…
Reference in a new issue