mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Merge bb144185a1 into a01e4be75d
This commit is contained in:
commit
b36bf77075
2 changed files with 67 additions and 13 deletions
|
|
@ -2513,6 +2513,10 @@ public class Blocks{
|
|||
ambientSoundVolume = 0.03f;
|
||||
generateEffect = Fx.generatespark;
|
||||
|
||||
explosionShake = 1f;
|
||||
explosionScorchSize = 1;
|
||||
explosionIgnitionChance = 0.2f;
|
||||
|
||||
consume(new ConsumeItemFlammable());
|
||||
consume(new ConsumeItemExplode());
|
||||
|
||||
|
|
@ -2542,6 +2546,10 @@ public class Blocks{
|
|||
ambientSound = Sounds.smelter;
|
||||
ambientSoundVolume = 0.06f;
|
||||
|
||||
explosionShake = 1f;
|
||||
explosionScorchSize = 2;
|
||||
explosionIgnitionChance = 0.2f;
|
||||
|
||||
consume(new ConsumeItemFlammable());
|
||||
consume(new ConsumeItemExplode());
|
||||
|
||||
|
|
@ -2611,6 +2619,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);
|
||||
}};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue