diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 55e608fcdf..da9537b54d 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2538,6 +2538,10 @@ public class Blocks{ ambientSoundVolume = 0.03f; generateEffect = Fx.generatespark; + explosionShake = 1f; + explosionScorchSize = 1; + explosionIgnitionChance = 0.2f; + consume(new ConsumeItemFlammable()); consume(new ConsumeItemExplode()); itemDurationMultipliers.put(Items.pyratite, 3f); @@ -2568,6 +2572,10 @@ public class Blocks{ ambientSound = Sounds.loopSmelter; ambientSoundVolume = 0.06f; + explosionShake = 1f; + explosionScorchSize = 2; + explosionIgnitionChance = 0.2f; + consume(new ConsumeItemFlammable()); consume(new ConsumeItemExplode()); itemDurationMultipliers.put(Items.pyratite, 3f); @@ -2638,6 +2646,10 @@ public class Blocks{ powerProduction = 15f; heating = 0.02f; + explosionShake = 4f; + explosionScorchSize = 8; + explosionIgnitionChance = 0.5f; + consumeItem(Items.thorium); consumeLiquid(Liquids.cryofluid, heating / coolantPower).update(false); }}; diff --git a/core/src/mindustry/world/blocks/power/PowerGenerator.java b/core/src/mindustry/world/blocks/power/PowerGenerator.java index 9b0ef63732..20d59c6f59 100644 --- a/core/src/mindustry/world/blocks/power/PowerGenerator.java +++ b/core/src/mindustry/world/blocks/power/PowerGenerator.java @@ -4,9 +4,11 @@ import arc.*; import arc.audio.*; import arc.graphics.g2d.*; import arc.math.*; +import arc.math.geom.*; import arc.struct.*; import arc.util.*; import arc.util.io.*; +import mindustry.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.entities.units.*; @@ -15,6 +17,7 @@ import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.world.*; +import mindustry.world.blocks.*; import mindustry.world.draw.*; import mindustry.world.meta.*; @@ -38,6 +41,15 @@ public class PowerGenerator extends PowerDistributor{ public float explosionMinWarmup = 0f; public float explosionShake = 0f, explosionShakeDuration = 6f; + public boolean explosionBreaksProps = true; + /** Size of scorch effect on the ground after explosion. Value from 1-9. < 1 to disable. */ + public int explosionScorchSize = 0; + /** Chance for each tile in the explosion radius to catch on fire. */ + public float explosionIgnitionChance = 0f; + /** If true, the ignition chance decreases with distance. */ + public boolean explosionScaleIgnitionChance = true; + /** The speed at which ignition spreads. */ + public float explosionSpeed = 0.5f; public PowerGenerator(String name){ super(name); @@ -120,25 +132,55 @@ public class PowerGenerator extends PowerDistributor{ public void createExplosion(){ if(shouldExplode()){ - if(explosionDamage > 0){ - Damage.damage(x, y, explosionRadius * tilesize, explosionDamage); - } + onExplosion(); + } + } - explodeEffect.at(this); - explodeSound.at(this); + public void onExplosion(){ + if(explosionDamage > 0){ + Damage.damage(x, y, explosionRadius * tilesize, explosionDamage); + } - 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(explosionIgnitionChance > 0 || explosionBreaksProps){ + Geometry.circle(tileX(), tileY(), explosionRadius, (tx, ty) -> { + Tile t = Vars.world.tile(tx, ty); + float dst = Mathf.dst(tileX(), tileY(), tx, ty); + + //Create fires + if(explosionIgnitionChance > 0 && + Mathf.chance(explosionIgnitionChance * + (explosionScaleIgnitionChance ? 1 - Mathf.sqrt(dst / explosionRadius) : 1)) + ){ + Time.run(dst / explosionSpeed, () -> { + Fires.create(t); + }); } - } - if(explosionShake > 0){ - Effect.shake(explosionShake, explosionShakeDuration, this); + //Break boulders + if(explosionBreaksProps && t != null && t.block().unitMoveBreakable){ //Probably a good enough indicator + ConstructBlock.deconstructFinish(t, t.block(), null); + } + }); + } + + 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); + } + + if(explosionScorchSize > 0){ + Effect.scorch(x, y, explosionScorchSize); + } } @Override