Don't allow movement for actors without IMove

However, this does not check if any existing IMove traits are enabled.
This commit is contained in:
abcdefg30
2019-09-26 21:59:54 +02:00
committed by reaperrr
parent 980c0c9cd4
commit a586f10875

View File

@@ -127,6 +127,9 @@ namespace OpenRA.Mods.Common.Traits
public class AutoTarget : ConditionalTrait<AutoTargetInfo>, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyOwnerChanged
{
public readonly IEnumerable<AttackBase> ActiveAttackBases;
readonly bool allowMovement;
[Sync]
int nextScanTime = 0;
@@ -187,6 +190,8 @@ namespace OpenRA.Mods.Common.Traits
stance = self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance;
PredictedStance = stance;
allowMovement = Info.AllowMovement && self.TraitOrDefault<IMove>() != null;
}
protected override void Created(Actor self)
@@ -244,7 +249,7 @@ namespace OpenRA.Mods.Common.Traits
}
// Don't fire at an invisible enemy when we can't move to reveal it
var allowMove = Info.AllowMovement && Stance > UnitStance.Defend;
var allowMove = allowMovement && Stance > UnitStance.Defend;
if (!allowMove && !attacker.CanBeViewedByPlayer(self.Owner))
return;
@@ -267,7 +272,7 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled || Stance < UnitStance.Defend)
return;
var allowMove = Info.AllowMovement && Stance > UnitStance.Defend;
var allowMove = allowMovement && Stance > UnitStance.Defend;
var allowTurn = Info.AllowTurning && Stance > UnitStance.HoldFire;
ScanAndAttack(self, allowMove, allowTurn);
}