Use heightmap to get correct groundlevel, fix additional behavior
This commit is contained in:
@@ -14,7 +14,7 @@ using OpenRA.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.")]
|
||||
public readonly int AttackTurnDelay = 50;
|
||||
@@ -25,11 +25,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class AttackPlane : AttackFrontal
|
||||
{
|
||||
public readonly AttackPlaneInfo AttackPlaneInfo;
|
||||
readonly AircraftInfo aircraftInfo;
|
||||
|
||||
public AttackPlane(Actor self, AttackPlaneInfo info)
|
||||
: base(self, info)
|
||||
{
|
||||
AttackPlaneInfo = info;
|
||||
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// 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
|
||||
{
|
||||
[Desc("Return to a player owned RearmBuildings. If none available, head back to base and circle over it.")]
|
||||
class ReturnOnIdleInfo : TraitInfo<ReturnOnIdle> { }
|
||||
|
||||
class ReturnOnIdle : INotifyIdle
|
||||
public class ReturnOnIdleInfo : ITraitInfo, Requires<AircraftInfo>
|
||||
{
|
||||
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)
|
||||
{
|
||||
// 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;
|
||||
|
||||
var airfield = ReturnToBase.ChooseAirfield(self, true);
|
||||
|
||||
Reference in New Issue
Block a user