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,
overlays,
names,
weather
}
/** 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.StandardEffectComp=7
mindustry.entities.def.TileComp=8
mindustry.type.Weather.WeatherComp=13
phantom=11
spirit=12
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
for(float i=0.0; i<LAYERS; i++){
vec2 q = uv* (1.+i*DEPTH);
q += vec2( q.y* WIDTH *( fract(i*7.238917) - .5 ),
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);
q += vec2(q.y* WIDTH * (fract(i*7.238917) - .5), 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);
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,
edge = .005*SIZE + .05 * SIZE * min( .5* abs(i-5.-dof), 1.);
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.);
gl_FragColor += smoothstep(edge,-edge,d) * r.x / (1.+.02*i*DEPTH);
}

View File

@ -10,6 +10,12 @@ public class Weathers implements ContentList{
@Override
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 Logic(){
Events.on(WorldLoadEvent.class, event -> {
//TODO remove later
Weathers.snow.create();
});
Events.on(WaveEvent.class, event -> {
if(state.isCampaign()){
//TODO implement

View File

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

View File

@ -1,28 +1,59 @@
package mindustry.type;
import arc.func.*;
import mindustry.annotations.Annotations.*;
import mindustry.ctype.*;
import mindustry.gen.*;
public abstract class Weather extends MappableContent{
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){
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
public ContentType getContentType(){
return ContentType.weather;
}
//TODO implement
@EntityDef(value = {Weatherc.class}, pooled = true, isFinal = false)
@Component
class WeatherComp{
abstract class WeatherComp implements Posc, DrawLayerWeatherc{
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.jvmargs=-Xms256m -Xmx1024m
archash=d781ecb488d5431692ffa509fa1a1a21a8f8185d
archash=3c2fae9b66b6affc1ba6701cce19ca9625c5e1b1