From 7a21c024768985bf43658e4772170559ff3dd93b Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Mon, 15 Feb 2021 15:32:46 +0100 Subject: [PATCH] Makes the top sprite visible on liquid turret icons (#4683) * Add top region to liquid turret icons * Attempt to change outline icon generation * Draw regions above the outlined icon over it * Draw regions **above** the outlined icon over it * Add clarrifying comment * Implement backwards compatibility for mods * an -> any --- core/src/mindustry/world/Block.java | 6 ++++-- .../world/blocks/defense/turrets/LiquidTurret.java | 7 +++++++ tools/src/mindustry/tools/Generators.java | 10 +++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index d8cca61641..da9702d902 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -160,8 +160,10 @@ public class Block extends UnlockableContent{ public boolean canOverdrive = true; /** Outlined icon color.*/ public Color outlineColor = Color.valueOf("404049"); - /** Whether the icon region has an outline added. */ + /** Whether any icon region has an outline added. */ public boolean outlineIcon = false; + /** Which of the icon regions gets the outline added. */ + public int outlinedIcon = -1; /** Whether this block has a shadow under it. */ public boolean hasShadow = true; /** Sounds made when this block breaks.*/ @@ -768,7 +770,7 @@ public class Block extends UnlockableContent{ if(outlineIcon){ final int radius = 4; - PixmapRegion region = Core.atlas.getPixmap(getGeneratedIcons()[getGeneratedIcons().length-1]); + PixmapRegion region = Core.atlas.getPixmap(getGeneratedIcons()[outlinedIcon >= 0 ? outlinedIcon : getGeneratedIcons().length -1]); Pixmap out = new Pixmap(region.width, region.height); Color color = new Color(); for(int x = 0; x < region.width; x++){ diff --git a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java index 4abfa3140c..bb53932b4c 100644 --- a/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java +++ b/core/src/mindustry/world/blocks/defense/turrets/LiquidTurret.java @@ -27,6 +27,7 @@ public class LiquidTurret extends Turret{ hasLiquids = true; loopSound = Sounds.spray; shootSound = Sounds.none; + outlinedIcon = 1; } /** Initializes accepted ammo map. Format: [liquid1, bullet1, liquid2, bullet2...] */ @@ -63,6 +64,12 @@ public class LiquidTurret extends Turret{ super.init(); } + @Override + public TextureRegion[] icons(){ + if(topRegion.found()) return new TextureRegion[]{baseRegion, region, topRegion}; + return super.icons(); + } + public class LiquidTurretBuild extends TurretBuild{ @Override public void draw(){ diff --git a/tools/src/mindustry/tools/Generators.java b/tools/src/mindustry/tools/Generators.java index 7c0f7869a7..ef579df8c4 100644 --- a/tools/src/mindustry/tools/Generators.java +++ b/tools/src/mindustry/tools/Generators.java @@ -247,7 +247,7 @@ public class Generators{ Image last = null; if(block.outlineIcon){ int radius = 4; - GenRegion region = (GenRegion)regions[regions.length - 1]; + GenRegion region = (GenRegion)regions[block.outlinedIcon >= 0 ? block.outlinedIcon : regions.length -1]; Image base = ImagePacker.get(region); Image out = last = new Image(region.width, region.height); for(int x = 0; x < out.width; x++){ @@ -273,6 +273,14 @@ public class Generators{ } } + //do not run for legacy ones + if(block.outlinedIcon >= 0){ + //prevents the regions above from being ignored/invisible/etc + for(int i = block.outlinedIcon + 1; i < regions.length; i++){ + out.draw(ImagePacker.get(regions[i])); + } + } + region.path.delete(); out.save(block.name);