From 8c7ff3b5b0c7306143d8ebce44444a137f3ce07c Mon Sep 17 00:00:00 2001 From: tovl Date: Sat, 27 Jul 2019 22:02:59 +0200 Subject: [PATCH] Make VisualMove uninterruptible by making Turn a Child of Drag. --- OpenRA.Mods.Common/Activities/Move/Drag.cs | 10 +++++++++- OpenRA.Mods.Common/Traits/Mobile.cs | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Drag.cs b/OpenRA.Mods.Common/Activities/Move/Drag.cs index 66c3d0fa45..0db2348cfa 100644 --- a/OpenRA.Mods.Common/Activities/Move/Drag.cs +++ b/OpenRA.Mods.Common/Activities/Move/Drag.cs @@ -23,17 +23,25 @@ namespace OpenRA.Mods.Common.Activities WPos start, end; int length; int ticks = 0; + int desiredFacing; - public Drag(Actor self, WPos start, WPos end, int length) + public Drag(Actor self, WPos start, WPos end, int length, int facing = -1) { positionable = self.Trait(); disableable = self.TraitOrDefault() as IDisabledTrait; this.start = start; this.end = end; this.length = length; + desiredFacing = facing; IsInterruptible = false; } + protected override void OnFirstRun(Actor self) + { + if (desiredFacing != -1) + QueueChild(new Turn(self, desiredFacing)); + } + public override bool Tick(Actor self) { if (disableable != null && disableable.IsTraitDisabled) diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index dd895caf29..2c4f565185 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -698,9 +698,7 @@ namespace OpenRA.Mods.Common.Traits var delta = toPos - fromPos; var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : Facing; - var activities = new Turn(self, facing); - activities.Queue(new Drag(self, fromPos, toPos, length)); - return activities; + return new Drag(self, fromPos, toPos, length, facing); } CPos? ClosestGroundCell()