Clean up Attack*.

This commit is contained in:
Paul Chote
2014-03-17 12:24:17 +13:00
parent 96cc1276c2
commit 9d1526f4e7
8 changed files with 147 additions and 115 deletions

View File

@@ -13,6 +13,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -35,6 +36,7 @@ namespace OpenRA.Mods.RA
protected Lazy<IFacing> facing;
Lazy<IEnumerable<Armament>> armaments;
protected IEnumerable<Armament> Armaments { get { return armaments.Value; } }
protected Lazy<Building> building;
public AttackBase(Actor self, AttackBaseInfo info)
{
@@ -43,6 +45,7 @@ namespace OpenRA.Mods.RA
armaments = Lazy.New(() => self.TraitsImplementing<Armament>());
facing = Lazy.New(() => self.TraitOrDefault<IFacing>());
building = Lazy.New(() => self.TraitOrDefault<Building>());
}
protected virtual bool CanAttack(Actor self, Target target)
@@ -50,6 +53,10 @@ namespace OpenRA.Mods.RA
if (!self.IsInWorld)
return false;
// Building is under construction or is being sold
if (building.Value != null && !building.Value.BuildComplete)
return false;
if (!target.IsValidFor(self))
return false;