From 06e94b18000841b6d3ef92bb0571bd7c3c1ee044 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 11 Mar 2020 10:08:27 -0400 Subject: [PATCH] Cleaned up weather class --- .../mindustry/annotations/Annotations.java | 1 + .../src/main/resources/classids.properties | 1 + .../resources/revisions/WeatherEntity/0.json | 1 + .../resources/revisions/WeatherEntity/1.json | 1 + core/assets-raw/sprites/effects/particle.png | Bin 0 -> 1598 bytes core/assets/shaders/snow.frag | 9 ++-- core/src/mindustry/content/Weathers.java | 6 +++ core/src/mindustry/core/Logic.java | 5 +++ core/src/mindustry/core/Renderer.java | 4 +- core/src/mindustry/type/Weather.java | 41 +++++++++++++++--- gradle.properties | 2 +- 11 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 annotations/src/main/resources/revisions/WeatherEntity/0.json create mode 100644 annotations/src/main/resources/revisions/WeatherEntity/1.json create mode 100644 core/assets-raw/sprites/effects/particle.png diff --git a/annotations/src/main/java/mindustry/annotations/Annotations.java b/annotations/src/main/java/mindustry/annotations/Annotations.java index c4ba024d88..95bd2b2a4a 100644 --- a/annotations/src/main/java/mindustry/annotations/Annotations.java +++ b/annotations/src/main/java/mindustry/annotations/Annotations.java @@ -17,6 +17,7 @@ public class Annotations{ effects, overlays, names, + weather } /** Indicates that a method overrides other methods. */ diff --git a/annotations/src/main/resources/classids.properties b/annotations/src/main/resources/classids.properties index 94cf6c6685..87a75e0f14 100644 --- a/annotations/src/main/resources/classids.properties +++ b/annotations/src/main/resources/classids.properties @@ -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 \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/WeatherEntity/0.json b/annotations/src/main/resources/revisions/WeatherEntity/0.json new file mode 100644 index 0000000000..eaaaeead96 --- /dev/null +++ b/annotations/src/main/resources/revisions/WeatherEntity/0.json @@ -0,0 +1 @@ +{fields:[]} \ No newline at end of file diff --git a/annotations/src/main/resources/revisions/WeatherEntity/1.json b/annotations/src/main/resources/revisions/WeatherEntity/1.json new file mode 100644 index 0000000000..254fbf608c --- /dev/null +++ b/annotations/src/main/resources/revisions/WeatherEntity/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:x,type:float,size:4},{name:y,type:float,size:4}]} \ No newline at end of file diff --git a/core/assets-raw/sprites/effects/particle.png b/core/assets-raw/sprites/effects/particle.png new file mode 100644 index 0000000000000000000000000000000000000000..dabcbab9a97b1b38f62667e3b428dd3567b96f92 GIT binary patch literal 1598 zcmV-E2EqA>P)EX>4Tx04R}tkv&MmP!xqvQ>CI62Rn#31gTCIL`5963Pq?8YK2xEOkVm2O&XFE z7e~Rh;NZ_<)xpJCR|i)?5c~mga&%I3krMAq3N2!M@OU5Ry>qzlUO=dqnPzp21DbA| zsYG1NWLL$|D}v|&(1&4}S;m|sCE>fi?h)YUU5sb>zx#9bsyT}R0g-r?8KzCVK|H-_ z8=UuvBdjQ^#OK6gCKX8h$aTfzH_io@1)do()2Vsl2(egbW2KE*(bR~ih@+~eQ@)V# zSmnIMSu0mrvrhiQa86%Y<~r>mB(R7jND!f*iW17O5u;Nl#X^ei<39dD*DsMvAy)~E z91EyGgY5djXYjkXR(^8AOA5z<&KJk|7y&}NK%?e3-^Y&AI01ssz?I(eSL(pbC+W48 z7CoZDZUYzBElt@2E_Z-|Cqp)6R|?V=@_FF>jK-7&`fq{mHLq{Ydz?N1Y3fz-1~@nb zMhld^?(^@i_P+i5rrEzA2U>D`97^LW00006VoOIv0B!(q0Dxu)nIixI010qNS#tmY zE+YT{E+YYWr9XB6000McNlirueSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00b6EL_t(o!>yR}O;0jeqBZvjXk zja!n>b;f(M+hS&ud=C2(!0=dOW-Wm2d<<*Eiz@(5umM0v%w0bNFhZFeT9LY z_g4(O-b*}pp>$WAh0y;|~a1i%iJ&dxL&7R}Mi0aYA@qLiZr zLN6uoUFE>St7ot5XD^_5Uhrj*c$Gv9G*ZP!DVP&@kEzfChyje|WbkSyYwxAd0?(X8 z5TpXgodDVkxHcme>Ws1(WUU;ygqN*SLElmPC4@1F)grrct#r=(ua&$l>C7q>v|kbx z(`KX<^NTM<4=&Pon|Ic(b6~!DRiFIrOOl^Gae1d-<|O=@8FTjT79eF*EmiP{o;pff zih1k~`hs(2{v>Pax~9FDn;WWIRm5B@?vsD63N%A`KNenkk!Mc)F3H=@@`jx#;ULmo zMl$6(Noc|W%BB}(-ARPzTrbv5&L}cHSpNXts?i}@|E~h12mW=YCD%O@)3(YJ-H)Cdt zIVr8Y(Q6xyfGY`MBec>K#HJovl7#1bCt4o`Xc72USct*WR woPGzu99X@#j0pY^sL!7A+Z_N_0QlwWFActeh*9Rt>Hq)$07*qoM6N<$f->dW`2YX_ literal 0 HcmV?d00001 diff --git a/core/assets/shaders/snow.frag b/core/assets/shaders/snow.frag index 599fa905b9..b17cc756e0 100644 --- a/core/assets/shaders/snow.frag +++ b/core/assets/shaders/snow.frag @@ -35,13 +35,10 @@ void main(){ //TODO this is very slow for(float i=0.0; i { + //TODO remove later + Weathers.snow.create(); + }); + Events.on(WaveEvent.class, event -> { if(state.isCampaign()){ //TODO implement diff --git a/core/src/mindustry/core/Renderer.java b/core/src/mindustry/core/Renderer.java index 29911d307f..87d3235bf4 100644 --- a/core/src/mindustry/core/Renderer.java +++ b/core/src/mindustry/core/Renderer.java @@ -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()){ diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 4a849ea601..4dc805e892 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -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 type = WeatherEntity::create; + + public Weather(String name, Prov 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; + } } } diff --git a/gradle.properties b/gradle.properties index 3601eb66f0..1bbf7facaa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=d781ecb488d5431692ffa509fa1a1a21a8f8185d +archash=3c2fae9b66b6affc1ba6701cce19ca9625c5e1b1