diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index d41cd7a7c4..5c6de4ce1a 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -159,7 +159,6 @@ - diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 6bdbb4f582..c6927a97a4 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -28,6 +28,7 @@ namespace OpenRA.Traits public readonly string[] AllowedTerrainTypes = { }; public readonly bool AllowUnderActors = false; + public readonly bool AllowUnderBuildings = false; public PipType PipColor = PipType.Yellow; diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index d2287918be..8c8c13aa1c 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -10,6 +10,7 @@ using System.Linq; using OpenRA.Traits; +using OpenRA.Mods.RA; namespace OpenRA.Mods.Cnc { diff --git a/OpenRA.Mods.D2k/D2kResourceLayer.cs b/OpenRA.Mods.D2k/D2kResourceLayer.cs index 7438e1948a..5484ef9008 100644 --- a/OpenRA.Mods.D2k/D2kResourceLayer.cs +++ b/OpenRA.Mods.D2k/D2kResourceLayer.cs @@ -11,8 +11,10 @@ using System; using System.Collections.Generic; using System.Linq; +using OpenRA.Mods.RA; +using OpenRA.Traits; -namespace OpenRA.Traits +namespace OpenRA.Mods.D2k { public class D2kResourceLayerInfo : TraitInfo { } diff --git a/OpenRA.Mods.RA/Buildings/FootprintUtils.cs b/OpenRA.Mods.RA/Buildings/FootprintUtils.cs index 0d288dfd97..95a595bfe1 100644 --- a/OpenRA.Mods.RA/Buildings/FootprintUtils.cs +++ b/OpenRA.Mods.RA/Buildings/FootprintUtils.cs @@ -23,13 +23,13 @@ namespace OpenRA.Mods.RA.Buildings var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x)); var buildingTraits = rules.Actors[name].Traits; - if (buildingTraits.Contains() && !(buildingTraits.Get().HasMinibib)) + if (buildingTraits.Contains() && !buildingTraits.Get().HasMinibib) { dim += new CVec(0, 1); footprint = footprint.Concat(new char[dim.X]); } - return TilesWhere( name, dim, footprint.ToArray(), a => a != '_' ).Select( t => t + topLeft ); + return TilesWhere(name, dim, footprint.ToArray(), a => a != '_').Select(t => t + topLeft); } public static IEnumerable Tiles(Actor a) @@ -39,20 +39,20 @@ namespace OpenRA.Mods.RA.Buildings public static IEnumerable UnpathableTiles(string name, BuildingInfo buildingInfo, CPos position) { - var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray(); - foreach( var tile in TilesWhere( name, (CVec)buildingInfo.Dimensions, footprint, a => a == 'x' ) ) + var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x)).ToArray(); + foreach (var tile in TilesWhere(name, (CVec)buildingInfo.Dimensions, footprint, a => a == 'x')) yield return tile + position; } static IEnumerable TilesWhere(string name, CVec dim, char[] footprint, Func cond) { - if( footprint.Length != dim.X * dim.Y ) - throw new InvalidOperationException( "Invalid footprint for " + name ); + if (footprint.Length != dim.X * dim.Y) + throw new InvalidOperationException("Invalid footprint for " + name); var index = 0; - for( var y = 0 ; y < dim.Y ; y++ ) - for( var x = 0 ; x < dim.X ; x++ ) - if( cond( footprint[ index++ ] ) ) + for (var y = 0; y < dim.Y; y++) + for (var x = 0; x < dim.X; x++) + if (cond(footprint[index++])) yield return new CVec(x, y); } diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index e95b277c30..df94f6de89 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -96,7 +96,8 @@ namespace OpenRA.Mods.RA if (!info.TerrainTypes.Contains(type)) return false; - if (self.World.WorldActor.Trait().GetBuildingAt(cell) != null) return false; + if (self.World.WorldActor.Trait().GetBuildingAt(cell) != null) + return false; if (!checkTransientActors) return true; diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index d60a95b5ce..19a2a6bd9d 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -520,6 +520,7 @@ + diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Mods.RA/World/ResourceLayer.cs similarity index 93% rename from OpenRA.Game/Traits/World/ResourceLayer.cs rename to OpenRA.Mods.RA/World/ResourceLayer.cs index 357c11339a..02eac34b10 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Mods.RA/World/ResourceLayer.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2013 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, @@ -12,9 +12,12 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; +using OpenRA.Mods.RA.Buildings; +using OpenRA.Traits; -namespace OpenRA.Traits +namespace OpenRA.Mods.RA { + [Desc("Attach this to the world actor.")] public class ResourceLayerInfo : TraitInfo, Requires { } public class ResourceLayer : IRenderOverlay, IWorldLoaded, ITickRender @@ -22,6 +25,9 @@ namespace OpenRA.Traits static readonly CellContents EmptyCell = new CellContents(); World world; + + BuildingInfluence buildingInfluence; + protected CellLayer content; protected CellLayer render; List dirty; @@ -54,6 +60,9 @@ namespace OpenRA.Traits public void WorldLoaded(World w, WorldRenderer wr) { this.world = w; + + buildingInfluence = world.WorldActor.Trait(); + content = new CellLayer(w.Map); render = new CellLayer(w.Map); dirty = new List(); @@ -139,6 +148,9 @@ namespace OpenRA.Traits if (!rt.Info.AllowUnderActors && world.ActorMap.AnyUnitsAt(cell)) return false; + if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null) + return false; + return true; } diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index 6b9e1eb993..6321b0a615 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -90,8 +90,8 @@ Chrome: mods/ts/chrome.yaml Assemblies: - mods/d2k/OpenRA.Mods.D2k.dll mods/ra/OpenRA.Mods.RA.dll + mods/d2k/OpenRA.Mods.D2k.dll mods/cnc/OpenRA.Mods.Cnc.dll mods/ts/OpenRA.Mods.TS.dll