refactor Targetable into Targetable{Unit,Building} and ITargetable
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
using System;
|
||||
#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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -6,19 +16,23 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class TargetableBuildingInfo : TargetableInfo, ITraitPrerequisite<BuildingInfo>
|
||||
class TargetableBuildingInfo : ITraitInfo, ITraitPrerequisite<BuildingInfo>
|
||||
{
|
||||
public override object Create( ActorInitializer init ) { return new TargetableBuilding( this ); }
|
||||
public readonly string[] TargetTypes = { };
|
||||
public object Create( ActorInitializer init ) { return new TargetableBuilding( this ); }
|
||||
}
|
||||
|
||||
class TargetableBuilding : Targetable
|
||||
class TargetableBuilding : ITargetable
|
||||
{
|
||||
readonly TargetableBuildingInfo info;
|
||||
public TargetableBuilding( TargetableBuildingInfo info )
|
||||
: base( info )
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public override IEnumerable<int2> TargetableSquares( Actor self )
|
||||
public string[] TargetTypes { get { return info.TargetTypes; } }
|
||||
|
||||
public IEnumerable<int2> TargetableSquares( Actor self )
|
||||
{
|
||||
return self.Trait<Building>().OccupiedCells();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user