Merge branch 'Anuken:master' into do-you-hear-the-voices-too
This commit is contained in:
@@ -125,6 +125,10 @@ public class GlobalVars{
|
||||
put("@" + type.name, type);
|
||||
}
|
||||
|
||||
for(Weather weather : Vars.content.weathers()){
|
||||
put("@" + weather.name, weather);
|
||||
}
|
||||
|
||||
//store sensor constants
|
||||
for(LAccess sensor : LAccess.all){
|
||||
put("@" + sensor.name(), sensor);
|
||||
|
||||
@@ -13,8 +13,8 @@ import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.MapObjectives.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -1363,13 +1363,21 @@ public class LExecutor{
|
||||
TeamData data = t.data();
|
||||
|
||||
switch(type){
|
||||
case unit -> exec.setobj(result, i < 0 || i >= data.units.size ? null : data.units.get(i));
|
||||
case unit -> {
|
||||
UnitType type = exec.obj(extra) instanceof UnitType u ? u : null;
|
||||
if(type == null){
|
||||
exec.setobj(result, i < 0 || i >= data.units.size ? null : data.units.get(i));
|
||||
}else{
|
||||
var units = data.unitCache(type);
|
||||
exec.setobj(result, units == null || i < 0 || i >= units.size ? null : 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);
|
||||
exec.setobj(result, i < 0 || i >= data.buildings.size ? null : data.buildings.get(i));
|
||||
}else{
|
||||
var builds = data.getBuildings(block);
|
||||
exec.setobj(result, i < 0 || i >= builds.size ? null : builds.get(i));
|
||||
@@ -1380,7 +1388,7 @@ public class LExecutor{
|
||||
if(type == null){
|
||||
exec.setnum(result, data.units.size);
|
||||
}else{
|
||||
exec.setnum(result, data.unitsByType[type.id].size);
|
||||
exec.setnum(result, data.unitCache(type) == null ? 0 : data.unitCache(type).size);
|
||||
}
|
||||
}
|
||||
case coreCount -> exec.setnum(result, data.cores.size);
|
||||
@@ -1511,6 +1519,47 @@ public class LExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
public static class SenseWeatherI implements LInstruction{
|
||||
public int type, to;
|
||||
|
||||
public SenseWeatherI(int type, int to){
|
||||
this.type = type;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
exec.setbool(to, exec.obj(type) instanceof Weather weather && weather.isActive());
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetWeatherI implements LInstruction{
|
||||
public int type, state;
|
||||
|
||||
public SetWeatherI(int type, int state){
|
||||
this.type = type;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(LExecutor exec){
|
||||
if(exec.obj(type) instanceof Weather weather){
|
||||
if(exec.bool(state)){
|
||||
if(!weather.isActive()){ //Create is not already active
|
||||
Tmp.v1.setToRandomDirection();
|
||||
Call.createWeather(weather, 1f, WeatherState.fadeTime, Tmp.v1.x, Tmp.v1.y);
|
||||
}else{
|
||||
weather.instance().life(WeatherState.fadeTime);
|
||||
}
|
||||
}else{
|
||||
if(weather.isActive() && weather.instance().life > WeatherState.fadeTime){
|
||||
weather.instance().life(WeatherState.fadeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ApplyEffectI implements LInstruction{
|
||||
public boolean clear;
|
||||
public String effect;
|
||||
|
||||
@@ -13,6 +13,7 @@ public enum LMarkerControl{
|
||||
stroke("stroke"),
|
||||
rotation("rotation"),
|
||||
shape("sides", "fill", "outline"),
|
||||
arc("start", "end"),
|
||||
flushText("fetch"),
|
||||
fontSize("size"),
|
||||
textHeight("height"),
|
||||
|
||||
@@ -16,7 +16,7 @@ import mindustry.logic.LCanvas.*;
|
||||
import mindustry.logic.LExecutor.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.ui;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.logic.LCanvas.*;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1380,6 +1380,115 @@ public class LStatements{
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("weathersense")
|
||||
public static class WeatherSenseStatement extends LStatement{
|
||||
public String to = "result";
|
||||
public String weather = "@rain";
|
||||
|
||||
private transient TextField tfield;
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
field(table, to, str -> to = str);
|
||||
|
||||
table.add(" = weather ");
|
||||
|
||||
row(table);
|
||||
|
||||
tfield = field(table, weather, str -> weather = str).padRight(0f).get();
|
||||
|
||||
table.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
|
||||
b.clicked(() -> showSelectTable(b, (t, hide) -> {
|
||||
t.row();
|
||||
t.table(i -> {
|
||||
i.left();
|
||||
int c = 0;
|
||||
for(Weather w : Vars.content.weathers()){
|
||||
i.button(w.name, Styles.flatt, () -> {
|
||||
weather = "@" + w.name;
|
||||
tfield.setText(weather);
|
||||
hide.run();
|
||||
}).height(40f).uniformX().wrapLabel(false).growX();
|
||||
|
||||
if(++c % 2 == 0) i.row();
|
||||
}
|
||||
}).left();
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-1).color(table.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean privileged(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new SenseWeatherI(builder.var(weather), builder.var(to));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.world;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("weatherset")
|
||||
public static class WeatherSetStatement extends LStatement{
|
||||
public String weather = "@rain", state = "true";
|
||||
|
||||
private transient TextField tfield;
|
||||
|
||||
@Override
|
||||
public void build(Table table){
|
||||
table.add(" set weather ");
|
||||
|
||||
tfield = field(table, weather, str -> weather = str).padRight(0f).get();
|
||||
|
||||
table.button(b -> {
|
||||
b.image(Icon.pencilSmall);
|
||||
|
||||
b.clicked(() -> showSelectTable(b, (t, hide) -> {
|
||||
t.row();
|
||||
t.table(i -> {
|
||||
i.left();
|
||||
int c = 0;
|
||||
for(Weather w : Vars.content.weathers()){
|
||||
i.button(w.name, Styles.flatt, () -> {
|
||||
weather = "@" + w.name;
|
||||
tfield.setText(weather);
|
||||
hide.run();
|
||||
}).height(40f).uniformX().wrapLabel(false).growX();
|
||||
|
||||
if(++c % 2 == 0) i.row();
|
||||
}
|
||||
}).left();
|
||||
}));
|
||||
}, Styles.logict, () -> {}).size(40f).padLeft(-1).color(table.color);
|
||||
|
||||
table.add(" state ");
|
||||
|
||||
fields(table, state, str -> state = str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean privileged(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LInstruction build(LAssembler builder){
|
||||
return new SetWeatherI(builder.var(weather), builder.var(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LCategory category(){
|
||||
return LCategory.world;
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterStatement("spawnwave")
|
||||
public static class SpawnWaveStatement extends LStatement{
|
||||
public String x = "10", y = "10", natural = "false";
|
||||
@@ -1747,11 +1856,17 @@ public class LStatements{
|
||||
fields(table, index, i -> index = i);
|
||||
}
|
||||
|
||||
if(type == FetchType.buildCount || type == FetchType.build || type == FetchType.unitCount){
|
||||
if(type == FetchType.buildCount || type == FetchType.build){
|
||||
row(table);
|
||||
|
||||
fields(table, "block", extra, i -> extra = i);
|
||||
}
|
||||
|
||||
if(type == FetchType.unitCount || type == FetchType.unit){
|
||||
row(table);
|
||||
|
||||
fields(table, "unit", extra, i -> extra = i);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user