From 4e493f265f151273c39026a1578d8ae9e42a72cf Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 11 Aug 2017 21:08:25 +0100 Subject: [PATCH] Revert TicksBeforePathing move from Mobile to Move. This partially reverts commit 11c8cda0c38ad0ac71c58557d34480925307cebd. --- OpenRA.Mods.Common/Activities/Move/Move.cs | 14 ++++---------- OpenRA.Mods.Common/Traits/Mobile.cs | 6 ++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index c3f1697de1..785e4508f9 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -23,8 +23,6 @@ namespace OpenRA.Mods.Common.Activities { public class Move : Activity { - const int AverageTicksBeforePathing = 5; - const int SpreadTicksBeforePathing = 5; static readonly List NoPath = new List(); readonly Mobile mobile; @@ -41,7 +39,6 @@ namespace OpenRA.Mods.Common.Activities int waitTicksRemaining; // To work around queued activity issues while minimizing changes to legacy behaviour - int ticksBeforePathing; bool evaluateNearestMovableCell; // Scriptable move order @@ -140,9 +137,6 @@ namespace OpenRA.Mods.Common.Activities protected override void OnFirstRun(Actor self) { - ticksBeforePathing = AverageTicksBeforePathing + - self.World.SharedRandom.Next(-SpreadTicksBeforePathing, SpreadTicksBeforePathing); - if (evaluateNearestMovableCell && destination.HasValue) { var movableDestination = mobile.NearestMoveableCell(destination.Value); @@ -165,9 +159,9 @@ namespace OpenRA.Mods.Common.Activities if (path == null) { - if (ticksBeforePathing > 0) + if (mobile.TicksBeforePathing > 0) { - --ticksBeforePathing; + --mobile.TicksBeforePathing; return this; } @@ -264,9 +258,9 @@ namespace OpenRA.Mods.Common.Activities if (--waitTicksRemaining >= 0) return null; - if (ticksBeforePathing > 0) + if (mobile.TicksBeforePathing > 0) { - --ticksBeforePathing; + --mobile.TicksBeforePathing; return null; } diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index a9f24b70cf..de3d639ab8 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -390,6 +390,10 @@ namespace OpenRA.Mods.Common.Traits public class Mobile : ConditionalTrait, INotifyCreated, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier, INotifyBecomingIdle { + const int AverageTicksBeforePathing = 5; + const int SpreadTicksBeforePathing = 5; + internal int TicksBeforePathing = 0; + readonly Actor self; readonly Lazy> speedModifiers; public bool IsMoving { get; set; } @@ -628,6 +632,8 @@ namespace OpenRA.Mods.Common.Traits if (!order.Queued) self.CancelActivity(); + TicksBeforePathing = AverageTicksBeforePathing + self.World.SharedRandom.Next(-SpreadTicksBeforePathing, SpreadTicksBeforePathing); + self.SetTargetLine(Target.FromCell(self.World, order.TargetLocation), Color.Green); self.QueueActivity(order.Queued, new Move(self, order.TargetLocation, WDist.FromCells(8), null, true)); }