diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 7331b1574a..38903a05c5 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Activities this.targetLineColor = targetLineColor; this.forceAttack = forceAttack; - attackTraits = self.TraitsImplementing().ToArray().Where(Exts.IsTraitEnabled); + attackTraits = self.TraitsImplementing().ToArray().Where(t => !t.IsTraitDisabled); revealsShroud = self.TraitsImplementing().ToArray(); facing = self.Trait(); positionable = self.Trait(); @@ -67,8 +67,7 @@ namespace OpenRA.Mods.Common.Activities // Lambdas can't use 'in' variables, so capture a copy for later var rangeTarget = target; - lastVisibleMaximumRange = attackTraits.Where(x => !x.IsTraitDisabled) - .Min(x => x.GetMaximumRangeVersusTarget(rangeTarget)); + lastVisibleMaximumRange = attackTraits.Min(x => x.GetMaximumRangeVersusTarget(rangeTarget)); if (target.Type == TargetType.Actor) { @@ -176,7 +175,7 @@ namespace OpenRA.Mods.Common.Activities return AttackStatus.UnableToAttack; var rs = revealsShroud - .Where(Exts.IsTraitEnabled) + .Where(t => !t.IsTraitDisabled) .MaxByOrDefault(s => s.Range); // Default to 2 cells if there are no active traits diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index bc8fff0455..01c7a4d01b 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Activities { foreach (var actor in self.World.ActorMap.GetActorsAt(cell)) { - if (!(actor.OccupiesSpace is Mobile move) || !move.IsTraitEnabled() || !move.IsLeaving()) + if (!(actor.OccupiesSpace is Mobile move) || move.IsTraitDisabled || !move.IsLeaving()) return false; } diff --git a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs index d3203e5539..bd3e3beb66 100644 --- a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs @@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Orders var cursor = OrderInner(world, mi) .SelectMany(o => o.Subject.TraitsImplementing()) - .Where(Exts.IsTraitEnabled) + .Where(t => !t.IsTraitDisabled) .Select(si => si.Info.Cursor) .FirstOrDefault(); diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 71e580883a..27b55cf3b2 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -325,7 +325,7 @@ namespace OpenRA.Mods.Common.Traits if (target.Type == TargetType.FrozenActor && !attack.Info.TargetFrozenActors && !forceAttack) { var rs = revealsShroud - .Where(Exts.IsTraitEnabled) + .Where(t => !t.IsTraitDisabled) .MaxByOrDefault(s => s.Range); // Default to 2 cells if there are no active traits diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index 484cf34665..161881aa1b 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -179,7 +179,7 @@ namespace OpenRA.Mods.Common.Traits : base(info) { var self = init.Self; - ActiveAttackBases = self.TraitsImplementing().ToArray().Where(Exts.IsTraitEnabled); + ActiveAttackBases = self.TraitsImplementing().ToArray().Where(t => !t.IsTraitDisabled); stance = init.GetValue(self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance); @@ -195,7 +195,7 @@ namespace OpenRA.Mods.Common.Traits activeTargetPriorities = self.TraitsImplementing() .OrderByDescending(ati => ati.Info.Priority).ToArray() - .Where(Exts.IsTraitEnabled).Select(atp => atp.Info); + .Where(t => !t.IsTraitDisabled).Select(atp => atp.Info); overrideAutoTarget = self.TraitsImplementing().ToArray(); notifyStanceChanged = self.TraitsImplementing().ToArray(); diff --git a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs index 01b5f0a211..7907bf7001 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Traits } // Less harvesters than refineries - build a new harvester - var unitBuilder = requestUnitProduction.FirstOrDefault(Exts.IsTraitEnabled); + var unitBuilder = requestUnitProduction.FirstEnabledTraitOrDefault(); if (unitBuilder != null && Info.HarvesterTypes.Count > 0) { var harvInfo = AIUtils.GetInfoByCommonName(Info.HarvesterTypes, player); diff --git a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs index de09596e38..fd650c2aa4 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/McvManagerBotModule.cs @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits // No construction yards - Build a new MCV if (ShouldBuildMCV()) { - var unitBuilder = requestUnitProduction.FirstOrDefault(Exts.IsTraitEnabled); + var unitBuilder = requestUnitProduction.FirstEnabledTraitOrDefault(); if (unitBuilder != null) { var mcvInfo = AIUtils.GetInfoByCommonName(Info.McvTypes, player); diff --git a/OpenRA.Mods.Common/Traits/Buildings/Exit.cs b/OpenRA.Mods.Common/Traits/Buildings/Exit.cs index fa104f2565..bef48ea614 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Exit.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Exit.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits return Enumerable.Empty(); var all = actor.TraitsImplementing() - .Where(Exts.IsTraitEnabled); + .Where(t => !t.IsTraitDisabled); if (string.IsNullOrEmpty(productionType)) return all; diff --git a/OpenRA.Mods.Common/Traits/CaptureManager.cs b/OpenRA.Mods.Common/Traits/CaptureManager.cs index b5de017ae8..527fda8d58 100644 --- a/OpenRA.Mods.Common/Traits/CaptureManager.cs +++ b/OpenRA.Mods.Common/Traits/CaptureManager.cs @@ -93,11 +93,11 @@ namespace OpenRA.Mods.Common.Traits enabledCapturable = self.TraitsImplementing() .ToArray() - .Where(Exts.IsTraitEnabled); + .Where(t => !t.IsTraitDisabled); enabledCaptures = self.TraitsImplementing() .ToArray() - .Where(Exts.IsTraitEnabled); + .Where(t => !t.IsTraitDisabled); RefreshCaptures(); RefreshCapturable(); diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 74d8ed61d7..2c08e7a819 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -604,7 +604,7 @@ namespace OpenRA.Mods.Common.Traits Activity WrapMove(Activity inner) { - var moveWrapper = moveWrappers.FirstOrDefault(Exts.IsTraitEnabled); + var moveWrapper = moveWrappers.FirstEnabledTraitOrDefault(); if (moveWrapper != null) return moveWrapper.WrapMove(inner); diff --git a/OpenRA.Mods.Common/Traits/RejectsOrders.cs b/OpenRA.Mods.Common/Traits/RejectsOrders.cs index 507bb8656c..787cdf147b 100644 --- a/OpenRA.Mods.Common/Traits/RejectsOrders.cs +++ b/OpenRA.Mods.Common/Traits/RejectsOrders.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits { public static bool AcceptsOrder(this Actor self, string orderString) { - var rejectsOrdersTraits = self.TraitsImplementing().Where(Exts.IsTraitEnabled).ToArray(); + var rejectsOrdersTraits = self.TraitsImplementing().Where(t => !t.IsTraitDisabled).ToArray(); if (rejectsOrdersTraits.Length == 0) return true; diff --git a/OpenRA.Mods.Common/Traits/Render/ReloadArmamentsBar.cs b/OpenRA.Mods.Common/Traits/Render/ReloadArmamentsBar.cs index 29e1e009ea..b098c515c4 100644 --- a/OpenRA.Mods.Common/Traits/Render/ReloadArmamentsBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/ReloadArmamentsBar.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render void INotifyCreated.Created(Actor self) { // Name check can be cached but enabled check can't. - armaments = self.TraitsImplementing().Where(a => info.Armaments.Contains(a.Info.Name)).ToArray().Where(Exts.IsTraitEnabled); + armaments = self.TraitsImplementing().Where(a => info.Armaments.Contains(a.Info.Name)).ToArray().Where(t => !t.IsTraitDisabled); } float ISelectionBar.GetValue() diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index f1b6e17d7c..b09035dac6 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Warheads if (!AffectsParent && victim == firedBy) continue; - var activeShapes = victim.TraitsImplementing().Where(Exts.IsTraitEnabled); + var activeShapes = victim.TraitsImplementing().Where(t => !t.IsTraitDisabled); if (!activeShapes.Any(s => s.DistanceFromEdge(victim, pos).Length <= 0)) continue;