Block type fetching
This commit is contained in:
@@ -6,7 +6,9 @@ public enum FetchType{
|
||||
player,
|
||||
playerCount,
|
||||
core,
|
||||
coreCount;
|
||||
coreCount,
|
||||
build,
|
||||
buildCount;
|
||||
|
||||
public static final FetchType[] all = values();
|
||||
}
|
||||
|
||||
@@ -1166,12 +1166,13 @@ public class LExecutor{
|
||||
|
||||
public static class FetchI implements LInstruction{
|
||||
public FetchType type = FetchType.unit;
|
||||
public int result, team, index;
|
||||
public int result, team, extra, index;
|
||||
|
||||
public FetchI(FetchType type, int result, int team, int index){
|
||||
public FetchI(FetchType type, int result, int team, int extra, int index){
|
||||
this.type = type;
|
||||
this.result = result;
|
||||
this.team = team;
|
||||
this.extra = extra;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@@ -1188,9 +1189,26 @@ public class LExecutor{
|
||||
case unit -> exec.setobj(result, i < 0 || i >= data.units.size ? null : data.units.get(i));
|
||||
case player -> exec.setobj(result, i < 0 || i >= data.players.size || data.players.get(i).unit().isNull() ? null : data.players.get(i).unit());
|
||||
case core -> exec.setobj(result, i < 0 || i >= data.cores.size ? null : data.cores.get(i));
|
||||
case build -> {
|
||||
Block block = exec.obj(extra) instanceof Block b ? b : null;
|
||||
if(block == null){
|
||||
exec.setobj(result, null);
|
||||
}else{
|
||||
var builds = data.getBuildings(block);
|
||||
exec.setobj(result, i < 0 || i >= builds.size ? null : builds.get(i));
|
||||
}
|
||||
}
|
||||
case unitCount -> exec.setnum(result, data.units.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);
|
||||
}else{
|
||||
exec.setnum(result, data.getBuildings(block).size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1464,7 +1464,7 @@ public class LStatements{
|
||||
@RegisterStatement("fetch")
|
||||
public static class FetchStatement extends LStatement{
|
||||
public FetchType type = FetchType.unit;
|
||||
public String result = "result", team = "@sharded", index = "0";
|
||||
public String result = "result", team = "@sharded", index = "0", extra = "@conveyor";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
@@ -1497,6 +1497,12 @@ public class LStatements{
|
||||
|
||||
fields(table, index, i -> index = i);
|
||||
}
|
||||
|
||||
if(type == FetchType.buildCount || type == FetchType.build){
|
||||
row(table);
|
||||
|
||||
fields(table, "block", extra, i -> extra = i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1511,7 +1517,7 @@ public class LStatements{
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new FetchI(type, builder.var(result), builder.var(team), builder.var(index));
|
||||
return new FetchI(type, builder.var(result), builder.var(team), builder.var(extra), builder.var(index));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user