This commit is contained in:
Anuken 2020-10-19 18:28:37 -04:00
parent d5fb0e924a
commit c27251cfb0
9 changed files with 72 additions and 27 deletions

View File

@ -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:

View File

@ -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);
}

BIN
core/assets/sprites/fog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -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;
}};
}
}

View File

@ -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){

View File

@ -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();

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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<Building, Liquid> current;