diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 1a3b4b1dde..d95145dfb6 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -512,6 +512,7 @@ weather.rain.name = Rain weather.snow.name = Snow weather.sandstorm.name = Sandstorm weather.sporestorm.name = Sporestorm +weather.fog.name = Fog sectors.unexplored = [lightgray]Unexplored sectors.resources = Resources: diff --git a/core/assets/shaders/default.frag b/core/assets/shaders/default.frag new file mode 100644 index 0000000000..93be3cffc9 --- /dev/null +++ b/core/assets/shaders/default.frag @@ -0,0 +1,9 @@ +varying lowp vec4 v_color; +varying lowp vec4 v_mix_color; +varying vec2 v_texCoords; +uniform sampler2D u_texture; + +void main(){ + vec4 c = texture2D(u_texture, v_texCoords); + gl_FragColor = v_color * mix(c, vec4(v_mix_color.rgb, c.a), v_mix_color.a); +} \ No newline at end of file diff --git a/core/assets/sprites/fog.png b/core/assets/sprites/fog.png new file mode 100644 index 0000000000..5121693e58 Binary files /dev/null and b/core/assets/sprites/fog.png differ diff --git a/core/src/mindustry/content/Weathers.java b/core/src/mindustry/content/Weathers.java index d3758eebfb..6f75d477ef 100644 --- a/core/src/mindustry/content/Weathers.java +++ b/core/src/mindustry/content/Weathers.java @@ -1,6 +1,7 @@ package mindustry.content; import arc.graphics.*; +import arc.util.*; import mindustry.ctype.*; import mindustry.type.*; import mindustry.type.weather.*; @@ -11,7 +12,8 @@ public class Weathers implements ContentList{ rain, snow, sandstorm, - sporestorm; + sporestorm, + fog; @Override public void load(){ @@ -29,8 +31,8 @@ public class Weathers implements ContentList{ }}; sandstorm = new ParticleWeather("sandstorm"){{ - color = stormColor = Color.valueOf("f7cba4"); - drawStorm = true; + color = noiseColor = Color.valueOf("f7cba4"); + drawNoise = true; useWindVector = true; sizeMax = 140f; sizeMin = 70f; @@ -45,9 +47,9 @@ public class Weathers implements ContentList{ }}; sporestorm = new ParticleWeather("sporestorm"){{ - color = stormColor = Color.valueOf("7457ce"); + color = noiseColor = Color.valueOf("7457ce"); particleRegion = "circle"; - drawStorm = true; + drawNoise = true; statusGround = false; useWindVector = true; sizeMax = 5f; @@ -62,5 +64,26 @@ public class Weathers implements ContentList{ opacityMultiplier = 0.85f; force = 0.1f; }}; + + fog = new ParticleWeather("fog"){{ + duration = 15f * Time.toMinutes; + noiseLayers = 3; + noiseLayerSclM = 0.8f; + noiseLayerAlphaM = 0.7f; + noiseLayerSpeedM = 2f; + noiseLayerSclM = 0.6f; + baseSpeed = 0.05f; + color = noiseColor = Color.grays(0.4f); + noiseScale = 1100f; + noisePath = "fog"; + drawParticles = false; + drawNoise = true; + useWindVector = false; + xspeed = 1f; + yspeed = 0.01f; + attrs.set(Attribute.light, -0.3f); + attrs.set(Attribute.water, 0.05f); + opacityMultiplier = 0.45f; + }}; } } diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 41472410f4..60beec266b 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -310,7 +310,7 @@ public class World{ //TODO bad code boolean hasSnow = floors[0].name.contains("ice") || floors[0].name.contains("snow"); - boolean hasRain = !hasSnow && floors[0].name.contains("water"); + boolean hasRain = !hasSnow && content.contains(Liquids.water) && !floors[0].name.contains("sand"); boolean hasDesert = !hasSnow && !hasRain && floors[0].name.contains("sand"); boolean hasSpores = floors[0].name.contains("spore") || floors[0].name.contains("moss") || floors[0].name.contains("tainted"); @@ -320,6 +320,7 @@ public class World{ if(hasRain){ state.rules.weather.add(new WeatherEntry(Weathers.rain)); + state.rules.weather.add(new WeatherEntry(Weathers.fog)); } if(hasDesert){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 55c1784fd3..43d5f05bd9 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -159,11 +159,11 @@ public class UnitType extends UnlockableContent{ table.table(bars -> { bars.defaults().growX().height(20f).pad(4); - bars.add(new Bar("blocks.health", Pal.health, unit::healthf).blink(Color.white)); + bars.add(new Bar("stat.health", Pal.health, unit::healthf).blink(Color.white)); bars.row(); if(state.rules.unitAmmo){ - bars.add(new Bar(ammoType.icon + " " + Core.bundle.get("blocks.ammo"), ammoType.barColor, () -> unit.ammo / ammoCapacity)); + bars.add(new Bar(ammoType.icon + " " + Core.bundle.get("stat.ammo"), ammoType.barColor, () -> unit.ammo / ammoCapacity)); bars.row(); } }).growX(); diff --git a/core/src/mindustry/type/Weather.java b/core/src/mindustry/type/Weather.java index 675e378541..4d17ab7c0e 100644 --- a/core/src/mindustry/type/Weather.java +++ b/core/src/mindustry/type/Weather.java @@ -209,15 +209,15 @@ public abstract class Weather extends UnlockableContent{ } } - public void drawNoise(Texture noise, Color color, float noisescl, float opacity, float baseSpeed, float intensity, Vec2 windVector){ + public void drawNoise(Texture noise, Color color, float noisescl, float opacity, float baseSpeed, float intensity, float vwindx, float vwindy, float offset){ Draw.alpha(opacity); Draw.tint(color); float speed = baseSpeed * intensity; - float windx = windVector.x * speed, windy = windVector.y * speed; + float windx = vwindx * speed, windy = vwindy * speed; float scale = 1f / noisescl; - float scroll = Time.time() * scale; + float scroll = Time.time() * scale + offset; Tmp.tr1.texture = noise; Core.camera.bounds(Tmp.r1); Tmp.tr1.set(Tmp.r1.x*scale, Tmp.r1.y*scale, (Tmp.r1.x + Tmp.r1.width)*scale, (Tmp.r1.y + Tmp.r1.height)*scale); diff --git a/core/src/mindustry/type/weather/ParticleWeather.java b/core/src/mindustry/type/weather/ParticleWeather.java index facb4d7297..060e9cbe62 100644 --- a/core/src/mindustry/type/weather/ParticleWeather.java +++ b/core/src/mindustry/type/weather/ParticleWeather.java @@ -15,8 +15,10 @@ public class ParticleWeather extends Weather{ public float yspeed = -2f, xspeed = 0.25f, padding = 16f, sizeMin = 2.4f, sizeMax = 12f, density = 1200f, minAlpha = 1f, maxAlpha = 1f, force = 0, noiseScale = 2000f, baseSpeed = 6.1f; public float sinSclMin = 30f, sinSclMax = 80f, sinMagMin = 1f, sinMagMax = 7f; - public Color stormColor = color; - public boolean drawStorm = false, drawParticles = true, useWindVector = false; + public Color noiseColor = color; + public boolean drawNoise = false, drawParticles = true, useWindVector = false; + public int noiseLayers = 1; + public float noiseLayerSpeedM = 1.1f, noiseLayerAlphaM = 0.8f, noiseLayerSclM = 0.99f, noiseLayerColorM = 1f; public String noisePath = "noiseAlpha"; public @Nullable Texture noise; @@ -32,7 +34,7 @@ public class ParticleWeather extends Weather{ //load noise texture //TODO mod support - if(drawStorm){ + if(drawNoise){ Core.assets.load("sprites/" + noisePath + ".png", Texture.class); } } @@ -52,27 +54,36 @@ public class ParticleWeather extends Weather{ @Override public void drawOver(WeatherState state){ - if(drawStorm){ + float windx, windy; + if(useWindVector){ + float speed = baseSpeed * state.intensity; + windx = state.windVector.x * speed; + windy = state.windVector.y * speed; + }else{ + windx = this.xspeed; + windy = this.yspeed; + } + + if(drawNoise){ if(noise == null){ noise = Core.assets.get("sprites/" + noisePath + ".png", Texture.class); noise.setWrap(TextureWrap.repeat); noise.setFilter(TextureFilter.linear); } - drawNoise(noise, stormColor, noiseScale, state.opacity, baseSpeed, state.intensity, state.windVector); + float sspeed = 1f, sscl = 1f, salpha = 1f, offset = 0f; + Color col = Tmp.c1.set(noiseColor); + for(int i = 0; i < noiseLayers; i++){ + drawNoise(noise, noiseColor, noiseScale * sscl, state.opacity * salpha * opacityMultiplier, baseSpeed * sspeed, state.intensity, windx, windy, offset); + sspeed *= noiseLayerSpeedM; + salpha *= noiseLayerAlphaM; + sscl *= noiseLayerSclM; + offset += 0.29f; + col.mul(noiseLayerColorM); + } } if(drawParticles){ - float windx, windy; - if(useWindVector){ - float speed = baseSpeed * state.intensity; - windx = state.windVector.x * speed; - windy = state.windVector.y * speed; - }else{ - windx = this.xspeed; - windy = this.yspeed; - } - drawParticles(region, color, sizeMin, sizeMax, density, state.intensity, state.opacity, windx, windy, minAlpha, maxAlpha, sinSclMin, sinSclMax, sinMagMin, sinMagMax); } } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index f977a24743..09814e1333 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -343,7 +343,7 @@ public class Block extends UnlockableContent{ } public void setBars(){ - bars.add("health", entity -> new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.white)); + bars.add("health", entity -> new Bar("stat.health", Pal.health, entity::healthf).blink(Color.white)); if(hasLiquids){ Func current;