Remove BuildingInfluence from ResourceLayer.

This commit is contained in:
Paul Chote
2020-10-07 17:54:58 +01:00
committed by Matthias Mailänder
parent e4faa6b0f0
commit 90b25be1b6

View File

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