Yet another floor

This commit is contained in:
Anuken
2025-07-15 14:45:50 -04:00
parent b714651055
commit cb7e027b2b
13 changed files with 70 additions and 25 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@@ -612,3 +612,5 @@
63070=crux-floor-9|block-crux-floor-9-ui 63070=crux-floor-9|block-crux-floor-9-ui
63069=crux-floor-10|block-crux-floor-10-ui 63069=crux-floor-10|block-crux-floor-10-ui
63068=colored-wall|block-colored-wall-ui 63068=colored-wall|block-colored-wall-ui
63067=crux-floor-11|block-crux-floor-11-ui
63066=crux-floor-12|block-crux-floor-12-ui

View File

@@ -60,8 +60,11 @@ public class Blocks{
arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystalOrbs, crystallineBoulder, redIceBoulder, rhyoliteBoulder, redStoneBoulder, arkyicBoulder, crystalCluster, vibrantCrystalCluster, crystalBlocks, crystalOrbs, crystallineBoulder, redIceBoulder, rhyoliteBoulder, redStoneBoulder,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall, metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall,
//old metal floors
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal,
//new metal floors //new metal floors
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4, cruxFloor5, cruxFloor6, cruxFloor7, cruxFloor8, cruxFloor9, cruxFloor10, cruxFloor1, cruxFloor2, cruxFloor3, cruxFloor4, cruxFloor5, cruxFloor6, cruxFloor7, cruxFloor8, cruxFloor9, cruxFloor10, cruxFloor11, cruxFloor12,
//colored //colored
coloredFloor, coloredWall, coloredFloor, coloredWall,
@@ -881,6 +884,23 @@ public class Blocks{
drawEdgeIn = false; drawEdgeIn = false;
}}; }};
cruxFloor11 = new Floor("crux-floor-11"){{
autotile = true;
drawEdgeOut = false;
drawEdgeIn = false;
autotileVariants = 3;
}};
cruxFloor12 = new Floor("crux-floor-12"){{
autotile = true;
drawEdgeOut = false;
drawEdgeIn = false;
autotileVariants = 4;
emitLight = true;
lightRadius = 30f;
lightColor = Team.crux.color.cpy().a(0.3f);
}};
coloredFloor = new ColoredFloor("colored-floor"){{ coloredFloor = new ColoredFloor("colored-floor"){{
autotile = true; autotile = true;
drawEdgeOut = false; drawEdgeOut = false;

View File

@@ -31,4 +31,15 @@ public class TileBitmask{
} }
return regions; return regions;
} }
public static TextureRegion[][] loadVariants(String name, int variants){
var regions = new TextureRegion[variants][47];
for(int v = 0; v < variants; v++){
for(int i = 0; i < 47; i++){
regions[v][i] = Core.atlas.find(name + "-" + (v+1) + "-" + i);
}
}
return regions;
}
} }

View File

