Make aircraft turn speed scale with speed modifiers

This commit is contained in:
reaperrr
2021-06-18 19:34:54 +02:00
committed by Paul Chote
parent 0ac277a88d
commit df8295fa2c
2 changed files with 13 additions and 1 deletions

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
move = moveOverride;
var oldFacing = aircraft.Facing;
var turnSpeed = idleTurn ? aircraft.IdleTurnSpeed ?? aircraft.TurnSpeed : aircraft.TurnSpeed;
var turnSpeed = aircraft.GetTurnSpeed(idleTurn);
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed);
var roll = idleTurn ? aircraft.Info.IdleRoll ?? aircraft.Info.Roll : aircraft.Info.Roll;

View File

@@ -268,6 +268,18 @@ namespace OpenRA.Mods.Common.Traits
public WAngle TurnSpeed => IsTraitDisabled || IsTraitPaused ? WAngle.Zero : Info.TurnSpeed;
public WAngle? IdleTurnSpeed => IsTraitDisabled || IsTraitPaused ? null : Info.IdleTurnSpeed;
public WAngle GetTurnSpeed(bool isIdleTurn)
{
// A MovementSpeed of zero indicates either a speed modifier of zero percent or that the trait is paused or disabled.
// Bail early in that case.
if ((isIdleTurn && IdleMovementSpeed == 0) || MovementSpeed == 0)
return WAngle.Zero;
var turnSpeed = isIdleTurn ? IdleTurnSpeed ?? TurnSpeed : TurnSpeed;
return new WAngle(Util.ApplyPercentageModifiers(turnSpeed.Angle, speedModifiers).Clamp(1, 1024));
}
public Actor ReservedActor { get; private set; }
public bool MayYieldReservation { get; private set; }
public bool ForceLanding { get; private set; }