Spore storms / Weather attribute effects
This commit is contained in:
Binary file not shown.
@@ -11,6 +11,7 @@ import mindustry.ctype.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -18,7 +19,8 @@ public class Weathers implements ContentList{
|
|||||||
public static Weather
|
public static Weather
|
||||||
rain,
|
rain,
|
||||||
snow,
|
snow,
|
||||||
sandstorm;
|
sandstorm,
|
||||||
|
sporestorm;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
@@ -26,6 +28,10 @@ public class Weathers implements ContentList{
|
|||||||
TextureRegion region;
|
TextureRegion region;
|
||||||
float yspeed = 2f, xspeed = 0.25f, padding = 16f, size = 12f, density = 1200f;
|
float yspeed = 2f, xspeed = 0.25f, padding = 16f, size = 12f, density = 1200f;
|
||||||
|
|
||||||
|
{
|
||||||
|
attrs.set(Attribute.light, -0.15f);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
super.load();
|
super.load();
|
||||||
@@ -69,6 +75,11 @@ public class Weathers implements ContentList{
|
|||||||
float yspeed = 5f, xspeed = 1.5f, padding = 16f, size = 40f, density = 1200f;
|
float yspeed = 5f, xspeed = 1.5f, padding = 16f, size = 40f, density = 1200f;
|
||||||
TextureRegion[] splashes = new TextureRegion[12];
|
TextureRegion[] splashes = new TextureRegion[12];
|
||||||
|
|
||||||
|
{
|
||||||
|
attrs.set(Attribute.light, -0.2f);
|
||||||
|
attrs.set(Attribute.water, 0.2f);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
super.load();
|
super.load();
|
||||||
@@ -164,6 +175,10 @@ public class Weathers implements ContentList{
|
|||||||
Color color = Color.valueOf("f7cba4");
|
Color color = Color.valueOf("f7cba4");
|
||||||
Texture noise;
|
Texture noise;
|
||||||
|
|
||||||
|
{
|
||||||
|
attrs.set(Attribute.light, -0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
region = Core.atlas.find("circle-shadow");
|
region = Core.atlas.find("circle-shadow");
|
||||||
@@ -229,5 +244,76 @@ public class Weathers implements ContentList{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sporestorm = new Weather("sporestorm"){
|
||||||
|
TextureRegion region;
|
||||||
|
float yspeed = 1f, xspeed = 4f, size = 5f, padding = size, invDensity = 2000f;
|
||||||
|
Color color = Color.valueOf("7457ce");
|
||||||
|
Texture noise;
|
||||||
|
|
||||||
|
{
|
||||||
|
attrs.set(Attribute.spores, 0.5f);
|
||||||
|
attrs.set(Attribute.light, -0.1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(){
|
||||||
|
region = Core.atlas.find("circle-shadow");
|
||||||
|
noise = new Texture("sprites/noiseAlpha.png");
|
||||||
|
noise.setWrap(TextureWrap.repeat);
|
||||||
|
noise.setFilter(TextureFilter.linear);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
noise.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawOver(WeatherState state){
|
||||||
|
Draw.alpha(state.opacity * 0.8f);
|
||||||
|
Draw.tint(color);
|
||||||
|
|
||||||
|
float scale = 1f / 2000f;
|
||||||
|
float scroll = Time.time() * scale;
|
||||||
|
Tmp.tr1.setTexture(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);
|
||||||
|
Tmp.tr1.scroll(-xspeed * scroll, -yspeed * scroll);
|
||||||
|
Draw.rect(Tmp.tr1, Core.camera.position.x, Core.camera.position.y, Core.camera.width, -Core.camera.height);
|
||||||
|
|
||||||
|
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 = state.opacity;
|
||||||
|
Draw.alpha(baseAlpha);
|
||||||
|
|
||||||
|
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.1f, 0.8f);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import mindustry.game.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.maps.*;
|
import mindustry.maps.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -23,6 +24,8 @@ public class GameState{
|
|||||||
public Rules rules = new Rules();
|
public Rules rules = new Rules();
|
||||||
/** Statistics for this save/game. Displayed after game over. */
|
/** Statistics for this save/game. Displayed after game over. */
|
||||||
public Stats stats = new Stats();
|
public Stats stats = new Stats();
|
||||||
|
/** Global attributes of the environment, calculated by weather. */
|
||||||
|
public Attributes envAttrs = new Attributes();
|
||||||
/** Sector information. Only valid in the campaign. */
|
/** Sector information. Only valid in the campaign. */
|
||||||
public SectorInfo secinfo = new SectorInfo();
|
public SectorInfo secinfo = new SectorInfo();
|
||||||
/** Team data. Gets reset every new game. */
|
/** Team data. Gets reset every new game. */
|
||||||
|
|||||||
@@ -352,6 +352,10 @@ public class Logic implements ApplicationListener{
|
|||||||
runWave();
|
runWave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//apply weather attributes
|
||||||
|
state.envAttrs.clear();
|
||||||
|
Groups.weather.each(w -> state.envAttrs.add(w.weather.attrs, w.opacity));
|
||||||
|
|
||||||
Groups.update();
|
Groups.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class WaveGraph extends Table{
|
|||||||
for(Mode m : Mode.all){
|
for(Mode m : Mode.all){
|
||||||
t.button("$wavemode." + m.name(), Styles.fullTogglet, () -> {
|
t.button("$wavemode." + m.name(), Styles.fullTogglet, () -> {
|
||||||
mode = m;
|
mode = m;
|
||||||
}).group(group).height(32f).update(b -> b.setChecked(m == mode)).width(100f);
|
}).group(group).height(32f).update(b -> b.setChecked(m == mode)).width(130f);
|
||||||
}
|
}
|
||||||
}).growX();
|
}).growX();
|
||||||
}
|
}
|
||||||
@@ -201,6 +201,7 @@ public class WaveGraph extends Table{
|
|||||||
|
|
||||||
enum Mode{
|
enum Mode{
|
||||||
counts, totals, health;
|
counts, totals, health;
|
||||||
|
|
||||||
static Mode[] all = values();
|
static Mode[] all = values();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -703,7 +703,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getProgressIncrease(float baseTime){
|
public float getProgressIncrease(float baseTime){
|
||||||
return 1f / baseTime * delta() * efficiency();
|
return 1f / baseTime * edelta();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getDisplayEfficiency(){
|
||||||
|
return getProgressIncrease(1f) / edelta();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return whether this block should play its active sound.*/
|
/** @return whether this block should play its active sound.*/
|
||||||
|
|||||||
@@ -390,6 +390,8 @@ public class Sector{
|
|||||||
/** Has sandstorms. */
|
/** Has sandstorms. */
|
||||||
desert,
|
desert,
|
||||||
/** Has an enemy base. */
|
/** Has an enemy base. */
|
||||||
base
|
base,
|
||||||
|
/** Has spore weather. */
|
||||||
|
spores
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ import mindustry.annotations.Annotations.*;
|
|||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static mindustry.Vars.renderer;
|
import static mindustry.Vars.renderer;
|
||||||
|
|
||||||
public abstract class Weather extends MappableContent{
|
public abstract class Weather extends MappableContent{
|
||||||
/** Default duration of this weather event in ticks. */
|
/** Default duration of this weather event in ticks. */
|
||||||
public float duration = 15f * Time.toMinutes;
|
public float duration = 15f * Time.toMinutes;
|
||||||
|
public Attributes attrs = new Attributes();
|
||||||
|
|
||||||
//internals
|
//internals
|
||||||
public Rand rand = new Rand();
|
public Rand rand = new Rand();
|
||||||
|
|||||||
@@ -1,15 +1,51 @@
|
|||||||
package mindustry.world.blocks;
|
package mindustry.world.blocks;
|
||||||
|
|
||||||
|
import arc.util.serialization.*;
|
||||||
|
import arc.util.serialization.Json.*;
|
||||||
import mindustry.world.meta.Attribute;
|
import mindustry.world.meta.Attribute;
|
||||||
|
|
||||||
public class Attributes{
|
import java.util.*;
|
||||||
private float[] array = new float[Attribute.values().length];
|
|
||||||
|
public class Attributes implements Serializable{
|
||||||
|
private final float[] arr = new float[Attribute.all.length];
|
||||||
|
|
||||||
|
public void clear(){
|
||||||
|
Arrays.fill(arr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public float get(Attribute attr){
|
public float get(Attribute attr){
|
||||||
return array[attr.ordinal()];
|
return arr[attr.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(Attribute attr, float value){
|
public void set(Attribute attr, float value){
|
||||||
array[attr.ordinal()] = value;
|
arr[attr.ordinal()] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Attributes other){
|
||||||
|
for(int i = 0; i < arr.length; i++){
|
||||||
|
arr[i] += other.arr[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Attributes other, float scl){
|
||||||
|
for(int i = 0; i < arr.length; i++){
|
||||||
|
arr[i] += other.arr[i] * scl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(Json json){
|
||||||
|
for(Attribute at : Attribute.all){
|
||||||
|
if(arr[at.ordinal()] != 0){
|
||||||
|
json.writeValue(at.name(), arr[at.ordinal()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Json json, JsonValue data){
|
||||||
|
for(Attribute at : Attribute.all){
|
||||||
|
arr[at.ordinal()] = data.getFloat(at.name(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package mindustry.world.blocks.power;
|
package mindustry.world.blocks.power;
|
||||||
|
|
||||||
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
@@ -23,7 +24,10 @@ public class SolarGenerator extends PowerGenerator{
|
|||||||
public class SolarGeneratorEntity extends GeneratorEntity{
|
public class SolarGeneratorEntity extends GeneratorEntity{
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
productionEfficiency = state.rules.solarPowerMultiplier < 0 ? (state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) : state.rules.solarPowerMultiplier;
|
productionEfficiency =
|
||||||
|
Mathf.maxZero(Attribute.light.env() + state.rules.solarPowerMultiplier < 0 ?
|
||||||
|
(state.rules.lighting ? 1f - state.rules.ambientLight.a : 1f) :
|
||||||
|
state.rules.solarPowerMultiplier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ public class ThermalGenerator extends PowerGenerator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class ThermalGeneratorEntity extends GeneratorEntity{
|
public class ThermalGeneratorEntity extends GeneratorEntity{
|
||||||
|
public float sum;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
|
productionEfficiency = sum + attribute.env();
|
||||||
|
|
||||||
if(productionEfficiency > 0.1f && Mathf.chance(0.05 * delta())){
|
if(productionEfficiency > 0.1f && Mathf.chance(0.05 * delta())){
|
||||||
generateEffect.at(x + Mathf.range(3f), y + Mathf.range(3f));
|
generateEffect.at(x + Mathf.range(3f), y + Mathf.range(3f));
|
||||||
}
|
}
|
||||||
@@ -53,14 +57,7 @@ public class ThermalGenerator extends PowerGenerator{
|
|||||||
public void onProximityAdded(){
|
public void onProximityAdded(){
|
||||||
super.onProximityAdded();
|
super.onProximityAdded();
|
||||||
|
|
||||||
productionEfficiency = sumAttribute(attribute, tile.x, tile.y);
|
sum = sumAttribute(attribute, tile.x, tile.y);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getPowerProduction(){
|
|
||||||
//in this case, productionEfficiency means 'total heat'
|
|
||||||
//thus, it may be greater than 1.0
|
|
||||||
return powerProduction * productionEfficiency;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class Cultivator extends GenericCrafter{
|
|||||||
super.setBars();
|
super.setBars();
|
||||||
bars.add("multiplier", (CultivatorEntity entity) -> new Bar(() ->
|
bars.add("multiplier", (CultivatorEntity entity) -> new Bar(() ->
|
||||||
Core.bundle.formatFloat("bar.efficiency",
|
Core.bundle.formatFloat("bar.efficiency",
|
||||||
((entity.boost + 1f) * entity.warmup) * 100f, 1),
|
((entity.boost + 1f + attribute.env()) * entity.warmup) * 100f, 1),
|
||||||
() -> Pal.ammo,
|
() -> Pal.ammo,
|
||||||
() -> entity.warmup));
|
() -> entity.warmup));
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public class Cultivator extends GenericCrafter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getProgressIncrease(float baseTime){
|
public float getProgressIncrease(float baseTime){
|
||||||
return super.getProgressIncrease(baseTime) * (1f + boost);
|
return super.getProgressIncrease(baseTime) * (1f + boost + attribute.env());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public class SolidPump extends Pump{
|
|||||||
if(canPump(tile)) fraction = 1f;
|
if(canPump(tile)) fraction = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
fraction += boost;
|
fraction += boost + (attribute == null ? 0 : attribute.env());
|
||||||
fraction = Math.max(fraction, 0);
|
fraction = Math.max(fraction, 0);
|
||||||
|
|
||||||
if(cons.valid() && typeLiquid() < liquidCapacity - 0.001f){
|
if(cons.valid() && typeLiquid() < liquidCapacity - 0.001f){
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package mindustry.world.meta;
|
package mindustry.world.meta;
|
||||||
|
|
||||||
|
import mindustry.*;
|
||||||
|
|
||||||
public enum Attribute{
|
public enum Attribute{
|
||||||
/** Heat of this block. Used for calculating output of thermal generators. */
|
/** Heat of this block. Used for calculating output of thermal generators. */
|
||||||
heat,
|
heat,
|
||||||
@@ -8,5 +10,15 @@ public enum Attribute{
|
|||||||
/** Water content of this block. Used for increasing water extractor yield. */
|
/** Water content of this block. Used for increasing water extractor yield. */
|
||||||
water,
|
water,
|
||||||
/** Oil content of this block. Used for increasing oil extractor yield. */
|
/** Oil content of this block. Used for increasing oil extractor yield. */
|
||||||
oil
|
oil,
|
||||||
|
/** Light coverage. Negative values decrease solar panel efficiency. */
|
||||||
|
light;
|
||||||
|
|
||||||
|
public static final Attribute[] all = values();
|
||||||
|
|
||||||
|
/** @return the envrionmental value for this attribute. */
|
||||||
|
public float env(){
|
||||||
|
if(Vars.state == null) return 0;
|
||||||
|
return Vars.state.envAttrs.get(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ public class SectorDataGenerator{
|
|||||||
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");
|
boolean hasDesert = !hasSnow && !hasRain && data.floors[0].name.contains("sand");
|
||||||
|
boolean hasSpores = data.floors[0].name.contains("spore") || data.floors[0].name.contains("moss") || data.floors[0].name.contains("tainted");
|
||||||
|
|
||||||
if(hasSnow){
|
if(hasSnow){
|
||||||
data.attributes |= (1 << SectorAttribute.snowy.ordinal());
|
data.attributes |= (1 << SectorAttribute.snowy.ordinal());
|
||||||
@@ -137,6 +138,10 @@ public class SectorDataGenerator{
|
|||||||
data.attributes |= (1 << SectorAttribute.desert.ordinal());
|
data.attributes |= (1 << SectorAttribute.desert.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(hasSpores){
|
||||||
|
data.attributes |= (1 << SectorAttribute.spores.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