Make AI skip harvester orders if map has no resources

This commit is contained in:
reaperrr
2017-12-06 21:02:35 +01:00
committed by abcdefg30
parent 9ad0d78cdd
commit b5ffe17d60
2 changed files with 11 additions and 1 deletions

View File

@@ -36,7 +36,10 @@ namespace OpenRA.Mods.Common.Traits
protected readonly CellLayer<CellContents> Content;
protected readonly CellLayer<CellContents> RenderContent;
public bool IsResourceLayerEmpty { get { return resCells < 1; } }
bool disposed;
int resCells;
public ResourceLayer(Actor self)
{
@@ -217,6 +220,7 @@ namespace OpenRA.Mods.Common.Traits
CellContents CreateResourceCell(ResourceType t, CPos cell)
{
world.Map.CustomTerrain[cell] = world.Map.Rules.TileSet.GetTerrainIndex(t.Info.TerrainType);
++resCells;
return new CellContents
{
@@ -255,6 +259,7 @@ namespace OpenRA.Mods.Common.Traits
{
Content[cell] = EmptyCell;
world.Map.CustomTerrain[cell] = byte.MaxValue;
--resCells;
}
else
Content[cell] = c;
@@ -270,6 +275,8 @@ namespace OpenRA.Mods.Common.Traits
if (Content[cell].Type == null)
return;
--resCells;
// Clear cell
Content[cell] = EmptyCell;
world.Map.CustomTerrain[cell] = byte.MaxValue;