Fixed #3045
This commit is contained in:
@@ -47,6 +47,7 @@ public class LExecutor{
|
||||
public LongSeq graphicsBuffer = new LongSeq();
|
||||
public StringBuilder textBuffer = new StringBuilder();
|
||||
public Building[] links = {};
|
||||
public IntSet linkIds = new IntSet();
|
||||
public Team team = Team.derelict;
|
||||
|
||||
public boolean initialized(){
|
||||
@@ -212,9 +213,9 @@ public class LExecutor{
|
||||
public LLocate locate = LLocate.building;
|
||||
public BlockFlag flag = BlockFlag.core;
|
||||
public int enemy, ore;
|
||||
public int outX, outY, outFound;
|
||||
public int outX, outY, outFound, outBuild;
|
||||
|
||||
public UnitLocateI(LLocate locate, BlockFlag flag, int enemy, int ore, int outX, int outY, int outFound){
|
||||
public UnitLocateI(LLocate locate, BlockFlag flag, int enemy, int ore, int outX, int outY, int outFound, int outBuild){
|
||||
this.locate = locate;
|
||||
this.flag = flag;
|
||||
this.enemy = enemy;
|
||||
@@ -271,6 +272,7 @@ public class LExecutor{
|
||||
cache.found = false;
|
||||
exec.setnum(outFound, 0);
|
||||
}
|
||||
exec.setobj(outFound, res != null && res.build != null && res.build.team == exec.team ? res.build : null);
|
||||
}else{
|
||||
exec.setbool(outFound, cache.found);
|
||||
exec.setnum(outX, cache.x);
|
||||
@@ -446,13 +448,13 @@ public class LExecutor{
|
||||
float range = Math.max(unit.range(), buildingRange);
|
||||
if(!unit.within(x1, y1, range)){
|
||||
exec.setobj(p3, null);
|
||||
exec.setnum(p4, 0);
|
||||
exec.setobj(p4, null);
|
||||
}else{
|
||||
Tile tile = world.tileWorld(x1, y1);
|
||||
//any environmental solid block is returned as StoneWall, aka "@solid"
|
||||
Block block = tile == null ? null : !tile.synthetic() ? (tile.solid() ? Blocks.stoneWall : Blocks.air) : tile.block();
|
||||
exec.setobj(p3, block);
|
||||
exec.setnum(p4, tile != null && tile.build != null ? tile.build.rotation : 0);
|
||||
exec.setobj(p4, tile != null && tile.build != null ? tile.build : null);
|
||||
}
|
||||
}
|
||||
case itemDrop -> {
|
||||
@@ -510,11 +512,11 @@ public class LExecutor{
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
Object obj = exec.obj(target);
|
||||
if(obj instanceof Controllable cont && cont.team() == exec.team){
|
||||
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id)){
|
||||
if(type.isObj){
|
||||
cont.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||
b.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||
}else{
|
||||
cont.control(type, exec.num(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||
b.control(type, exec.num(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,6 +609,7 @@ public class LExecutor{
|
||||
Object target = exec.obj(from);
|
||||
Object sense = exec.obj(type);
|
||||
|
||||
//TODO should remote enemy buildings be senseable?
|
||||
if(target instanceof Senseable se){
|
||||
if(sense instanceof Content){
|
||||
exec.setnum(to, se.sense(((Content)sense)));
|
||||
|
||||
@@ -819,7 +819,7 @@ public class LStatements{
|
||||
public LLocate locate = LLocate.building;
|
||||
public BlockFlag flag = BlockFlag.core;
|
||||
public String enemy = "true", ore = "@copper";
|
||||
public String outX = "outx", outY = "outy", outFound = "found";
|
||||
public String outX = "outx", outY = "outy", outFound = "found", outBuild = "building";
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
@@ -905,6 +905,8 @@ public class LStatements{
|
||||
table.add(" found ").left();
|
||||
fields(table, outFound, str -> outFound = str);
|
||||
|
||||
table.add(" building ").left();
|
||||
fields(table, outBuild, str -> outBuild = str);
|
||||
|
||||
}
|
||||
|
||||
@@ -915,7 +917,7 @@ public class LStatements{
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new UnitLocateI(locate, flag, builder.var(enemy), builder.var(ore), builder.var(outX), builder.var(outY), builder.var(outFound));
|
||||
return new UnitLocateI(locate, flag, builder.var(enemy), builder.var(ore), builder.var(outX), builder.var(outY), builder.var(outFound), builder.var(outBuild));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public enum LUnitControl{
|
||||
mine("x", "y"),
|
||||
flag("value"),
|
||||
build("x", "y", "block", "rotation"),
|
||||
getBlock("x", "y", "result", "resRot"),
|
||||
getBlock("x", "y", "type", "building"),
|
||||
within("x", "y", "radius", "result");
|
||||
|
||||
public final String[] params;
|
||||
|
||||
Reference in New Issue
Block a user