diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 6fa564d92..7917b0f7d 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -406,14 +406,9 @@ public class ActionGameManager : MonoBehaviour // Flips the player's own stance on the current target between hostile and neutral. Going // neutral mid-fight safes weapons (Weapon.StanceAllowsFire); an unmarked/undetected target - // reads as non-hostile, so the first press declares hostile. The flip reads the stance when applied, so two - // presses in a step cancel. - Input.Player.ToggleStance.performed += context => - { - var target = CurrentEntity.Target.Value.Entity; - if (target == null) return; - CurrentEntity.Command.ToggleStance(target); - }; + // reads as non-hostile, so the first press declares hostile. The flip reads the target and its stance when applied, + // after the step's target presses, so two presses in a step cancel. + Input.Player.ToggleStance.performed += context => CurrentEntity.Command.ToggleStance(); #region Targeting diff --git a/Assets/Scripts/ServerShared/Pilot.cs b/Assets/Scripts/ServerShared/Pilot.cs index 576191b7d..8b04637d9 100644 --- a/Assets/Scripts/ServerShared/Pilot.cs +++ b/Assets/Scripts/ServerShared/Pilot.cs @@ -69,8 +69,9 @@ public sealed class PilotCommand public void Verb(TargetVerb verb) => TargetVerb = verb; public void CycleAim() => AimCycles++; public void Iff(Entity other, bool? hostile) => Iffs.Add((other, hostile, false)); - // A press that flips the stance on `other` as it stands when applied, in order with Iff, so two in a step cancel. - public void ToggleStance(Entity other) => Iffs.Add((other, null, true)); + // A press that flips the stance on the entity's target as both stand when applied, after the step's target verbs and in + // order with Iff, so two in a step cancel. With no target then, it does nothing. + public void ToggleStance() => Iffs.Add((null, null, true)); // The entity's own switches, pressed: each press flips its switch when applied, so two in a step cancel. public void ToggleOverrideShutdown() => ShutdownOverrideToggles++; public void ToggleHeatsinks() => HeatsinkToggles++; @@ -121,7 +122,11 @@ public static class PilotApplier } foreach (var item in command.Selections) entity.TrySelectTargetItem(item); for (var i = 0; i < command.AimCycles; i++) entity.CycleAim(); - foreach (var (other, hostile, toggle) in command.Iffs) entity.SetIff(other, toggle ? !entity.IsHostileTo(other) : hostile); + foreach (var (other, hostile, toggle) in command.Iffs) + { + if (!toggle) entity.SetIff(other, hostile); + else if (entity.Target.Value.Entity is Entity target) entity.SetIff(target, !entity.IsHostileTo(target)); + } for (var i = 0; i < command.ShutdownOverrideToggles; i++) entity.OverrideShutdown = !entity.OverrideShutdown; for (var i = 0; i < command.HeatsinkToggles; i++) entity.HeatsinksEnabled = !entity.HeatsinksEnabled; if (entity.Shield != null)