Fix StyleCop issues in TechTree.

This commit is contained in:
Paul Chote
2013-12-08 21:40:59 +13:00
parent e76dbcd4bf
commit bbc19df512

View File

@@ -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<string, List<Actor>> GatherBuildables( Player player )
static Cache<string, List<Actor>> GatherBuildables(Player player)
{
var ret = new Cache<string, List<Actor>>( x => new List<Actor>() );
var ret = new Cache<string, List<Actor>>(x => new List<Actor>());
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<string, List<Actor>> 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<string> ProvidesPrerequisites { get { yield return Info.Prerequisite; } }
public IEnumerable<string> ProvidesPrerequisites { get { yield return info.Prerequisite; } }
public ProvidesCustomPrerequisite(ProvidesCustomPrerequisiteInfo info)
{
Info = info;
this.info = info;
}
}
}