ResourceLayer: use BuildingInfo.TerrainTypes to check, if a resource can be placed underneath the building

This commit is contained in:
michaeldgg2
2025-06-14 16:57:47 +02:00
committed by Gustas Kažukauskas
parent 25571df2b6
commit abc3a79330

View File

@@ -172,10 +172,11 @@ namespace OpenRA.Mods.Common.Traits
if (resourceType == null || !info.ResourceTypes.TryGetValue(resourceType, out var resourceInfo))
return false;
if (!resourceInfo.AllowedTerrainTypes.Contains(Map.GetTerrainInfo(cell).Type))
var cellTerrainType = Map.GetTerrainInfo(cell).Type;
if (!resourceInfo.AllowedTerrainTypes.Contains(cellTerrainType))
return false;
return !BuildingInfluence.AnyBuildingAt(cell);
return BuildingInfluence.GetBuildingsAt(cell).All(a => a.Info.TraitInfo<BuildingInfo>().TerrainTypes.Contains(cellTerrainType));
}
ResourceLayerContents CreateResourceCell(string resourceType, CPos cell, int density)