Add IdleTurnSpeed to Aircraft
Instead of hardcoding 1/3 of normal TurnSpeed on HeliFlyCircle.
This commit is contained in:
@@ -37,14 +37,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
this.minRange = minRange;
|
this.minRange = minRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void FlyToward(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude)
|
public static void FlyToward(Actor self, Aircraft aircraft, int desiredFacing, WDist desiredAltitude, int turnSpeedOverride = -1)
|
||||||
{
|
{
|
||||||
desiredAltitude = new WDist(aircraft.CenterPosition.Z) + desiredAltitude - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
desiredAltitude = new WDist(aircraft.CenterPosition.Z) + desiredAltitude - self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||||
|
|
||||||
var move = aircraft.FlyStep(aircraft.Facing);
|
var move = aircraft.FlyStep(aircraft.Facing);
|
||||||
var altitude = aircraft.CenterPosition.Z;
|
var altitude = aircraft.CenterPosition.Z;
|
||||||
|
|
||||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.TurnSpeed);
|
var turnSpeed = turnSpeedOverride > -1 ? turnSpeedOverride : aircraft.TurnSpeed;
|
||||||
|
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed);
|
||||||
|
|
||||||
if (altitude != desiredAltitude.Length)
|
if (altitude != desiredAltitude.Length)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public class FlyCircle : Activity
|
public class FlyCircle : Activity
|
||||||
{
|
{
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
readonly WDist cruiseAltitude;
|
readonly int turnSpeedOverride;
|
||||||
int remainingTicks;
|
int remainingTicks;
|
||||||
|
|
||||||
public FlyCircle(Actor self, int ticks = -1)
|
public FlyCircle(Actor self, int ticks = -1, int turnSpeedOverride = -1)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
cruiseAltitude = aircraft.Info.CruiseAltitude;
|
|
||||||
remainingTicks = ticks;
|
remainingTicks = ticks;
|
||||||
|
this.turnSpeedOverride = turnSpeedOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// We can't possibly turn this fast
|
// We can't possibly turn this fast
|
||||||
var desiredFacing = aircraft.Facing + 64;
|
var desiredFacing = aircraft.Facing + 64;
|
||||||
Fly.FlyToward(self, aircraft, desiredFacing, cruiseAltitude);
|
Fly.FlyToward(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude, turnSpeedOverride);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public class HeliFlyCircle : Activity
|
public class HeliFlyCircle : Activity
|
||||||
{
|
{
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
|
readonly int turnSpeedOverride;
|
||||||
|
|
||||||
public HeliFlyCircle(Actor self)
|
public HeliFlyCircle(Actor self, int turnSpeedOverride = -1)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
|
this.turnSpeedOverride = turnSpeedOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -42,7 +44,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
aircraft.SetPosition(self, aircraft.CenterPosition + move);
|
aircraft.SetPosition(self, aircraft.CenterPosition + move);
|
||||||
|
|
||||||
var desiredFacing = aircraft.Facing + 64;
|
var desiredFacing = aircraft.Facing + 64;
|
||||||
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.TurnSpeed / 3);
|
var turnSpeed = turnSpeedOverride > -1 ? turnSpeedOverride : aircraft.TurnSpeed;
|
||||||
|
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, turnSpeed);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -942,6 +942,7 @@
|
|||||||
<Compile Include="UpdateRules\Rules\20180923\MergeAttackPlaneAndHeli.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\MergeAttackPlaneAndHeli.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\ExtractHackyAIModules.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\ExtractHackyAIModules.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\DefineLevelUpImageDefault.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\DefineLevelUpImageDefault.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\20180923\RemovedAutoCarryallCircleTurnSpeed.cs" />
|
||||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||||
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
|
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
|
||||||
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />
|
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public readonly int TurnSpeed = 255;
|
public readonly int TurnSpeed = 255;
|
||||||
|
|
||||||
|
[Desc("Turn speed to apply when aircraft flies in circles while idle. Defaults to TurnSpeed if negative.")]
|
||||||
|
public readonly int IdleTurnSpeed = -1;
|
||||||
|
|
||||||
public readonly int Speed = 1;
|
public readonly int Speed = 1;
|
||||||
|
|
||||||
[Desc("Minimum altitude where this aircraft is considered airborne.")]
|
[Desc("Minimum altitude where this aircraft is considered airborne.")]
|
||||||
|
|||||||
@@ -33,9 +33,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
busy = false;
|
busy = false;
|
||||||
FindCarryableForTransport(self);
|
FindCarryableForTransport(self);
|
||||||
|
|
||||||
// TODO: This should be handled by the aircraft trait
|
// TODO: This should be handled by the Aircraft trait
|
||||||
if (!busy)
|
if (!busy)
|
||||||
self.QueueActivity(new HeliFlyCircle(self));
|
{
|
||||||
|
var aircraft = self.Trait<Aircraft>();
|
||||||
|
var turnSpeedOverride = aircraft.Info.IdleTurnSpeed > -1 ? aircraft.Info.IdleTurnSpeed : aircraft.TurnSpeed;
|
||||||
|
self.QueueActivity(new HeliFlyCircle(self, turnSpeedOverride));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A carryable notifying us that he'd like to be carried
|
// A carryable notifying us that he'd like to be carried
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 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;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class RemovedAutoCarryallCircleTurnSpeed : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Removed AutoCarryall idle circling turnspeed hardcoding"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "Aircraft that circle while idle despite having CanHover (AutoCarryall) have their\n" +
|
||||||
|
"turn speed during idle circling no longer hardcoded to 1/3 of regular TurnSpeed." +
|
||||||
|
"Note that the new IdleTurnSpeed override works on all aircraft that circle when idle.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool showMessage;
|
||||||
|
bool messageShown;
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
var message = "While circling idle, your AutoCarryall(s) will now turn at full TurnSpeed,\n" +
|
||||||
|
"unless you manually define a custom IdleTurnSpeed.";
|
||||||
|
|
||||||
|
if (showMessage && !messageShown)
|
||||||
|
yield return message;
|
||||||
|
|
||||||
|
showMessage = false;
|
||||||
|
messageShown = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
var autoCarryall = actorNode.LastChildMatching("AutoCarryall");
|
||||||
|
if (autoCarryall == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
showMessage = true;
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,6 +109,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new RemoveNegativeDamageFullHealthCheck(),
|
new RemoveNegativeDamageFullHealthCheck(),
|
||||||
new RemoveResourceExplodeModifier(),
|
new RemoveResourceExplodeModifier(),
|
||||||
new DefineLevelUpImageDefault(),
|
new DefineLevelUpImageDefault(),
|
||||||
|
new RemovedAutoCarryallCircleTurnSpeed(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ carryall.reinforce:
|
|||||||
AirborneCondition: airborne
|
AirborneCondition: airborne
|
||||||
CanHover: True
|
CanHover: True
|
||||||
VTOL: true
|
VTOL: true
|
||||||
|
IdleTurnSpeed: 1
|
||||||
Targetable@GROUND:
|
Targetable@GROUND:
|
||||||
TargetTypes: Ground, Vehicle
|
TargetTypes: Ground, Vehicle
|
||||||
RequiresCondition: !airborne
|
RequiresCondition: !airborne
|
||||||
|
|||||||
Reference in New Issue
Block a user