@@ -82,6 +82,8 @@ public class Floor extends Block{
public boolean autotile = false; public boolean autotile = false;
/** If >1, the middle region of the autotile has random variants. */ /** If >1, the middle region of the autotile has random variants. */
public int autotileMidVariants = 1; public int autotileMidVariants = 1;
/** Variants of the main autotile sprite. */
public int autotileVariants = 1;
/** If true (default), this floor will draw edges of other floors on itself. */ /** If true (default), this floor will draw edges of other floors on itself. */
public boolean drawEdgeIn = true; public boolean drawEdgeIn = true;
/** If true (default), this floor will draw its edges onto other floors. */ /** If true (default), this floor will draw its edges onto other floors. */
@@ -89,6 +91,7 @@ public class Floor extends Block{
protected TextureRegion[][][] tilingRegions; protected TextureRegion[][][] tilingRegions;
protected TextureRegion[] autotileRegions, autotileMidRegions; protected TextureRegion[] autotileRegions, autotileMidRegions;
protected TextureRegion[][] autotileVariantRegions;
protected int tilingSize; protected int tilingSize;
protected TextureRegion[][] edges; protected TextureRegion[][] edges;
protected Seq<Floor> blenders = new Seq<>(); protected Seq<Floor> blenders = new Seq<>();
@@ -148,6 +151,9 @@ public class Floor extends Block{
if(autotile){ if(autotile){
autotileRegions = TileBitmask.load(name); autotileRegions = TileBitmask.load(name);
if(autotileVariants > 1){
autotileVariantRegions = TileBitmask.loadVariants(name, autotileVariants);
}
if(autotileMidVariants > 1){ if(autotileMidVariants > 1){
autotileMidRegions = new TextureRegion[autotileMidVariants]; autotileMidRegions = new TextureRegion[autotileMidVariants];
for(int i = 0; i < autotileMidVariants; i++){ for(int i = 0; i < autotileMidVariants; i++){
@@ -235,6 +241,8 @@ public class Floor extends Block{
}else if(autotile){ }else if(autotile){
int bits = 0; int bits = 0;
TextureRegion[] regions = autotileVariants > 1 ? autotileVariantRegions[variant(tile.x, tile.y, autotileVariantRegions.length)] : autotileRegions;
for(int i = 0; i < 8; i++){ for(int i = 0; i < 8; i++){
Tile other = tile.nearby(Geometry.d8[i]); Tile other = tile.nearby(Geometry.d8[i]);
if(checkAutotileSame(tile, other)){ if(checkAutotileSame(tile, other)){
@@ -243,7 +251,7 @@ public class Floor extends Block{
} }
int bit = TileBitmask.values[bits]; int bit = TileBitmask.values[bits];
TextureRegion region = bit == 13 && autotileMidVariants > 1 ? autotileMidRegions[variant(tile.x, tile.y, autotileMidRegions.length)] : autotileRegions[bit]; TextureRegion region = bit == 13 && autotileMidVariants > 1 ? autotileMidRegions[variant(tile.x, tile.y, autotileMidRegions.length)] : regions[bit];
Draw.rect(region, tile.worldx(), tile.worldy()); Draw.rect(region, tile.worldx(), tile.worldy());
}else{ }else{

View File

@@ -71,32 +71,36 @@ public class Generators{
generate("autotiles", () -> { generate("autotiles", () -> {
for(Block block : content.blocks().select(b -> (b.isFloor() && b.asFloor().autotile) || (b instanceof StaticWall && ((StaticWall)b).autotile))){ for(Block block : content.blocks().select(b -> (b.isFloor() && b.asFloor().autotile) || (b instanceof StaticWall && ((StaticWall)b).autotile))){
Fi basePath = new Fi("../../../assets-raw/sprites_out/blocks/environment/" + block.name + "-autotile.png"), iconPath = basePath.parent().child(block.name + ".png"); int variants = block instanceof Floor f && f.autotileVariants > 1 ? f.autotileVariants : 1;
for(int v = 0; v < variants; v++){
Fi basePath = new Fi("../../../assets-raw/sprites_out/blocks/environment/" + block.name + "-autotile" + (variants <= 1 ? "" : "" + (v+1)) + ".png"), iconPath = basePath.parent().child(block.name + ".png");
if(basePath.exists()){ if(basePath.exists()){
//theoretically this might not finish in time, but I doubt that will ever happen int variant = v;
mainExecutor.submit(() -> { //theoretically this might not finish in time, but I doubt that will ever happen
try{ mainExecutor.submit(() -> {
ImageTileGenerator.generate(basePath, block.name, new Fi("../../../assets-raw/sprites_out/blocks/environment/" + block.name)); try{
}catch(Throwable e){ ImageTileGenerator.generate(basePath, block.name + (variants <= 1 ? "" : "-" + (variant+1)), new Fi("../../../assets-raw/sprites_out/blocks/environment/" + (block.name + (variants <= 1 ? "" : "-" + (variant+1)))));
Log.err("Failed to autotile: " + block.name, e); }catch(Throwable e){
}finally{ Log.err("Failed to autotile: " + block.name, e);
//the raw autotile source image must never be included, it isn't useful }finally{
basePath.delete(); //the raw autotile source image must never be included, it isn't useful
basePath.delete();
}
});
if(!iconPath.exists() && v == 0){
//save the bottom right region as the "main" sprite for previews
Pixmap out = new Pixmap(basePath);
Pixmap cropped = out.crop(32, 32, 32, 32);
iconPath.writePng(cropped);
iconPath.parent().parent().parent().child("editor").child("editor-" + block.name + ".png").writePng(cropped);
out.dispose();
gens.put(block, cropped);
} }
}); }else{
Log.warn("Autotile floor '@' not found: @", block.name, basePath.absolutePath());
if(!iconPath.exists()){
//save the bottom right region as the "main" sprite for previews
Pixmap out = new Pixmap(basePath);
Pixmap cropped = out.crop(32, 32, 32, 32);
iconPath.writePng(cropped);
iconPath.parent().parent().parent().child("editor").child("editor-" + block.name + ".png").writePng(cropped);
out.dispose();
gens.put(block, cropped);
} }
}else{
Log.warn("Autotile floor '@' not found: @", block.name, basePath.absolutePath());
} }
} }
}); });