This commit is contained in:
Anuken
2020-10-24 10:21:57 -04:00
parent 1ffa3f21f0
commit 646b022d38
10 changed files with 51 additions and 19 deletions
+10 -1
View File
@@ -38,12 +38,15 @@ public enum LAccess{
//values with parameters are considered controllable
enabled("to"), //"to" is standard for single parameter access
shoot("x", "y", "shoot"),
shootp(true, "unit", "shoot")
shootp(true, "unit", "shoot"),
configure(true, 30, "to")
;
public final String[] params;
public final boolean isObj;
/** Tick cooldown between invocations. */
public float cooldown = -1;
public static final LAccess[]
all = values(),
@@ -59,4 +62,10 @@ public enum LAccess{
this.params = params;
isObj = obj;
}
LAccess(boolean obj, float cooldown, String... params){
this.params = params;
this.cooldown = cooldown;
isObj = obj;
}
}
+6 -4
View File
@@ -292,14 +292,15 @@ public class LExecutor{
/** Controls the unit based on some parameters. */
public static class UnitControlI implements LInstruction{
public LUnitControl type = LUnitControl.move;
public int p1, p2, p3, p4;
public int p1, p2, p3, p4, p5;
public UnitControlI(LUnitControl type, int p1, int p2, int p3, int p4){
public UnitControlI(LUnitControl type, int p1, int p2, int p3, int p4, int p5){
this.type = type;
this.p1 = p1;
this.p2 = p2;
this.p3 = p3;
this.p4 = p4;
this.p5 = p5;
}
public UnitControlI(){
@@ -437,7 +438,7 @@ public class LExecutor{
}
ai.plan.set(x, y, rot, block);
ai.plan.config = null;
ai.plan.config = exec.obj(p5) instanceof Content c ? c : null;
builder.clearBuilding();
@@ -500,6 +501,7 @@ public class LExecutor{
public int target;
public LAccess type = LAccess.enabled;
public int p1, p2, p3, p4;
public Interval timer = new Interval(1);
public ControlI(LAccess type, int target, int p1, int p2, int p3, int p4){
this.type = type;
@@ -515,7 +517,7 @@ public class LExecutor{
@Override
public void run(LExecutor exec){
Object obj = exec.obj(target);
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id)){
if(obj instanceof Building b && b.team == exec.team && exec.linkIds.contains(b.id) && (type.cooldown <= 0 || timer.get(type.cooldown))){
if(type.isObj){
b.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
}else{
+8 -6
View File
@@ -748,7 +748,7 @@ public class LStatements{
@RegisterStatement("ucontrol")
public static class UnitControlStatement extends LStatement{
public LUnitControl type = LUnitControl.move;
public String p1 = "0", p2 = "0", p3 = "0", p4 = "0";
public String p1 = "0", p2 = "0", p3 = "0", p4 = "0", p5 = "";
@Override
public void build(Table table){
@@ -777,7 +777,7 @@ public class LStatements{
int c = 0;
for(int i = 0; i < type.params.length; i++){
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : v -> p4 = v).width(110f);
fields(table, type.params[i], i == 0 ? p1 : i == 1 ? p2 : i == 2 ? p3 : p4, i == 0 ? v -> p1 = v : i == 1 ? v -> p2 = v : i == 2 ? v -> p3 = v : i == 3 ? v -> p4 = v : v -> p5 = v).width(110f);
if(++c % 2 == 0) row(table);
}
@@ -790,7 +790,7 @@ public class LStatements{
@Override
public LInstruction build(LAssembler builder){
return new UnitControlI(type, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4));
return new UnitControlI(type, builder.var(p1), builder.var(p2), builder.var(p3), builder.var(p4), builder.var(p5));
}
}
@@ -861,7 +861,7 @@ public class LStatements{
table.table(ts -> {
ts.color.set(table.color);
field(ts, ore, str -> ore = str);
fields(ts, ore, str -> ore = str);
ts.button(b -> {
b.image(Icon.pencilSmall);
@@ -905,8 +905,10 @@ public class LStatements{
table.add(" found ").left();
fields(table, outFound, str -> outFound = str);
table.add(" building ").left();
fields(table, outBuild, str -> outBuild = str);
if(locate != LLocate.ore){
table.add(" building ").left();
fields(table, outBuild, str -> outBuild = str);
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ public enum LUnitControl{
payTake("takeUnits"),
mine("x", "y"),
flag("value"),
build("x", "y", "block", "rotation"),
build("x", "y", "block", "rotation", "config"),
getBlock("x", "y", "type", "building"),
within("x", "y", "radius", "result");