Refactoring to remove static Rules & SequenceProvider
This commit is contained in:
6
OpenRA.Mods.RA/Buildings/Building.cs
Executable file → Normal file
6
OpenRA.Mods.RA/Buildings/Building.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
return false;
|
||||
|
||||
var buildingMaxBounds = (CVec)Dimensions;
|
||||
var buildingTraits = Rules.Info[buildingName].Traits;
|
||||
var buildingTraits = world.Map.Rules.Actors[buildingName].Traits;
|
||||
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib))
|
||||
buildingMaxBounds += new CVec(0, 1);
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
}
|
||||
}
|
||||
|
||||
var buildingTiles = FootprintUtils.Tiles(buildingName, this, topLeft).ToList();
|
||||
var buildingTiles = FootprintUtils.Tiles(world.Map.Rules, buildingName, this, topLeft).ToList();
|
||||
return nearnessCandidates
|
||||
.Any(a => buildingTiles
|
||||
.Any(b => Math.Abs(a.X - b.X) <= Adjacent
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(a.Info.Name, b.Info, a.Location))
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
if (map.IsInMap(u) && influence[u.X, u.Y] == null)
|
||||
influence[u.X, u.Y] = a;
|
||||
};
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(a.Info.Name, b.Info, a.Location))
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
if (map.IsInMap(u) && influence[u.X, u.Y] == a)
|
||||
influence[u.X, u.Y] = null;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (order.OrderString == "PowerDown")
|
||||
{
|
||||
disabled = !disabled;
|
||||
Sound.PlayNotification(self.Owner, "Sounds", (disabled ? "EnablePower" : "DisablePower"), self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", (disabled ? "EnablePower" : "DisablePower"), self.Owner.Country.Race);
|
||||
PowerManager.UpdateActor(self, disabled ? 0 : normalPower);
|
||||
|
||||
if (disabled)
|
||||
|
||||
8
OpenRA.Mods.RA/Buildings/FootprintUtils.cs
Executable file → Normal file
8
OpenRA.Mods.RA/Buildings/FootprintUtils.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -16,13 +16,13 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
public static class FootprintUtils
|
||||
{
|
||||
public static IEnumerable<CPos> Tiles(string name, BuildingInfo buildingInfo, CPos topLeft)
|
||||
public static IEnumerable<CPos> Tiles(MapRuleset rules, string name, BuildingInfo buildingInfo, CPos topLeft)
|
||||
{
|
||||
var dim = (CVec)buildingInfo.Dimensions;
|
||||
|
||||
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x));
|
||||
|
||||
var buildingTraits = Rules.Info[name].Traits;
|
||||
var buildingTraits = rules.Actors[name].Traits;
|
||||
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib))
|
||||
{
|
||||
dim += new CVec(0, 1);
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public static IEnumerable<CPos> Tiles(Actor a)
|
||||
{
|
||||
return Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location );
|
||||
return Tiles(a.World.Map.Rules, a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location);
|
||||
}
|
||||
|
||||
public static IEnumerable<CPos> UnpathableTiles(string name, BuildingInfo buildingInfo, CPos position)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2012 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (--nextPowerAdviceTime <= 0)
|
||||
{
|
||||
if (lowPower)
|
||||
Sound.PlayNotification(self.Owner, "Speech", "LowPower", self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", "LowPower", self.Owner.Country.Race);
|
||||
nextPowerAdviceTime = Info.AdviceInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
else
|
||||
{
|
||||
Repairer = p;
|
||||
Sound.PlayNotification(Repairer, "Speech", "Repairing", self.Owner.Country.Race);
|
||||
Sound.PlayNotification(self.World.Map.Rules, Repairer, "Speech", "Repairing", self.Owner.Country.Race);
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix, p)));
|
||||
|
||||
6
OpenRA.Mods.RA/Buildings/Util.cs
Executable file → Normal file
6
OpenRA.Mods.RA/Buildings/Util.cs
Executable file → Normal file
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 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,
|
||||
@@ -35,14 +35,14 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
return true;
|
||||
|
||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||
return FootprintUtils.Tiles(name, building, topLeft).All(
|
||||
return FootprintUtils.Tiles(world.Map.Rules, name, building, topLeft).All(
|
||||
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
||||
world.IsCellBuildable(t, building, toIgnore));
|
||||
}
|
||||
|
||||
public static IEnumerable<CPos> GetLineBuildCells(World world, CPos location, string name, BuildingInfo bi)
|
||||
{
|
||||
var lbi = Rules.Info[name].Traits.Get<LineBuildInfo>();
|
||||
var lbi = world.Map.Rules.Actors[name].Traits.Get<LineBuildInfo>();
|
||||
var topLeft = location; // 1x1 assumption!
|
||||
|
||||
if (world.IsCellBuildable(topLeft, bi))
|
||||
|
||||
Reference in New Issue
Block a user