Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -17,7 +17,7 @@ public class Weathers{
|
||||
suspendParticles;
|
||||
|
||||
public static void load(){
|
||||
snow = new ParticleWeather("snow"){{
|
||||
snow = new ParticleWeather("snowing"){{
|
||||
particleRegion = "particle";
|
||||
sizeMax = 13f;
|
||||
sizeMin = 2.6f;
|
||||
|
||||
@@ -314,6 +314,14 @@ public class ContentLoader{
|
||||
return getByName(ContentType.planet, name);
|
||||
}
|
||||
|
||||
public Seq<Weather> weathers(){
|
||||
return getBy(ContentType.weather);
|
||||
}
|
||||
|
||||
public Weather weather(String name){
|
||||
return getByName(ContentType.weather, name);
|
||||
}
|
||||
|
||||
public Seq<UnitStance> unitStances(){
|
||||
return getBy(ContentType.unitStance);
|
||||
}
|
||||
|
||||
@@ -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.*;
|
||||
@@ -1511,6 +1511,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;
|
||||
|
||||
@@ -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("weathersensor")
|
||||
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";
|
||||
|
||||
@@ -218,7 +218,10 @@ public class Mods implements Loadable{
|
||||
}
|
||||
//this returns a *runnable* which actually packs the resulting pixmap; this has to be done synchronously outside the method
|
||||
return () -> {
|
||||
String fullName = (prefix ? mod.name + "-" : "") + baseName;
|
||||
//don't prefix with mod name if it's already prefixed by a category, e.g. `block-modname-content-full`.
|
||||
int hyphen = baseName.indexOf('-');
|
||||
String fullName = ((prefix && !(hyphen != -1 && baseName.substring(hyphen + 1).startsWith(mod.name + "-"))) ? mod.name + "-" : "") + baseName;
|
||||
|
||||
packer.add(getPage(file), fullName, new PixmapRegion(pix));
|
||||
if(textureScale != 1.0f){
|
||||
textureResize.put(fullName, textureScale);
|
||||
|
||||
@@ -314,7 +314,7 @@ public class Weather extends UnlockableContent{
|
||||
@EntityDef(value = {WeatherStatec.class}, pooled = true, isFinal = false)
|
||||
@Component(base = true)
|
||||
abstract static class WeatherStateComp implements Drawc, Syncc{
|
||||
private static final float fadeTime = 60 * 4;
|
||||
public static final float fadeTime = 60 * 4;
|
||||
|
||||
Weather weather;
|
||||
float intensity = 1f, opacity = 0f, life, effectTimer;
|
||||
|
||||
Reference in New Issue
Block a user