Some cleanups

This commit is contained in:
penev92
2015-07-04 16:16:33 +03:00
parent 41cdc57ea5
commit c3fcd9a8a1
7 changed files with 16 additions and 17 deletions

View File

@@ -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<Actor> own, IEnumerable<Actor> enemy)
{
return RelativeValue(own, enemy, 100, SumOfValues<AttackBase>, (Actor a) =>
return RelativeValue(own, enemy, 100, SumOfValues<AttackBase>, a =>
{
var sumOfDamage = 0;
var arms = a.TraitsImplementing<Armament>();
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<DamageWarhead>().FirstOrDefault();
if (warhead != null)
sumOfDamage += warhead.Damage;
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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