From be5c46beb8df633b9dcb3578aaa781b181eb9594 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 27 Oct 2021 15:51:46 -0400 Subject: [PATCH] Weapon layerOffset --- core/src/mindustry/type/Weapon.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index af6b19b05e..04facbab05 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -97,6 +97,8 @@ public class Weapon implements Cloneable{ public boolean parentizeEffects; /** internal value used for alternation - do not change! */ public int otherSide = -1; + /** draw Z offset relative to the default value */ + public float layerOffset = 0f; /** sound used for shooting */ public Sound shootSound = Sounds.pew; /** sound used for weapons that have a delay */ @@ -161,6 +163,10 @@ public class Weapon implements Cloneable{ } public void draw(Unit unit, WeaponMount mount){ + //apply layer offset, roll it back at the end + float z = Draw.z(); + Draw.z(z + layerOffset); + float rotation = unit.rotation - 90, weaponRotation = rotation + (rotate ? mount.rotation : 0), @@ -196,6 +202,8 @@ public class Weapon implements Cloneable{ Draw.blend(); Draw.color(); } + + Draw.z(z); } public void update(Unit unit, WeaponMount mount){