Save unit variables in processors

This commit is contained in:
Anuken
2021-11-29 10:57:42 -05:00
parent ea6d794c36
commit 635027bb81
11 changed files with 76 additions and 18 deletions

View File

@@ -22,7 +22,7 @@ public class LAssembler{
public LAssembler(){
//instruction counter
putVar("@counter").value = 0;
//unix timestamp
//timestamp
putConst("@time", 0);
//currently controlled unit
putConst("@unit", null);

View File

@@ -208,7 +208,7 @@ public class LExecutor{
}
//binding to `null` was previously possible, but was too powerful and exploitable
if(exec.obj(type) instanceof UnitType type){
if(exec.obj(type) instanceof UnitType type && type.logicControllable){
Seq<Unit> seq = exec.team.data().unitCache(type);
if(seq != null && seq.any()){
@@ -222,7 +222,7 @@ public class LExecutor{
//no units of this type found
exec.setconst(varUnit, null);
}
}else if(exec.obj(type) instanceof Unit u && u.team == exec.team){
}else if(exec.obj(type) instanceof Unit u && u.team == exec.team && u.type.logicControllable){
//bind to specific unit object
exec.setconst(varUnit, u);
}else{

View File

@@ -836,7 +836,7 @@ public class LStatements{
i.left();
int c = 0;
for(UnitType item : Vars.content.units()){
if(!item.unlockedNow() || item.isHidden()) continue;
if(!item.unlockedNow() || item.isHidden() || !item.logicControllable) continue;
i.button(new TextureRegionDrawable(item.uiIcon), Styles.cleari, iconSmall, () -> {
type = "@" + item.name;
field.setText(type);