mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-31 07:00:06 +07:00
Always-on weather rule support
This commit is contained in:
@ -957,6 +957,7 @@ rules.explosions = Block/Unit Explosion Damage
|
||||
rules.ambientlight = Ambient Light
|
||||
rules.weather = Weather
|
||||
rules.weather.frequency = Frequency:
|
||||
rules.weather.always = Always
|
||||
rules.weather.duration = Duration:
|
||||
|
||||
content.item.name = Items
|
||||
|
@ -258,13 +258,12 @@ public class Logic implements ApplicationListener{
|
||||
state.rules.weather.removeAll(w -> w.weather == null);
|
||||
|
||||
for(WeatherEntry entry : state.rules.weather){
|
||||
if(entry.weather == null) continue;
|
||||
//update cooldown
|
||||
entry.cooldown -= Time.delta;
|
||||
|
||||
//create new event when not active
|
||||
if(entry.cooldown < 0 && !entry.weather.isActive()){
|
||||
float duration = Mathf.random(entry.minDuration, entry.maxDuration);
|
||||
if((entry.cooldown < 0 || entry.always) && !entry.weather.isActive()){
|
||||
float duration = entry.always ? Float.POSITIVE_INFINITY : Mathf.random(entry.minDuration, entry.maxDuration);
|
||||
entry.cooldown = duration + Mathf.random(entry.minFrequency, entry.maxFrequency);
|
||||
Tmp.v1.setToRandomDirection();
|
||||
Call.createWeather(entry.weather, entry.intensity, duration, Tmp.v1.x, Tmp.v1.y);
|
||||
|
@ -61,12 +61,17 @@ public class Weather extends UnlockableContent{
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public WeatherState instance(){
|
||||
return Groups.weather.find(w -> w.weather() == this);
|
||||
}
|
||||
|
||||
public boolean isActive(){
|
||||
return Groups.weather.find(w -> w.weather() == this) != null;
|
||||
return instance() != null;
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
Entityc e = Groups.weather.find(w -> w.weather() == this);
|
||||
var e = instance();
|
||||
if(e != null) e.remove();
|
||||
}
|
||||
|
||||
@ -259,6 +264,8 @@ public class Weather extends UnlockableContent{
|
||||
public float cooldown;
|
||||
/** Intensity of the weather produced. */
|
||||
public float intensity = 1f;
|
||||
/** If true, this weather is always active. */
|
||||
public boolean always = false;
|
||||
|
||||
/** Creates a weather entry with some approximate weather values. */
|
||||
public WeatherEntry(Weather weather){
|
||||
|
@ -284,19 +284,23 @@ public class CustomRulesDialog extends BaseDialog{
|
||||
f.defaults().padRight(4).left();
|
||||
|
||||
f.add("@rules.weather.duration");
|
||||
field(f, entry.minDuration / toMinutes, v -> entry.minDuration = v * toMinutes);
|
||||
field(f, entry.minDuration / toMinutes, v -> entry.minDuration = v * toMinutes).disabled(v -> entry.always);
|
||||
f.add("@waves.to");
|
||||
field(f, entry.maxDuration / toMinutes, v -> entry.maxDuration = v * toMinutes);
|
||||
field(f, entry.maxDuration / toMinutes, v -> entry.maxDuration = v * toMinutes).disabled(v -> entry.always);
|
||||
f.add("@unit.minutes");
|
||||
|
||||
f.row();
|
||||
|
||||
f.add("@rules.weather.frequency");
|
||||
field(f, entry.minFrequency / toMinutes, v -> entry.minFrequency = v * toMinutes);
|
||||
field(f, entry.minFrequency / toMinutes, v -> entry.minFrequency = v * toMinutes).disabled(v -> entry.always);
|
||||
f.add("@waves.to");
|
||||
field(f, entry.maxFrequency / toMinutes, v -> entry.maxFrequency = v * toMinutes);
|
||||
field(f, entry.maxFrequency / toMinutes, v -> entry.maxFrequency = v * toMinutes).disabled(v -> entry.always);
|
||||
f.add("@unit.minutes");
|
||||
|
||||
f.row();
|
||||
|
||||
f.check("@rules.weather.always", val -> entry.always = val).checked(cc -> entry.always).padBottom(4);
|
||||
|
||||
//intensity can't currently be customized
|
||||
|
||||
}).grow().left().pad(6).top();
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=9b130afd1b8b6899c8c39843622842930c8ddcbf
|
||||
archash=b647f8dd4e96daf1ed869f1fd1fb38bb3f37135c
|
||||
|
Reference in New Issue
Block a user