Cleaned up weather class

This commit is contained in:
Anuken
2020-03-11 10:08:27 -04:00
parent 930c342fb6
commit 06e94b1800
11 changed files with 58 additions and 13 deletions

View File

@@ -17,6 +17,7 @@ public class Annotations{
effects, effects,
overlays, overlays,
names, names,
weather
} }
/** Indicates that a method overrides other methods. */ /** Indicates that a method overrides other methods. */

View File

@@ -10,6 +10,7 @@ mindustry.entities.def.PlayerComp=5
mindustry.entities.def.PuddleComp=6 mindustry.entities.def.PuddleComp=6
mindustry.entities.def.StandardEffectComp=7 mindustry.entities.def.StandardEffectComp=7
mindustry.entities.def.TileComp=8 mindustry.entities.def.TileComp=8
mindustry.type.Weather.WeatherComp=13
phantom=11 phantom=11
spirit=12 spirit=12
vanguard=9 vanguard=9

View File

@@ -0,0 +1 @@
{fields:[]}

View File

@@ -0,0 +1 @@
{version:1,fields:[{name:x,type:float,size:4},{name:y,type:float,size:4}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -35,13 +35,10 @@ void main(){
//TODO this is very slow //TODO this is very slow
for(float i=0.0; i<LAYERS; i++){ for(float i=0.0; i<LAYERS; i++){
vec2 q = uv* (1.+i*DEPTH); vec2 q = uv* (1.+i*DEPTH);
q += vec2( q.y* WIDTH *( fract(i*7.238917) - .5 ), q += vec2(q.y* WIDTH * (fract(i*7.238917) - .5), SPEED * u_time / (1.+i*DEPTH*.03));
SPEED* u_time / (1.+i*DEPTH*.03) ); vec3 n = vec3(floor(q), 31.189+i), m = floor(n)/1e5 + fract(n), mp = (31.9+m) / fract(p*m), r = fract(mp);
vec3 n = vec3(floor(q), 31.189+i), m = floor(n)/1e5 + fract(n), mp = (31.9+m) / fract(p*m),
r = fract(mp);
vec2 s = abs(fract(q)-.5 +.9*r.xy-.45) + .01*abs(2.0*fract(10.*q.yx) - 1.0); vec2 s = abs(fract(q)-.5 +.9*r.xy-.45) + .01*abs(2.0*fract(10.*q.yx) - 1.0);
float d = .6 * (s.x+s.y) + max(s.x,s.y) -.01, float d = .6 * (s.x+s.y) + max(s.x,s.y) -.01, edge = .005*SIZE + .05 * SIZE * min(.5* abs(i-5.-dof), 1.);
edge = .005*SIZE + .05 * SIZE * min( .5* abs(i-5.-dof), 1.);
gl_FragColor += smoothstep(edge,-edge,d) * r.x / (1.+.02*i*DEPTH); gl_FragColor += smoothstep(edge,-edge,d) * r.x / (1.+.02*i*DEPTH);
} }

View File

@@ -10,6 +10,12 @@ public class Weathers implements ContentList{
@Override @Override
public void load(){ public void load(){
snow = new Weather("snow"){
@Override
public void draw(){
//TODO
}
};
} }
} }

View File

@@ -30,6 +30,11 @@ import static mindustry.Vars.*;
public class Logic implements ApplicationListener{ public class Logic implements ApplicationListener{
public Logic(){ public Logic(){
Events.on(WorldLoadEvent.class, event -> {
//TODO remove later
Weathers.snow.create();
});
Events.on(WaveEvent.class, event -> { Events.on(WaveEvent.class, event -> {
if(state.isCampaign()){ if(state.isCampaign()){
//TODO implement //TODO implement

View File

@@ -39,7 +39,7 @@ public class Renderer implements ApplicationListener{
camera = new Camera(); camera = new Camera();
Shaders.init(); Shaders.init();
fx.addEffect(new SnowFilter()); //fx.addEffect(new SnowFilter());
} }
public void shake(float intensity, float duration){ public void shake(float intensity, float duration){
@@ -253,6 +253,8 @@ public class Renderer implements ApplicationListener{
overlays.drawTop(); overlays.drawTop();
Groups.drawWeather();
endFx(); endFx();
if(!pixelator.enabled()){ if(!pixelator.enabled()){

View File

@@ -1,28 +1,59 @@
package mindustry.type; package mindustry.type;
import arc.func.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.gen.*;
public abstract class Weather extends MappableContent{ public abstract class Weather extends MappableContent{
protected float duration = 100f; protected float duration = 100f;
protected Prov<Weatherc> type = WeatherEntity::create;
public Weather(String name, Prov<Weatherc> type){
super(name);
this.type = type;
}
public Weather(String name){ public Weather(String name){
super(name); super(name);
} }
public abstract void update(); public void create(){
Weatherc entity = type.get();
entity.init(this);
entity.add();
}
public abstract void draw(); public void update(){
}
public void draw(){
}
@Override @Override
public ContentType getContentType(){ public ContentType getContentType(){
return ContentType.weather; return ContentType.weather;
} }
//TODO implement @EntityDef(value = {Weatherc.class}, pooled = true, isFinal = false)
@Component @Component
class WeatherComp{ abstract class WeatherComp implements Posc, DrawLayerWeatherc{
Weather weather; Weather weather;
void init(Weather weather){
this.weather = weather;
}
@Override
public void drawWeather(){
weather.draw();
}
@Override
public float clipSize(){
return Float.MAX_VALUE;
}
} }
} }

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=d781ecb488d5431692ffa509fa1a1a21a8f8185d archash=3c2fae9b66b6affc1ba6701cce19ca9625c5e1b1