diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 32c194356a..396df73011 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -1022,6 +1022,12 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, } } + public void drawCustomShadow(){ + Draw.color(0f, 0f, 0f, BlockRenderer.shadowColor.a); + Draw.rect(block.customShadowRegion, x, y, drawrot()); + Draw.color(); + } + public void drawCracks(){ if(!damaged() || block.size > BlockRenderer.maxCrackSize) return; int id = pos(); diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 7db6191701..44d5ad9298 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -24,9 +24,9 @@ public class BlockRenderer{ //TODO cracks take up far to much space, so I had to limit it to 7. this means larger blocks won't have cracks - draw tiling mirrored stuff instead? public static final int crackRegions = 8, maxCrackSize = 7; public static boolean drawQuadtreeDebug = false; + public static final Color shadowColor = new Color(0, 0, 0, 0.71f), blendShadowColor = Color.white.cpy().lerp(Color.black, shadowColor.a); private static final int initialRequests = 32 * 32; - private static final Color shadowColor = new Color(0, 0, 0, 0.71f), blendShadowColor = Color.white.cpy().lerp(Color.black, shadowColor.a); public final FloorRenderer floor = new FloorRenderer(); public TextureRegion[][] cracks; @@ -369,6 +369,12 @@ public class BlockRenderer{ Draw.z(Layer.block); if(entity != null){ + if(block.customShadow){ + Draw.z(Layer.block - 1); + entity.drawCustomShadow(); + Draw.z(Layer.block); + } + if(entity.damaged()){ entity.drawCracks(); Draw.z(Layer.block); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index c62b2e954b..a0f0c7de7e 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -220,6 +220,8 @@ public class Block extends UnlockableContent{ public int outlinedIcon = -1; /** Whether this block has a shadow under it. */ public boolean hasShadow = true; + /** If true, a custom shadow (name-shadow) is drawn under this block. */ + public boolean customShadow = false; /** Should the sound made when this block is built change in pitch. */ public boolean placePitchChange = true; /** Should the sound made when this block is deconstructed change in pitch. */ @@ -288,6 +290,7 @@ public class Block extends UnlockableContent{ protected TextureRegion[] editorVariantRegions; public TextureRegion region, editorIcon; + public @Load("@-shadow") TextureRegion customShadowRegion; public @Load("@-team") TextureRegion teamRegion; public TextureRegion[] teamRegions, variantRegions; @@ -914,6 +917,11 @@ public class Block extends UnlockableContent{ @Override @CallSuper public void init(){ + //disable standard shadow + if(customShadow){ + hasShadow = false; + } + //initialize default health based on size if(health == -1){ boolean round = false;