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