Colored floor tile

This commit is contained in:
Anuken
2025-07-12 18:16:26 -04:00
parent 0939076b4d
commit e53201347f
8 changed files with 74 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

View File

@@ -604,3 +604,4 @@
63078=crux-floor-2|block-crux-floor-2-ui
63077=crux-floor-3|block-crux-floor-3-ui
63076=crux-floor-4|block-crux-floor-4-ui
63075=colored-floor|block-colored-floor-ui

View File

@@ -11,7 +11,6 @@ import mindustry.entities.effect.*;
import mindustry.entities.part.DrawPart.*;
import mindustry.entities.part.*;
import mindustry.entities.pattern.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
@@ -59,7 +58,7 @@ public class Blocks{
shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, carbonBoulder, ferricBoulder, beryllicBoulder, yellowStoneBoulder,
arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystalOrbs, crystallineBoulder, redIceBoulder, rhyoliteBoulder, redStoneBoulder,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall,
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4,
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4, coloredFloor,
pebbles, tendrils,
//ores
@@ -819,23 +818,27 @@ public class Blocks{
cruxFloor2 = new Floor("crux-floor-2"){{
autotile = true;
emitLight = true;
lightRadius = 30f;
lightColor = Team.crux.color.cpy().a(0.3f);
//emitLight = true;
//lightRadius = 30f;
//lightColor = Team.crux.color.cpy().a(0.3f);
drawEdgeOut = false;
drawEdgeIn = false;
}};
cruxFloor3 = new Floor("crux-floor-3"){{
autotile = true;
emitLight = true;
drawEdgeOut = false;
drawEdgeIn = false;
}};
cruxFloor4 = new Floor("crux-floor-4"){{
autotile = true;
emitLight = true;
drawEdgeOut = false;
drawEdgeIn = false;
}};
coloredFloor = new ColoredFloor("colored-floor"){{
autotile = true;
drawEdgeOut = false;
drawEdgeIn = false;
}};

View File

@@ -360,6 +360,7 @@ public class MinimapRenderer{
if(tile == null) return 0;
Block real = realBlock(tile);
int bc = real.minimapColor(tile);
if(bc == 0 && tile.block() == Blocks.air && tile.overlay() == Blocks.air) bc = tile.floor().minimapColor(tile);
Color color = Tmp.c1.set(bc == 0 ? MapIO.colorFor(real, tile.floor(), tile.overlay(), tile.team()) : bc);
color.mul(1f - Mathf.clamp(world.getDarkness(tile.x, tile.y) / 4f));

View File

@@ -209,7 +209,7 @@ public abstract class SaveVersion extends SaveFileReader{
//floor + overlay
for(int i = 0; i < world.width() * world.height(); i++){
Tile tile = world.rawTile(i % world.width(), i / world.width());
Tile tile = world.tiles.geti(i);
stream.writeShort(tile.floorID());
stream.writeShort(tile.overlayID());
int consecutives = 0;
@@ -230,10 +230,10 @@ public abstract class SaveVersion extends SaveFileReader{
//blocks
for(int i = 0; i < world.width() * world.height(); i++){
Tile tile = world.rawTile(i % world.width(), i / world.width());
Tile tile = world.tiles.geti(i);
stream.writeShort(tile.blockID());
boolean savedata = tile.floor().saveData || tile.overlay().saveData || tile.block().saveData;
boolean savedata = tile.shouldSaveData();
//in the old version, the second bit was set to indicate presence of data, but that approach was flawed - it didn't allow buildings + data on the same tile
//so now the third bit is used instead
@@ -268,7 +268,7 @@ public abstract class SaveVersion extends SaveFileReader{
for(int j = i + 1; j < world.width() * world.height() && consecutives < 255; j++){
Tile nextTile = world.rawTile(j % world.width(), j / world.width());
if(nextTile.blockID() != tile.blockID()){
if(nextTile.blockID() != tile.blockID() || savedata != nextTile.shouldSaveData()){
break;
}

View File

@@ -311,6 +311,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
if(!world.isGenerating() && prev != type){
Events.fire(floorChange.set(this, prev, type));
}
if(this.floor != prev){
this.floor.floorChanged(this);
}
}
public boolean isEditorTile(){
@@ -564,6 +568,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{
null : null;
}
public boolean shouldSaveData(){
return floor.saveData || overlay.saveData || block.saveData;
}
public int staticDarkness(){
return block.solid && block.fillsTile && !block.synthetic() ? data : 0;
}

View File

@@ -0,0 +1,47 @@
package mindustry.world.blocks.environment;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.world.*;
public class ColoredFloor extends Floor{
public Color defaultColor = Color.white;
protected int defaultColorRgba;
public ColoredFloor(String name){
super(name);
saveData = true;
}
@Override
public void init(){
super.init();
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
Draw.color(tile.extraData | 0xff);
super.drawBase(tile);
Draw.color();
}
@Override
public void drawOverlay(Tile tile){
//make sure color doesn't carry over
Draw.color();
super.drawOverlay(tile);
}
@Override
public void floorChanged(Tile tile){
//reset to white
tile.extraData = defaultColorRgba;
}
@Override
public int minimapColor(Tile tile){
return tile.extraData | 0xff;
}
}

View File

@@ -268,6 +268,9 @@ public class Floor extends Block{
return new TextureRegion[]{Core.atlas.find(Core.atlas.has(name) ? name : name + "1")};
}
/** Called when this floor is set on the specified tile. */
public void floorChanged(Tile tile){}
/** @return whether to index this floor by flag */
public boolean shouldIndex(Tile tile){
return true;