Generator explosion system cleanup
This commit is contained in:
@@ -21,6 +21,8 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
public float generateEffectRange = 3f;
|
||||
|
||||
public @Nullable LiquidStack outputLiquid;
|
||||
/** If true, this block explodes when outputLiquid exceeds capacity. */
|
||||
public boolean explodeOnFull = false;
|
||||
|
||||
public @Nullable ConsumeItemFilter filterItem;
|
||||
public @Nullable ConsumeLiquidFilter filterLiquid;
|
||||
@@ -48,6 +50,10 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
hasLiquids = true;
|
||||
}
|
||||
|
||||
if(explodeOnFull && outputLiquid != null && explosionPuddleLiquid == null){
|
||||
explosionPuddleLiquid = outputLiquid.liquid;
|
||||
}
|
||||
|
||||
//TODO hardcoded
|
||||
emitLight = true;
|
||||
lightRadius = 65f * size;
|
||||
@@ -106,6 +112,10 @@ public class ConsumeGenerator extends PowerGenerator{
|
||||
float added = Math.min(productionEfficiency * delta() * outputLiquid.amount, liquidCapacity - liquids.get(outputLiquid.liquid));
|
||||
liquids.add(outputLiquid.liquid, added);
|
||||
dumpLiquid(outputLiquid.liquid);
|
||||
|
||||
if(explodeOnFull && liquids.get(outputLiquid.liquid) >= liquidCapacity - 0.0001f){
|
||||
kill();
|
||||
}
|
||||
}
|
||||
|
||||
//generation time always goes down, but only at the end so consumeTriggerValid doesn't assume fake items
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -16,17 +14,10 @@ import mindustry.ui.*;
|
||||
import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ImpactReactor extends PowerGenerator{
|
||||
public final int timerUse = timers++;
|
||||
|
||||
public float warmupSpeed = 0.001f;
|
||||
public float itemDuration = 60f;
|
||||
public int explosionRadius = 23;
|
||||
public int explosionDamage = 1900;
|
||||
public Effect explodeEffect = Fx.impactReactorExplosion;
|
||||
public Sound explodeSound = Sounds.explosionbig;
|
||||
|
||||
public ImpactReactor(String name){
|
||||
super(name);
|
||||
@@ -41,6 +32,12 @@ public class ImpactReactor extends PowerGenerator{
|
||||
envEnabled = Env.any;
|
||||
|
||||
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawPlasma(), new DrawDefault());
|
||||
|
||||
explosionShake = 6f;
|
||||
explosionShakeDuration = 16f;
|
||||
explosionDamage = 1900 * 4;
|
||||
explodeEffect = Fx.impactReactorExplosion;
|
||||
explodeSound = Sounds.explosionbig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,16 +111,10 @@ public class ImpactReactor extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
if(warmup < 0.3f || !state.rules.reactorExplosions) return;
|
||||
|
||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
|
||||
|
||||
Effect.shake(6f, 16f, x, y);
|
||||
explodeEffect.at(this);
|
||||
explodeSound.at(this);
|
||||
public void createExplosion(){
|
||||
if(warmup >= 0.3f){
|
||||
super.createExplosion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -10,7 +9,6 @@ import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@@ -27,8 +25,6 @@ public class NuclearReactor extends PowerGenerator{
|
||||
public Color lightColor = Color.valueOf("7f19ea");
|
||||
public Color coolColor = new Color(1, 1, 1, 0f);
|
||||
public Color hotColor = Color.valueOf("ff9575a3");
|
||||
public Effect explodeEffect = Fx.reactorExplosion;
|
||||
public Sound explodeSound = Sounds.explosionbig;
|
||||
/** ticks to consume 1 fuel */
|
||||
public float itemDuration = 120;
|
||||
/** heating per frame * fullness */
|
||||
@@ -37,8 +33,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
public float smokeThreshold = 0.3f;
|
||||
/** heat threshold at which lights start flashing */
|
||||
public float flashThreshold = 0.46f;
|
||||
public int explosionRadius = 19;
|
||||
public int explosionDamage = 1250;
|
||||
|
||||
/** heat removed per unit of coolant */
|
||||
public float coolantPower = 0.5f;
|
||||
public float smoothLight;
|
||||
@@ -58,6 +53,15 @@ public class NuclearReactor extends PowerGenerator{
|
||||
flags = EnumSet.of(BlockFlag.reactor, BlockFlag.generator);
|
||||
schematicPriority = -5;
|
||||
envEnabled = Env.any;
|
||||
|
||||
explosionShake = 6f;
|
||||
explosionShakeDuration = 16f;
|
||||
|
||||
explosionRadius = 19;
|
||||
explosionDamage = 1250 * 4;
|
||||
|
||||
explodeEffect = Fx.reactorExplosion;
|
||||
explodeSound = Sounds.explosionbig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,19 +128,10 @@ public class NuclearReactor extends PowerGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
int fuel = items.get(fuelItem);
|
||||
|
||||
if((fuel < 5 && heat < 0.5f) || !state.rules.reactorExplosions) return;
|
||||
|
||||
Effect.shake(6f, 16f, x, y);
|
||||
// * ((float)fuel / itemCapacity) to scale based on fullness
|
||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
|
||||
|
||||
explodeEffect.at(this);
|
||||
explodeSound.at(this);
|
||||
public void createExplosion(){
|
||||
if(items.get(fuelItem) >= 5 && heat >= 0.5f){
|
||||
super.createExplosion();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,43 @@
|
||||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PowerGenerator extends PowerDistributor{
|
||||
/** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */
|
||||
public float powerProduction;
|
||||
public Stat generationType = Stat.basePowerGeneration;
|
||||
public DrawBlock drawer = new DrawDefault();
|
||||
|
||||
public int explosionRadius = 12;
|
||||
public int explosionDamage = 0;
|
||||
public Effect explodeEffect = Fx.none;
|
||||
public Sound explodeSound = Sounds.none;
|
||||
|
||||
public int explosionPuddles = 10;
|
||||
public float explosionPuddleRange = tilesize * 2f;
|
||||
public float explosionPuddleAmount = 100f;
|
||||
public @Nullable Liquid explosionPuddleLiquid;
|
||||
|
||||
public float explosionShake = 0f, explosionShakeDuration = 6f;
|
||||
|
||||
public PowerGenerator(String name){
|
||||
super(name);
|
||||
sync = true;
|
||||
@@ -81,6 +100,36 @@ public class PowerGenerator extends PowerDistributor{
|
||||
return productionEfficiency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
if(state.rules.reactorExplosions){
|
||||
createExplosion();
|
||||
}
|
||||
}
|
||||
|
||||
public void createExplosion(){
|
||||
if(explosionDamage > 0){
|
||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage);
|
||||
}
|
||||
|
||||
explodeEffect.at(this);
|
||||
explodeSound.at(this);
|
||||
|
||||
if(explosionPuddleLiquid != null){
|
||||
for(int i = 0; i < explosionPuddles; i++){
|
||||
Tmp.v1.trns(Mathf.random(360f), Mathf.random(explosionPuddleRange));
|
||||
Tile tile = world.tileWorld(x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
Puddles.deposit(tile, explosionPuddleLiquid, explosionPuddleAmount);
|
||||
}
|
||||
}
|
||||
|
||||
if(explosionShake > 0){
|
||||
Effect.shake(explosionShake, explosionShakeDuration, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(){
|
||||
super.drawLight();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package mindustry.world.blocks.power;
|
||||
|
||||
import arc.*;
|
||||
import arc.audio.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
@@ -13,9 +12,7 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@@ -32,22 +29,23 @@ public class VariableReactor extends PowerGenerator{
|
||||
public float flashThreshold = 0.01f, flashAlpha = 0.4f, flashSpeed = 7f;
|
||||
public Color flashColor1 = Color.red, flashColor2 = Color.valueOf("89e8b6");
|
||||
|
||||
public int explosionRadius = 12;
|
||||
public int explosionDamage = 1000;
|
||||
public Effect explodeEffect = new MultiEffect(Fx.bigShockwave, new WrapEffect(Fx.titanSmoke, Color.valueOf("e3ae6f")));
|
||||
public Sound explodeSound = Sounds.explosionbig;
|
||||
|
||||
public int puddles = 70;
|
||||
public float puddleRange = tilesize * 6f;
|
||||
public Liquid puddleLiquid = Liquids.slag;
|
||||
public float puddleAmount = 100f;
|
||||
|
||||
public @Load("@-lights") TextureRegion lightsRegion;
|
||||
|
||||
public VariableReactor(String name){
|
||||
super(name);
|
||||
powerProduction = 20f;
|
||||
rebuildable = false;
|
||||
|
||||
|
||||
explosionRadius = 12;
|
||||
explosionDamage = 1000;
|
||||
explodeEffect = new MultiEffect(Fx.bigShockwave, new WrapEffect(Fx.titanSmoke, Color.valueOf("e3ae6f")));
|
||||
explodeSound = Sounds.explosionbig;
|
||||
|
||||
explosionPuddles = 70;
|
||||
explosionPuddleRange = tilesize * 6f;
|
||||
explosionPuddleLiquid = Liquids.slag;
|
||||
explosionPuddleAmount = 100f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,24 +84,6 @@ public class VariableReactor extends PowerGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
if(!state.rules.reactorExplosions) return;
|
||||
|
||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage);
|
||||
|
||||
explodeEffect.at(this);
|
||||
explodeSound.at(this);
|
||||
|
||||
for(int i = 0; i < puddles; i++){
|
||||
Tmp.v1.trns(Mathf.random(360f), Mathf.random(puddleRange));
|
||||
Tile tile = world.tileWorld(x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
Puddles.deposit(tile, puddleLiquid, puddleAmount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
super.draw();
|
||||
|
||||
Reference in New Issue
Block a user