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