Weather status effects

This commit is contained in:
Anuken
2020-08-04 21:26:24 -04:00
parent 55903576b6
commit 03b5bc9449
9 changed files with 33 additions and 16 deletions

View File

@@ -0,0 +1 @@
{version:1,fields:[{name:effectTimer,type:float,size:4},{name:intensity,type:float,size:4},{name:life,type:float,size:4},{name:opacity,type:float,size:4},{name:weather,type:mindustry.type.Weather,size:-1},{name:x,type:float,size:4},{name:y,type:float,size:4}]}

View File

@@ -1696,7 +1696,7 @@ public class Blocks implements ContentList{
requirements(Category.units, with(Items.copper, 50, Items.lead, 120, Items.silicon, 80)); requirements(Category.units, with(Items.copper, 50, Items.lead, 120, Items.silicon, 80));
plans = new UnitPlan[]{ plans = new UnitPlan[]{
new UnitPlan(UnitTypes.dagger, 60f * 20, with(Items.silicon, 10, Items.lead, 10)), new UnitPlan(UnitTypes.dagger, 60f * 20, with(Items.silicon, 10, Items.lead, 10)),
new UnitPlan(UnitTypes.crawler, 60f * 15, with(Items.silicon, 10, Items.blastCompound, 10)), new UnitPlan(UnitTypes.crawler, 60f * 15, with(Items.silicon, 10, Items.coal, 20)),
new UnitPlan(UnitTypes.nova, 60f * 40, with(Items.silicon, 30, Items.lead, 20, Items.titanium, 20)), new UnitPlan(UnitTypes.nova, 60f * 40, with(Items.silicon, 30, Items.lead, 20, Items.titanium, 20)),
}; };
size = 3; size = 3;
@@ -1706,7 +1706,7 @@ public class Blocks implements ContentList{
airFactory = new UnitFactory("air-factory"){{ airFactory = new UnitFactory("air-factory"){{
requirements(Category.units, with(Items.copper, 30, Items.lead, 70)); requirements(Category.units, with(Items.copper, 30, Items.lead, 70));
plans = new UnitPlan[]{ plans = new UnitPlan[]{
new UnitPlan(UnitTypes.flare, 60f * 15, with(Items.silicon, 10)), new UnitPlan(UnitTypes.flare, 60f * 15, with(Items.silicon, 15)),
new UnitPlan(UnitTypes.mono, 60f * 35, with(Items.silicon, 30, Items.lead, 15)), new UnitPlan(UnitTypes.mono, 60f * 35, with(Items.silicon, 30, Items.lead, 15)),
}; };
size = 3; size = 3;

View File

@@ -654,13 +654,11 @@ public class Fx{
}), }),
wet = new Effect(40f, e -> { wet = new Effect(80f, e -> {
color(Liquids.water.color); color(Liquids.water.color);
alpha(Mathf.clamp(e.fin() * 2f));
randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> { Fill.circle(e.x, e.y, e.fout() * 1f);
Fill.circle(e.x + x, e.y + y, e.fout() * 1f);
});
}), }),
sapped = new Effect(40f, e -> { sapped = new Effect(40f, e -> {

View File

@@ -47,8 +47,9 @@ public class StatusEffects implements ContentList{
wet = new StatusEffect("wet"){{ wet = new StatusEffect("wet"){{
color = Color.royal; color = Color.royal;
speedMultiplier = 0.9f; speedMultiplier = 0.94f;
effect = Fx.wet; effect = Fx.wet;
effectChance = 0.09f;
init(() -> { init(() -> {
trans(shocked, ((unit, time, newTime, result) -> { trans(shocked, ((unit, time, newTime, result) -> {

View File

@@ -263,7 +263,7 @@ public class UnitTypes implements ContentList{
speed = 1f; speed = 1f;
splashDamageRadius = 55f; splashDamageRadius = 55f;
instantDisappear = true; instantDisappear = true;
splashDamage = 40f; splashDamage = 45f;
killShooter = true; killShooter = true;
hittable = false; hittable = false;
collidesAir = true; collidesAir = true;
@@ -527,7 +527,7 @@ public class UnitTypes implements ContentList{
}}; }};
antumbra = new UnitType("antumbra"){{ antumbra = new UnitType("antumbra"){{
speed = 1.25f; speed = 1.13f;
accel = 0.035f; accel = 0.035f;
drag = 0.05f; drag = 0.05f;
rotateSpeed = 1.9f; rotateSpeed = 1.9f;
@@ -599,7 +599,7 @@ public class UnitTypes implements ContentList{
}}; }};
eclipse = new UnitType("eclipse"){{ eclipse = new UnitType("eclipse"){{
speed = 1.1f; speed = 1.09f;
accel = 0.02f; accel = 0.02f;
drag = 0.05f; drag = 0.05f;
rotateSpeed = 1f; rotateSpeed = 1f;

View File

@@ -70,7 +70,6 @@ public class Weathers implements ContentList{
} }
}; };
//TODO should apply wet effect
rain = new Weather("rain"){ rain = new Weather("rain"){
float yspeed = 5f, xspeed = 1.5f, padding = 16f, size = 40f, density = 1200f; float yspeed = 5f, xspeed = 1.5f, padding = 16f, size = 40f, density = 1200f;
TextureRegion[] splashes = new TextureRegion[12]; TextureRegion[] splashes = new TextureRegion[12];
@@ -78,6 +77,7 @@ public class Weathers implements ContentList{
{ {
attrs.set(Attribute.light, -0.2f); attrs.set(Attribute.light, -0.2f);
attrs.set(Attribute.water, 0.2f); attrs.set(Attribute.water, 0.2f);
status = StatusEffects.wet;
} }
@Override @Override

View File

@@ -18,7 +18,7 @@ import java.util.regex.*;
public class Scripts implements Disposable{ public class Scripts implements Disposable{
private final Seq<String> blacklist = Seq.with(".net.", "java.net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk", private final Seq<String> blacklist = Seq.with(".net.", "java.net", "files", "reflect", "javax", "rhino", "file", "channels", "jdk",
"runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system", "runtime", "util.os", "rmi", "security", "org.", "sun.", "beans", "sql", "http", "exec", "compiler", "process", "system",
".awt", "socket", "classloader", "oracle", "invoke", "java.util.function", "java.util.stream"); ".awt", "socket", "classloader", "oracle", "invoke", "java.util.function", "java.util.stream", "org.");
private final Seq<String> whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen."); private final Seq<String> whitelist = Seq.with("mindustry.net", "netserver", "netclient", "com.sun.proxy.$proxy", "mindustry.gen.");
private final Context context; private final Context context;
private final Scriptable scope; private final Scriptable scope;

View File

@@ -56,7 +56,8 @@ public class StatusEffect extends MappableContent{
} }
if(effect != Fx.none && Mathf.chanceDelta(effectChance)){ if(effect != Fx.none && Mathf.chanceDelta(effectChance)){
effect.at(unit.x + Mathf.range(unit.bounds() / 2f), unit.y + Mathf.range(unit.bounds() / 2f)); Tmp.v1.rnd(unit.type().hitsize/2f);
effect.at(unit.x + Tmp.v1.x, unit.y + Tmp.v1.y);
} }
} }

View File

@@ -5,12 +5,13 @@ import arc.graphics.g2d.*;
import arc.math.*; import arc.math.*;
import arc.util.*; import arc.util.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.world.blocks.*; import mindustry.world.blocks.*;
import static mindustry.Vars.renderer; import static mindustry.Vars.*;
public abstract class Weather extends MappableContent{ public abstract class Weather extends MappableContent{
/** Default duration of this weather event in ticks. */ /** Default duration of this weather event in ticks. */
@@ -20,6 +21,8 @@ public abstract class Weather extends MappableContent{
//internals //internals
public Rand rand = new Rand(); public Rand rand = new Rand();
public Prov<WeatherState> type = WeatherState::create; public Prov<WeatherState> type = WeatherState::create;
public StatusEffect status = StatusEffects.none;
public float statusDuration = 60f * 2;
public Weather(String name, Prov<WeatherState> type){ public Weather(String name, Prov<WeatherState> type){
super(name); super(name);
@@ -60,6 +63,18 @@ public abstract class Weather extends MappableContent{
} }
public void updateEffect(WeatherState state){
if(status != StatusEffects.none){
if(state.effectTimer <= 0){
state.effectTimer = statusDuration - 5f;
Groups.unit.each(u -> u.apply(status, statusDuration));
}else{
state.effectTimer -= Time.delta;
}
}
}
public void drawOver(WeatherState state){ public void drawOver(WeatherState state){
} }
@@ -115,7 +130,7 @@ public abstract class Weather extends MappableContent{
private static final float fadeTime = 60 * 4; private static final float fadeTime = 60 * 4;
Weather weather; Weather weather;
float intensity = 1f, opacity = 0f, life; float intensity = 1f, opacity = 0f, life, effectTimer;
void init(Weather weather){ void init(Weather weather){
this.weather = weather; this.weather = weather;
@@ -132,6 +147,7 @@ public abstract class Weather extends MappableContent{
life -= Time.delta; life -= Time.delta;
weather.update(base()); weather.update(base());
weather.updateEffect(base());
if(life < 0){ if(life < 0){
remove(); remove();