Merge HeliFly into Fly
This commit is contained in:
@@ -51,26 +51,56 @@ namespace OpenRA.Mods.Common.Activities
|
||||
this.minRange = minRange;
|
||||
}
|
||||
|
||||
public static void FlyToward(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, int turnSpeedOverride = -1)
|
||||
public static void FlyTick(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, WVec moveOverride, int turnSpeedOverride = -1)
|
||||
{
|
||||
desiredAltitude = new WDist(aircraft.CenterPosition.Z) + desiredAltitude - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
|
||||
var move = aircraft.FlyStep(aircraft.Facing);
|
||||
var altitude = aircraft.CenterPosition.Z;
|
||||
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
var move = aircraft.Info.CanHover ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
if (moveOverride != WVec.Zero)
|
||||
move = moveOverride;
|
||||
|
||||
var turnSpeed = turnSpeedOverride > -1 ? turnSpeedOverride : aircraft.TurnSpeed;
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed);
|
||||
|
||||
if (altitude != desiredAltitude.Length)
|
||||
// Note: we assume that if move.Z is not zero, it's intentional and we want to move in that vertical direction instead of towards desiredAltitude.
|
||||
// If that is not desired, the place that calls this should make sure moveOverride.Z is zero.
|
||||
if (dat != desiredAltitude || move.Z != 0)
|
||||
{
|
||||
var delta = move.HorizontalLength * aircraft.Info.MaximumPitch.Tan() / 1024;
|
||||
var dz = (desiredAltitude.Length - altitude).Clamp(-delta, delta);
|
||||
move += new WVec(0, 0, dz);
|
||||
var maxDelta = move.HorizontalLength * aircraft.Info.MaximumPitch.Tan() / 1024;
|
||||
var moveZ = move.Z != 0 ? move.Z : (desiredAltitude.Length - dat.Length);
|
||||
var deltaZ = moveZ.Clamp(-maxDelta, maxDelta);
|
||||
move = new WVec(move.X, move.Y, deltaZ);
|
||||
}
|
||||
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + move);
|
||||
}
|
||||
|
||||
public static void FlyTick(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, int turnSpeedOverride = -1)
|
||||
{
|
||||
FlyTick(self, aircraft, desiredFacing, desiredAltitude, WVec.Zero, turnSpeedOverride);
|
||||
}
|
||||
|
||||
// Should only be used for vertical-only movement, usually VTOL take-off or land. Terrain-induced altitude changes should always be handled by FlyTick.
|
||||
public static bool VerticalTakeOffOrLandTick(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, int turnSpeedOverride = -1)
|
||||
{
|
||||
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
var move = WVec.Zero;
|
||||
|
||||
var turnSpeed = turnSpeedOverride > -1 ? turnSpeedOverride : aircraft.TurnSpeed;
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed);
|
||||
|
||||
if (dat != desiredAltitude)
|
||||
{
|
||||
var maxDelta = aircraft.Info.AltitudeVelocity.Length;
|
||||
var deltaZ = (desiredAltitude.Length - dat.Length).Clamp(-maxDelta, maxDelta);
|
||||
move += new WVec(0, 0, deltaZ);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + move);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
// Refuse to take off if it would land immediately again.
|
||||
@@ -96,18 +126,28 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
|
||||
if (!soundPlayed && aircraft.Info.TakeoffSounds.Length > 0 && self.IsAtGroundLevel())
|
||||
// We are taking off, so remove influence in ground cells.
|
||||
if (dat <= aircraft.LandAltitude)
|
||||
{
|
||||
if (!soundPlayed && aircraft.Info.TakeoffSounds.Length > 0)
|
||||
{
|
||||
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSounds, self.World, aircraft.CenterPosition);
|
||||
soundPlayed = true;
|
||||
}
|
||||
|
||||
// We are taking off, so remove influence in ground cells.
|
||||
if (self.IsAtGroundLevel())
|
||||
aircraft.RemoveInfluence();
|
||||
}
|
||||
|
||||
// If we're a VTOL, rise before flying forward
|
||||
if (aircraft.Info.VTOL)
|
||||
if (VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude))
|
||||
return this;
|
||||
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
var delta = checkTarget.CenterPosition - self.CenterPosition;
|
||||
var desiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : aircraft.Facing;
|
||||
|
||||
// Inside the target annulus, so we're done
|
||||
var insideMaxRange = maxRange.Length > 0 && checkTarget.IsInRange(aircraft.CenterPosition, maxRange);
|
||||
@@ -115,19 +155,43 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (insideMaxRange && !insideMinRange)
|
||||
return NextActivity;
|
||||
|
||||
var delta = checkTarget.CenterPosition - self.CenterPosition;
|
||||
var move = aircraft.Info.CanHover ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
|
||||
// The next move would overshoot, so consider it close enough
|
||||
var move = aircraft.FlyStep(aircraft.Facing);
|
||||
// Inside the minimum range, so reverse if CanHover
|
||||
if (aircraft.Info.CanHover && insideMinRange)
|
||||
{
|
||||
FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, -move);
|
||||
return this;
|
||||
}
|
||||
|
||||
// The next move would overshoot, so consider it close enough or set final position if CanHover
|
||||
if (delta.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
||||
{
|
||||
if (aircraft.Info.CanHover)
|
||||
{
|
||||
// Set final (horizontal) position
|
||||
if (delta.HorizontalLengthSquared != 0)
|
||||
{
|
||||
// Ensure we don't include a non-zero vertical component here that would move us away from CruiseAltitude
|
||||
var deltaMove = new WVec(delta.X, delta.Y, 0);
|
||||
FlyTick(self, aircraft, desiredFacing, dat, deltaMove);
|
||||
}
|
||||
|
||||
// Move to CruiseAltitude, if not already there
|
||||
if (dat != aircraft.Info.CruiseAltitude)
|
||||
{
|
||||
Fly.VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
// Don't turn until we've reached the cruise altitude
|
||||
var desiredFacing = delta.Yaw.Facing;
|
||||
var targetAltitude = aircraft.CenterPosition.Z + aircraft.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length;
|
||||
if (aircraft.CenterPosition.Z < targetAltitude)
|
||||
if (dat < aircraft.Info.CruiseAltitude)
|
||||
desiredFacing = aircraft.Facing;
|
||||
else
|
||||
else if (!aircraft.Info.CanHover)
|
||||
{
|
||||
// Using the turn rate, compute a hypothetical circle traced by a continuous turn.
|
||||
// If it contains the destination point, it's unreachable without more complex manuvering.
|
||||
@@ -148,7 +212,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
desiredFacing = aircraft.Facing;
|
||||
}
|
||||
|
||||
FlyToward(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
||||
FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// We can't possibly turn this fast
|
||||
var desiredFacing = aircraft.Facing + 64;
|
||||
Fly.FlyToward(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, turnSpeedOverride);
|
||||
|
||||
// This override is necessary, otherwise CanHover aircraft would circle sideways
|
||||
var move = aircraft.FlyStep(aircraft.Facing);
|
||||
|
||||
Fly.FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, move, turnSpeedOverride);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// otherwise if it is hidden or dead we give up
|
||||
if (checkTarget.IsInRange(pos, maxRange) && !checkTarget.IsInRange(pos, minRange))
|
||||
{
|
||||
Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
return useLastVisibleTarget ? NextActivity : this;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceling || !self.World.Map.Contains(self.Location))
|
||||
return NextActivity;
|
||||
|
||||
Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceling || remainingTicks-- == 0)
|
||||
return NextActivity;
|
||||
|
||||
Fly.FlyToward(self, aircraft, aircraft.Facing, cruiseAltitude);
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, cruiseAltitude);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -133,13 +133,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var pos = self.CenterPosition;
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
|
||||
// Update facing
|
||||
// Update facing and altitude
|
||||
var delta = attackAircraft.GetTargetPosition(pos, checkTarget) - pos;
|
||||
var desiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : aircraft.Facing;
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.TurnSpeed);
|
||||
if (HeliFly.AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))
|
||||
if (Fly.VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude))
|
||||
return this;
|
||||
|
||||
var move = aircraft.FlyStep(desiredFacing);
|
||||
|
||||
// We don't know where the target actually is, so move to where we last saw it
|
||||
if (useLastVisibleTarget)
|
||||
{
|
||||
@@ -151,16 +153,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// Fly towards the last known position
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + aircraft.FlyStep(desiredFacing));
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude, move);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Fly towards the target
|
||||
// Fly towards the target if outside max range and backwards if within min range
|
||||
if (!target.IsInRange(pos, attackAircraft.GetMaximumRangeVersusTarget(target)))
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + aircraft.FlyStep(desiredFacing));
|
||||
|
||||
// Fly backwards from the target
|
||||
if (target.IsInRange(pos, attackAircraft.GetMinimumRangeVersusTarget(target)))
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude, move);
|
||||
else if (target.IsInRange(pos, attackAircraft.GetMinimumRangeVersusTarget(target)))
|
||||
{
|
||||
// Facing 0 doesn't work with the following position change
|
||||
var facing = 1;
|
||||
@@ -168,7 +168,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
facing = desiredFacing;
|
||||
else if (aircraft.Facing != 0)
|
||||
facing = aircraft.Facing;
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + aircraft.FlyStep(-facing));
|
||||
|
||||
move = aircraft.FlyStep(-facing);
|
||||
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude, move);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2019 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, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public class HeliFly : Activity
|
||||
{
|
||||
readonly Aircraft aircraft;
|
||||
readonly WDist maxRange;
|
||||
readonly WDist minRange;
|
||||
readonly Color? targetLineColor;
|
||||
bool soundPlayed;
|
||||
|
||||
Target target;
|
||||
Target lastVisibleTarget;
|
||||
bool useLastVisibleTarget;
|
||||
|
||||
public HeliFly(Actor self, Target t, WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
target = t;
|
||||
this.targetLineColor = targetLineColor;
|
||||
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
if ((target.Type == TargetType.Actor && target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
|| target.Type == TargetType.FrozenActor || target.Type == TargetType.Terrain)
|
||||
lastVisibleTarget = Target.FromPos(target.CenterPosition);
|
||||
else if (initialTargetPosition.HasValue)
|
||||
lastVisibleTarget = Target.FromPos(initialTargetPosition.Value);
|
||||
}
|
||||
|
||||
public HeliFly(Actor self, Target t, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
: this(self, t, initialTargetPosition, targetLineColor)
|
||||
{
|
||||
this.maxRange = maxRange;
|
||||
this.minRange = minRange;
|
||||
}
|
||||
|
||||
public static bool AdjustAltitude(Actor self, Aircraft aircraft, WDist targetAltitude)
|
||||
{
|
||||
targetAltitude = new WDist(aircraft.CenterPosition.Z) + targetAltitude - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
|
||||
var altitude = aircraft.CenterPosition.Z;
|
||||
if (altitude == targetAltitude.Length)
|
||||
return false;
|
||||
|
||||
var delta = aircraft.Info.AltitudeVelocity.Length;
|
||||
var dz = (targetAltitude.Length - altitude).Clamp(-delta, delta);
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + new WVec(0, 0, dz));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
Cancel(self);
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
bool targetIsHiddenActor;
|
||||
target = target.Recalculate(self.Owner, out targetIsHiddenActor);
|
||||
if (!targetIsHiddenActor && target.Type == TargetType.Actor)
|
||||
lastVisibleTarget = Target.FromTargetPositions(target);
|
||||
|
||||
var oldUseLastVisibleTarget = useLastVisibleTarget;
|
||||
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
|
||||
|
||||
// Update target lines if required
|
||||
if (useLastVisibleTarget != oldUseLastVisibleTarget && targetLineColor.HasValue)
|
||||
self.SetTargetLine(useLastVisibleTarget ? lastVisibleTarget : target, targetLineColor.Value, false);
|
||||
|
||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
if (!soundPlayed && aircraft.Info.TakeoffSounds.Length > 0 && self.IsAtGroundLevel())
|
||||
{
|
||||
Game.Sound.Play(SoundType.World, aircraft.Info.TakeoffSounds, self.World, aircraft.CenterPosition);
|
||||
soundPlayed = true;
|
||||
}
|
||||
|
||||
// We are taking off, so remove influence in ground cells.
|
||||
if (self.IsAtGroundLevel())
|
||||
aircraft.RemoveInfluence();
|
||||
|
||||
if (AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))
|
||||
return this;
|
||||
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
|
||||
// Update facing
|
||||
var delta = checkTarget.CenterPosition - aircraft.CenterPosition;
|
||||
var desiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : aircraft.Facing;
|
||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.TurnSpeed);
|
||||
if (AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))
|
||||
return this;
|
||||
|
||||
var move = aircraft.FlyStep(desiredFacing);
|
||||
|
||||
// Inside the minimum range, so reverse
|
||||
if (minRange.Length > 0 && checkTarget.IsInRange(aircraft.CenterPosition, minRange))
|
||||
{
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition - move);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Inside the maximum range, so we're done
|
||||
if (maxRange.Length > 0 && checkTarget.IsInRange(aircraft.CenterPosition, maxRange))
|
||||
return NextActivity;
|
||||
|
||||
// The next move would overshoot, so just set the final position
|
||||
if (delta.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
||||
{
|
||||
var targetAltitude = aircraft.CenterPosition.Z + aircraft.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length;
|
||||
aircraft.SetPosition(self, checkTarget.CenterPosition + new WVec(0, 0, targetAltitude - checkTarget.CenterPosition.Z));
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
aircraft.SetPosition(self, aircraft.CenterPosition + move);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override IEnumerable<Target> GetTargets(Actor self)
|
||||
{
|
||||
yield return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// For VTOLs we assume we've already arrived at the target location and just need to move downward
|
||||
if (aircraft.Info.VTOL)
|
||||
{
|
||||
if (HeliFly.AdjustAltitude(self, aircraft, landAltitude))
|
||||
if (Fly.VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, landAltitude))
|
||||
return this;
|
||||
|
||||
return NextActivity;
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition + offset) + aircraft.LandAltitude;
|
||||
Fly.FlyToward(self, aircraft, d.Yaw.Facing, landingAlt);
|
||||
Fly.FlyTick(self, aircraft, d.Yaw.Facing, landingAlt);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024;
|
||||
var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition);
|
||||
|
||||
QueueChild(self, new HeliFly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), true);
|
||||
QueueChild(self, new Fly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), true);
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -206,9 +206,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var exit = dest.FirstExitOrDefault(null);
|
||||
var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero;
|
||||
|
||||
if (aircraft.Info.CanHover)
|
||||
QueueChild(self, new HeliFly(self, Target.FromPos(dest.CenterPosition + offset)), true);
|
||||
else if (aircraft.Info.VTOL)
|
||||
if (aircraft.Info.VTOL || aircraft.Info.CanHover)
|
||||
QueueChild(self, new Fly(self, Target.FromPos(dest.CenterPosition + offset)), true);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Can't land, so wait at the target until something changes
|
||||
if (target.Type == TargetType.Invalid)
|
||||
{
|
||||
QueueChild(self, new HeliFly(self, destination), true);
|
||||
QueueChild(self, new Fly(self, destination), true);
|
||||
QueueChild(self, new Wait(25));
|
||||
return this;
|
||||
}
|
||||
@@ -98,12 +98,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
var dropFacing = (target.CenterPosition - self.CenterPosition).Yaw.Facing;
|
||||
localOffset = carryall.CarryableOffset.Rotate(body.QuantizeOrientation(self, WRot.FromFacing(dropFacing)));
|
||||
QueueChild(self, new HeliFly(self, Target.FromPos(target.CenterPosition - body.LocalToWorld(localOffset))), true);
|
||||
QueueChild(self, new Fly(self, Target.FromPos(target.CenterPosition - body.LocalToWorld(localOffset))), true);
|
||||
QueueChild(self, new Turn(self, dropFacing));
|
||||
return this;
|
||||
}
|
||||
|
||||
QueueChild(self, new HeliFly(self, target), true);
|
||||
QueueChild(self, new Fly(self, target), true);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Release carried actor
|
||||
QueueChild(self, new ReleaseUnit(self));
|
||||
QueueChild(self, new HeliFly(self, Target.FromPos(self.CenterPosition)));
|
||||
QueueChild(self, new Fly(self, Target.FromPos(self.CenterPosition)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var targetPosition = cargo.CenterPosition - carryableBody.LocalToWorld(localOffset);
|
||||
if ((self.CenterPosition - targetPosition).HorizontalLengthSquared != 0)
|
||||
{
|
||||
QueueChild(self, new HeliFly(self, Target.FromPos(targetPosition)), true);
|
||||
QueueChild(self, new Fly(self, Target.FromPos(targetPosition)), true);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("Fly within the cell grid.")]
|
||||
public void Move(CPos cell)
|
||||
{
|
||||
if (!aircraft.Info.CanHover)
|
||||
Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell)));
|
||||
else
|
||||
Self.QueueActivity(new HeliFly(Self, Target.FromCell(Self.World, cell)));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
|
||||
@@ -755,38 +755,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough)
|
||||
{
|
||||
if (!Info.CanHover)
|
||||
return new Fly(self, Target.FromCell(self.World, cell));
|
||||
|
||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, Actor ignoreActor)
|
||||
{
|
||||
if (!Info.CanHover)
|
||||
return new Fly(self, Target.FromCell(self.World, cell));
|
||||
|
||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist range,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
if (!Info.CanHover)
|
||||
return new Fly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||
|
||||
return new HeliFly(self, target, WDist.Zero, range, initialTargetPosition, targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange,
|
||||
WPos? initialTargetPosition = null, Color? targetLineColor = null)
|
||||
{
|
||||
if (!Info.CanHover)
|
||||
return new Fly(self, target, minRange, maxRange,
|
||||
initialTargetPosition, targetLineColor);
|
||||
|
||||
return new HeliFly(self, target, minRange, maxRange,
|
||||
initialTargetPosition, targetLineColor);
|
||||
}
|
||||
|
||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
|
||||
@@ -802,10 +789,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
||||
{
|
||||
if (!Info.CanHover)
|
||||
return new Fly(self, Target.FromCell(self.World, cell));
|
||||
|
||||
return new HeliFly(self, Target.FromCell(self.World, cell, subCell));
|
||||
return new Fly(self, Target.FromCell(self.World, cell, subCell));
|
||||
}
|
||||
|
||||
public Activity MoveToTarget(Actor self, Target target,
|
||||
@@ -816,7 +800,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
initialTargetPosition, targetLineColor);
|
||||
|
||||
return ActivityUtils.SequenceActivities(self,
|
||||
new HeliFly(self, target, initialTargetPosition, targetLineColor),
|
||||
new Fly(self, target, initialTargetPosition, targetLineColor),
|
||||
new Turn(self, Info.InitialFacing));
|
||||
}
|
||||
|
||||
@@ -828,14 +812,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
||||
{
|
||||
// TODO: Ignore repulsion when moving
|
||||
if (!Info.CanHover)
|
||||
return ActivityUtils.SequenceActivities(self,
|
||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
new Fly(self, Target.FromPos(toPos)));
|
||||
|
||||
return ActivityUtils.SequenceActivities(self,
|
||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
new HeliFly(self, Target.FromPos(toPos)));
|
||||
}
|
||||
|
||||
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
|
||||
@@ -940,13 +919,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
UnReserve();
|
||||
|
||||
var target = Target.FromCell(self.World, cell);
|
||||
|
||||
self.SetTargetLine(target, Color.Green);
|
||||
|
||||
if (!Info.CanHover)
|
||||
self.QueueActivity(order.Queued, new Fly(self, target));
|
||||
else
|
||||
self.QueueActivity(order.Queued, new HeliFly(self, target));
|
||||
}
|
||||
else if (order.OrderString == "Enter" || order.OrderString == "Repair")
|
||||
{
|
||||
@@ -1008,12 +982,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.CancelActivity();
|
||||
self.SetTargetLine(target, Color.Green, false);
|
||||
|
||||
if (!Info.CanHover)
|
||||
self.QueueActivity(new Fly(self, target));
|
||||
else
|
||||
self.QueueActivity(new HeliFly(self, target));
|
||||
|
||||
UnReserve();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
carrier.Trait<Carryall>().AttachCarryable(carrier, cargo);
|
||||
carrier.QueueActivity(new DeliverUnit(carrier, location));
|
||||
carrier.QueueActivity(new HeliFly(carrier, Target.FromCell(self.World, self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom))));
|
||||
carrier.QueueActivity(new Fly(carrier, Target.FromCell(self.World, self.World.Map.ChooseRandomEdgeCell(self.World.SharedRandom))));
|
||||
carrier.QueueActivity(new RemoveSelf());
|
||||
|
||||
self.World.AddFrameEndTask(w => self.World.Add(carrier));
|
||||
|
||||
Reference in New Issue
Block a user