mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 15:27:45 +07:00
Fog
This commit is contained in:
@ -512,6 +512,7 @@ weather.rain.name = Rain
|
|||||||
weather.snow.name = Snow
|
weather.snow.name = Snow
|
||||||
weather.sandstorm.name = Sandstorm
|
weather.sandstorm.name = Sandstorm
|
||||||
weather.sporestorm.name = Sporestorm
|
weather.sporestorm.name = Sporestorm
|
||||||
|
weather.fog.name = Fog
|
||||||
|
|
||||||
sectors.unexplored = [lightgray]Unexplored
|
sectors.unexplored = [lightgray]Unexplored
|
||||||
sectors.resources = Resources:
|
sectors.resources = Resources:
|
||||||
|
9
core/assets/shaders/default.frag
Normal file
9
core/assets/shaders/default.frag
Normal 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
BIN
core/assets/sprites/fog.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
@ -1,6 +1,7 @@
|
|||||||
package mindustry.content;
|
package mindustry.content;
|
||||||
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.type.weather.*;
|
import mindustry.type.weather.*;
|
||||||
@ -11,7 +12,8 @@ public class Weathers implements ContentList{
|
|||||||
rain,
|
rain,
|
||||||
snow,
|
snow,
|
||||||
sandstorm,
|
sandstorm,
|
||||||
sporestorm;
|
sporestorm,
|
||||||
|
fog;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
@ -29,8 +31,8 @@ public class Weathers implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
sandstorm = new ParticleWeather("sandstorm"){{
|
sandstorm = new ParticleWeather("sandstorm"){{
|
||||||
color = stormColor = Color.valueOf("f7cba4");
|
color = noiseColor = Color.valueOf("f7cba4");
|
||||||
drawStorm = true;
|
drawNoise = true;
|
||||||
useWindVector = true;
|
useWindVector = true;
|
||||||
sizeMax = 140f;
|
sizeMax = 140f;
|
||||||
sizeMin = 70f;
|
sizeMin = 70f;
|
||||||
@ -45,9 +47,9 @@ public class Weathers implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
sporestorm = new ParticleWeather("sporestorm"){{
|
sporestorm = new ParticleWeather("sporestorm"){{
|
||||||
color = stormColor = Color.valueOf("7457ce");
|
color = noiseColor = Color.valueOf("7457ce");
|
||||||
particleRegion = "circle";
|
particleRegion = "circle";
|
||||||
drawStorm = true;
|
drawNoise = true;
|
||||||
statusGround = false;
|
statusGround = false;
|
||||||
useWindVector = true;
|
useWindVector = true;
|
||||||
sizeMax = 5f;
|
sizeMax = 5f;
|
||||||
@ -62,5 +64,26 @@ public class Weathers implements ContentList{
|
|||||||
opacityMultiplier = 0.85f;
|
opacityMultiplier = 0.85f;
|
||||||
force = 0.1f;
|
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;
|
||||||
|
}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ public class World{
|
|||||||
|
|
||||||
//TODO bad code
|
//TODO bad code
|
||||||
boolean hasSnow = floors[0].name.contains("ice") || floors[0].name.contains("snow");
|
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 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");
|
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){
|
if(hasRain){
|
||||||
state.rules.weather.add(new WeatherEntry(Weathers.rain));
|
state.rules.weather.add(new WeatherEntry(Weathers.rain));
|
||||||
|
state.rules.weather.add(new WeatherEntry(Weathers.fog));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasDesert){
|
if(hasDesert){
|
||||||
|
@ -159,11 +159,11 @@ public class UnitType extends UnlockableContent{
|
|||||||
table.table(bars -> {
|
table.table(bars -> {
|
||||||
bars.defaults().growX().height(20f).pad(4);
|
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();
|
bars.row();
|
||||||
|
|
||||||
if(state.rules.unitAmmo){
|
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();
|
bars.row();
|
||||||
}
|
}
|
||||||
}).growX();
|
}).growX();
|
||||||
|
@ -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.alpha(opacity);
|
||||||
Draw.tint(color);
|
Draw.tint(color);
|
||||||
|
|
||||||
float speed = baseSpeed * intensity;
|
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 scale = 1f / noisescl;
|
||||||
float scroll = Time.time() * scale;
|
float scroll = Time.time() * scale + offset;
|
||||||
Tmp.tr1.texture = noise;
|
Tmp.tr1.texture = noise;
|
||||||
Core.camera.bounds(Tmp.r1);
|
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);
|
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);
|
||||||
|
@ -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 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 float sinSclMin = 30f, sinSclMax = 80f, sinMagMin = 1f, sinMagMax = 7f;
|
||||||
|
|
||||||
public Color stormColor = color;
|
public Color noiseColor = color;
|
||||||
public boolean drawStorm = false, drawParticles = true, useWindVector = false;
|
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 String noisePath = "noiseAlpha";
|
||||||
public @Nullable Texture noise;
|
public @Nullable Texture noise;
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ public class ParticleWeather extends Weather{
|
|||||||
|
|
||||||
//load noise texture
|
//load noise texture
|
||||||
//TODO mod support
|
//TODO mod support
|
||||||
if(drawStorm){
|
if(drawNoise){
|
||||||
Core.assets.load("sprites/" + noisePath + ".png", Texture.class);
|
Core.assets.load("sprites/" + noisePath + ".png", Texture.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,17 +54,6 @@ public class ParticleWeather extends Weather{
|
|||||||
@Override
|
@Override
|
||||||
public void drawOver(WeatherState state){
|
public void drawOver(WeatherState state){
|
||||||
|
|
||||||
if(drawStorm){
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(drawParticles){
|
|
||||||
float windx, windy;
|
float windx, windy;
|
||||||
if(useWindVector){
|
if(useWindVector){
|
||||||
float speed = baseSpeed * state.intensity;
|
float speed = baseSpeed * state.intensity;
|
||||||
@ -73,6 +64,26 @@ public class ParticleWeather extends Weather{
|
|||||||
windy = this.yspeed;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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){
|
||||||
drawParticles(region, color, sizeMin, sizeMax, density, state.intensity, state.opacity, windx, windy, minAlpha, maxAlpha, sinSclMin, sinSclMax, sinMagMin, sinMagMax);
|
drawParticles(region, color, sizeMin, sizeMax, density, state.intensity, state.opacity, windx, windy, minAlpha, maxAlpha, sinSclMin, sinSclMax, sinMagMin, sinMagMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ public class Block extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBars(){
|
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){
|
if(hasLiquids){
|
||||||
Func<Building, Liquid> current;
|
Func<Building, Liquid> current;
|
||||||
|
Reference in New Issue
Block a user