diff --git a/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs b/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs index fc229fe4d5..8ba55a2971 100644 --- a/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs +++ b/OpenRA.Mods.Common/AI/AttackOrFleeFuzzy.cs @@ -12,8 +12,8 @@ using System; using System.Collections.Generic; using System.Linq; using AI.Fuzzy.Library; -using OpenRA.GameRules; using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.AI @@ -191,13 +191,13 @@ namespace OpenRA.Mods.Common.AI protected float RelativePower(IEnumerable own, IEnumerable enemy) { - return RelativeValue(own, enemy, 100, SumOfValues, (Actor a) => + return RelativeValue(own, enemy, 100, SumOfValues, a => { var sumOfDamage = 0; var arms = a.TraitsImplementing(); foreach (var arm in arms) { - var warhead = arm.Weapon.Warheads.Select(w => w as DamageWarhead).FirstOrDefault(w => w != null); + var warhead = arm.Weapon.Warheads.OfType().FirstOrDefault(); if (warhead != null) sumOfDamage += warhead.Damage; } diff --git a/OpenRA.Mods.Common/Lint/CheckDeathTypes.cs b/OpenRA.Mods.Common/Lint/CheckDeathTypes.cs index b3c6b427e9..d4f4276563 100644 --- a/OpenRA.Mods.Common/Lint/CheckDeathTypes.cs +++ b/OpenRA.Mods.Common/Lint/CheckDeathTypes.cs @@ -10,8 +10,8 @@ using System; using System.Linq; -using OpenRA.GameRules; using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.Lint diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 0cca327725..7f60c9e0bd 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -13,7 +13,7 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using OpenRA.Activities; -using OpenRA.GameRules; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits @@ -101,8 +101,11 @@ namespace OpenRA.Mods.Common.Traits { get { + if (IsTraitDisabled) + yield break; + var armament = Armaments.FirstOrDefault(a => a.Weapon.Warheads.Any(w => (w is DamageWarhead))); - if (armament == null || IsTraitDisabled) + if (armament == null) yield break; var negativeDamage = (armament.Weapon.Warheads.FirstOrDefault(w => (w is DamageWarhead)) as DamageWarhead).Damage < 0; diff --git a/OpenRA.Mods.Common/UtilityCommands/ActorStatsExport.cs b/OpenRA.Mods.Common/UtilityCommands/ActorStatsExport.cs index 9ae4a9510d..ab7368b82c 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ActorStatsExport.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ActorStatsExport.cs @@ -12,8 +12,8 @@ using System; using System.Collections.Generic; using System.Data; using System.Linq; -using OpenRA.GameRules; using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; namespace OpenRA.Mods.Common.UtilityCommands diff --git a/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs index a2232f7c3e..bdc7b03fbd 100644 --- a/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/HealthPercentageDamageWarhead.cs @@ -8,11 +8,8 @@ */ #endregion -using System; using System.Collections.Generic; using System.Linq; -using OpenRA.Effects; -using OpenRA.GameRules; using OpenRA.Traits; namespace OpenRA.Mods.Common.Warheads diff --git a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs index 5a1c1fa8fb..18723907f3 100644 --- a/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/SpreadDamageWarhead.cs @@ -10,9 +10,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using OpenRA.Effects; -using OpenRA.GameRules; using OpenRA.Traits; namespace OpenRA.Mods.Common.Warheads diff --git a/OpenRA.Mods.D2k/Warheads/ChangeOwnerWarhead.cs b/OpenRA.Mods.D2k/Warheads/ChangeOwnerWarhead.cs index ee7fbdd758..4c253f9e39 100644 --- a/OpenRA.Mods.D2k/Warheads/ChangeOwnerWarhead.cs +++ b/OpenRA.Mods.D2k/Warheads/ChangeOwnerWarhead.cs @@ -9,7 +9,7 @@ #endregion using System.Collections.Generic; -using OpenRA.GameRules; +using OpenRA.Mods.Common.Warheads; using OpenRA.Mods.D2k.Traits; using OpenRA.Traits; @@ -30,11 +30,12 @@ namespace OpenRA.Mods.D2k.Warheads foreach (var a in actors) { - if (a.Owner == firedBy.Owner) // don't do anything on friendly fire + // Don't do anything on friendly fire + if (a.Owner == firedBy.Owner) continue; if (Duration == 0) - a.ChangeOwner(firedBy.Owner); // permanent + a.ChangeOwner(firedBy.Owner); // Permanent else { var tempOwnerManager = a.TraitOrDefault(); @@ -44,7 +45,8 @@ namespace OpenRA.Mods.D2k.Warheads tempOwnerManager.ChangeOwner(a, firedBy.Owner, Duration); } - a.CancelActivity(); // stop shooting, you have got new enemies + // Stop shooting, you have new enemies + a.CancelActivity(); } } }