mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-18 23:32:08 -08:00
Added sandstorm weather
This commit is contained in:
parent
42c323365a
commit
47b06d0eac
6 changed files with 73 additions and 8 deletions
Binary file not shown.
|
|
@ -4,6 +4,7 @@ import arc.*;
|
|||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -15,7 +16,8 @@ import static mindustry.Vars.*;
|
|||
public class Weathers implements ContentList{
|
||||
public static Weather
|
||||
rain,
|
||||
snow;
|
||||
snow,
|
||||
sandstorm;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
|
@ -152,5 +154,58 @@ public class Weathers implements ContentList{
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
sandstorm = new Weather("sandstorm"){
|
||||
TextureRegion region;
|
||||
float yspeed = 0.3f, xspeed = 6f, padding = 110f, size = 110f, invDensity = 800f;
|
||||
Vec2 force = new Vec2(0.35f, 0.01f);
|
||||
Color color = Color.valueOf("f7cba4");
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
region = Core.atlas.find("circle-shadow");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOver(Weatherc state){
|
||||
rand.setSeed(0);
|
||||
Tmp.r1.setCentered(Core.camera.position.x, Core.camera.position.y, Core.graphics.getWidth() / renderer.minScale(), Core.graphics.getHeight() / renderer.minScale());
|
||||
Tmp.r1.grow(padding);
|
||||
Core.camera.bounds(Tmp.r2);
|
||||
int total = (int)(Tmp.r1.area() / invDensity * state.intensity());
|
||||
Draw.tint(color);
|
||||
float baseAlpha = Draw.getColor().a;
|
||||
|
||||
for(Unitc unit : Groups.unit){
|
||||
unit.impulse(force.x * state.intensity(), force.y * state.intensity());
|
||||
}
|
||||
|
||||
for(int i = 0; i < total; i++){
|
||||
float scl = rand.random(0.5f, 1f);
|
||||
float scl2 = rand.random(0.5f, 1f);
|
||||
float sscl = rand.random(0.5f, 1f);
|
||||
float x = (rand.random(0f, world.unitWidth()) + Time.time() * xspeed * scl2);
|
||||
float y = (rand.random(0f, world.unitHeight()) - Time.time() * yspeed * scl);
|
||||
float alpha = rand.random(0.2f);
|
||||
|
||||
x += Mathf.sin(y, rand.random(30f, 80f), rand.random(1f, 7f));
|
||||
|
||||
x -= Tmp.r1.x;
|
||||
y -= Tmp.r1.y;
|
||||
x = Mathf.mod(x, Tmp.r1.width);
|
||||
y = Mathf.mod(y, Tmp.r1.height);
|
||||
x += Tmp.r1.x;
|
||||
y += Tmp.r1.y;
|
||||
|
||||
if(Tmp.r3.setCentered(x, y, size * sscl).overlaps(Tmp.r2)){
|
||||
Draw.alpha(alpha * baseAlpha);
|
||||
//Fill.circle(x, y, size * sscl / 2f);
|
||||
Draw.rect(region, x, y, size * sscl, size * sscl);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,13 +257,10 @@ public class World{
|
|||
|
||||
state.rules.weather.clear();
|
||||
|
||||
if(sector.is(SectorAttribute.rainy)){
|
||||
state.rules.weather.add(new WeatherEntry(Weathers.rain));
|
||||
}
|
||||
if(sector.is(SectorAttribute.rainy)) state.rules.weather.add(new WeatherEntry(Weathers.rain));
|
||||
if(sector.is(SectorAttribute.snowy)) state.rules.weather.add(new WeatherEntry(Weathers.snow));
|
||||
if(sector.is(SectorAttribute.desert)) state.rules.weather.add(new WeatherEntry(Weathers.sandstorm));
|
||||
|
||||
if(sector.is(SectorAttribute.snowy)){
|
||||
state.rules.weather.add(new WeatherEntry(Weathers.snow));
|
||||
}
|
||||
}
|
||||
|
||||
public Context filterContext(Map map){
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ public class BaseGenerator{
|
|||
this.tiles = tiles;
|
||||
this.team = team;
|
||||
this.cores = cores;
|
||||
|
||||
//don't generate bases when there are no loaded schematics
|
||||
if(bases.cores.isEmpty()) return;
|
||||
|
||||
Mathf.random.setSeed(sector.id);
|
||||
|
||||
for(Block block : content.blocks()){
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ public class Sector{
|
|||
/** Has rain. */
|
||||
rainy,
|
||||
/** Has snow. */
|
||||
snowy
|
||||
snowy,
|
||||
/** Has sandstorms. */
|
||||
desert
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mindustry.tools;
|
||||
|
||||
import arc.*;
|
||||
import arc.backend.headless.mock.*;
|
||||
import arc.files.*;
|
||||
import arc.mock.*;
|
||||
import arc.struct.*;
|
||||
|
|
@ -27,6 +28,7 @@ public class SectorDataGenerator{
|
|||
Core.files = new MockFiles();
|
||||
Core.app = new MockApplication();
|
||||
Core.settings = new MockSettings();
|
||||
Core.graphics = new MockGraphics();
|
||||
|
||||
headless = true;
|
||||
net = new Net(null);
|
||||
|
|
@ -121,6 +123,7 @@ public class SectorDataGenerator{
|
|||
//TODO bad code
|
||||
boolean hasSnow = data.floors[0].name.contains("ice") || data.floors[0].name.contains("snow");
|
||||
boolean hasRain = !hasSnow && data.floors[0].name.contains("water");
|
||||
boolean hasDesert = !hasSnow && !hasRain && data.floors[0].name.contains("sand");
|
||||
|
||||
if(hasSnow){
|
||||
data.attributes |= (1 << SectorAttribute.snowy.ordinal());
|
||||
|
|
@ -130,6 +133,10 @@ public class SectorDataGenerator{
|
|||
data.attributes |= (1 << SectorAttribute.rainy.ordinal());
|
||||
}
|
||||
|
||||
if(hasDesert){
|
||||
data.attributes |= (1 << SectorAttribute.desert.ordinal());
|
||||
}
|
||||
|
||||
data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(UnlockableContent.class);
|
||||
|
||||
//50% water -> naval attribute
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue