refactor Targetable into Targetable{Unit,Building} and ITargetable

This commit is contained in:
Bob
2010-11-03 22:28:53 +13:00
committed by Chris Forbes
parent 98dec6dc8e
commit 39b09780f6
15 changed files with 106 additions and 84 deletions

View File

@@ -1,42 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
#endregion
using System.Drawing;
using OpenRA.Graphics;
using System.Linq;
using System.Collections.Generic;
namespace OpenRA.Traits
{
public class TargetableInfo : ITraitInfo
{
public readonly string[] TargetTypes = {};
public virtual object Create( ActorInitializer init ) { return new Targetable(this); }
}
public class Targetable
{
protected TargetableInfo Info;
public Targetable(TargetableInfo info)
{
Info = info;
}
public virtual string[] TargetTypes
{
get { return Info.TargetTypes;}
}
public virtual IEnumerable<int2> TargetableSquares( Actor self )
{
yield return self.Location;
}
}
}

View File

@@ -237,4 +237,10 @@ namespace OpenRA.Traits
public Actor Actor { get { return IsActor ? actor : null; } }
public bool IsActor { get { return actor != null && !actor.Destroyed; } }
}
public interface ITargetable
{
string[] TargetTypes { get; }
IEnumerable<int2> TargetableSquares( Actor self );
}
}