From 9b8098f7312a2da37d3849d1d3d7e996fed8f7b2 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 27 Apr 2022 11:17:01 -0400 Subject: [PATCH] Added flag for killable units --- core/assets-raw/sprites/items/item-titanium.png | Bin 463 -> 443 bytes .../src/mindustry/entities/comp/ShieldComp.java | 4 +++- core/src/mindustry/entities/comp/UnitComp.java | 4 ++-- core/src/mindustry/type/UnitType.java | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/assets-raw/sprites/items/item-titanium.png b/core/assets-raw/sprites/items/item-titanium.png index fda457e770103059c061c6ea6e9bff64a27fd873..8f9214a89c40b14b79bdde54d6797a3ff7d88549 100644 GIT binary patch delta 404 zcmV;F0c-xx1G@u|F@JSQL_t(og~gXYZo?oL#UDsH0h6Ul-Ft!b2Aw;1>Iu5p9KlMq zo}f$S%sE0X(7jTncF74Mg-+NQKJW+r(>K`|^L{)&V;lHq2>>w0kQWc9E7k0G7B5em zGIJpyV;7m`0AM10St0>4%qK$x00rigAO-*v%!?s9fcKAImVf!>=Q1mV1c16eQ-ep% z=Y;4I`2PHI2Oo`{0})A;25=xuY;aYnEC^MpQ3(Gj=w`kagbQGReks<1umFQKUkV}x z5NHXA!|578L;==f^5&(9)ttf>^88J4iK7kSl-#}H0y&SfEumrgf zzBzSFLAd8Z4S$qC_=YJ6ABHT#DK(MX7JUkqDokI=uVMhG>+|TV`R?JKZD{rOS_xoe zAJAGu%42b1rp)c6$pp04!A-Z@^DIdW%v1jbzUD~6HMa^9pl0uilLRF@fwpaX^PB|y yf#$j=8z2{Azkf{jEdt;|NO=@Z)0A4Qqd)X@9Vf5|wGD~@0000nVVY1tK z0-LS3-XrV<>`hG8W>2umV#Uh92YmcdUpK(;e%}Ko4Dinq0AP$EJ2$%%)$9)zPY+jh z=0ZTmI+^AGU?O8#A^{4_n;`;#3iBq21wey&HN*wr_3evget$e1yFy3+7{@&|dDOfo z#3g~x_YZgSY~>t?NUAh|13|928dT7hgHVIYLine^q$d6i2p7Nr!BTXAKw>#8z#{gZ z5KcR}w9!v-4+!^J4GNpxDS(Iqv_kmiRz5@$pcNw4??Pk&I1n*W=01c3fYs_w)Iy}7 zIKY<#Y9M?AHGim}>fGsAEI~^Wu5k{+eGc|O2}H~=1>wVxo3IpuikaIMJq0ZgC8s5M zD+YjZ+-Gk@*S9xpL#vnPK>(TWfYusPZj1K>$J`c8CZM$rUOJy2yCktNPyHA8>XC$N zZWSazRqu+E1SMO*JkLMoB? 0){ + if(amount > 0 && type.killable){ health -= amount; if(health <= 0 && !dead){ kill(); diff --git a/core/src/mindustry/entities/comp/UnitComp.java b/core/src/mindustry/entities/comp/UnitComp.java index 2fd333d6e5..edb7e5a001 100644 --- a/core/src/mindustry/entities/comp/UnitComp.java +++ b/core/src/mindustry/entities/comp/UnitComp.java @@ -541,7 +541,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()) return; + if(!isAdded() || !type.killable) return; float explosiveness = 2f + item().explosiveness * stack().amount * 1.53f; float flammability = item().flammability * stack().amount / 1.9f; @@ -645,7 +645,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I @Override @Replace public void kill(){ - if(dead || net.client()) return; + if(dead || net.client() || !type.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 712f618ebc..3cb412ca7d 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -68,7 +68,9 @@ public class UnitType extends UnlockableContent{ public boolean logicControllable = true; public boolean playerControllable = true; public boolean allowedInPayloads = true; - /** TODO If true, core units will re-appear on this unit when respawning. */ + /** If false, this unit does not take damage and cannot be kill() / destroy()-ed. */ + public boolean killable = true; + /** If true, this core unit will "dock" to other units, making it re-appear when "undocking". */ public boolean coreUnitDock = false; public boolean createWreck = true; public boolean createScorch = true;