diff --git a/OpenRA.Mods.RA/AutoTarget.cs b/OpenRA.Mods.RA/AutoTarget.cs index 18679b74b9..ea9461c2b0 100644 --- a/OpenRA.Mods.RA/AutoTarget.cs +++ b/OpenRA.Mods.RA/AutoTarget.cs @@ -32,12 +32,14 @@ namespace OpenRA.Mods.RA [Sync] int nextScanTime = 0; [Sync] public UnitStance stance; + public UnitStance predictedStance; /* NOT SYNCED: do not refer to this anywhere other than UI code */ public AutoTarget(Actor self, AutoTargetInfo info) { Info = info; attack = self.Trait(); stance = Info.InitialStance; + predictedStance = stance; } public void ResolveOrder(Actor self, Order order) diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index c977d27455..09a615d831 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -129,10 +129,14 @@ namespace OpenRA.Mods.RA.Widgets var stances = (UnitStance[])Enum.GetValues(typeof(UnitStance)); - var nextStance = stances.Concat(stances).SkipWhile(s => s != actor.Second.stance).Skip(1).First(); + var nextStance = stances.Concat(stances).SkipWhile(s => s != actor.Second.predictedStance).Skip(1).First(); PerformKeyboardOrderOnSelection(a => - new Order("SetUnitStance", a, false) { TargetLocation = new int2((int)nextStance, 0) }); + { + var at = a.TraitOrDefault(); + if (at != null) at.predictedStance = nextStance; + return new Order("SetUnitStance", a, false) { TargetLocation = new int2((int)nextStance, 0) }; + }); Game.Debug( "Unit stance set to: {0}".F(nextStance) );