Replace various Aircraft fields with FlightDynamics
Replaces various booleans with a FlightDynamics flag list.
This commit is contained in:
@@ -53,7 +53,8 @@ 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 move = aircraft.Info.CanHover ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
var isSlider = aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Slide);
|
||||
var move = isSlider ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
if (moveOverride != WVec.Zero)
|
||||
move = moveOverride;
|
||||
|
||||
@@ -115,7 +116,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.CanHover && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
|
||||
if (aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Hover) && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
|
||||
{
|
||||
if (dat <= aircraft.LandAltitude)
|
||||
QueueChild(new TakeOff(self, target));
|
||||
@@ -160,19 +161,22 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (insideMaxRange && !insideMinRange)
|
||||
return true;
|
||||
|
||||
var move = aircraft.Info.CanHover ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
var isSlider = aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.Slide);
|
||||
var move = isSlider ? aircraft.FlyStep(desiredFacing) : aircraft.FlyStep(aircraft.Facing);
|
||||
|
||||
// Inside the minimum range, so reverse if CanHover
|
||||
if (aircraft.Info.CanHover && insideMinRange)
|
||||
// Inside the minimum range, so reverse if we have Slide flag
|
||||
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 CanHover
|
||||
// The next move would overshoot, so consider it close enough or set final position if we have Slide flag
|
||||
if (delta.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
||||
{
|
||||
if (aircraft.Info.CanHover)
|
||||
// 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))
|
||||
{
|
||||
// Set final (horizontal) position
|
||||
if (delta.HorizontalLengthSquared != 0)
|
||||
@@ -193,7 +197,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!aircraft.Info.CanHover)
|
||||
if (!isSlider)
|
||||
{
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user