diff --git a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs index 4411f6ae08..f80f31b75b 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits } [Desc("Attach this to the world actor.", "Order of the layers defines the Z sorting.")] - public class ResourceLayerInfo : TraitInfo, IResourceLayerInfo, Requires + public class ResourceLayerInfo : TraitInfo, IResourceLayerInfo, Requires, Requires { public override object Create(ActorInitializer init) { return new ResourceLayer(init.Self); } } @@ -43,6 +43,7 @@ namespace OpenRA.Mods.Common.Traits public class ResourceLayer : IResourceLayer, IWorldLoaded { readonly World world; + readonly BuildingInfluence buildingInfluence; protected readonly CellLayer Content; @@ -55,6 +56,7 @@ namespace OpenRA.Mods.Common.Traits public ResourceLayer(Actor self) { world = self.World; + buildingInfluence = self.Trait(); Content = new CellLayer(world.Map); } @@ -114,14 +116,11 @@ namespace OpenRA.Mods.Common.Traits if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type)) return false; - foreach (var a in world.ActorMap.GetActorsAt(cell)) - { - if (!rt.Info.AllowUnderActors) - return false; + if (!rt.Info.AllowUnderActors && world.ActorMap.AnyActorsAt(cell)) + return false; - if (!rt.Info.AllowUnderBuildings && a.TraitOrDefault() != null) - return false; - } + if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null) + return false; return rt.Info.AllowOnRamps || world.Map.Ramp[cell] == 0; }