Building custom shadow support
This commit is contained in:
@@ -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(){
|
public void drawCracks(){
|
||||||
if(!damaged() || block.size > BlockRenderer.maxCrackSize) return;
|
if(!damaged() || block.size > BlockRenderer.maxCrackSize) return;
|
||||||
int id = pos();
|
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?
|
//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 final int crackRegions = 8, maxCrackSize = 7;
|
||||||
public static boolean drawQuadtreeDebug = false;
|
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 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 final FloorRenderer floor = new FloorRenderer();
|
||||||
public TextureRegion[][] cracks;
|
public TextureRegion[][] cracks;
|
||||||
@@ -369,6 +369,12 @@ public class BlockRenderer{
|
|||||||
Draw.z(Layer.block);
|
Draw.z(Layer.block);
|
||||||
|
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
|
if(block.customShadow){
|
||||||
|
Draw.z(Layer.block - 1);
|
||||||
|
entity.drawCustomShadow();
|
||||||
|
Draw.z(Layer.block);
|
||||||
|
}
|
||||||
|
|
||||||
if(entity.damaged()){
|
if(entity.damaged()){
|
||||||
entity.drawCracks();
|
entity.drawCracks();
|
||||||
Draw.z(Layer.block);
|
Draw.z(Layer.block);
|
||||||
|
|||||||
@@ -220,6 +220,8 @@ public class Block extends UnlockableContent{
|
|||||||
public int outlinedIcon = -1;
|
public int outlinedIcon = -1;
|
||||||
/** Whether this block has a shadow under it. */
|
/** Whether this block has a shadow under it. */
|
||||||
public boolean hasShadow = true;
|
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. */
|
/** Should the sound made when this block is built change in pitch. */
|
||||||
public boolean placePitchChange = true;
|
public boolean placePitchChange = true;
|
||||||
/** Should the sound made when this block is deconstructed change in pitch. */
|
/** Should the sound made when this block is deconstructed change in pitch. */
|
||||||
@@ -288,6 +290,7 @@ public class Block extends UnlockableContent{
|
|||||||
protected TextureRegion[] editorVariantRegions;
|
protected TextureRegion[] editorVariantRegions;
|
||||||
|
|
||||||
public TextureRegion region, editorIcon;
|
public TextureRegion region, editorIcon;
|
||||||
|
public @Load("@-shadow") TextureRegion customShadowRegion;
|
||||||
public @Load("@-team") TextureRegion teamRegion;
|
public @Load("@-team") TextureRegion teamRegion;
|
||||||
public TextureRegion[] teamRegions, variantRegions;
|
public TextureRegion[] teamRegions, variantRegions;
|
||||||
|
|
||||||
@@ -914,6 +917,11 @@ public class Block extends UnlockableContent{
|
|||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public void init(){
|
public void init(){
|
||||||
|
//disable standard shadow
|
||||||
|
if(customShadow){
|
||||||
|
hasShadow = false;
|
||||||
|
}
|
||||||
|
|
||||||
//initialize default health based on size
|
//initialize default health based on size
|
||||||
if(health == -1){
|
if(health == -1){
|
||||||
boolean round = false;
|
boolean round = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user