Revert "Remove BuildingInfluence from ResourceLayer."

This reverts commit 1634f3b70e97c015b97a047facd877155af2a402.
This commit is contained in:
Paul Chote
2020-11-26 22:51:57 +00:00
parent 582e2774ac
commit d61bd675c4

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> public class ResourceLayerInfo : TraitInfo, IResourceLayerInfo, Requires<ResourceTypeInfo>, Requires<BuildingInfluenceInfo>
{ {
public override object Create(ActorInitializer init) { return new ResourceLayer(init.Self); } 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 public class ResourceLayer : IResourceLayer, IWorldLoaded
{ {
readonly World world; readonly World world;
readonly BuildingInfluence buildingInfluence;
protected readonly CellLayer<ResourceLayerContents> Content; protected readonly CellLayer<ResourceLayerContents> Content;
@@ -55,6 +56,7 @@ 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);
} }
@@ -114,14 +116,11 @@ 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;
foreach (var a in world.ActorMap.GetActorsAt(cell)) if (!rt.Info.AllowUnderActors && world.ActorMap.AnyActorsAt(cell))
{ return false;
if (!rt.Info.AllowUnderActors)
return false;
if (!rt.Info.AllowUnderBuildings && a.TraitOrDefault<Building>() != null) if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
return false; return false;
}
return rt.Info.AllowOnRamps || world.Map.Ramp[cell] == 0; return rt.Info.AllowOnRamps || world.Map.Ramp[cell] == 0;
} }