Fix StyleCop issues in TechTree.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class TechTreeInfo : ITraitInfo
|
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
|
public class TechTree
|
||||||
@@ -42,23 +42,23 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
var buildables = GatherBuildables(player);
|
var buildables = GatherBuildables(player);
|
||||||
foreach(var w in watchers)
|
foreach (var w in watchers)
|
||||||
w.Update(buildables);
|
w.Update(buildables);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string key, BuildableInfo info, ITechTreeElement tte)
|
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)
|
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)
|
if (player == null)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -89,16 +89,17 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class Watcher
|
class Watcher
|
||||||
{
|
{
|
||||||
public readonly string key;
|
public readonly string Key;
|
||||||
|
|
||||||
// strings may be either actor type, or "alternate name" key
|
// strings may be either actor type, or "alternate name" key
|
||||||
public readonly string[] prerequisites;
|
readonly string[] prerequisites;
|
||||||
public readonly ITechTreeElement watcher;
|
readonly ITechTreeElement watcher;
|
||||||
bool hasPrerequisites;
|
bool hasPrerequisites;
|
||||||
int buildLimit;
|
int buildLimit;
|
||||||
|
|
||||||
public Watcher(string key, BuildableInfo info, ITechTreeElement watcher)
|
public Watcher(string key, BuildableInfo info, ITechTreeElement watcher)
|
||||||
{
|
{
|
||||||
this.key = key;
|
this.Key = key;
|
||||||
this.prerequisites = info.Prerequisites;
|
this.prerequisites = info.Prerequisites;
|
||||||
this.watcher = watcher;
|
this.watcher = watcher;
|
||||||
this.hasPrerequisites = false;
|
this.hasPrerequisites = false;
|
||||||
@@ -112,15 +113,14 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Update(Cache<string, List<Actor>> buildables)
|
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;
|
var nowHasPrerequisites = HasPrerequisites(buildables) && !hasReachedBuildLimit;
|
||||||
|
|
||||||
if( nowHasPrerequisites && !hasPrerequisites )
|
if (nowHasPrerequisites && !hasPrerequisites)
|
||||||
watcher.PrerequisitesAvailable(key);
|
watcher.PrerequisitesAvailable(Key);
|
||||||
|
|
||||||
if( !nowHasPrerequisites && hasPrerequisites )
|
if (!nowHasPrerequisites && hasPrerequisites)
|
||||||
watcher.PrerequisitesUnavailable(key);
|
watcher.PrerequisitesUnavailable(Key);
|
||||||
|
|
||||||
hasPrerequisites = nowHasPrerequisites;
|
hasPrerequisites = nowHasPrerequisites;
|
||||||
}
|
}
|
||||||
@@ -131,18 +131,18 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public readonly string Prerequisite;
|
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
|
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)
|
public ProvidesCustomPrerequisite(ProvidesCustomPrerequisiteInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user