diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index f112c31479..5c474f3acf 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -259,12 +259,19 @@ namespace OpenRA.Mods.Common.Traits } [Desc("Will not get automatically targeted by enemy (like walls)")] - class AutoTargetIgnoreInfo : TraitInfo { } - class AutoTargetIgnore : IPreventsAutoTarget + class AutoTargetIgnoreInfo : ConditionalTraitInfo { + public override object Create(ActorInitializer init) { return new AutoTargetIgnore(this); } + } + + class AutoTargetIgnore : ConditionalTrait, IPreventsAutoTarget + { + public AutoTargetIgnore(AutoTargetIgnoreInfo info) + : base(info) { } + public bool PreventsAutoTarget(Actor self, Actor attacker) { - return true; + return !IsTraitDisabled; } }