From 0fd46cf05721cf427f32c259eba90896296d9960 Mon Sep 17 00:00:00 2001 From: Moreperbullet Date: Sun, 17 Aug 2025 22:26:00 +0800 Subject: [PATCH] Turn killable from variable to method (#11146) * Turn killable from variable to method * Update UnitType.java * Update UnitComp.java --- core/src/mindustry/entities/comp/UnitComp.java | 8 ++++++-- core/src/mindustry/type/UnitType.java | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 68a22f48fc..8e47c5ea52 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -532,6 +532,10 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I return type.targetable(self(), targeter); } + public boolean killable(){ + return type.killable(self()); + } + public boolean hittable(){ return type.hittable(self()); } @@ -832,7 +836,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I /** Actually destroys the unit, removing it and creating explosions. **/ public void destroy(){ - if(!isAdded() || !type.killable) return; + if(!isAdded() || !killable()) return; float explosiveness = 2f + item().explosiveness * stack().amount * 1.53f; float flammability = item().flammability * stack().amount / 1.9f; @@ -937,7 +941,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override @Replace public void kill(){ - if(dead || net.client() || !type.killable) return; + if(dead || net.client() || !killable()) return; //deaths are synced; this calls killed() Call.unitDeath(id); diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 540bfe33eb..f6a463c41a 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -593,6 +593,10 @@ public class UnitType extends UnlockableContent implements Senseable{ return targetable || (vulnerableWithPayloads && unit instanceof Payloadc p && p.hasPayload()); } + public boolean killable(Unit unit){ + return killable; + } + public boolean hittable(Unit unit){ return hittable || (vulnerableWithPayloads && unit instanceof Payloadc p && p.hasPayload()); }