diff --git a/OpenRA.Game/Traits/ActivityUtils.cs b/OpenRA.Game/Traits/ActivityUtils.cs index 00896ab499..9a9e7f331c 100644 --- a/OpenRA.Game/Traits/ActivityUtils.cs +++ b/OpenRA.Game/Traits/ActivityUtils.cs @@ -50,11 +50,5 @@ namespace OpenRA.Traits return act; } - - public static Activity SequenceActivities(params Activity[] acts) - { - return acts.Reverse().Aggregate( - (next, a) => { a.Queue(next); return a; }); - } } } diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 476768d004..8573cc551b 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -99,23 +99,19 @@ namespace OpenRA.Mods.Common.Activities (closeEnough.LengthSquared > 0 && !host.IsInRange(self.CenterPosition, closeEnough))) { var targetCell = self.World.Map.CellContaining(host.Actor.CenterPosition); - List movement = new List(); - movement.Add(move.MoveWithinRange(host, closeEnough, targetLineColor: Color.Green)); + QueueChild(move.MoveWithinRange(host, closeEnough, targetLineColor: Color.Green)); // HACK: Repairable needs the actor to move to host center. // TODO: Get rid of this or at least replace it with something less hacky. if (repairableNear == null) - movement.Add(move.MoveTo(targetCell, host.Actor)); - - var moveActivities = ActivityUtils.SequenceActivities(movement.ToArray()); + QueueChild(move.MoveTo(targetCell, host.Actor)); var delta = (self.CenterPosition - host.CenterPosition).LengthSquared; var transport = transportCallers.FirstOrDefault(t => t.MinimumDistance.LengthSquared < delta); if (transport != null) transport.RequestTransport(self, targetCell); - QueueChild(moveActivities); return false; } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index ec45085bb1..bd9d3be34c 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -858,9 +858,9 @@ namespace OpenRA.Mods.Common.Traits public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { // TODO: Ignore repulsion when moving - return ActivityUtils.SequenceActivities( - new CallFunc(() => SetVisualPosition(self, fromPos)), - new Fly(self, Target.FromPos(toPos))); + var activities = new CallFunc(() => SetVisualPosition(self, fromPos)); + activities.Queue(new Fly(self, Target.FromPos(toPos))); + return activities; } public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos) diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index fd30b17e7c..7493158bd2 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -319,10 +319,9 @@ namespace OpenRA.Mods.Common.Traits if (cellInfo != null) { self.CancelActivity(); - var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell)); - var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell)); - var move = new Move(self, cellInfo.Cell); - self.QueueActivity(ActivityUtils.SequenceActivities(notifyBlocking, waitFor, move)); + self.QueueActivity(new CallFunc(() => self.NotifyBlocker(cellInfo.Cell))); + self.QueueActivity(new WaitFor(() => CanEnterCell(cellInfo.Cell))); + self.QueueActivity(new Move(self, cellInfo.Cell)); Log.Write("debug", "OnNudge (notify next blocking actor, wait and move) #{0} from {1} to {2}", self.ActorID, self.Location, cellInfo.Cell); @@ -691,7 +690,10 @@ namespace OpenRA.Mods.Common.Traits var delta = toPos - fromPos; var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : Facing; - return ActivityUtils.SequenceActivities(new Turn(self, facing), new Drag(self, fromPos, toPos, length)); + + var activities = new Turn(self, facing); + activities.Queue(new Drag(self, fromPos, toPos, length)); + return activities; } CPos? ClosestGroundCell()