Generalize Land activities Aircraft caching naming
To make a possible future merger (or inheritance or other code-sharing) of these activities easier.
This commit is contained in:
@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
public class HeliLand : Activity
|
public class HeliLand : Activity
|
||||||
{
|
{
|
||||||
readonly Aircraft helicopter;
|
readonly Aircraft aircraft;
|
||||||
readonly WDist landAltitude;
|
readonly WDist landAltitude;
|
||||||
readonly bool requireSpace;
|
readonly bool requireSpace;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
this.requireSpace = requireSpace;
|
this.requireSpace = requireSpace;
|
||||||
this.landAltitude = landAltitude;
|
this.landAltitude = landAltitude;
|
||||||
helicopter = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -37,16 +37,16 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (IsCanceled)
|
if (IsCanceled)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (requireSpace && !helicopter.CanLand(self.Location))
|
if (requireSpace && !aircraft.CanLand(self.Location))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
if (!playedSound && helicopter.Info.LandingSound != null && !self.IsAtGroundLevel())
|
if (!playedSound && aircraft.Info.LandingSound != null && !self.IsAtGroundLevel())
|
||||||
{
|
{
|
||||||
Game.Sound.Play(SoundType.World, helicopter.Info.LandingSound);
|
Game.Sound.Play(SoundType.World, aircraft.Info.LandingSound);
|
||||||
playedSound = true;
|
playedSound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HeliFly.AdjustAltitude(self, helicopter, landAltitude))
|
if (HeliFly.AdjustAltitude(self, aircraft, landAltitude))
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public class Land : Activity
|
public class Land : Activity
|
||||||
{
|
{
|
||||||
readonly Target target;
|
readonly Target target;
|
||||||
readonly Aircraft plane;
|
readonly Aircraft aircraft;
|
||||||
|
|
||||||
public Land(Actor self, Target t)
|
public Land(Actor self, Target t)
|
||||||
{
|
{
|
||||||
target = t;
|
target = t;
|
||||||
plane = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -37,15 +37,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var d = target.CenterPosition - self.CenterPosition;
|
var d = target.CenterPosition - self.CenterPosition;
|
||||||
|
|
||||||
// The next move would overshoot, so just set the final position
|
// The next move would overshoot, so just set the final position
|
||||||
var move = plane.FlyStep(plane.Facing);
|
var move = aircraft.FlyStep(aircraft.Facing);
|
||||||
if (d.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
if (d.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
||||||
{
|
{
|
||||||
plane.SetPosition(self, target.CenterPosition);
|
aircraft.SetPosition(self, target.CenterPosition);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
|
var landingAlt = self.World.Map.DistanceAboveTerrain(target.CenterPosition);
|
||||||
Fly.FlyToward(self, plane, d.Yaw.Facing, landingAlt);
|
Fly.FlyToward(self, aircraft, d.Yaw.Facing, landingAlt);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user