Merge pull request #8938 from abcdefg30/heliheigth
Have flying actors account for terrain height
This commit is contained in:
@@ -37,6 +37,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public static void FlyToward(Actor self, Plane plane, int desiredFacing, WDist desiredAltitude)
|
public static void FlyToward(Actor self, Plane plane, int desiredFacing, WDist desiredAltitude)
|
||||||
{
|
{
|
||||||
|
desiredAltitude = new WDist(plane.CenterPosition.Z) + desiredAltitude - self.World.Map.DistanceAboveTerrain(plane.CenterPosition);
|
||||||
|
|
||||||
var move = plane.FlyStep(plane.Facing);
|
var move = plane.FlyStep(plane.Facing);
|
||||||
var altitude = plane.CenterPosition.Z;
|
var altitude = plane.CenterPosition.Z;
|
||||||
|
|
||||||
@@ -71,7 +73,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var desiredFacing = Util.GetFacing(d, plane.Facing);
|
var desiredFacing = Util.GetFacing(d, plane.Facing);
|
||||||
|
|
||||||
// Don't turn until we've reached the cruise altitude
|
// Don't turn until we've reached the cruise altitude
|
||||||
if (plane.CenterPosition.Z < plane.Info.CruiseAltitude.Length)
|
var targetAltitude = plane.CenterPosition.Z + plane.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(plane.CenterPosition).Length;
|
||||||
|
if (plane.CenterPosition.Z < targetAltitude)
|
||||||
desiredFacing = plane.Facing;
|
desiredFacing = plane.Facing;
|
||||||
|
|
||||||
FlyToward(self, plane, desiredFacing, plane.Info.CruiseAltitude);
|
FlyToward(self, plane, desiredFacing, plane.Info.CruiseAltitude);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public static bool AdjustAltitude(Actor self, Helicopter helicopter, WDist targetAltitude)
|
public static bool AdjustAltitude(Actor self, Helicopter helicopter, WDist targetAltitude)
|
||||||
{
|
{
|
||||||
|
targetAltitude = new WDist(helicopter.CenterPosition.Z) + targetAltitude - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition);
|
||||||
|
|
||||||
var altitude = helicopter.CenterPosition.Z;
|
var altitude = helicopter.CenterPosition.Z;
|
||||||
if (altitude == targetAltitude.Length)
|
if (altitude == targetAltitude.Length)
|
||||||
return false;
|
return false;
|
||||||
@@ -85,7 +87,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// The next move would overshoot, so just set the final position
|
// The next move would overshoot, so just set the final position
|
||||||
if (dist.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
if (dist.HorizontalLengthSquared < move.HorizontalLengthSquared)
|
||||||
{
|
{
|
||||||
helicopter.SetPosition(self, pos + new WVec(0, 0, helicopter.Info.CruiseAltitude.Length - pos.Z));
|
var targetAltitude = helicopter.CenterPosition.Z + helicopter.Info.CruiseAltitude.Length - self.World.Map.DistanceAboveTerrain(helicopter.CenterPosition).Length;
|
||||||
|
helicopter.SetPosition(self, pos + new WVec(0, 0, targetAltitude - pos.Z));
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user