Replace ActorInfo.Traits.WithInterface with ActorInfo.TraitInfos<T>()

This commit is contained in:
atlimit8
2015-09-19 13:22:00 -05:00
parent 6e39a5e264
commit 9acf121eb1
48 changed files with 76 additions and 77 deletions

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Graphics
var width = b.Width;
var height = b.Height + heightOffset;
var resources = resourceRules.Actors["world"].Traits.WithInterface<ResourceTypeInfo>()
var resources = resourceRules.Actors["world"].TraitInfos<ResourceTypeInfo>()
.ToDictionary(r => r.ResourceType, r => r.TerrainType);
var bitmapData = terrain.LockBits(terrain.Bounds(),

View File

@@ -28,8 +28,8 @@ namespace OpenRA
public MapPlayers(Ruleset rules, int playerCount)
{
var firstFaction = rules.Actors["world"].Traits
.WithInterface<FactionInfo>().First(f => f.Selectable).InternalName;
var firstFaction = rules.Actors["world"].TraitInfos<FactionInfo>()
.First(f => f.Selectable).InternalName;
Players = new Dictionary<string, PlayerReference>
{

View File

@@ -53,8 +53,8 @@ namespace OpenRA
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
{
var selectableFactions = world.Map.Rules.Actors["world"].Traits
.WithInterface<FactionInfo>().Where(f => !requireSelectable || f.Selectable)
var selectableFactions = world.Map.Rules.Actors["world"].TraitInfos<FactionInfo>()
.Where(f => !requireSelectable || f.Selectable)
.ToList();
var selected = selectableFactions.FirstOrDefault(f => f.InternalName == name)
@@ -75,7 +75,7 @@ namespace OpenRA
static FactionInfo ChooseDisplayFaction(World world, string factionName)
{
var factions = world.Map.Rules.Actors["world"].Traits.WithInterface<FactionInfo>().ToArray();
var factions = world.Map.Rules.Actors["world"].TraitInfos<FactionInfo>().ToArray();
return factions.FirstOrDefault(f => f.InternalName == factionName) ?? factions.First();
}

View File

@@ -394,7 +394,7 @@ namespace OpenRA
public static string SanitizedPlayerName(string dirty)
{
var forbiddenNames = new string[] { "Open", "Closed" };
var botNames = OpenRA.Game.ModData.DefaultRules.Actors["player"].Traits.WithInterface<IBotInfo>().Select(t => t.Name);
var botNames = OpenRA.Game.ModData.DefaultRules.Actors["player"].TraitInfos<IBotInfo>().Select(t => t.Name);
var clean = SanitizedName(dirty);

View File

@@ -128,7 +128,7 @@ namespace OpenRA.Traits
bool HasVoice(Actor self, string voice);
}
public interface IDemolishableInfo { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); }
public interface IDemolishableInfo : ITraitInfo { bool IsValidTarget(ActorInfo actorInfo, Actor saboteur); }
public interface IDemolishable
{
void Demolish(Actor self, Actor saboteur);
@@ -172,7 +172,7 @@ namespace OpenRA.Traits
IEnumerable<Pair<CPos, Color>> RadarSignatureCells(Actor self);
}
public interface IDefaultVisibilityInfo { }
public interface IDefaultVisibilityInfo : ITraitInfo { }
public interface IDefaultVisibility { bool IsVisible(Actor self, Player byPlayer); }
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
public interface IFogVisibilityModifier { bool HasFogVisibility(Player byPlayer); }
@@ -286,7 +286,7 @@ namespace OpenRA.Traits
public interface IWorldLoaded { void WorldLoaded(World w, WorldRenderer wr); }
public interface ICreatePlayers { void CreatePlayers(World w); }
public interface IBotInfo { string Name { get; } }
public interface IBotInfo : ITraitInfo { string Name { get; } }
public interface IBot
{
void Activate(Player p);