diff --git a/OpenRA.Mods.RA/Player/TechTree.cs b/OpenRA.Mods.RA/Player/TechTree.cs index 32bd2f2ec3..cb627cca48 100755 --- a/OpenRA.Mods.RA/Player/TechTree.cs +++ b/OpenRA.Mods.RA/Player/TechTree.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2013 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, @@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA { public class TechTreeInfo : ITraitInfo { - public object Create(ActorInitializer init) { return new TechTree(init);} + public object Create(ActorInitializer init) { return new TechTree(init); } } public class TechTree @@ -42,23 +42,23 @@ namespace OpenRA.Mods.RA public void Update() { var buildables = GatherBuildables(player); - foreach(var w in watchers) + foreach (var w in watchers) w.Update(buildables); } public void Add(string key, BuildableInfo info, ITechTreeElement tte) { - watchers.Add(new Watcher( key, info, tte )); + watchers.Add(new Watcher(key, info, tte)); } public void Remove(string key) { - watchers.RemoveAll(x => x.key == key); + watchers.RemoveAll(x => x.Key == key); } - static Cache> GatherBuildables( Player player ) + static Cache> GatherBuildables(Player player) { - var ret = new Cache>( x => new List() ); + var ret = new Cache>(x => new List()); if (player == null) return ret; @@ -89,16 +89,17 @@ namespace OpenRA.Mods.RA class Watcher { - public readonly string key; + public readonly string Key; + // strings may be either actor type, or "alternate name" key - public readonly string[] prerequisites; - public readonly ITechTreeElement watcher; + readonly string[] prerequisites; + readonly ITechTreeElement watcher; bool hasPrerequisites; int buildLimit; public Watcher(string key, BuildableInfo info, ITechTreeElement watcher) { - this.key = key; + this.Key = key; this.prerequisites = info.Prerequisites; this.watcher = watcher; this.hasPrerequisites = false; @@ -112,15 +113,14 @@ namespace OpenRA.Mods.RA public void Update(Cache> buildables) { - var hasReachedBuildLimit = buildLimit > 0 && buildables[key].Count >= buildLimit; - + var hasReachedBuildLimit = buildLimit > 0 && buildables[Key].Count >= buildLimit; var nowHasPrerequisites = HasPrerequisites(buildables) && !hasReachedBuildLimit; - if( nowHasPrerequisites && !hasPrerequisites ) - watcher.PrerequisitesAvailable(key); + if (nowHasPrerequisites && !hasPrerequisites) + watcher.PrerequisitesAvailable(Key); - if( !nowHasPrerequisites && hasPrerequisites ) - watcher.PrerequisitesUnavailable(key); + if (!nowHasPrerequisites && hasPrerequisites) + watcher.PrerequisitesUnavailable(Key); hasPrerequisites = nowHasPrerequisites; } @@ -131,18 +131,18 @@ namespace OpenRA.Mods.RA { public readonly string Prerequisite; - public object Create(ActorInitializer init) { return new ProvidesCustomPrerequisite(this);} + public object Create(ActorInitializer init) { return new ProvidesCustomPrerequisite(this); } } public class ProvidesCustomPrerequisite : ITechTreePrerequisite { - ProvidesCustomPrerequisiteInfo Info; + ProvidesCustomPrerequisiteInfo info; - public IEnumerable ProvidesPrerequisites { get { yield return Info.Prerequisite; } } + public IEnumerable ProvidesPrerequisites { get { yield return info.Prerequisite; } } public ProvidesCustomPrerequisite(ProvidesCustomPrerequisiteInfo info) { - Info = info; + this.info = info; } } }