Split out an ActivityUtils class.
This commit is contained in:
@@ -145,7 +145,7 @@ namespace OpenRA
|
||||
public void Tick()
|
||||
{
|
||||
var wasIdle = IsIdle;
|
||||
currentActivity = Traits.Util.RunActivity(this, currentActivity);
|
||||
currentActivity = ActivityUtils.RunActivity(this, currentActivity);
|
||||
|
||||
if (!wasIdle && IsIdle)
|
||||
foreach (var n in TraitsImplementing<INotifyBecomingIdle>())
|
||||
|
||||
@@ -255,6 +255,7 @@
|
||||
<Compile Include="Primitives\ObservableList.cs" />
|
||||
<Compile Include="Graphics\RgbaColorRenderer.cs" />
|
||||
<Compile Include="Traits\Player\IndexedPlayerPalette.cs" />
|
||||
<Compile Include="Traits\ActivityUtils.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FileSystem\D2kSoundResources.cs" />
|
||||
|
||||
59
OpenRA.Game/Traits/ActivityUtils.cs
Normal file
59
OpenRA.Game/Traits/ActivityUtils.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Support;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
public static class ActivityUtils
|
||||
{
|
||||
public static Activity RunActivity(Actor self, Activity act)
|
||||
{
|
||||
// PERF: If there are no activities we can bail straight away and save ourselves a call to
|
||||
// Stopwatch.GetTimestamp.
|
||||
if (act == null)
|
||||
return act;
|
||||
|
||||
// PERF: This is a hot path and must run with minimal added overhead.
|
||||
// Calling Stopwatch.GetTimestamp is a bit expensive, so we enumerate manually to allow us to call it only
|
||||
// once per iteration in the normal case.
|
||||
// See also: DoTimed
|
||||
var longTickThresholdInStopwatchTicks = PerfTimer.LongTickThresholdInStopwatchTicks;
|
||||
var start = Stopwatch.GetTimestamp();
|
||||
while (act != null)
|
||||
{
|
||||
var prev = act;
|
||||
act = act.Tick(self);
|
||||
var current = Stopwatch.GetTimestamp();
|
||||
if (current - start > longTickThresholdInStopwatchTicks)
|
||||
{
|
||||
PerfTimer.LogLongTick(start, current, "Activity", prev);
|
||||
start = Stopwatch.GetTimestamp();
|
||||
}
|
||||
else
|
||||
start = current;
|
||||
|
||||
if (prev == act)
|
||||
break;
|
||||
}
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
public static Activity SequenceActivities(params Activity[] acts)
|
||||
{
|
||||
return acts.Reverse().Aggregate(
|
||||
(next, a) => { a.Queue(next); return a; });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,45 +54,6 @@ namespace OpenRA.Traits
|
||||
return WPos.Lerp(w.Map.CenterOfCell(from), w.Map.CenterOfCell(to), 1, 2);
|
||||
}
|
||||
|
||||
public static Activity SequenceActivities(params Activity[] acts)
|
||||
{
|
||||
return acts.Reverse().Aggregate(
|
||||
(next, a) => { a.Queue(next); return a; });
|
||||
}
|
||||
|
||||
public static Activity RunActivity(Actor self, Activity act)
|
||||
{
|
||||
// PERF: If there are no activities we can bail straight away and save ourselves a call to
|
||||
// Stopwatch.GetTimestamp.
|
||||
if (act == null)
|
||||
return act;
|
||||
|
||||
// PERF: This is a hot path and must run with minimal added overhead.
|
||||
// Calling Stopwatch.GetTimestamp is a bit expensive, so we enumerate manually to allow us to call it only
|
||||
// once per iteration in the normal case.
|
||||
// See also: DoTimed
|
||||
var longTickThresholdInStopwatchTicks = PerfTimer.LongTickThresholdInStopwatchTicks;
|
||||
var start = Stopwatch.GetTimestamp();
|
||||
while (act != null)
|
||||
{
|
||||
var prev = act;
|
||||
act = act.Tick(self);
|
||||
var current = Stopwatch.GetTimestamp();
|
||||
if (current - start > longTickThresholdInStopwatchTicks)
|
||||
{
|
||||
PerfTimer.LogLongTick(start, current, "Activity", prev);
|
||||
start = Stopwatch.GetTimestamp();
|
||||
}
|
||||
else
|
||||
start = current;
|
||||
|
||||
if (prev == act)
|
||||
break;
|
||||
}
|
||||
|
||||
return act;
|
||||
}
|
||||
|
||||
/* pretty crap */
|
||||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> ts, MersenneTwister random)
|
||||
{
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// TODO: This should fire each weapon at its maximum range
|
||||
if (attackPlane != null && target.IsInRange(self.CenterPosition, attackPlane.Armaments.Select(a => a.Weapon.MinRange).Min()))
|
||||
inner = Util.SequenceActivities(new FlyTimed(ticksUntilTurn, self), new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
|
||||
inner = ActivityUtils.SequenceActivities(new FlyTimed(ticksUntilTurn, self), new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
|
||||
else
|
||||
inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
|
||||
inner = ActivityUtils.SequenceActivities(new Fly(self, target), new FlyTimed(ticksUntilTurn, self));
|
||||
}
|
||||
|
||||
inner = Util.RunActivity(self, inner);
|
||||
inner = ActivityUtils.RunActivity(self, inner);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return this;
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), this);
|
||||
return ActivityUtils.SequenceActivities(new Fly(self, target, minRange, maxRange), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
self.CancelActivity();
|
||||
self.SetTargetLine(newTarget, Color.Green);
|
||||
return Util.SequenceActivities(new HeliFly(self, newTarget));
|
||||
return ActivityUtils.SequenceActivities(new HeliFly(self, newTarget));
|
||||
}
|
||||
|
||||
// If all ammo pools are depleted and none reload automatically, return to helipad to reload and then move to next activity
|
||||
// TODO: This should check whether there is ammo left that is actually suitable for the target
|
||||
if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo()))
|
||||
return Util.SequenceActivities(new HeliReturnToBase(self), NextActivity);
|
||||
return ActivityUtils.SequenceActivities(new HeliReturnToBase(self), NextActivity);
|
||||
|
||||
var dist = target.CenterPosition - self.CenterPosition;
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
.ClosestTo(self);
|
||||
|
||||
if (nearestHpad == null)
|
||||
return Util.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, initialFacing), new HeliLand(self, true), NextActivity);
|
||||
else
|
||||
return Util.SequenceActivities(new HeliFly(self, Target.FromActor(nearestHpad)));
|
||||
return ActivityUtils.SequenceActivities(new HeliFly(self, Target.FromActor(nearestHpad)));
|
||||
}
|
||||
|
||||
heli.MakeReservation(dest);
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var exit = dest.Info.TraitInfos<ExitInfo>().FirstOrDefault();
|
||||
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new HeliFly(self, Target.FromPos(dest.CenterPosition + offset)),
|
||||
new Turn(self, initialFacing),
|
||||
new HeliLand(self, false),
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (host == null)
|
||||
return NextActivity;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
aircraft.GetResupplyActivities(host).Append(NextActivity).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
self.CancelActivity();
|
||||
if (nearestAfld != null)
|
||||
return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle(self));
|
||||
return ActivityUtils.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle(self));
|
||||
else
|
||||
return new FlyCircle(self);
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new Fly(self, Target.FromPos(w1)),
|
||||
new Fly(self, Target.FromPos(w2)),
|
||||
new Fly(self, Target.FromPos(w3)),
|
||||
|
||||
@@ -78,11 +78,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Try to move within range
|
||||
if (move != null && (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange)))
|
||||
return Util.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this);
|
||||
return ActivityUtils.SequenceActivities(move.MoveWithinRange(Target, minRange, maxRange), this);
|
||||
|
||||
var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing;
|
||||
if (facing.Facing != desiredFacing)
|
||||
return Util.SequenceActivities(new Turn(self, desiredFacing), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, desiredFacing), this);
|
||||
|
||||
attack.DoAttack(self, Target, armaments);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// No refineries exist; check again after delay defined in Harvester.
|
||||
if (harv.LinkedProc == null)
|
||||
return Util.SequenceActivities(new Wait(harv.Info.SearchForDeliveryBuildingDelay), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(harv.Info.SearchForDeliveryBuildingDelay), this);
|
||||
|
||||
var proc = harv.LinkedProc;
|
||||
var iao = proc.Trait<IAcceptResources>();
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var n in notify)
|
||||
n.MovingToRefinery(self, proc.Location + iao.DeliveryOffset, next);
|
||||
|
||||
return Util.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this);
|
||||
return ActivityUtils.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this);
|
||||
}
|
||||
|
||||
if (!isDocking)
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
iao.OnDock(self, this);
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(new Wait(10), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(10), this);
|
||||
}
|
||||
|
||||
// Cannot be cancelled
|
||||
|
||||
@@ -252,10 +252,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Activity CanceledTick(Actor self)
|
||||
{
|
||||
if (inner == null)
|
||||
return Util.RunActivity(self, NextActivity);
|
||||
return ActivityUtils.RunActivity(self, NextActivity);
|
||||
inner.Cancel(self);
|
||||
inner.Queue(NextActivity);
|
||||
return Util.RunActivity(self, inner);
|
||||
return ActivityUtils.RunActivity(self, inner);
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -272,7 +272,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return CanceledTick(self);
|
||||
|
||||
// Run inner activity/InsideTick
|
||||
inner = inner == this ? InsideTick(self) : Util.RunActivity(self, inner);
|
||||
inner = inner == this ? InsideTick(self) : ActivityUtils.RunActivity(self, inner);
|
||||
|
||||
// If we are finished, move on to next activity
|
||||
if (inner == null && nextState == State.Done)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var nearest = target.Actor.OccupiesSpace.NearestCellTo(mobile.ToCell);
|
||||
|
||||
if ((nearest - mobile.ToCell).LengthSquared > 2)
|
||||
return Util.SequenceActivities(new MoveAdjacentTo(self, target), this);
|
||||
return ActivityUtils.SequenceActivities(new MoveAdjacentTo(self, target), this);
|
||||
|
||||
if (!capturable.CaptureInProgress)
|
||||
capturable.BeginCapture(self);
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var deliver = new DeliverResources(self);
|
||||
|
||||
if (harv.IsFull)
|
||||
return Util.SequenceActivities(deliver, NextActivity);
|
||||
return ActivityUtils.SequenceActivities(deliver, NextActivity);
|
||||
|
||||
var closestHarvestablePosition = ClosestHarvestablePos(self);
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
var randFrames = self.World.SharedRandom.Next(100, 175);
|
||||
return Util.SequenceActivities(NextActivity, new Wait(randFrames), this);
|
||||
return ActivityUtils.SequenceActivities(NextActivity, new Wait(randFrames), this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (territory != null)
|
||||
{
|
||||
if (!territory.ClaimResource(self, closestHarvestablePosition.Value))
|
||||
return Util.SequenceActivities(new Wait(25), next);
|
||||
return ActivityUtils.SequenceActivities(new Wait(25), next);
|
||||
}
|
||||
|
||||
// If not given a direct order, assume ordered to the first resource location we find:
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var n in notify)
|
||||
n.MovingToResources(self, closestHarvestablePosition.Value, next);
|
||||
|
||||
return Util.SequenceActivities(mobile.MoveTo(closestHarvestablePosition.Value, 1), new HarvestResource(self), next);
|
||||
return ActivityUtils.SequenceActivities(mobile.MoveTo(closestHarvestablePosition.Value, 1), new HarvestResource(self), next);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var current = facing.Facing;
|
||||
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
||||
if (desired != current)
|
||||
return Util.SequenceActivities(new Turn(self, desired), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, desired), this);
|
||||
}
|
||||
|
||||
var resource = resLayer.Harvest(self.Location);
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var t in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
t.Harvested(self, resource);
|
||||
|
||||
return Util.SequenceActivities(new Wait(harvInfo.LoadTicksPerBale), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(harvInfo.LoadTicksPerBale), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
case State.Turn:
|
||||
dockingState = State.Dock;
|
||||
if (IsDragRequired)
|
||||
return Util.SequenceActivities(new Turn(self, DockAngle), new Drag(self, StartDrag, EndDrag, DragLength), this);
|
||||
return Util.SequenceActivities(new Turn(self, DockAngle), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, DockAngle), new Drag(self, StartDrag, EndDrag, DragLength), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, DockAngle), this);
|
||||
case State.Dock:
|
||||
if (Refinery.IsInWorld && !Refinery.IsDead)
|
||||
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Harv.LastLinkedProc = Harv.LinkedProc;
|
||||
Harv.LinkProc(self, null);
|
||||
if (IsDragRequired)
|
||||
return Util.SequenceActivities(new Drag(self, EndDrag, StartDrag, DragLength), NextActivity);
|
||||
return ActivityUtils.SequenceActivities(new Drag(self, EndDrag, StartDrag, DragLength), NextActivity);
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (target == null)
|
||||
return this;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new AttackMoveActivity(self, new Move(self, target.Location, WDist.FromCells(2))),
|
||||
new Wait(25),
|
||||
this);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (inner == null)
|
||||
return NextActivity;
|
||||
|
||||
inner = Util.RunActivity(self, inner);
|
||||
inner = ActivityUtils.RunActivity(self, inner);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (target.IsInRange(self.CenterPosition, maxRange) && !target.IsInRange(self.CenterPosition, minRange))
|
||||
{
|
||||
var wait = new WaitFor(() => !target.IsValidFor(self) || target.CenterPosition != cachedPosition);
|
||||
return Util.SequenceActivities(wait, path, this);
|
||||
return ActivityUtils.SequenceActivities(wait, path, this);
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(path, this);
|
||||
return ActivityUtils.SequenceActivities(path, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (firstFacing != mobile.Facing)
|
||||
{
|
||||
path.Add(nextCell.Value.First);
|
||||
return Util.SequenceActivities(new Turn(self, firstFacing), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, firstFacing), this);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
inner.Cancel(self);
|
||||
|
||||
self.SetTargetLine(Target.FromCell(self.World, targetPosition), Color.Green);
|
||||
return Util.RunActivity(self, new AttackMoveActivity(self, mobile.MoveTo(targetPosition, 0)));
|
||||
return ActivityUtils.RunActivity(self, new AttackMoveActivity(self, mobile.MoveTo(targetPosition, 0)));
|
||||
}
|
||||
|
||||
// Inner move order has completed.
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// Ticks the inner move activity to actually move the actor.
|
||||
inner = Util.RunActivity(self, inner);
|
||||
inner = ActivityUtils.RunActivity(self, inner);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
self.NotifyBlocker(BlockedExitCells(actor));
|
||||
|
||||
return Util.SequenceActivities(new Wait(10), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(10), this);
|
||||
}
|
||||
|
||||
cargo.Unload(self);
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
inner = Util.RunActivity(self, inner);
|
||||
inner = ActivityUtils.RunActivity(self, inner);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsPlane)
|
||||
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5));
|
||||
|
||||
return Util.SequenceActivities(new HeliFly(self, target), new Turn(self, Info.InitialFacing));
|
||||
return ActivityUtils.SequenceActivities(new HeliFly(self, target), new Turn(self, Info.InitialFacing));
|
||||
}
|
||||
|
||||
public Activity MoveIntoTarget(Actor self, Target target)
|
||||
@@ -439,11 +439,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// TODO: Ignore repulsion when moving
|
||||
if (IsPlane)
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
new Fly(self, Target.FromPos(toPos)));
|
||||
|
||||
return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
return ActivityUtils.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
new HeliFly(self, Target.FromPos(toPos)));
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (IsPlane)
|
||||
{
|
||||
self.QueueActivity(order.Queued, Util.SequenceActivities(
|
||||
self.QueueActivity(order.Queued, ActivityUtils.SequenceActivities(
|
||||
new ReturnToBase(self, order.TargetActor),
|
||||
new ResupplyAircraft(self)));
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
||||
Game.Sound.Play(attack.info.ChargeAudio, self.CenterPosition);
|
||||
|
||||
return Util.SequenceActivities(new Wait(attack.info.InitialChargeDelay), new ChargeFire(attack, target), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(attack.info.InitialChargeDelay), new ChargeFire(attack, target), this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
attack.DoAttack(self, target);
|
||||
|
||||
return Util.SequenceActivities(new Wait(attack.info.ChargeDelay), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(attack.info.ChargeDelay), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
attack.Target = target;
|
||||
|
||||
if (move != null)
|
||||
return Util.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);
|
||||
return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
|
||||
@@ -682,7 +682,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell));
|
||||
var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell));
|
||||
var move = new Move(self, cellInfo.Cell);
|
||||
self.QueueActivity(Util.SequenceActivities(notifyBlocking, waitFor, move));
|
||||
self.QueueActivity(ActivityUtils.SequenceActivities(notifyBlocking, waitFor, move));
|
||||
|
||||
Log.Write("debug", "OnNudge (notify next blocking actor, wait and move) #{0} from {1} to {2}",
|
||||
self.ActorID, self.Location, cellInfo.Cell);
|
||||
@@ -797,7 +797,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var delta = toPos - fromPos;
|
||||
var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : Facing;
|
||||
return Util.SequenceActivities(new Turn(self, facing), new Drag(self, fromPos, toPos, length));
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, facing), new Drag(self, fromPos, toPos, length));
|
||||
}
|
||||
|
||||
public void ModifyDeathActorInit(Actor self, TypeDictionary init)
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.SetTargetLine(target, Color.Green);
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new WaitForTransport(self, Util.SequenceActivities(new MoveAdjacentTo(self, target),
|
||||
self.QueueActivity(new WaitForTransport(self, ActivityUtils.SequenceActivities(new MoveAdjacentTo(self, target),
|
||||
new CallFunc(() => AfterReachActivities(self, order, movement)))));
|
||||
|
||||
TryCallTransport(self, target, new CallFunc(() => AfterReachActivities(self, order, movement)));
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
case State.Transport:
|
||||
var targetl = GetLocationToDrop(carryable.Destination);
|
||||
state = State.Land;
|
||||
return Util.SequenceActivities(movement.MoveTo(targetl, 0), this);
|
||||
return ActivityUtils.SequenceActivities(movement.MoveTo(targetl, 0), this);
|
||||
|
||||
case State.Land:
|
||||
if (!CanDropHere())
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
if (HeliFly.AdjustAltitude(self, aircraft, aircraft.Info.LandAltitude))
|
||||
return this;
|
||||
state = State.Release;
|
||||
return Util.SequenceActivities(new Wait(15), this);
|
||||
return ActivityUtils.SequenceActivities(new Wait(15), this);
|
||||
|
||||
case State.Release:
|
||||
if (!CanDropHere())
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Mods.D2k.Traits;
|
||||
@@ -54,7 +55,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
{
|
||||
case State.Intercept:
|
||||
state = State.LockCarryable;
|
||||
return Util.SequenceActivities(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4)), this);
|
||||
return ActivityUtils.SequenceActivities(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4)), this);
|
||||
|
||||
case State.LockCarryable:
|
||||
// Last check
|
||||
@@ -75,13 +76,13 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
return this;
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(movement.MoveTo(cargo.Location, 0), this);
|
||||
return ActivityUtils.SequenceActivities(movement.MoveTo(cargo.Location, 0), this);
|
||||
|
||||
case State.Turn: // Align facing and Land
|
||||
if (selfFacing.Facing != cargoFacing.Facing)
|
||||
return Util.SequenceActivities(new Turn(self, cargoFacing.Facing), this);
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, cargoFacing.Facing), this);
|
||||
state = State.Pickup;
|
||||
return Util.SequenceActivities(new HeliLand(self, false), new Wait(10), this);
|
||||
return ActivityUtils.SequenceActivities(new HeliLand(self, false), new Wait(10), this);
|
||||
|
||||
case State.Pickup:
|
||||
// Remove our carryable from world
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (rearmTarget == null)
|
||||
return new Wait(20);
|
||||
|
||||
return Util.SequenceActivities(
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new MoveAdjacentTo(self, Target.FromActor(rearmTarget)),
|
||||
movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget),
|
||||
new Rearm(self),
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (minelayer.Minefield.Contains(self.Location) && ShouldLayMine(self, self.Location))
|
||||
{
|
||||
LayMine(self);
|
||||
return Util.SequenceActivities(new Wait(20), this); // A little wait after placing each mine, for show
|
||||
return ActivityUtils.SequenceActivities(new Wait(20), this); // A little wait after placing each mine, for show
|
||||
}
|
||||
|
||||
if (minelayer.Minefield.Length > 0)
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
var p = minelayer.Minefield.Random(self.World.SharedRandom);
|
||||
if (ShouldLayMine(self, p))
|
||||
return Util.SequenceActivities(movement.MoveTo(p, 0), this);
|
||||
return ActivityUtils.SequenceActivities(movement.MoveTo(p, 0), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user