Revert FlightDynamics

This needs more thought and most parts might get superseded
by other approaches.

Kept CanSlide separation from CanHover.
This commit is contained in:
reaperrr
2019-07-12 23:10:05 +02:00
committed by abcdefg30
parent aa5c8b4efa
commit cf4d73ab91
9 changed files with 58 additions and 57 deletions

View File

@@ -53,8 +53,7 @@ namespace OpenRA.Mods.Common.Activities
public static void FlyTick(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, WVec moveOverride, int turnSpeedOverride = -1)
{
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
var isSlider = aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Slide);
var move = isSlider ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
var move = aircraft.Info.CanSlide ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
if (moveOverride != WVec.Zero)
move = moveOverride;
@@ -116,7 +115,7 @@ namespace OpenRA.Mods.Common.Activities
// If the aircraft lands when idle and is idle, we let the default idle handler manage this.
// TODO: Remove this after fixing all activities to work properly with arbitrary starting altitudes.
var skipHeightAdjustment = aircraft.Info.LandWhenIdle && self.CurrentActivity.IsCanceling && self.CurrentActivity.NextActivity == null;
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Hover) && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
if (aircraft.Info.CanHover && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
{
if (dat <= aircraft.LandAltitude)
QueueChild(new TakeOff(self, target));
@@ -161,22 +160,22 @@ namespace OpenRA.Mods.Common.Activities
if (insideMaxRange && !insideMinRange)
return true;
var isSlider = aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Slide);
var isSlider = aircraft.Info.CanSlide;
var move = isSlider ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
// Inside the minimum range, so reverse if we have Slide flag
// Inside the minimum range, so reverse if we CanSlide
if (isSlider && insideMinRange)
{
FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, -move);
return false;
}
// The next move would overshoot, so consider it close enough or set final position if we have Slide flag
// The next move would overshoot, so consider it close enough or set final position if we CanSlide
if (delta.HorizontalLengthSquared < move.HorizontalLengthSquared)
{
// For VTOL landing to succeed, it must reach the exact target position,
// so for the final move it needs to behave as if it had the Slide flag.
if (isSlider || aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL))
// so for the final move it needs to behave as if it had CanSlide.
if (isSlider || aircraft.Info.VTOL)
{
// Set final (horizontal) position
if (delta.HorizontalLengthSquared != 0)

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
// We can't possibly turn this fast
var desiredFacing = aircraft.Facing + 64;
// This override is necessary, otherwise aircraft with Slide flag would circle sideways
// This override is necessary, otherwise aircraft with CanSlide would circle sideways
var move = aircraft.FlyStep(aircraft.Facing);
Fly.FlyTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, move, turnSpeedOverride);

View File

@@ -84,7 +84,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))
{
if (!aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Hover))
if (!aircraft.Info.CanHover)
Fly.FlyTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
return useLastVisibleTarget;

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
// NOTE: desiredFacing = -1 means we should not prefer any particular facing and instead just
// use whatever facing gives us the most direct path to the landing site.
if (facing == -1 && aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.TurnToLand))
if (facing == -1 && aircraft.Info.TurnToLand)
desiredFacing = aircraft.Info.InitialFacing;
else
desiredFacing = facing;
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Activities
}
// Move towards landing location
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL) && (pos - targetPosition).HorizontalLengthSquared != 0)
if (aircraft.Info.VTOL && (pos - targetPosition).HorizontalLengthSquared != 0)
{
QueueChild(new Fly(self, Target.FromPos(targetPosition)));
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Activities
return false;
}
if (!aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL) && !finishedApproach)
if (!aircraft.Info.VTOL && !finishedApproach)
{
// Calculate approach trajectory
var altitude = aircraft.Info.CruiseAltitude.Length;
@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Activities
if (!aircraft.CanLand(blockingCells, target.Actor))
{
// Maintain holding pattern.
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Hover))
if (aircraft.Info.CanHover)
QueueChild(new Wait(25));
else
QueueChild(new FlyCircle(self, 25));
@@ -226,7 +226,7 @@ namespace OpenRA.Mods.Common.Activities
}
// Final descent.
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL))
if (aircraft.Info.VTOL)
{
var landAltitude = self.World.Map.DistanceAboveTerrain(targetPosition) + aircraft.LandAltitude;
if (Fly.VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, landAltitude))

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Activities
if (nearestResupplier != null)
{
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Hover))
if (aircraft.Info.CanHover)
{
var distanceFromResupplier = (nearestResupplier.CenterPosition - self.CenterPosition).HorizontalLength;
var distanceLength = aircraft.Info.WaitDistanceFromResupplyBase.Length;
@@ -113,9 +113,9 @@ namespace OpenRA.Mods.Common.Activities
{
var exit = dest.FirstExitOrDefault(null);
var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero;
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.TurnToDock))
if (aircraft.Info.TurnToDock)
facing = aircraft.Info.InitialFacing;
if (!aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL))
if (!aircraft.Info.VTOL)
facing = 192;
aircraft.MakeReservation(dest);

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Activities
if (dat < aircraft.Info.CruiseAltitude)
{
// If we're a VTOL, rise before flying forward
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL))
if (aircraft.Info.VTOL)
{
Fly.VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
return false;
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Activities
// Checking for NextActivity == null again in case another activity was queued while taking off
if (moveToRallyPoint && NextActivity == null)
{
if (!aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.VTOL) && assignTargetOnFirstRun)
if (!aircraft.Info.VTOL && assignTargetOnFirstRun)
return true;
QueueChild(new AttackMoveActivity(self, () => move.MoveToTarget(self, target)));

View File

@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Activities
{
aircraft.AllowYieldingReservation();
if (wasRepaired ||
(!stayOnResupplier && aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.TakeOffOnResupply)))
(!stayOnResupplier && aircraft.Info.TakeOffOnResupply))
QueueChild(new TakeOff(self));
}
else if (!stayOnResupplier)