Better colored floor/wall support
This commit is contained in:
@@ -80,6 +80,8 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
public boolean displayFlow = true;
|
||||
/** whether this block is visible in the editor */
|
||||
public boolean inEditor = true;
|
||||
/** if true, a color picker will be shown for the lastConfig field in the in-game-editor, and will be assigned as an integer. */
|
||||
public boolean showColorEdit;
|
||||
/** the last configuration value applied to this block. */
|
||||
public @Nullable Object lastConfig;
|
||||
/** whether to save the last config and apply it to newly placed blocks */
|
||||
|
||||
@@ -26,6 +26,9 @@ public interface WorldContext{
|
||||
/** Called when a building is finished reading. */
|
||||
default void onReadBuilding(){}
|
||||
|
||||
/** Called when data finishes reading for a tile. */
|
||||
default void onReadTileData(){}
|
||||
|
||||
default @Nullable Sector getSector(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,14 @@ public class ColoredFloor extends Floor{
|
||||
public ColoredFloor(String name){
|
||||
super(name);
|
||||
saveData = true;
|
||||
showColorEdit = true;
|
||||
saveConfig = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
defaultColorRgba = defaultColor.rgba();
|
||||
lastConfig = defaultColorRgba = defaultColor.rgba();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,7 +134,9 @@ public class ColoredFloor extends Floor{
|
||||
@Override
|
||||
public void floorChanged(Tile tile){
|
||||
//reset to white
|
||||
tile.extraData = defaultColorRgba;
|
||||
if(tile.extraData == 0){
|
||||
tile.extraData = defaultColorRgba;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,17 +19,19 @@ public class ColoredWall extends StaticWall{
|
||||
public ColoredWall(String name){
|
||||
super(name);
|
||||
saveData = true;
|
||||
showColorEdit = true;
|
||||
saveConfig = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
defaultColorRgba = defaultColor.rgba();
|
||||
lastConfig = defaultColorRgba = defaultColor.rgba();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Tile tile){
|
||||
//make sure to mask out the alpha channel - it's generally undesirable, and leads to invisible blocks when the data is not initialized
|
||||
//make sure to mask out the alpha channel - it's generally undesirable, and leads to invisible blocks when thtoe data is not initialized
|
||||
Draw.color(tile.extraData | 0xff);
|
||||
super.drawBase(tile);
|
||||
Draw.color();
|
||||
@@ -37,8 +39,10 @@ public class ColoredWall extends StaticWall{
|
||||
|
||||
@Override
|
||||
public void blockChanged(Tile tile){
|
||||
//reset to white
|
||||
tile.extraData = defaultColorRgba;
|
||||
//reset to white on first placement
|
||||
if(tile.extraData == 0){
|
||||
tile.extraData = defaultColorRgba;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,12 +63,12 @@ public class ColoredWall extends StaticWall{
|
||||
|
||||
@Override
|
||||
public boolean checkAutotileSame(Tile tile, @Nullable Tile other){
|
||||
return other != null && other.block() == this && ((tile.extraData & flagIgnoreDifferentColor) != 0 || tile.extraData == other.extraData);
|
||||
return other != null && other.block() == this && ((tile.extraData == flagIgnoreDifferentColor) || tile.extraData == other.extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDarkened(Tile tile){
|
||||
return (tile.extraData & flagApplyDarkness) != 0;
|
||||
return (tile.extraData == flagApplyDarkness);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -378,19 +378,6 @@ public class Floor extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
//'new' style of edges with shadows instead of colors, not used currently
|
||||
protected void drawEdgesFlat(Tile tile, boolean sameLayer){
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tile.nearby(i);
|
||||
if(other != null && doEdge(tile, other, other.floor())){
|
||||
Color color = other.floor().mapColor;
|
||||
Draw.color(color.r, color.g, color.b, 1f);
|
||||
Draw.rect(edgeRegion, tile.worldx(), tile.worldy(), i*90);
|
||||
}
|
||||
}
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
public int realBlendId(Tile tile){
|
||||
if(tile.floor().isLiquid && !tile.overlay().isAir() && !(tile.overlay() instanceof OreBlock)){
|
||||
return -((tile.overlay().blendId) | (tile.floor().blendId << 15));
|
||||
|
||||
Reference in New Issue
Block a user