Move Targetable*, Seeds/StoresResource(s) and two RenderBuilding traits to Mods.Common

This commit is contained in:
reaperrr
2015-01-04 17:06:33 +01:00
parent b7a3b9fdbf
commit 7a8826f5e0
9 changed files with 15 additions and 21 deletions

View File

@@ -0,0 +1,48 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 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 COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class TargetableBuildingInfo : ITraitInfo, ITargetableInfo, Requires<BuildingInfo>
{
public readonly string[] TargetTypes = { };
public string[] GetTargetTypes() { return TargetTypes; }
public bool RequiresForceFire = false;
public object Create(ActorInitializer init) { return new TargetableBuilding(init.Self, this); }
}
public class TargetableBuilding : ITargetable
{
readonly TargetableBuildingInfo info;
readonly Building building;
public TargetableBuilding(Actor self, TargetableBuildingInfo info)
{
this.info = info;
building = self.Trait<Building>();
}
public string[] TargetTypes { get { return info.TargetTypes; } }
public bool TargetableBy(Actor self, Actor byActor) { return true; }
public IEnumerable<WPos> TargetablePositions(Actor self)
{
return building.OccupiedCells().Select(c => self.World.Map.CenterOfCell(c.First));
}
public bool RequiresForceFire { get { return info.RequiresForceFire; } }
}
}