Can now set the race of the TechTree
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1139 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -90,9 +90,9 @@ namespace OpenRa.TechTreeTest
|
||||
bool buildable = false;
|
||||
public bool Buildable { get { return buildable; } }
|
||||
|
||||
public void CheckPrerequisites(IEnumerable<string> buildings)
|
||||
public void CheckPrerequisites(IEnumerable<string> buildings, BuildingRace currentRace)
|
||||
{
|
||||
if (buildable && ShouldMakeUnbuildable(buildings))
|
||||
if ((buildable && ShouldMakeUnbuildable(buildings)) || !((owner & currentRace) == currentRace))
|
||||
buildable = false;
|
||||
else if (!buildable && ShouldMakeBuildable(buildings))
|
||||
buildable = true;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace OpenRa.TechTreeTest
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
TechTree techTree = new TechTree();
|
||||
TechTree techTree = new TechTree(BuildingRace.Soviet);
|
||||
|
||||
public Form1()
|
||||
{
|
||||
|
||||
@@ -11,8 +11,11 @@ namespace OpenRa.TechTreeTest
|
||||
{
|
||||
Dictionary<string, Building> buildings = new Dictionary<string, Building>();
|
||||
public ICollection<string> built = new List<string>();
|
||||
public TechTree()
|
||||
readonly BuildingRace currentRace;
|
||||
|
||||
public TechTree(BuildingRace race)
|
||||
{
|
||||
this.currentRace = race;
|
||||
LoadBuildings();
|
||||
LoadRules();
|
||||
|
||||
@@ -85,7 +88,7 @@ namespace OpenRa.TechTreeTest
|
||||
void CheckAll()
|
||||
{
|
||||
foreach (Building building in buildings.Values)
|
||||
building.CheckPrerequisites(built);
|
||||
building.CheckPrerequisites(built, currentRace);
|
||||
}
|
||||
|
||||
public IEnumerable<Building> BuildableItems
|
||||
|
||||
Reference in New Issue
Block a user