From a09771b569a06930fdd31aa5d3359cd13e05ef84 Mon Sep 17 00:00:00 2001 From: MEEP of Faith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sun, 6 Jun 2021 16:38:12 -0700 Subject: [PATCH] Custom Unit Death Explosion Effects (#5389) --- core/src/mindustry/entities/Damage.java | 9 +++++++-- core/src/mindustry/entities/comp/UnitComp.java | 2 +- core/src/mindustry/type/UnitType.java | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index beb1e2b6c3..176761c349 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -31,11 +31,16 @@ public class Damage{ /** Creates a dynamic explosion based on specified parameters. */ public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, boolean damage){ - dynamicExplosion(x, y, flammability, explosiveness, power, radius, damage, true, null); + dynamicExplosion(x, y, flammability, explosiveness, power, radius, damage, true, null, Fx.dynamicExplosion); } /** Creates a dynamic explosion based on specified parameters. */ public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, boolean damage, boolean fire, @Nullable Team ignoreTeam){ + dynamicExplosion(x, y, flammability, explosiveness, power, radius, damage, fire, ignoreTeam, Fx.dynamicExplosion); + } + + /** Creates a dynamic explosion based on specified parameters. */ + public static void dynamicExplosion(float x, float y, float flammability, float explosiveness, float power, float radius, boolean damage, boolean fire, @Nullable Team ignoreTeam, Effect explosion){ if(damage){ for(int i = 0; i < Mathf.clamp(power / 700, 0, 8); i++){ int length = 5 + Mathf.clamp((int)(power / 500), 1, 20); @@ -69,7 +74,7 @@ public class Damage{ float shake = Math.min(explosiveness / 4f + 3f, 9f); Effect.shake(shake, shake, x, y); - Fx.dynamicExplosion.at(x, y, radius / 8f); + explosion.at(x, y, radius / 8f); } public static void createIncend(float x, float y, float range, int amount){ diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 47a10d113c..370c738d6f 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -450,7 +450,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I float power = item().charge * stack().amount * 150f; if(!spawnedByCore){ - Damage.dynamicExplosion(x, y, flammability, explosiveness, power, bounds() / 2f, state.rules.damageExplosions, item().flammability > 1, team); + Damage.dynamicExplosion(x, y, flammability, explosiveness, power, bounds() / 2f, state.rules.damageExplosions, item().flammability > 1, team, type.deathExplosionEffect); } float shake = hitSize / 3f; diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 14ced69a2d..0bc82be792 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -71,6 +71,7 @@ public class UnitType extends UnlockableContent{ public boolean omniMovement = true; public Effect fallEffect = Fx.fallSmoke; public Effect fallThrusterEffect = Fx.fallSmoke; + public Effect deathExplosionEffect = Fx.dynamicExplosion; public Seq abilities = new Seq<>(); public BlockFlag targetFlag = BlockFlag.generator;