Remove IsPlane hack
The new VTOL boolean together with CanHover is enough to replace this.
This commit is contained in:
committed by
Matthias Mailänder
parent
28ffcfea3c
commit
2f66f83051
@@ -19,19 +19,19 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[ScriptPropertyGroup("Movement")]
|
[ScriptPropertyGroup("Movement")]
|
||||||
public class AircraftProperties : ScriptActorProperties, Requires<AircraftInfo>
|
public class AircraftProperties : ScriptActorProperties, Requires<AircraftInfo>
|
||||||
{
|
{
|
||||||
readonly bool isPlane;
|
readonly AircraftInfo aircraftInfo;
|
||||||
|
|
||||||
public AircraftProperties(ScriptContext context, Actor self)
|
public AircraftProperties(ScriptContext context, Actor self)
|
||||||
: base(context, self)
|
: base(context, self)
|
||||||
{
|
{
|
||||||
isPlane = self.Trait<Aircraft>().IsPlane;
|
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ScriptActorPropertyActivity]
|
[ScriptActorPropertyActivity]
|
||||||
[Desc("Fly within the cell grid.")]
|
[Desc("Fly within the cell grid.")]
|
||||||
public void Move(CPos cell)
|
public void Move(CPos cell)
|
||||||
{
|
{
|
||||||
if (isPlane)
|
if (!aircraftInfo.CanHover)
|
||||||
Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell)));
|
Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell)));
|
||||||
else
|
else
|
||||||
Self.QueueActivity(new HeliFly(Self, Target.FromCell(Self.World, cell)));
|
Self.QueueActivity(new HeliFly(Self, Target.FromCell(Self.World, cell)));
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Return to the base, which is either the destination given, or an auto-selected one otherwise.")]
|
[Desc("Return to the base, which is either the destination given, or an auto-selected one otherwise.")]
|
||||||
public void ReturnToBase(Actor destination = null)
|
public void ReturnToBase(Actor destination = null)
|
||||||
{
|
{
|
||||||
if (isPlane)
|
if (!aircraftInfo.CanHover)
|
||||||
Self.QueueActivity(new ReturnToBase(Self, false, destination));
|
Self.QueueActivity(new ReturnToBase(Self, false, destination));
|
||||||
else
|
else
|
||||||
Self.QueueActivity(new HeliReturnToBase(Self, false, destination));
|
Self.QueueActivity(new HeliReturnToBase(Self, false, destination));
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
||||||
|
|
||||||
public readonly bool IsPlane;
|
|
||||||
public readonly AircraftInfo Info;
|
public readonly AircraftInfo Info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
@@ -192,11 +191,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (init.Contains<CenterPositionInit>())
|
if (init.Contains<CenterPositionInit>())
|
||||||
SetPosition(self, init.Get<CenterPositionInit, WPos>());
|
SetPosition(self, init.Get<CenterPositionInit, WPos>());
|
||||||
|
|
||||||
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
|
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : Info.InitialFacing;
|
||||||
|
|
||||||
// TODO: HACK: This is a hack until we can properly distinguish between airplane and helicopter!
|
|
||||||
// Or until the activities get unified enough so that it doesn't matter.
|
|
||||||
IsPlane = !info.CanHover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<VariableObserver> GetVariableObservers()
|
public virtual IEnumerable<VariableObserver> GetVariableObservers()
|
||||||
@@ -553,7 +548,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveTo(CPos cell, int nearEnough)
|
public Activity MoveTo(CPos cell, int nearEnough)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new FlyAndContinueWithCirclesWhenIdle(self, Target.FromCell(self.World, cell));
|
return new FlyAndContinueWithCirclesWhenIdle(self, Target.FromCell(self.World, cell));
|
||||||
|
|
||||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||||
@@ -561,7 +556,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveTo(CPos cell, Actor ignoreActor)
|
public Activity MoveTo(CPos cell, Actor ignoreActor)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new FlyAndContinueWithCirclesWhenIdle(self, Target.FromCell(self.World, cell));
|
return new FlyAndContinueWithCirclesWhenIdle(self, Target.FromCell(self.World, cell));
|
||||||
|
|
||||||
return new HeliFly(self, Target.FromCell(self.World, cell));
|
return new HeliFly(self, Target.FromCell(self.World, cell));
|
||||||
@@ -569,7 +564,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist range)
|
public Activity MoveWithinRange(Target target, WDist range)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new FlyAndContinueWithCirclesWhenIdle(self, target, WDist.Zero, range);
|
return new FlyAndContinueWithCirclesWhenIdle(self, target, WDist.Zero, range);
|
||||||
|
|
||||||
return new HeliFly(self, target, WDist.Zero, range);
|
return new HeliFly(self, target, WDist.Zero, range);
|
||||||
@@ -577,7 +572,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange)
|
public Activity MoveWithinRange(Target target, WDist minRange, WDist maxRange)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new FlyAndContinueWithCirclesWhenIdle(self, target, minRange, maxRange);
|
return new FlyAndContinueWithCirclesWhenIdle(self, target, minRange, maxRange);
|
||||||
|
|
||||||
return new HeliFly(self, target, minRange, maxRange);
|
return new HeliFly(self, target, minRange, maxRange);
|
||||||
@@ -585,7 +580,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange)
|
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new FlyFollow(self, target, minRange, maxRange);
|
return new FlyFollow(self, target, minRange, maxRange);
|
||||||
|
|
||||||
return new Follow(self, target, minRange, maxRange);
|
return new Follow(self, target, minRange, maxRange);
|
||||||
@@ -593,7 +588,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new Fly(self, Target.FromCell(self.World, cell));
|
return new Fly(self, Target.FromCell(self.World, cell));
|
||||||
|
|
||||||
return new HeliFly(self, Target.FromCell(self.World, cell, subCell));
|
return new HeliFly(self, Target.FromCell(self.World, cell, subCell));
|
||||||
@@ -601,7 +596,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveToTarget(Actor self, Target target)
|
public Activity MoveToTarget(Actor self, Target target)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5));
|
return new Fly(self, target, WDist.FromCells(3), WDist.FromCells(5));
|
||||||
|
|
||||||
return ActivityUtils.SequenceActivities(new HeliFly(self, target), new Turn(self, Info.InitialFacing));
|
return ActivityUtils.SequenceActivities(new HeliFly(self, target), new Turn(self, Info.InitialFacing));
|
||||||
@@ -609,7 +604,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public Activity MoveIntoTarget(Actor self, Target target)
|
public Activity MoveIntoTarget(Actor self, Target target)
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.VTOL)
|
||||||
return new Land(self, target);
|
return new Land(self, target);
|
||||||
|
|
||||||
return new HeliLand(self, false);
|
return new HeliLand(self, false);
|
||||||
@@ -618,7 +613,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
||||||
{
|
{
|
||||||
// TODO: Ignore repulsion when moving
|
// TODO: Ignore repulsion when moving
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
return ActivityUtils.SequenceActivities(
|
return ActivityUtils.SequenceActivities(
|
||||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||||
new Fly(self, Target.FromPos(toPos)));
|
new Fly(self, Target.FromPos(toPos)));
|
||||||
@@ -703,7 +698,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
self.SetTargetLine(target, Color.Green);
|
self.SetTargetLine(target, Color.Green);
|
||||||
|
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
self.QueueActivity(order.Queued, new FlyAndContinueWithCirclesWhenIdle(self, target));
|
self.QueueActivity(order.Queued, new FlyAndContinueWithCirclesWhenIdle(self, target));
|
||||||
else
|
else
|
||||||
self.QueueActivity(order.Queued, new HeliFlyAndLandWhenIdle(self, target, Info));
|
self.QueueActivity(order.Queued, new HeliFlyAndLandWhenIdle(self, target, Info));
|
||||||
@@ -715,7 +710,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (Reservable.IsReserved(order.TargetActor))
|
if (Reservable.IsReserved(order.TargetActor))
|
||||||
{
|
{
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply));
|
self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply));
|
||||||
else
|
else
|
||||||
self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply));
|
self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply));
|
||||||
@@ -724,7 +719,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
|
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
|
||||||
|
|
||||||
if (IsPlane)
|
if (!Info.CanHover && !Info.VTOL)
|
||||||
{
|
{
|
||||||
self.QueueActivity(order.Queued, ActivityUtils.SequenceActivities(
|
self.QueueActivity(order.Queued, ActivityUtils.SequenceActivities(
|
||||||
new ReturnToBase(self, Info.AbortOnResupply, order.TargetActor),
|
new ReturnToBase(self, Info.AbortOnResupply, order.TargetActor),
|
||||||
@@ -773,7 +768,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
UnReserve();
|
UnReserve();
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
if (IsPlane)
|
if (!Info.CanHover)
|
||||||
self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply, null, false));
|
self.QueueActivity(new ReturnToBase(self, Info.AbortOnResupply, null, false));
|
||||||
else
|
else
|
||||||
self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply, null, false));
|
self.QueueActivity(new HeliReturnToBase(self, Info.AbortOnResupply, null, false));
|
||||||
|
|||||||
Reference in New Issue
Block a user