Add AnyBuildingAt method to BuildingInfluence.
This commit is contained in:
@@ -50,5 +50,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
return influence.Contains(cell) ? influence[cell] : null;
|
||||
}
|
||||
|
||||
public bool AnyBuildingAt(CPos cell)
|
||||
{
|
||||
return influence.Contains(cell) && influence[cell] != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
// Replacements are enabled and the cell contained at least one (not ignored) actor or building bib
|
||||
var building = world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell);
|
||||
if (foundActors || building != null)
|
||||
var foundBuilding = world.WorldActor.Trait<BuildingInfluence>().AnyBuildingAt(cell);
|
||||
if (foundActors || foundBuilding)
|
||||
{
|
||||
// The cell contains at least one actor, and none were replaceable
|
||||
if (acceptedReplacements == null)
|
||||
@@ -73,8 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// HACK: To preserve legacy behaviour, AllowInvalidPlacement should display red placement indicators
|
||||
// if (and only if) there is a building or bib in the cell
|
||||
var building = world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell);
|
||||
if (building != null)
|
||||
if (world.WorldActor.Trait<BuildingInfluence>().AnyBuildingAt(cell))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!resourceInfo.AllowedTerrainTypes.Contains(Map.GetTerrainInfo(cell).Type))
|
||||
return false;
|
||||
|
||||
return BuildingInfluence.GetBuildingAt(cell) == null;
|
||||
return !BuildingInfluence.AnyBuildingAt(cell);
|
||||
}
|
||||
|
||||
ResourceLayerContents CreateResourceCell(string resourceType, CPos cell, int density)
|
||||
|
||||
Reference in New Issue
Block a user