Added sandstorm weather
This commit is contained in:
Binary file not shown.
@@ -4,6 +4,7 @@ import arc.*;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -15,7 +16,8 @@ import static mindustry.Vars.*;
|
|||||||
public class Weathers implements ContentList{
|
public class Weathers implements ContentList{
|
||||||
public static Weather
|
public static Weather
|
||||||
rain,
|
rain,
|
||||||
snow;
|
snow,
|
||||||
|
sandstorm;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
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();
|
state.rules.weather.clear();
|
||||||
|
|
||||||
if(sector.is(SectorAttribute.rainy)){
|
if(sector.is(SectorAttribute.rainy)) state.rules.weather.add(new WeatherEntry(Weathers.rain));
|
||||||
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){
|
public Context filterContext(Map map){
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ public class BaseGenerator{
|
|||||||
this.tiles = tiles;
|
this.tiles = tiles;
|
||||||
this.team = team;
|
this.team = team;
|
||||||
this.cores = cores;
|
this.cores = cores;
|
||||||
|
|
||||||
|
//don't generate bases when there are no loaded schematics
|
||||||
|
if(bases.cores.isEmpty()) return;
|
||||||
|
|
||||||
Mathf.random.setSeed(sector.id);
|
Mathf.random.setSeed(sector.id);
|
||||||
|
|
||||||
for(Block block : content.blocks()){
|
for(Block block : content.blocks()){
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ public class Sector{
|
|||||||
/** Has rain. */
|
/** Has rain. */
|
||||||
rainy,
|
rainy,
|
||||||
/** Has snow. */
|
/** Has snow. */
|
||||||
snowy
|
snowy,
|
||||||
|
/** Has sandstorms. */
|
||||||
|
desert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.tools;
|
package mindustry.tools;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.backend.headless.mock.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.mock.*;
|
import arc.mock.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
@@ -27,6 +28,7 @@ public class SectorDataGenerator{
|
|||||||
Core.files = new MockFiles();
|
Core.files = new MockFiles();
|
||||||
Core.app = new MockApplication();
|
Core.app = new MockApplication();
|
||||||
Core.settings = new MockSettings();
|
Core.settings = new MockSettings();
|
||||||
|
Core.graphics = new MockGraphics();
|
||||||
|
|
||||||
headless = true;
|
headless = true;
|
||||||
net = new Net(null);
|
net = new Net(null);
|
||||||
@@ -121,6 +123,7 @@ public class SectorDataGenerator{
|
|||||||
//TODO bad code
|
//TODO bad code
|
||||||
boolean hasSnow = data.floors[0].name.contains("ice") || data.floors[0].name.contains("snow");
|
boolean hasSnow = data.floors[0].name.contains("ice") || data.floors[0].name.contains("snow");
|
||||||
boolean hasRain = !hasSnow && data.floors[0].name.contains("water");
|
boolean hasRain = !hasSnow && data.floors[0].name.contains("water");
|
||||||
|
boolean hasDesert = !hasSnow && !hasRain && data.floors[0].name.contains("sand");
|
||||||
|
|
||||||
if(hasSnow){
|
if(hasSnow){
|
||||||
data.attributes |= (1 << SectorAttribute.snowy.ordinal());
|
data.attributes |= (1 << SectorAttribute.snowy.ordinal());
|
||||||
@@ -130,6 +133,10 @@ public class SectorDataGenerator{
|
|||||||
data.attributes |= (1 << SectorAttribute.rainy.ordinal());
|
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);
|
data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(UnlockableContent.class);
|
||||||
|
|
||||||
//50% water -> naval attribute
|
//50% water -> naval attribute
|
||||||
|
|||||||
Reference in New Issue
Block a user