From 1f93029e51d543bdac7c54d874afcc90f117fa10 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 26 May 2017 09:49:17 +0200 Subject: [PATCH] Always make sure to be on the host actor when repairing --- OpenRA.Mods.Cnc/Activities/LayMines.cs | 3 ++- OpenRA.Mods.Common/Activities/Repair.cs | 5 +---- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 4 +++- OpenRA.Mods.Common/Traits/Repairable.cs | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Cnc/Activities/LayMines.cs b/OpenRA.Mods.Cnc/Activities/LayMines.cs index 2fb4100d41..d7bfcb01c5 100644 --- a/OpenRA.Mods.Cnc/Activities/LayMines.cs +++ b/OpenRA.Mods.Cnc/Activities/LayMines.cs @@ -53,11 +53,12 @@ namespace OpenRA.Mods.Cnc.Activities if (rearmTarget == null) return new Wait(20); + // Add a CloseEnough range of 512 to the Repair activity in order to ensure that we're at the host actor return ActivityUtils.SequenceActivities( new MoveAdjacentTo(self, Target.FromActor(rearmTarget)), movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget), new Rearm(self), - new Repair(self, rearmTarget), + new Repair(self, rearmTarget, new WDist(512)), this); } diff --git a/OpenRA.Mods.Common/Activities/Repair.cs b/OpenRA.Mods.Common/Activities/Repair.cs index 295befa282..1022a358b2 100644 --- a/OpenRA.Mods.Common/Activities/Repair.cs +++ b/OpenRA.Mods.Common/Activities/Repair.cs @@ -19,17 +19,14 @@ namespace OpenRA.Mods.Common.Activities { public class Repair : Activity { + readonly Health health; readonly RepairsUnits[] allRepairsUnits; readonly Target host; readonly WDist closeEnough; int remainingTicks; - Health health; bool played = false; - public Repair(Actor self, Actor host) - : this(self, host, WDist.Zero) { } - public Repair(Actor self, Actor host, WDist closeEnough) { this.host = Target.FromActor(host); diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 87f15baaca..bd870b4c76 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -391,8 +391,10 @@ namespace OpenRA.Mods.Common.Traits var name = a.Info.Name; if (Info.RearmBuildings.Contains(name)) yield return new Rearm(self); + + // Add a CloseEnough range of 512 to ensure we're at the host actor if (Info.RepairBuildings.Contains(name)) - yield return new Repair(self, a); + yield return new Repair(self, a, new WDist(512)); } public void ModifyDeathActorInit(Actor self, TypeDictionary init) diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index 7ada78a98c..d52e94d26b 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -114,7 +114,8 @@ namespace OpenRA.Mods.Common.Traits if (CanRearmAt(order.TargetActor) && CanRearm()) self.QueueActivity(new Rearm(self)); - self.QueueActivity(new Repair(self, order.TargetActor)); + // Add a CloseEnough range of 512 to ensure we're at the host actor + self.QueueActivity(new Repair(self, order.TargetActor, new WDist(512))); var rp = order.TargetActor.TraitOrDefault(); if (rp != null)