Add dedicated TDGunboat traits

And get rid of Mobile.OnRails hack.
This commit is contained in:
reaperrr
2017-07-14 02:28:01 +02:00
committed by Oliver Brakmann
parent 3bdd35fd2d
commit 94fa24088b
8 changed files with 323 additions and 29 deletions

View File

@@ -63,7 +63,6 @@ namespace OpenRA.Mods.Common.Traits
readonly IMove move;
readonly Target target;
readonly bool forceAttack;
readonly bool onRailsHack;
bool hasTicked;
public AttackActivity(Actor self, Target target, bool allowMove, bool forceAttack)
@@ -71,14 +70,6 @@ namespace OpenRA.Mods.Common.Traits
attack = self.Trait<AttackFollow>();
move = allowMove ? self.TraitOrDefault<IMove>() : null;
// HACK: Mobile.OnRails is horrible. Blergh.
var mobile = move as Mobile;
if (mobile != null && mobile.Info.OnRails)
{
move = null;
onRailsHack = true;
}
this.target = target;
this.forceAttack = forceAttack;
}
@@ -112,14 +103,12 @@ namespace OpenRA.Mods.Common.Traits
if (move != null)
return ActivityUtils.SequenceActivities(move.MoveFollow(self, target, weapon.Weapon.MinRange, maxRange), this);
if (!onRailsHack &&
target.IsInRange(self.CenterPosition, weapon.MaxRange()) &&
if (target.IsInRange(self.CenterPosition, weapon.MaxRange()) &&
!target.IsInRange(self.CenterPosition, weapon.Weapon.MinRange))
return this;
}
if (!onRailsHack)
attack.Target = Target.Invalid;
attack.Target = Target.Invalid;
return NextActivity;
}