New environment blocks

This commit is contained in:
Anuken
2022-01-22 13:33:16 -05:00
parent f4701f6b8a
commit 97da66cd44
32 changed files with 119 additions and 26 deletions

View File

@@ -87,7 +87,7 @@ public class EditorTile extends Tile{
return;
}
if(!floor.hasSurface() && overlay.asFloor().needsSurface) return;
if(!floor.hasSurface() && overlay.asFloor().needsSurface && (overlay instanceof OreBlock || !floor.supportsOverlay)) return;
if(overlay() == overlay) return;
op(OpType.overlay, this.overlay.id);
super.setOverlay(overlay);

View File

@@ -45,7 +45,8 @@ public enum EditorTool{
});
}
},
pencil(KeyCode.b, "replace", "square", "drawteams"){
//the "under liquid" rendering is too buggy to make public
pencil(KeyCode.b, "replace", "square", "drawteams"/*, "underliquid"*/){
{
edit = true;
draggable = true;
@@ -61,10 +62,12 @@ public enum EditorTool{
editor.drawBlocksReplace(x, y);
}else if(mode == 1){
//square mode
editor.drawBlocks(x, y, true, tile -> true);
editor.drawBlocks(x, y, true, false, tile -> true);
}else if(mode == 2){
//draw teams
editor.drawCircle(x, y, tile -> tile.setTeam(editor.drawTeam));
}else if(mode == 3){
editor.drawBlocks(x, y, false, true, tile -> tile.floor().isLiquid);
}
}

View File

@@ -116,14 +116,14 @@ public class MapEditor{
}
public void drawBlocks(int x, int y){
drawBlocks(x, y, false, tile -> true);
drawBlocks(x, y, false, false, tile -> true);
}
public void drawBlocks(int x, int y, Boolf<Tile> tester){
drawBlocks(x, y, false, tester);
drawBlocks(x, y, false, false, tester);
}
public void drawBlocks(int x, int y, boolean square, Boolf<Tile> tester){
public void drawBlocks(int x, int y, boolean square, boolean forceOverlay, Boolf<Tile> tester){
if(drawBlock.isMultiblock()){
x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1);
y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1);
@@ -137,7 +137,11 @@ public class MapEditor{
if(!tester.get(tile)) return;
if(isFloor){
tile.setFloor(drawBlock.asFloor());
if(forceOverlay){
tile.setOverlay(drawBlock.asFloor());
}else{
tile.setFloor(drawBlock.asFloor());
}
}else if(!(tile.block().isMultiblock() && !drawBlock.isMultiblock())){
if(drawBlock.rotate && tile.build != null && tile.build.rotation != rotation){
addTileOp(TileOp.get(tile.x, tile.y, (byte)OpType.rotation.ordinal(), (byte)rotation));

View File

@@ -149,6 +149,9 @@ public class MapRenderer implements Disposable{
offsetX = tilesize / 2f - region.width / 2f * Draw.scl;
offsetY = tilesize / 2f - region.height / 2f * Draw.scl;
}else if((wall == Blocks.air || overlay.wallOre) && !overlay.isAir()){
if(floor.isLiquid){
mesh.setColor(Tmp.c1.set(1f, 1f, 1f, floor.overlayAlpha));
}
region = overlay.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
}else{
region = clearEditor;