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

@@ -21,34 +21,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Flags]
public enum FlightDynamic
{
None = 0,
MoveIntoShroud = 1,
Slide = 2,
Hover = 4,
VTOL = 8,
TurnToLand = 16,
TurnToDock = 32,
TakeOffOnResupply = 64,
TakeOffOnCreation = 128,
}
public class AircraftInfo : ITraitInfo, IPositionableInfo, IFacingInfo, IMoveInfo, ICruiseAltitudeInfo,
IActorPreviewInitInfo, IEditorActorOptions, IObservesVariablesInfo
{
[Desc("List of flags that alter the movement behavior. Options:",
"MoveIntoShroud = Can be ordered to move into shroud.",
"Slide = Changes direction immediately, independently of current facing. Without this flag, needs to fly a curve.",
"Hover = Able to statically hover in air while idle or waiting. Without this flag, aircraft will fly in circles.",
"VTOL = Vertical-only take-off/land. Without this flag, lands/takes off diagonally.",
"TurnToLand = Does the aircraft need to turn towards InitialFacing before landing on terrain? No effect if VTOL flag is missing.",
"TurnToDock = Does the aircraft need to turn towards InitialFacing before landing on dock? No effect if VTOL flag is missing.",
"TakeOffOnResupply = Take off as soon as resupplies/repairs are finished.",
"TakeOffOnCreation = Take off from creator when spawned.")]
public readonly FlightDynamic FlightDynamics = FlightDynamic.TakeOffOnCreation | FlightDynamic.MoveIntoShroud;
public readonly WDist CruiseAltitude = new WDist(1280);
[Desc("Whether the aircraft can be repulsed.")]
@@ -74,6 +49,9 @@ namespace OpenRA.Mods.Common.Traits
public readonly HashSet<string> LandableTerrainTypes = new HashSet<string>();
[Desc("Can the actor be ordered to move in to shroud?")]
public readonly bool MoveIntoShroud = true;
[Desc("e.g. crate, wall, infantry")]
public readonly BitSet<CrushClass> Crushes = default(BitSet<CrushClass>);
@@ -91,9 +69,33 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The condition to grant to self while at cruise altitude.")]
public readonly string CruisingCondition = null;
[Desc("Can the actor hover in place mid-air? If not, then the actor will have to remain in motion (circle around).")]
public readonly bool CanHover = false;
[Desc("Can the actor immediately change direction without turning first (doesn't need to fly in a curve)?")]
public readonly bool CanSlide = false;
[Desc("Does the actor land and take off vertically?")]
public readonly bool VTOL = false;
[Desc("Will this actor try to land after it has no more commands?")]
public readonly bool LandWhenIdle = true;
[Desc("Does this VTOL actor need to turn before landing (on terrain)?")]
public readonly bool TurnToLand = false;
[Desc("Does this VTOL actor need to turn before landing on a resupplier?")]
public readonly bool TurnToDock = true;
[Desc("Does this actor cancel its previous activity after resupplying?")]
public readonly bool AbortOnResupply = true;
[Desc("Does this actor automatically take off after resupplying?")]
public readonly bool TakeOffOnResupply = false;
[Desc("Does this actor automatically take off after creation?")]
public readonly bool TakeOffOnCreation = true;
[Desc("Altitude at which the aircraft considers itself landed.")]
public readonly WDist LandAltitude = WDist.Zero;
@@ -345,7 +347,7 @@ namespace OpenRA.Mods.Common.Traits
MakeReservation(host);
if (Info.FlightDynamics.HasFlag(FlightDynamic.TakeOffOnCreation))
if (Info.TakeOffOnCreation)
self.QueueActivity(new TakeOff(self));
}
@@ -441,7 +443,7 @@ namespace OpenRA.Mods.Common.Traits
repulsionForce += new WVec(1024, 0, 0).Rotate(WRot.FromYaw((self.CenterPosition - center).Yaw));
}
if (Info.FlightDynamics.HasFlag(FlightDynamic.Slide))
if (Info.CanSlide)
return repulsionForce;
// Non-hovering actors mush always keep moving forward, so they need extra calculations.
@@ -682,7 +684,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
var isCircler = !Info.FlightDynamics.HasFlag(FlightDynamic.Hover);
var isCircler = !Info.CanHover;
if (!atLandAltitude && Info.LandWhenIdle && Info.LandableTerrainTypes.Count > 0)
self.QueueActivity(new Land(self));
else if (isCircler && !atLandAltitude)
@@ -935,7 +937,7 @@ namespace OpenRA.Mods.Common.Traits
{
case "Land":
case "Move":
if (!Info.FlightDynamics.HasFlag(FlightDynamic.MoveIntoShroud) && order.Target.Type != TargetType.Invalid)
if (!Info.MoveIntoShroud && order.Target.Type != TargetType.Invalid)
{
var cell = self.World.Map.CellContaining(order.Target.CenterPosition);
if (!self.Owner.Shroud.IsExplored(cell))
@@ -960,7 +962,7 @@ namespace OpenRA.Mods.Common.Traits
if (orderString == "Move")
{
var cell = self.World.Map.Clamp(self.World.Map.CellContaining(order.Target.CenterPosition));
if (!Info.FlightDynamics.HasFlag(FlightDynamic.MoveIntoShroud) && !self.Owner.Shroud.IsExplored(cell))
if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(cell))
return;
if (!order.Queued)
@@ -973,7 +975,7 @@ namespace OpenRA.Mods.Common.Traits
else if (orderString == "Land")
{
var cell = self.World.Map.Clamp(self.World.Map.CellContaining(order.Target.CenterPosition));
if (!Info.FlightDynamics.HasFlag(FlightDynamic.MoveIntoShroud) && !self.Owner.Shroud.IsExplored(cell))
if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(cell))
return;
if (!order.Queued)
@@ -1003,7 +1005,7 @@ namespace OpenRA.Mods.Common.Traits
// Aircraft with TakeOffOnResupply would immediately take off again, so there's no point in automatically forcing
// them to land on a resupplier. For aircraft without it, it makes more sense to land than to idle above a
// free resupplier.
var forceLand = orderString == "ForceEnter" || !Info.FlightDynamics.HasFlag(FlightDynamic.TakeOffOnResupply);
var forceLand = orderString == "ForceEnter" || !Info.TakeOffOnResupply;
self.QueueActivity(order.Queued, new ReturnToBase(self, targetActor, forceLand));
}
else if (orderString == "Stop")
@@ -1028,7 +1030,7 @@ namespace OpenRA.Mods.Common.Traits
// Aircraft with TakeOffOnResupply would immediately take off again, so there's no point in forcing them to land
// on a resupplier. For aircraft without it, it makes more sense to land than to idle above a free resupplier.
self.QueueActivity(order.Queued, new ReturnToBase(self, null, !Info.FlightDynamics.HasFlag(FlightDynamic.TakeOffOnResupply)));
self.QueueActivity(order.Queued, new ReturnToBase(self, null, !Info.TakeOffOnResupply));
}
else if (orderString == "Scatter")
Nudge(self);
@@ -1146,7 +1148,7 @@ namespace OpenRA.Mods.Common.Traits
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
if (!explored && !aircraft.Info.FlightDynamics.HasFlag(FlightDynamic.MoveIntoShroud))
if (!explored && !aircraft.Info.MoveIntoShroud)
cursor = "move-blocked";
return true;