Merge pull request #10537 from pchote/move-util
Move OpenRA.Traits.Util to Mods.Common
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>())
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
<Compile Include="Traits\Selectable.cs" />
|
||||
<Compile Include="Traits\Target.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\Util.cs" />
|
||||
<Compile Include="Traits\ValidateOrder.cs" />
|
||||
<Compile Include="Traits\World\Faction.cs" />
|
||||
<Compile Include="Traits\World\ResourceType.cs" />
|
||||
@@ -255,6 +254,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; });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly IFacing facing;
|
||||
readonly ResourceClaimLayer territory;
|
||||
readonly ResourceLayer resLayer;
|
||||
readonly BodyOrientation body;
|
||||
|
||||
public HarvestResource(Actor self)
|
||||
{
|
||||
harv = self.Trait<Harvester>();
|
||||
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
||||
facing = self.Trait<IFacing>();
|
||||
body = self.Trait<BodyOrientation>();
|
||||
territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
}
|
||||
@@ -53,9 +55,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (harvInfo.HarvestFacings != 0)
|
||||
{
|
||||
var current = facing.Facing;
|
||||
var desired = Util.QuantizeFacing(current, harvInfo.HarvestFacings) * (256 / harvInfo.HarvestFacings);
|
||||
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);
|
||||
@@ -71,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
target = args.PassiveTarget;
|
||||
if (info.Inaccuracy.Length > 0)
|
||||
{
|
||||
var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
var maxOffset = inaccuracy * (target - headPos).Length / args.Weapon.Range.Length;
|
||||
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ namespace OpenRA.Mods.Common.Effects
|
||||
target = args.PassiveTarget;
|
||||
if (info.Inaccuracy.Length > 0)
|
||||
{
|
||||
var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
var range = OpenRA.Traits.Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers);
|
||||
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
var range = Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers);
|
||||
var maxOffset = inaccuracy * (target - pos).Length / range;
|
||||
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
@@ -200,7 +201,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
if (info.Inaccuracy.Length > 0)
|
||||
{
|
||||
var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024;
|
||||
}
|
||||
|
||||
@@ -723,8 +724,8 @@ namespace OpenRA.Mods.Common.Effects
|
||||
desiredHFacing = hFacing;
|
||||
|
||||
// Compute new direction the projectile will be facing
|
||||
hFacing = OpenRA.Traits.Util.TickFacing(hFacing, desiredHFacing, info.HorizontalRateOfTurn);
|
||||
vFacing = OpenRA.Traits.Util.TickFacing(vFacing, desiredVFacing, info.VerticalRateOfTurn);
|
||||
hFacing = Util.TickFacing(hFacing, desiredHFacing, info.HorizontalRateOfTurn);
|
||||
vFacing = Util.TickFacing(vFacing, desiredVFacing, info.VerticalRateOfTurn);
|
||||
|
||||
// Compute the projectile's guided displacement
|
||||
return new WVec(0, -1024 * speed, 0)
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
protected virtual Sprite GetSprite(int start, int frame, int facing)
|
||||
{
|
||||
var f = OpenRA.Traits.Util.QuantizeFacing(facing, Facings);
|
||||
var f = Util.QuantizeFacing(facing, Facings);
|
||||
|
||||
if (reverseFacings)
|
||||
f = (Facings - f) % Facings;
|
||||
|
||||
@@ -144,19 +144,19 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
// Draw voxel bounding box
|
||||
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
|
||||
var scaleTransform = Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
|
||||
var cameraTransform = Util.MakeFloatMatrix(voxel.camera.AsMatrix());
|
||||
var scaleTransform = OpenRA.Graphics.Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
|
||||
var cameraTransform = OpenRA.Graphics.Util.MakeFloatMatrix(voxel.camera.AsMatrix());
|
||||
|
||||
foreach (var v in draw)
|
||||
{
|
||||
var bounds = v.Voxel.Bounds(v.FrameFunc());
|
||||
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
|
||||
(x, y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
|
||||
float sx, sy, sz;
|
||||
wr.ScreenVectorComponents(v.OffsetFunc(), out sx, out sy, out sz);
|
||||
var pxPos = pxOrigin + new float2(sx, sy);
|
||||
var screenTransform = Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
DrawBoundsBox(pxPos, screenTransform, bounds, iz, Color.Yellow);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
var vec = new float[] { bounds[CornerXIndex[i]], bounds[CornerYIndex[i]], bounds[CornerZIndex[i]], 1 };
|
||||
var screen = Util.MatrixVectorMultiply(transform, vec);
|
||||
var screen = OpenRA.Graphics.Util.MatrixVectorMultiply(transform, vec);
|
||||
corners[i] = pxPos + new float2(screen[0], screen[1]);
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
var pxOrigin = wr.ScreenPosition(voxel.pos);
|
||||
var draw = voxel.voxels.Where(v => v.DisableFunc == null || !v.DisableFunc());
|
||||
var scaleTransform = Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
|
||||
var cameraTransform = Util.MakeFloatMatrix(voxel.camera.AsMatrix());
|
||||
var scaleTransform = OpenRA.Graphics.Util.ScaleMatrix(voxel.scale, voxel.scale, voxel.scale);
|
||||
var cameraTransform = OpenRA.Graphics.Util.MakeFloatMatrix(voxel.camera.AsMatrix());
|
||||
|
||||
var minX = float.MaxValue;
|
||||
var minY = float.MaxValue;
|
||||
@@ -203,17 +203,17 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
{
|
||||
var bounds = v.Voxel.Bounds(v.FrameFunc());
|
||||
var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform,
|
||||
(x, y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
(x, y) => OpenRA.Graphics.Util.MatrixMultiply(x, OpenRA.Graphics.Util.MakeFloatMatrix(y.AsMatrix())));
|
||||
|
||||
float sx, sy, sz;
|
||||
wr.ScreenVectorComponents(v.OffsetFunc(), out sx, out sy, out sz);
|
||||
var pxPos = pxOrigin + new float2(sx, sy);
|
||||
var screenTransform = Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
var screenTransform = OpenRA.Graphics.Util.MatrixMultiply(cameraTransform, worldTransform);
|
||||
|
||||
for (var i = 0; i < 8; i++)
|
||||
{
|
||||
var vec = new float[] { bounds[CornerXIndex[i]], bounds[CornerYIndex[i]], bounds[CornerZIndex[i]], 1 };
|
||||
var screen = Util.MatrixVectorMultiply(screenTransform, vec);
|
||||
var screen = OpenRA.Graphics.Util.MatrixVectorMultiply(screenTransform, vec);
|
||||
minX = Math.Min(minX, pxPos.X + screen[0]);
|
||||
minY = Math.Min(minY, pxPos.Y + screen[1]);
|
||||
maxX = Math.Max(maxX, pxPos.X + screen[0]);
|
||||
|
||||
@@ -730,6 +730,7 @@
|
||||
<Compile Include="Orders\GuardOrderGenerator.cs" />
|
||||
<Compile Include="UtilityCommands\CheckExplicitInterfacesCommand.cs" />
|
||||
<Compile Include="FileFormats\LZOCompression.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Graphics;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using Util = OpenRA.Traits.Util;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Orders
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var sequence = a.Info.MuzzleSequence;
|
||||
|
||||
if (a.Info.MuzzleSplitFacings > 0)
|
||||
sequence += OpenRA.Traits.Util.QuantizeFacing(muzzleFacing, a.Info.MuzzleSplitFacings).ToString();
|
||||
sequence += Util.QuantizeFacing(muzzleFacing, a.Info.MuzzleSplitFacings).ToString();
|
||||
|
||||
var muzzleFlash = new AnimationWithOffset(muzzleAnim,
|
||||
() => PortOffset(self, port),
|
||||
|
||||
@@ -42,12 +42,17 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return orientation;
|
||||
|
||||
// Map yaw to the closest facing
|
||||
var facing = Util.QuantizeFacing(orientation.Yaw.Angle / 4, facings) * (256 / facings);
|
||||
var facing = QuantizeFacing(orientation.Yaw.Angle / 4, facings);
|
||||
|
||||
// Roll and pitch are always zero if yaw is quantized
|
||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||
}
|
||||
|
||||
public int QuantizeFacing(int facing, int facings)
|
||||
{
|
||||
return Util.QuantizeFacing(facing, facings) * (256 / facings);
|
||||
}
|
||||
|
||||
public object Create(ActorInitializer init) { return new BodyOrientation(init, this); }
|
||||
}
|
||||
|
||||
@@ -97,5 +102,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
return info.QuantizeOrientation(orientation, quantizedFacings.Value);
|
||||
}
|
||||
|
||||
public int QuantizeFacing(int facing)
|
||||
{
|
||||
return info.QuantizeFacing(facing, quantizedFacings.Value);
|
||||
}
|
||||
|
||||
public int QuantizeFacing(int facing, int facings)
|
||||
{
|
||||
return info.QuantizeFacing(facing, facings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
if (a.Info.MuzzleSplitFacings > 0)
|
||||
sequence += OpenRA.Traits.Util.QuantizeFacing(getFacing(), a.Info.MuzzleSplitFacings).ToString();
|
||||
sequence += Util.QuantizeFacing(getFacing(), a.Info.MuzzleSplitFacings).ToString();
|
||||
|
||||
if (barrel == null)
|
||||
return;
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var info = Info as AirstrikePowerInfo;
|
||||
|
||||
if (randomize)
|
||||
attackFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
|
||||
attackFacing = 256 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings;
|
||||
|
||||
var altitude = self.World.Map.Rules.Actors[info.UnitType].TraitInfo<AircraftInfo>().CruiseAltitude.Length;
|
||||
var attackRotation = WRot.FromFacing(attackFacing);
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Quantize orientation to match a rendered sprite
|
||||
// Implies no pitch or yaw
|
||||
var facing = Util.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings) * (256 / QuantizedFacings);
|
||||
var facing = body.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings);
|
||||
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (info.DeliveryAircraft != null)
|
||||
{
|
||||
var crate = w.CreateActor(false, crateActor, new TypeDictionary { new OwnerInit(w.WorldActor.Owner) });
|
||||
var dropFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
|
||||
var dropFacing = 256 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings;
|
||||
var delta = new WVec(0, -1024, 0).Rotate(WRot.FromFacing(dropFacing));
|
||||
|
||||
var altitude = self.World.Map.Rules.Actors[info.DeliveryAircraft].TraitInfo<AircraftInfo>().CruiseAltitude.Length;
|
||||
|
||||
@@ -190,14 +190,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void UpdateNeighbours(IReadOnlyDictionary<CPos, SubCell> footprint)
|
||||
{
|
||||
// Include actors inside the footprint too
|
||||
var cells = OpenRA.Traits.Util.ExpandFootprint(footprint.Keys, true);
|
||||
var cells = Util.ExpandFootprint(footprint.Keys, true);
|
||||
foreach (var p in cells.SelectMany(c => PreviewsAt(c)))
|
||||
p.ReplaceInit(new RuntimeNeighbourInit(NeighbouringPreviews(p.Footprint)));
|
||||
}
|
||||
|
||||
Dictionary<CPos, string[]> NeighbouringPreviews(IReadOnlyDictionary<CPos, SubCell> footprint)
|
||||
{
|
||||
var cells = OpenRA.Traits.Util.ExpandFootprint(footprint.Keys, true).Except(footprint.Keys);
|
||||
var cells = Util.ExpandFootprint(footprint.Keys, true).Except(footprint.Keys);
|
||||
return cells.ToDictionary(c => c, c => PreviewsAt(c).Select(p => p.Info.Name).ToArray());
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
public static class Util
|
||||
{
|
||||
@@ -54,45 +53,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)
|
||||
{
|
||||
@@ -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;
|
||||
@@ -86,7 +87,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 +99,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
var info = Info as ParatroopersPowerInfo;
|
||||
|
||||
if (randomize)
|
||||
dropFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
|
||||
dropFacing = 256 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings;
|
||||
|
||||
var altitude = self.World.Map.Rules.Actors[info.UnitType].TraitInfo<AircraftInfo>().CruiseAltitude.Length;
|
||||
var dropRotation = WRot.FromFacing(dropFacing);
|
||||
|
||||
Reference in New Issue
Block a user