diff --git a/OpenRA.Editor/OpenRA.Editor.csproj b/OpenRA.Editor/OpenRA.Editor.csproj
index a6b94efb4b..0b2befb264 100644
--- a/OpenRA.Editor/OpenRA.Editor.csproj
+++ b/OpenRA.Editor/OpenRA.Editor.csproj
@@ -145,6 +145,10 @@
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}
OpenRA.Game
+
+ {4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}
+ OpenRA.Mods.RA
+
diff --git a/OpenRA.Editor/RenderUtils.cs b/OpenRA.Editor/RenderUtils.cs
index 65f3aaae34..5c9b84b70e 100644
--- a/OpenRA.Editor/RenderUtils.cs
+++ b/OpenRA.Editor/RenderUtils.cs
@@ -8,10 +8,12 @@
*/
#endregion
+using System;
using System.Drawing;
using System.Drawing.Imaging;
using OpenRA.FileFormats;
using OpenRA.Traits;
+using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Editor
{
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 6f34e6745e..32e3f0ec5b 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -79,7 +79,6 @@
-
@@ -116,12 +115,10 @@
-
-
@@ -130,7 +127,6 @@
-
@@ -146,8 +142,6 @@
-
-
@@ -161,12 +155,10 @@
-
-
@@ -200,8 +192,6 @@
-
-
@@ -220,13 +210,12 @@
+
-
-
diff --git a/OpenRA.Game/Traits/BaseBuilding.cs b/OpenRA.Game/Traits/BaseBuilding.cs
index d77d59d957..548e4bb308 100755
--- a/OpenRA.Game/Traits/BaseBuilding.cs
+++ b/OpenRA.Game/Traits/BaseBuilding.cs
@@ -8,6 +8,8 @@
*/
#endregion
+using OpenRA.Traits;
+
namespace OpenRA.Traits
{
/* tag trait for "bases": mcv/fact */
diff --git a/OpenRA.Game/Traits/Valued.cs b/OpenRA.Game/Traits/Valued.cs
deleted file mode 100755
index ecde8885ea..0000000000
--- a/OpenRA.Game/Traits/Valued.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace OpenRA.Traits
-{
- public class ValuedInfo : TraitInfo
- {
- public readonly int Cost = 0;
- }
-
- public class TooltipInfo : TraitInfo
- {
- public readonly string Description = "";
- public readonly string Name = "";
- public readonly string Icon = null;
- public readonly string[] AlternateName = { };
- }
-
- public class Valued { }
- public class Tooltip { }
-}
diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs
index 3c810ffd26..cce3d4cbc5 100644
--- a/OpenRA.Game/Traits/World/ResourceLayer.cs
+++ b/OpenRA.Game/Traits/World/ResourceLayer.cs
@@ -71,7 +71,7 @@ namespace OpenRA.Traits
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
{
// Todo: Valid terrain should be specified in the resource
- if (!w.IsCellBuildable(new int2(x,y), false))
+ if (!AllowOreAt(new int2(x,y)))
continue;
content[x, y].type = resourceTypes.FirstOrDefault(
@@ -89,6 +89,14 @@ namespace OpenRA.Traits
}
}
+ bool AllowOreAt( int2 a )
+ {
+ if( !world.Map.IsInMap( a.X, a.Y ) ) return false;
+ if( !world.GetTerrainInfo( a ).Buildable ) return false;
+ if( world.WorldActor.Trait().AnyUnitsAt( a ) ) return false;
+ return true;
+ }
+
Sprite[] ChooseContent(ResourceType t)
{
return t.info.Sprites[world.SharedRandom.Next(t.info.Sprites.Length)];
diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs
index 1b1a348bdb..a66045ded6 100644
--- a/OpenRA.Game/Traits/World/Shroud.cs
+++ b/OpenRA.Game/Traits/World/Shroud.cs
@@ -12,9 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using OpenRA.FileFormats;
-using OpenRA.GameRules;
-using OpenRA.Traits;
namespace OpenRA.Traits
{
@@ -122,22 +119,14 @@ namespace OpenRA.Traits
public static IEnumerable GetVisOrigins(Actor a)
{
- if (a.Info.Traits.Contains())
+ var ios = a.TraitOrDefault();
+ if (ios != null)
{
- var bi = a.Info.Traits.Get();
- return Footprint.Tiles(a.Info.Name, bi, a.Location);
+ var cells = ios.OccupiedCells();
+ if (cells.Any()) return cells;
}
- else
- {
- var ios = a.TraitOrDefault();
- if (ios != null)
- {
- var cells = ios.OccupiedCells();
- if (cells.Any()) return cells;
- }
- return new[] { (1f / Game.CellSize * a.CenterLocation).ToInt2() };
- }
+ return new[] { (1f / Game.CellSize * a.CenterLocation).ToInt2() };
}
void RemoveActor(Actor a)
diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs
index 77fc77849e..39a08cf0e2 100644
--- a/OpenRA.Game/UiOverlay.cs
+++ b/OpenRA.Game/UiOverlay.cs
@@ -11,7 +11,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
@@ -58,68 +57,5 @@ namespace OpenRA
foreach( var c in cells )
( c.Value ? buildOk : buildBlocked ).DrawAt( wr, Game.CellSize * c.Key, "terrain" );
}
-
- public void DrawBuildingGrid( WorldRenderer wr, World world, string name, BuildingInfo bi )
- {
- var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
- var topLeft = position - Footprint.AdjustForBuildingSize( bi );
-
- var cells = new Dictionary();
- // Linebuild for walls.
- // Assumes a 1x1 footprint; weird things will happen for other footprints
- if (Rules.Info[name].Traits.Contains())
- {
- foreach( var t in LineBuildUtils.GetLineBuildCells( world, topLeft, name, bi ) )
- cells.Add( t, world.IsCloseEnoughToBase( world.LocalPlayer, name, bi, t ) );
- }
- else
- {
- var res = world.WorldActor.Trait();
- var isCloseEnough = world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, topLeft);
- foreach (var t in Footprint.Tiles(name, bi, topLeft))
- cells.Add( t, isCloseEnough && world.IsCellBuildable(t, bi.WaterBound) && res.GetResource(t) == null );
- }
- DrawGrid( wr, cells );
- }
- }
-
- public static class LineBuildUtils
- {
- public static IEnumerable GetLineBuildCells(World world, int2 location, string name, BuildingInfo bi)
- {
- int range = Rules.Info[name].Traits.Get().Range;
- var topLeft = location; // 1x1 assumption!
-
- if (world.IsCellBuildable(topLeft, bi.WaterBound))
- yield return topLeft;
-
- // Start at place location, search outwards
- // TODO: First make it work, then make it nice
- var vecs = new[] { new int2(1, 0), new int2(0, 1), new int2(-1, 0), new int2(0, -1) };
- int[] dirs = { 0, 0, 0, 0 };
- for (int d = 0; d < 4; d++)
- {
- for (int i = 1; i < range; i++)
- {
- if (dirs[d] != 0)
- continue;
-
- int2 cell = topLeft + i * vecs[d];
- if (world.IsCellBuildable(cell, bi.WaterBound))
- continue; // Cell is empty; continue search
-
- // Cell contains an actor. Is it the type we want?
- if (world.Queries.WithTrait().Any(a => (a.Actor.Info.Name == name && a.Actor.Location.X == cell.X && a.Actor.Location.Y == cell.Y)))
- dirs[d] = i; // Cell contains actor of correct type
- else
- dirs[d] = -1; // Cell is blocked by another actor type
- }
-
- // Place intermediate-line sections
- if (dirs[d] > 0)
- for (int i = 1; i < dirs[d]; i++)
- yield return topLeft + i * vecs[d];
- }
- }
}
}
diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
index 8c5177e28c..37138f4df1 100644
--- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
+++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
@@ -8,13 +8,13 @@
*/
#endregion
-using System.Collections.Generic;
-using System.Drawing;
-using System.Linq;
-using OpenRA.FileFormats;
-using OpenRA.Orders;
-using OpenRA.Traits;
-using OpenRA.Graphics;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using OpenRA.FileFormats;
+using OpenRA.Graphics;
+using OpenRA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Widgets
{
@@ -158,7 +158,7 @@ namespace OpenRA.Widgets
}
public void GotoNextBase()
- {
+ {
var bases = world.Queries.OwnedBy[world.LocalPlayer].WithTrait().ToArray();
if (!bases.Any()) return;
diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs
index 6f402914b8..0baee936d2 100755
--- a/OpenRA.Game/WorldUtils.cs
+++ b/OpenRA.Game/WorldUtils.cs
@@ -8,7 +8,6 @@
*/
#endregion
-using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -21,22 +20,6 @@ namespace OpenRA
{
public static class WorldUtils
{
- public static bool IsCellBuildable(this World world, int2 a, bool waterBound)
- {
- return world.IsCellBuildable(a, waterBound, null);
- }
-
- public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore)
- {
- if (world.WorldActor.Trait().GetBuildingAt(a) != null) return false;
- if (world.WorldActor.Trait().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
-
- if (waterBound)
- return world.Map.IsInMap(a.X,a.Y) && GetTerrainInfo(world,a).IsWater;
-
- return world.Map.IsInMap(a.X, a.Y) && world.GetTerrainInfo(a).Buildable;
- }
-
public static IEnumerable FindUnitsAtMouse(this World world, int2 mouseLocation)
{
var loc = mouseLocation + Game.viewport.Location;
@@ -93,14 +76,6 @@ namespace OpenRA
return world.TileSet.Terrain[world.GetTerrainType(cell)];
}
- public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
- {
- var res = world.WorldActor.Trait();
- return Footprint.Tiles(name, building, topLeft).All(
- t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
- world.IsCellBuildable(t, building.WaterBound, toIgnore));
- }
-
public static bool IsVisible(this Actor a, Player byPlayer) /* must never be relied on in synced code! */
{
if (byPlayer == null) return true; // Observer
@@ -117,34 +92,7 @@ namespace OpenRA
return true;
}
- public static bool IsCloseEnoughToBase(this World world, Player p, string buildingName, BuildingInfo bi, int2 topLeft)
- {
- var buildingMaxBounds = bi.Dimensions;
- if( Rules.Info[ buildingName ].Traits.Contains() )
- buildingMaxBounds.Y += 1;
-
- var scanStart = world.ClampToWorld( topLeft - new int2( bi.Adjacent, bi.Adjacent ) );
- var scanEnd = world.ClampToWorld( topLeft + buildingMaxBounds + new int2( bi.Adjacent, bi.Adjacent ) );
-
- var nearnessCandidates = new List();
-
- for( int y = scanStart.Y ; y < scanEnd.Y ; y++ )
- {
- for( int x = scanStart.X ; x < scanEnd.X ; x++ )
- {
- var at = world.WorldActor.Trait().GetBuildingAt( new int2( x, y ) );
- if( at != null && at.Owner.Stances[ p ] == Stance.Ally && at.Info.Traits.Get().BaseNormal )
- nearnessCandidates.Add( new int2( x, y ) );
- }
- }
- var buildingTiles = Footprint.Tiles( buildingName, bi, topLeft ).ToList();
- return nearnessCandidates
- .Any( a => buildingTiles
- .Any( b => Math.Abs( a.X - b.X ) <= bi.Adjacent
- && Math.Abs( a.Y - b.Y ) <= bi.Adjacent ) );
- }
-
- static int2 ClampToWorld( this World world, int2 xy )
+ public static int2 ClampToWorld( this World world, int2 xy )
{
return int2.Min(world.Map.BottomRight, int2.Max(world.Map.TopLeft, xy));
}
diff --git a/OpenRA.Mods.RA/Activities/Transform.cs b/OpenRA.Mods.RA/Activities/Transform.cs
index 66adcca6f0..08925f8e5c 100644
--- a/OpenRA.Mods.RA/Activities/Transform.cs
+++ b/OpenRA.Mods.RA/Activities/Transform.cs
@@ -8,12 +8,10 @@
*/
#endregion
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using OpenRA.Traits;
-using OpenRA.Mods.RA.Render;
using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Mods.RA.Render;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
diff --git a/OpenRA.Mods.RA/AttackOmni.cs b/OpenRA.Mods.RA/AttackOmni.cs
index 60923d1dc2..24fc908918 100644
--- a/OpenRA.Mods.RA/AttackOmni.cs
+++ b/OpenRA.Mods.RA/AttackOmni.cs
@@ -8,6 +8,7 @@
*/
#endregion
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/AttackTurreted.cs b/OpenRA.Mods.RA/AttackTurreted.cs
index 38129ec3a1..005b8ddb92 100644
--- a/OpenRA.Mods.RA/AttackTurreted.cs
+++ b/OpenRA.Mods.RA/AttackTurreted.cs
@@ -9,10 +9,11 @@
#endregion
using System;
-using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
using System.Linq;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Move;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Mods.RA/Buildings/BibLayer.cs
similarity index 95%
rename from OpenRA.Game/Traits/World/BibLayer.cs
rename to OpenRA.Mods.RA/Buildings/BibLayer.cs
index 951b89a2ff..1c16ac52cd 100755
--- a/OpenRA.Game/Traits/World/BibLayer.cs
+++ b/OpenRA.Mods.RA/Buildings/BibLayer.cs
@@ -13,9 +13,10 @@ using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
-using OpenRA.Graphics;
+using OpenRA.Graphics;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA.Buildings
{
class BibLayerInfo : ITraitInfo
{
@@ -88,6 +89,6 @@ namespace OpenRA.Traits
}
}
- class BibInfo : TraitInfo { }
+ public class BibInfo : TraitInfo { }
public class Bib { }
}
diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs
old mode 100644
new mode 100755
similarity index 53%
rename from OpenRA.Game/Traits/Building.cs
rename to OpenRA.Mods.RA/Buildings/Building.cs
index bb3ca451e8..d774fd2002
--- a/OpenRA.Game/Traits/Building.cs
+++ b/OpenRA.Mods.RA/Buildings/Building.cs
@@ -10,13 +10,11 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
using System.Linq;
-using OpenRA.Effects;
-using OpenRA.GameRules;
-using OpenRA.Traits.Activities;
+using OpenRA.Graphics;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA.Buildings
{
public class BuildingInfo : ITraitInfo
{
@@ -36,6 +34,56 @@ namespace OpenRA.Traits
public readonly string DestroyedSound = "kaboom22.aud";
public object Create(ActorInitializer init) { return new Building(init); }
+
+ public bool IsCloseEnoughToBase(World world, Player p, string buildingName, int2 topLeft)
+ {
+ var buildingMaxBounds = Dimensions;
+ if( Rules.Info[ buildingName ].Traits.Contains() )
+ buildingMaxBounds.Y += 1;
+
+ var scanStart = world.ClampToWorld( topLeft - new int2( Adjacent, Adjacent ) );
+ var scanEnd = world.ClampToWorld( topLeft + buildingMaxBounds + new int2( Adjacent, Adjacent ) );
+
+ var nearnessCandidates = new List();
+
+ for( int y = scanStart.Y ; y < scanEnd.Y ; y++ )
+ {
+ for( int x = scanStart.X ; x < scanEnd.X ; x++ )
+ {
+ var at = world.WorldActor.Trait().GetBuildingAt( new int2( x, y ) );
+ if( at != null && at.Owner.Stances[ p ] == Stance.Ally && at.Info.Traits.Get().BaseNormal )
+ nearnessCandidates.Add( new int2( x, y ) );
+ }
+ }
+ var buildingTiles = FootprintUtils.Tiles( buildingName, this, topLeft ).ToList();
+ return nearnessCandidates
+ .Any( a => buildingTiles
+ .Any( b => Math.Abs( a.X - b.X ) <= Adjacent
+ && Math.Abs( a.Y - b.Y ) <= Adjacent ) );
+ }
+
+ public void DrawBuildingGrid( WorldRenderer wr, World world, string name )
+ {
+ var position = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
+ var topLeft = position - FootprintUtils.AdjustForBuildingSize( this );
+
+ var cells = new Dictionary();
+ // Linebuild for walls.
+ // Assumes a 1x1 footprint; weird things will happen for other footprints
+ if (Rules.Info[name].Traits.Contains())
+ {
+ foreach( var t in BuildingUtils.GetLineBuildCells( world, topLeft, name, this ) )
+ cells.Add( t, IsCloseEnoughToBase( world, world.LocalPlayer, name, t ) );
+ }
+ else
+ {
+ var res = world.WorldActor.Trait();
+ var isCloseEnough = IsCloseEnoughToBase(world, world.LocalPlayer, name, topLeft);
+ foreach (var t in FootprintUtils.Tiles(name, this, topLeft))
+ cells.Add( t, isCloseEnough && world.IsCellBuildable(t, WaterBound) && res.GetResource(t) == null );
+ }
+ wr.uiOverlay.DrawGrid( wr, cells );
+ }
}
public class Building : INotifyDamage, IResolveOrder, IOccupySpace
@@ -98,7 +146,7 @@ namespace OpenRA.Traits
public IEnumerable OccupiedCells()
{
- return Footprint.UnpathableTiles( self.Info.Name, Info, TopLeft );
+ return FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft );
}
}
}
diff --git a/OpenRA.Game/Traits/World/BuildingInfluence.cs b/OpenRA.Mods.RA/Buildings/BuildingInfluence.cs
old mode 100644
new mode 100755
similarity index 83%
rename from OpenRA.Game/Traits/World/BuildingInfluence.cs
rename to OpenRA.Mods.RA/Buildings/BuildingInfluence.cs
index 23babfc37f..3b5e622094
--- a/OpenRA.Game/Traits/World/BuildingInfluence.cs
+++ b/OpenRA.Mods.RA/Buildings/BuildingInfluence.cs
@@ -8,11 +8,9 @@
*/
#endregion
-using OpenRA.FileFormats;
-using OpenRA.GameRules;
-using System;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA.Buildings
{
public class BuildingInfluenceInfo : ITraitInfo
{
@@ -40,7 +38,7 @@ namespace OpenRA.Traits
void ChangeInfluence( Actor a, Building building, bool isAdd )
{
- foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location ) )
+ foreach( var u in FootprintUtils.Tiles( a.Info.Name, a.Info.Traits.Get(), a.Location ) )
if( map.IsInMap( u ) )
influence[ u.X, u.Y ] = isAdd ? a : null;
}
diff --git a/OpenRA.Mods.RA/CanPowerDown.cs b/OpenRA.Mods.RA/Buildings/CanPowerDown.cs
similarity index 94%
rename from OpenRA.Mods.RA/CanPowerDown.cs
rename to OpenRA.Mods.RA/Buildings/CanPowerDown.cs
index 012491a7bc..4d9a493be4 100755
--- a/OpenRA.Mods.RA/CanPowerDown.cs
+++ b/OpenRA.Mods.RA/Buildings/CanPowerDown.cs
@@ -10,7 +10,7 @@
using OpenRA.Traits;
-namespace OpenRA.Mods.RA
+namespace OpenRA.Mods.RA.Buildings
{
public class CanPowerDownInfo : ITraitInfo
{
diff --git a/OpenRA.Game/Traits/CustomSellValue.cs b/OpenRA.Mods.RA/Buildings/CustomSellValue.cs
old mode 100644
new mode 100755
similarity index 87%
rename from OpenRA.Game/Traits/CustomSellValue.cs
rename to OpenRA.Mods.RA/Buildings/CustomSellValue.cs
index 3babdf565b..3ea834724b
--- a/OpenRA.Game/Traits/CustomSellValue.cs
+++ b/OpenRA.Mods.RA/Buildings/CustomSellValue.cs
@@ -8,7 +8,9 @@
*/
#endregion
-namespace OpenRA.Traits
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Buildings
{
// allow a nonstandard sell/repair value to avoid
// buy-sell exploits like c&c's PROC.
diff --git a/OpenRA.Game/GameRules/Footprint.cs b/OpenRA.Mods.RA/Buildings/FootprintUtils.cs
old mode 100644
new mode 100755
similarity index 93%
rename from OpenRA.Game/GameRules/Footprint.cs
rename to OpenRA.Mods.RA/Buildings/FootprintUtils.cs
index 8b15dbb3d7..26d3de4eb9
--- a/OpenRA.Game/GameRules/Footprint.cs
+++ b/OpenRA.Mods.RA/Buildings/FootprintUtils.cs
@@ -11,11 +11,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using OpenRA.Traits;
-namespace OpenRA.GameRules
+namespace OpenRA.Mods.RA.Buildings
{
- public static class Footprint
+ public static class FootprintUtils
{
public static IEnumerable Tiles( string name, BuildingInfo buildingInfo, int2 topLeft )
{
diff --git a/OpenRA.Game/Traits/LineBuild.cs b/OpenRA.Mods.RA/Buildings/LineBuild.cs
old mode 100644
new mode 100755
similarity index 85%
rename from OpenRA.Game/Traits/LineBuild.cs
rename to OpenRA.Mods.RA/Buildings/LineBuild.cs
index 3fe319c155..a8f7a99959
--- a/OpenRA.Game/Traits/LineBuild.cs
+++ b/OpenRA.Mods.RA/Buildings/LineBuild.cs
@@ -8,7 +8,9 @@
*/
#endregion
-namespace OpenRA.Traits
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Buildings
{
public class LineBuildInfo : TraitInfo
{
diff --git a/OpenRA.Game/Traits/Player/PowerManager.cs b/OpenRA.Mods.RA/Buildings/PowerManager.cs
old mode 100644
new mode 100755
similarity index 96%
rename from OpenRA.Game/Traits/Player/PowerManager.cs
rename to OpenRA.Mods.RA/Buildings/PowerManager.cs
index 93092bf41e..4a7d477c80
--- a/OpenRA.Game/Traits/Player/PowerManager.cs
+++ b/OpenRA.Mods.RA/Buildings/PowerManager.cs
@@ -6,14 +6,12 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
-#endregion
+#endregion
+
+using System.Collections.Generic;
+using OpenRA.Traits;
-using System;
-using System.Linq;
-using System.Collections.Generic;
-using OpenRA.FileFormats;
-
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA.Buildings
{
public class PowerManagerInfo : ITraitInfo
{
diff --git a/OpenRA.Mods.RA/RepairableBuilding.cs b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs
similarity index 98%
rename from OpenRA.Mods.RA/RepairableBuilding.cs
rename to OpenRA.Mods.RA/Buildings/RepairableBuilding.cs
index 3c13fe0d6d..208ed3f21b 100755
--- a/OpenRA.Mods.RA/RepairableBuilding.cs
+++ b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs
@@ -12,7 +12,7 @@ using System;
using OpenRA.Mods.RA.Effects;
using OpenRA.Traits;
-namespace OpenRA.Mods.RA
+namespace OpenRA.Mods.RA.Buildings
{
public class RepairableBuildingInfo : ITraitInfo, ITraitPrerequisite
{
diff --git a/OpenRA.Mods.RA/RequiresPower.cs b/OpenRA.Mods.RA/Buildings/RequiresPower.cs
old mode 100644
new mode 100755
similarity index 91%
rename from OpenRA.Mods.RA/RequiresPower.cs
rename to OpenRA.Mods.RA/Buildings/RequiresPower.cs
index 5a3f8c0f35..f4f0ed246d
--- a/OpenRA.Mods.RA/RequiresPower.cs
+++ b/OpenRA.Mods.RA/Buildings/RequiresPower.cs
@@ -10,7 +10,7 @@
using OpenRA.Traits;
-namespace OpenRA.Mods.RA
+namespace OpenRA.Mods.RA.Buildings
{
class RequiresPowerInfo : ITraitInfo
{
diff --git a/OpenRA.Game/Traits/Activities/Sell.cs b/OpenRA.Mods.RA/Buildings/Sell.cs
old mode 100644
new mode 100755
similarity index 93%
rename from OpenRA.Game/Traits/Activities/Sell.cs
rename to OpenRA.Mods.RA/Buildings/Sell.cs
index 860f43cafd..960e18f13a
--- a/OpenRA.Game/Traits/Activities/Sell.cs
+++ b/OpenRA.Mods.RA/Buildings/Sell.cs
@@ -9,8 +9,9 @@
#endregion
using System.Collections.Generic;
+using OpenRA.Traits;
-namespace OpenRA.Traits.Activities
+namespace OpenRA.Mods.RA.Buildings
{
class Sell : IActivity
{
diff --git a/OpenRA.Game/Traits/Player/TechTree.cs b/OpenRA.Mods.RA/Buildings/TechTree.cs
similarity index 94%
rename from OpenRA.Game/Traits/Player/TechTree.cs
rename to OpenRA.Mods.RA/Buildings/TechTree.cs
index 5a5af226ca..938d08ffbd 100755
--- a/OpenRA.Game/Traits/Player/TechTree.cs
+++ b/OpenRA.Mods.RA/Buildings/TechTree.cs
@@ -11,8 +11,9 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA.Buildings
{
public class TechTreeInfo : ITraitInfo
{
diff --git a/OpenRA.Mods.RA/Buildings/Util.cs b/OpenRA.Mods.RA/Buildings/Util.cs
new file mode 100755
index 0000000000..ca61c8eb84
--- /dev/null
+++ b/OpenRA.Mods.RA/Buildings/Util.cs
@@ -0,0 +1,80 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2010 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,
+ * see LICENSE.
+ */
+#endregion
+
+using System.Collections.Generic;
+using System.Linq;
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Buildings
+{
+ public static class BuildingUtils
+ {
+ public static bool IsCellBuildable(this World world, int2 a, bool waterBound)
+ {
+ return world.IsCellBuildable(a, waterBound, null);
+ }
+
+ public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore)
+ {
+ if (world.WorldActor.Trait().GetBuildingAt(a) != null) return false;
+ if (world.WorldActor.Trait().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
+
+ if (waterBound)
+ return world.Map.IsInMap(a.X,a.Y) && world.GetTerrainInfo(a).IsWater;
+
+ return world.Map.IsInMap(a.X, a.Y) && world.GetTerrainInfo(a).Buildable;
+ }
+
+ public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
+ {
+ var res = world.WorldActor.Trait();
+ return FootprintUtils.Tiles(name, building, topLeft).All(
+ t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
+ world.IsCellBuildable(t, building.WaterBound, toIgnore));
+ }
+
+ public static IEnumerable GetLineBuildCells(World world, int2 location, string name, BuildingInfo bi)
+ {
+ int range = Rules.Info[name].Traits.Get().Range;
+ var topLeft = location; // 1x1 assumption!
+
+ if (world.IsCellBuildable(topLeft, bi.WaterBound))
+ yield return topLeft;
+
+ // Start at place location, search outwards
+ // TODO: First make it work, then make it nice
+ var vecs = new[] { new int2(1, 0), new int2(0, 1), new int2(-1, 0), new int2(0, -1) };
+ int[] dirs = { 0, 0, 0, 0 };
+ for (int d = 0; d < 4; d++)
+ {
+ for (int i = 1; i < range; i++)
+ {
+ if (dirs[d] != 0)
+ continue;
+
+ int2 cell = topLeft + i * vecs[d];
+ if (world.IsCellBuildable(cell, bi.WaterBound))
+ continue; // Cell is empty; continue search
+
+ // Cell contains an actor. Is it the type we want?
+ if (world.Queries.WithTrait().Any(a => (a.Actor.Info.Name == name && a.Actor.Location.X == cell.X && a.Actor.Location.Y == cell.Y)))
+ dirs[d] = i; // Cell contains actor of correct type
+ else
+ dirs[d] = -1; // Cell is blocked by another actor type
+ }
+
+ // Place intermediate-line sections
+ if (dirs[d] > 0)
+ for (int i = 1; i < dirs[d]; i++)
+ yield return topLeft + i * vecs[d];
+ }
+ }
+ }
+}
diff --git a/OpenRA.Mods.RA/Wall.cs b/OpenRA.Mods.RA/Buildings/Wall.cs
old mode 100644
new mode 100755
similarity index 93%
rename from OpenRA.Mods.RA/Wall.cs
rename to OpenRA.Mods.RA/Buildings/Wall.cs
index 8a228e7254..8e93e5314a
--- a/OpenRA.Mods.RA/Wall.cs
+++ b/OpenRA.Mods.RA/Buildings/Wall.cs
@@ -11,7 +11,7 @@
using System.Collections.Generic;
using OpenRA.Traits;
-namespace OpenRA.Mods.RA
+namespace OpenRA.Mods.RA.Buildings
{
public class WallInfo : ITraitInfo, ITraitPrerequisite
{
diff --git a/OpenRA.Mods.RA/C4Demolition.cs b/OpenRA.Mods.RA/C4Demolition.cs
index 595cf8dee7..2ee93da100 100644
--- a/OpenRA.Mods.RA/C4Demolition.cs
+++ b/OpenRA.Mods.RA/C4Demolition.cs
@@ -8,15 +8,14 @@
*/
#endregion
-using System;
using System.Collections.Generic;
using System.Drawing;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Mods.RA.Move;
using OpenRA.Mods.RA.Orders;
using OpenRA.Traits;
-using OpenRA.Traits.Activities;
-using OpenRA.Mods.RA.Move;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/CrateDrop.cs b/OpenRA.Mods.RA/CrateDrop.cs
index 190fd98daa..efa3cdaf8c 100644
--- a/OpenRA.Mods.RA/CrateDrop.cs
+++ b/OpenRA.Mods.RA/CrateDrop.cs
@@ -11,9 +11,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs
index 0da56602b8..e2e1ed02f4 100644
--- a/OpenRA.Mods.RA/CrateSpawner.cs
+++ b/OpenRA.Mods.RA/CrateSpawner.cs
@@ -6,13 +6,14 @@
* as published by the Free Software Foundation. For more information,
* see LICENSE.
*/
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
-using OpenRA.FileFormats;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/Effects/RepairIndicator.cs b/OpenRA.Mods.RA/Effects/RepairIndicator.cs
index d5eb66ba8d..86a1441a40 100755
--- a/OpenRA.Mods.RA/Effects/RepairIndicator.cs
+++ b/OpenRA.Mods.RA/Effects/RepairIndicator.cs
@@ -11,6 +11,7 @@
using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Effects
diff --git a/OpenRA.Mods.RA/EmitInfantryOnSell.cs b/OpenRA.Mods.RA/EmitInfantryOnSell.cs
index 7d9eb8c197..aa74300ec3 100644
--- a/OpenRA.Mods.RA/EmitInfantryOnSell.cs
+++ b/OpenRA.Mods.RA/EmitInfantryOnSell.cs
@@ -8,11 +8,10 @@
*/
#endregion
-using System;
using System.Linq;
-using OpenRA.GameRules;
-using OpenRA.Traits;
using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -39,7 +38,7 @@ namespace OpenRA.Mods.RA
var health = self.TraitOrDefault();
var hpFraction = (health == null) ? 1f : health.HPFraction;
var dudesValue = (int)(hpFraction * info.ValueFraction * cost);
- var eligibleLocations = Footprint.Tiles(self).ToList();
+ var eligibleLocations = FootprintUtils.Tiles(self).ToList();
var actorTypes = info.ActorTypes.Select(a => new { Name = a, Cost = Rules.Info[a].Traits.Get().Cost }).ToArray();
while (eligibleLocations.Count > 0 && actorTypes.Any(a => a.Cost <= dudesValue))
diff --git a/OpenRA.Mods.RA/EngineerCapture.cs b/OpenRA.Mods.RA/EngineerCapture.cs
index 657f8e19df..f4c38c9431 100644
--- a/OpenRA.Mods.RA/EngineerCapture.cs
+++ b/OpenRA.Mods.RA/EngineerCapture.cs
@@ -8,13 +8,13 @@
*/
#endregion
+using System.Collections.Generic;
using System.Drawing;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
-using System.Collections.Generic;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/EngineerRepair.cs b/OpenRA.Mods.RA/EngineerRepair.cs
index 51422159da..54564b5368 100644
--- a/OpenRA.Mods.RA/EngineerRepair.cs
+++ b/OpenRA.Mods.RA/EngineerRepair.cs
@@ -12,9 +12,9 @@ using System.Collections.Generic;
using System.Drawing;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs
index 16eed6952c..57528e021d 100644
--- a/OpenRA.Mods.RA/HackyAI.cs
+++ b/OpenRA.Mods.RA/HackyAI.cs
@@ -11,10 +11,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using OpenRA.Network;
+using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
using XRandom = OpenRA.Thirdparty.Random;
-using OpenRA.FileFormats;
//TODO:
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.RA
for (var k = 0; k < MaxBaseDistance; k++)
foreach (var t in world.FindTilesInCircle(baseCenter, k))
if (world.CanPlaceBuilding(item.Item, bi, t, null))
- if (world.IsCloseEnoughToBase(p, item.Item, bi, t))
+ if (bi.IsCloseEnoughToBase(world, p, item.Item, t))
return t;
return null; // i don't know where to put it.
diff --git a/OpenRA.Mods.RA/Helicopter.cs b/OpenRA.Mods.RA/Helicopter.cs
index 3f1aae7252..4a22042aec 100644
--- a/OpenRA.Mods.RA/Helicopter.cs
+++ b/OpenRA.Mods.RA/Helicopter.cs
@@ -10,13 +10,13 @@
using System;
using System.Collections.Generic;
+using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
-using System.Drawing;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 9e3419d5fb..59c7f19b7b 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -83,6 +83,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -126,7 +137,7 @@
-
+
@@ -143,7 +154,7 @@
-
+
@@ -202,7 +213,7 @@
-
+
@@ -229,7 +240,7 @@
-
+
@@ -240,6 +251,7 @@
+
diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs
index f17b10428b..bea6b33628 100755
--- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs
+++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs
@@ -10,8 +10,8 @@
using System.Collections.Generic;
using System.Linq;
-using OpenRA.GameRules;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
@@ -44,9 +44,9 @@ namespace OpenRA.Mods.RA.Orders
{
if (mi.Button == MouseButton.Left)
{
- var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo );
+ var topLeft = xy - FootprintUtils.AdjustForBuildingSize( BuildingInfo );
if (!world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null)
- || !world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft))
+ || !BuildingInfo.IsCloseEnoughToBase(world, Producer.Owner, Building, topLeft))
{
var eva = world.WorldActor.Info.Traits.Get();
Sound.Play(eva.BuildingCannotPlaceAudio);
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA.Orders
public void RenderBeforeWorld( WorldRenderer wr, World world )
{
- wr.uiOverlay.DrawBuildingGrid( wr, world, Building, BuildingInfo );
+ BuildingInfo.DrawBuildingGrid( wr, world, Building );
}
public string GetCursor(World world, int2 xy, MouseInput mi) { return "default"; }
diff --git a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs
index 4a292f41ca..8a88ea09e5 100755
--- a/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs
+++ b/OpenRA.Mods.RA/Orders/PowerDownOrderGenerator.cs
@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
namespace OpenRA.Mods.RA.Orders
{
diff --git a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
index 8237e2222a..46a547b114 100644
--- a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
+++ b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
diff --git a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs
index ed6aef20ef..c173a3c9b6 100755
--- a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs
+++ b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs
@@ -11,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Orders
diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs
index 8760db3b43..855a2e8f68 100644
--- a/OpenRA.Mods.RA/OreRefinery.cs
+++ b/OpenRA.Mods.RA/OreRefinery.cs
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/Plane.cs b/OpenRA.Mods.RA/Plane.cs
index 8ff30d804c..500a21447e 100644
--- a/OpenRA.Mods.RA/Plane.cs
+++ b/OpenRA.Mods.RA/Plane.cs
@@ -14,8 +14,9 @@ using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs b/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs
index 2a1327d99c..eb159ebdcb 100755
--- a/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs
+++ b/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs
@@ -8,8 +8,9 @@
*/
#endregion
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/Player/PlaceBuilding.cs b/OpenRA.Mods.RA/Player/PlaceBuilding.cs
index 34971cc369..f18224e515 100755
--- a/OpenRA.Mods.RA/Player/PlaceBuilding.cs
+++ b/OpenRA.Mods.RA/Player/PlaceBuilding.cs
@@ -11,6 +11,7 @@
using System.Linq;
using OpenRA.Effects;
using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -45,7 +46,7 @@ namespace OpenRA.Mods.RA
if (order.OrderString == "LineBuild")
{
bool playSounds = true;
- foreach (var t in LineBuildUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
+ foreach (var t in BuildingUtils.GetLineBuildCells(w, order.TargetLocation, order.TargetString, buildingInfo))
{
var building = w.CreateActor(order.TargetString, new TypeDictionary
{
diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs
index 0c2f04fa55..f42c640cbe 100755
--- a/OpenRA.Mods.RA/Player/ProductionQueue.cs
+++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs
index 24e0d7553f..ab582e3768 100755
--- a/OpenRA.Mods.RA/Render/RenderBuilding.cs
+++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs
@@ -9,11 +9,11 @@
#endregion
using System;
-using OpenRA.Mods.RA.Effects;
-using OpenRA.Traits;
-using OpenRA.GameRules;
using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Mods.RA.Effects;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
{
@@ -87,10 +87,10 @@ namespace OpenRA.Mods.RA.Render
return;
if (e.DamageState == DamageState.Dead)
- foreach (var t in Footprint.UnpathableTiles( self.Info.Name, self.Info.Traits.Get(), self.Location ))
+ foreach (var t in FootprintUtils.UnpathableTiles( self.Info.Name, self.Info.Traits.Get(), self.Location ))
{
var cell = t; // required: c# fails at bindings
- self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Util.CenterOfCell(cell), "building", false, 0)));
+ self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Traits.Util.CenterOfCell(cell), "building", false, 0)));
}
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
{
diff --git a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs
index ee892a9a12..f6b35a935e 100644
--- a/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs
+++ b/OpenRA.Mods.RA/Render/RenderBuildingTurreted.cs
@@ -8,6 +8,7 @@
*/
#endregion
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs
index b7156ee7a2..cd894bf1eb 100644
--- a/OpenRA.Mods.RA/Render/RenderBuildingWall.cs
+++ b/OpenRA.Mods.RA/Render/RenderBuildingWall.cs
@@ -9,6 +9,7 @@
#endregion
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Render
diff --git a/OpenRA.Mods.RA/Repairable.cs b/OpenRA.Mods.RA/Repairable.cs
index 638d30258b..7d8782b6a9 100644
--- a/OpenRA.Mods.RA/Repairable.cs
+++ b/OpenRA.Mods.RA/Repairable.cs
@@ -8,15 +8,15 @@
*/
#endregion
-using System.Linq;
-using OpenRA.Mods.RA.Activities;
-using OpenRA.Effects;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
-using System.Drawing;
using System.Collections.Generic;
-using OpenRA.Mods.RA.Orders;
+using System.Drawing;
+using System.Linq;
+using OpenRA.Effects;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Move;
+using OpenRA.Mods.RA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.RA
});
self.CancelActivity();
- self.QueueActivity(mobile.MoveTo(Util.CellContaining(order.TargetActor.CenterLocation), order.TargetActor));
+ self.QueueActivity(mobile.MoveTo(Traits.Util.CellContaining(order.TargetActor.CenterLocation), order.TargetActor));
self.QueueActivity(new Rearm());
self.QueueActivity(new Repair(order.TargetActor));
diff --git a/OpenRA.Mods.RA/RepairableNear.cs b/OpenRA.Mods.RA/RepairableNear.cs
index b446932985..4bb5a875fd 100644
--- a/OpenRA.Mods.RA/RepairableNear.cs
+++ b/OpenRA.Mods.RA/RepairableNear.cs
@@ -8,14 +8,14 @@
*/
#endregion
+using System.Collections.Generic;
+using System.Drawing;
using System.Linq;
using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
-using System.Drawing;
-using System.Collections.Generic;
-using OpenRA.Mods.RA.Orders;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Move;
+using OpenRA.Mods.RA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/SeedsResource.cs b/OpenRA.Mods.RA/SeedsResource.cs
index f34f955f8d..ac93a96837 100644
--- a/OpenRA.Mods.RA/SeedsResource.cs
+++ b/OpenRA.Mods.RA/SeedsResource.cs
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Render;
using OpenRA.Traits;
diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs
index 545d44555b..0964329801 100755
--- a/OpenRA.Mods.RA/SupportPowers/SupportPower.cs
+++ b/OpenRA.Mods.RA/SupportPowers/SupportPower.cs
@@ -9,6 +9,7 @@
#endregion
using System.Linq;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/TargetableBuilding.cs b/OpenRA.Mods.RA/TargetableBuilding.cs
index 91ca3a216b..5b217587bc 100755
--- a/OpenRA.Mods.RA/TargetableBuilding.cs
+++ b/OpenRA.Mods.RA/TargetableBuilding.cs
@@ -8,10 +8,8 @@
*/
#endregion
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
diff --git a/OpenRA.Mods.RA/Transforms.cs b/OpenRA.Mods.RA/Transforms.cs
index 40c37cec90..d897d99979 100644
--- a/OpenRA.Mods.RA/Transforms.cs
+++ b/OpenRA.Mods.RA/Transforms.cs
@@ -8,12 +8,11 @@
*/
#endregion
-using OpenRA.Mods.RA.Activities;
-using OpenRA.Traits;
-using OpenRA.Traits.Activities;
-using OpenRA.GameRules;
using System.Collections.Generic;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
diff --git a/OpenRA.Mods.RA/Valued.cs b/OpenRA.Mods.RA/Valued.cs
new file mode 100755
index 0000000000..54fdd77381
--- /dev/null
+++ b/OpenRA.Mods.RA/Valued.cs
@@ -0,0 +1,30 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2010 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,
+ * see LICENSE.
+ */
+#endregion
+
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA
+{
+ public class ValuedInfo : TraitInfo
+ {
+ public readonly int Cost = 0;
+ }
+
+ public class TooltipInfo : TraitInfo
+ {
+ public readonly string Description = "";
+ public readonly string Name = "";
+ public readonly string Icon = null;
+ public readonly string[] AlternateName = { };
+ }
+
+ public class Valued { }
+ public class Tooltip { }
+}
diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
index 2ab7bf5d7b..57694c2711 100755
--- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
+++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
@@ -14,6 +14,7 @@ using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Orders;
using OpenRA.Traits;
using OpenRA.Widgets;
diff --git a/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs
index e6b71e2b55..d45ee64973 100755
--- a/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs
+++ b/OpenRA.Mods.RA/Widgets/PowerBinWidget.cs
@@ -11,7 +11,7 @@
using System;
using System.Drawing;
using OpenRA.Graphics;
-using OpenRA.Traits;
+using OpenRA.Mods.RA.Buildings;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets
diff --git a/OpenRA.Game/Widgets/WorldTooltipWidget.cs b/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs
old mode 100644
new mode 100755
similarity index 95%
rename from OpenRA.Game/Widgets/WorldTooltipWidget.cs
rename to OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs
index 78ee214449..d25f428eb6
--- a/OpenRA.Game/Widgets/WorldTooltipWidget.cs
+++ b/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs
@@ -12,9 +12,9 @@ using System;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
-using OpenRA.Traits;
+using OpenRA.Widgets;
-namespace OpenRA.Widgets
+namespace OpenRA.Mods.RA.Widgets
{
public class WorldTooltipWidget : Widget
{
diff --git a/RALint/RALint.cs b/RALint/RALint.cs
index 9bcf6c3bf4..c57421e7bb 100644
--- a/RALint/RALint.cs
+++ b/RALint/RALint.cs
@@ -10,7 +10,6 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using System.Reflection;
using OpenRA;
using OpenRA.FileFormats;
@@ -43,10 +42,10 @@ namespace RALint
Rules.LoadRules(Game.modData.Manifest, new Map());
// all the @something names which actually EXIST.
- var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null)
- .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct();
+ //var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null)
+ // .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct();
- ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0);
+ //ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0);
foreach (var actorInfo in Rules.Info)
foreach (var traitInfo in actorInfo.Value.Traits.WithInterface())