This commit is contained in:
Anuken
2020-10-04 12:48:33 -04:00
parent 605a370679
commit 702ba0ae84
7 changed files with 51 additions and 19 deletions

View File

@@ -3,4 +3,5 @@ package mindustry.logic;
/** An object that can be controlled with logic. */
public interface Controllable{
void control(LAccess type, double p1, double p2, double p3, double p4);
void control(LAccess type, Object p1, double p2, double p3, double p4);
}

View File

@@ -30,10 +30,12 @@ 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")
;
public final String[] parameters;
public final boolean isObj;
public static final LAccess[]
all = values(),
@@ -42,5 +44,11 @@ public enum LAccess{
LAccess(String... parameters){
this.parameters = parameters;
isObj = false;
}
LAccess(boolean obj, String... parameters){
this.parameters = parameters;
isObj = obj;
}
}

View File

@@ -164,7 +164,11 @@ public class LExecutor{
Object obj = exec.obj(target);
if(obj instanceof Controllable){
Controllable cont = (Controllable)obj;
cont.control(type, exec.num(p1), exec.num(p2), exec.num(p3), exec.num(p4));
if(type.isObj){
cont.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));
}
}
}
}