Merge pull request #10168 from teees/heightmap-fixes
Use heightmap to get correct groundlevel, use AircraftInfo for correct ground level
This commit is contained in:
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
public class AttackPlaneInfo : AttackFrontalInfo
|
public class AttackPlaneInfo : AttackFrontalInfo, Requires<AircraftInfo>
|
||||||
{
|
{
|
||||||
[Desc("Delay, in game ticks, before turning to attack.")]
|
[Desc("Delay, in game ticks, before turning to attack.")]
|
||||||
public readonly int AttackTurnDelay = 50;
|
public readonly int AttackTurnDelay = 50;
|
||||||
@@ -25,11 +25,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public class AttackPlane : AttackFrontal
|
public class AttackPlane : AttackFrontal
|
||||||
{
|
{
|
||||||
public readonly AttackPlaneInfo AttackPlaneInfo;
|
public readonly AttackPlaneInfo AttackPlaneInfo;
|
||||||
|
readonly AircraftInfo aircraftInfo;
|
||||||
|
|
||||||
public AttackPlane(Actor self, AttackPlaneInfo info)
|
public AttackPlane(Actor self, AttackPlaneInfo info)
|
||||||
: base(self, info)
|
: base(self, info)
|
||||||
{
|
{
|
||||||
AttackPlaneInfo = info;
|
AttackPlaneInfo = info;
|
||||||
|
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
public override Activity GetAttackActivity(Actor self, Target newTarget, bool allowMove, bool forceAttack)
|
||||||
@@ -40,7 +42,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
protected override bool CanAttack(Actor self, Target target)
|
protected override bool CanAttack(Actor self, Target target)
|
||||||
{
|
{
|
||||||
// Don't fire while landed or when outside the map.
|
// Don't fire while landed or when outside the map.
|
||||||
return base.CanAttack(self, target) && self.CenterPosition.Z > 0 && self.World.Map.Contains(self.Location);
|
return base.CanAttack(self, target)
|
||||||
|
&& self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length >= aircraftInfo.MinAirborneAltitude
|
||||||
|
&& self.World.Map.Contains(self.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,14 +15,24 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Return to a player owned RearmBuildings. If none available, head back to base and circle over it.")]
|
[Desc("Return to a player owned RearmBuildings. If none available, head back to base and circle over it.")]
|
||||||
class ReturnOnIdleInfo : TraitInfo<ReturnOnIdle> { }
|
public class ReturnOnIdleInfo : ITraitInfo, Requires<AircraftInfo>
|
||||||
|
|
||||||
class ReturnOnIdle : INotifyIdle
|
|
||||||
{
|
{
|
||||||
|
public object Create(ActorInitializer init) { return new ReturnOnIdle(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ReturnOnIdle : INotifyIdle
|
||||||
|
{
|
||||||
|
readonly AircraftInfo aircraftInfo;
|
||||||
|
|
||||||
|
public ReturnOnIdle(Actor self, ReturnOnIdleInfo info)
|
||||||
|
{
|
||||||
|
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
public void TickIdle(Actor self)
|
public void TickIdle(Actor self)
|
||||||
{
|
{
|
||||||
// We're on the ground, let's stay there.
|
// We're on the ground, let's stay there.
|
||||||
if (self.CenterPosition.Z == 0)
|
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length < aircraftInfo.MinAirborneAltitude)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var airfield = ReturnToBase.ChooseAirfield(self, true);
|
var airfield = ReturnToBase.ChooseAirfield(self, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user