mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-21 01:37:13 +07:00
Building custom shadow support
This commit is contained in:
parent
38cb7aa41d
commit
2e0f9ed020
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user