Selection info into Area selection tab

Selection info into Area selection tab

add Resource counter and measure info into Area selection tab
This commit is contained in:
N.N
2024-01-24 11:59:54 +01:00
committed by Gustas
parent 311d55ff45
commit 4e031a6ea5
6 changed files with 200 additions and 5 deletions

View File

@@ -182,6 +182,24 @@ namespace OpenRA.Mods.Common.Traits
NetWorth += (newDensity + 1) * newResourceValue;
}
public int CalculateRegionValue(CellRegion sourceRegion)
{
var resourceValueInRegion = 0;
foreach (var cell in sourceRegion)
{
var mcell = cell.ToMPos(Map);
if (Map.Resources.Contains(mcell) && Map.Resources[mcell].Type != 0)
{
resourceValueInRegion++;
var rcell = Map.Resources[mcell];
if (ResourceTypesByIndex.TryGetValue(rcell.Type, out var resourceType) && resourceValues.TryGetValue(resourceType, out var resourceValuePerUnit))
resourceValueInRegion += Tiles[mcell].Density * resourceValuePerUnit;
}
}
return resourceValueInRegion;
}
protected virtual int CalculateCellDensity(ResourceLayerContents contents, CPos c)
{
var resources = Map.Resources;