Allow fetching unitCount by type, and buildCount without type (#9374)

* Allow fetching unitCount by type, and buildCount without type

* show in processor ui
This commit is contained in:
BalaM314
2023-12-12 19:17:40 +05:30
committed by GitHub
parent 588732c856
commit 68b06fdea6
2 changed files with 10 additions and 3 deletions

View File

@@ -1360,13 +1360,20 @@ public class LExecutor{
exec.setobj(result, i < 0 || i >= builds.size ? null : builds.get(i));
}
}
case unitCount -> exec.setnum(result, data.units.size);
case unitCount -> {
UnitType type = exec.obj(extra) instanceof UnitType u ? u : null;
if(type == null){
exec.setnum(result, data.units.size);
}else{
exec.setnum(result, data.unitsByType[type.id].size);
}
}
case coreCount -> exec.setnum(result, data.cores.size);
case playerCount -> exec.setnum(result, data.players.size);
case buildCount -> {
Block block = exec.obj(extra) instanceof Block b ? b : null;
if(block == null){
exec.setobj(result, null);
exec.setnum(result, data.buildings.size);
}else{
exec.setnum(result, data.getBuildings(block).size);
}

View File

@@ -1748,7 +1748,7 @@ public class LStatements{
fields(table, index, i -> index = i);
}
if(type == FetchType.buildCount || type == FetchType.build){
if(type == FetchType.buildCount || type == FetchType.build || type == FetchType.unitCount){
row(table);
fields(table, "block", extra, i -> extra = i);