From e990a83b7a16f671d9643511f24607218fdc63ab Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 10 Jan 2021 12:17:25 +0000 Subject: [PATCH] Cancel support power targeting if power cannot be activated. --- OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs | 2 +- OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs | 4 ++-- .../Traits/SupportPowers/GrantExternalConditionPower.cs | 2 +- .../Traits/SupportPowers/SelectDirectionalTarget.cs | 2 +- .../Traits/SupportPowers/SupportPowerManager.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs index 6c4c3c16b6..ab227a1783 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/AttackOrderPower.cs @@ -120,7 +120,7 @@ namespace OpenRA.Mods.Cnc.Traits protected override void Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); } diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs index 993ef21ce7..4cb0abb4ac 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs @@ -174,7 +174,7 @@ namespace OpenRA.Mods.Cnc.Traits protected override void Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); } @@ -274,7 +274,7 @@ namespace OpenRA.Mods.Cnc.Traits protected override void Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs index 1621cd9ea1..3ac0e372ab 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs @@ -137,7 +137,7 @@ namespace OpenRA.Mods.Common.Traits protected override void Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SelectDirectionalTarget.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SelectDirectionalTarget.cs index d3a9d3e010..4513e2db60 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SelectDirectionalTarget.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SelectDirectionalTarget.cs @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Traits void IOrderGenerator.Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index d7ad4c4e77..5a9dbe95ce 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -309,7 +309,7 @@ namespace OpenRA.Mods.Common.Traits protected override void Tick(World world) { // Cancel the OG if we can't use the power - if (!manager.Powers.ContainsKey(order)) + if (!manager.Powers.TryGetValue(order, out var p) || !p.Active || !p.Ready) world.CancelInputMode(); }