Allow placing floors (for mods)

This commit is contained in:
Anuken
2023-05-10 12:37:25 -04:00
parent 778e7d5f3f
commit 0acb112f29
5 changed files with 18 additions and 4 deletions

View File

@@ -53,7 +53,9 @@ abstract class BuilderComp implements Posc, Statusc, Teamc, Rotc{
while(it.hasNext()){
BuildPlan plan = it.next();
Tile tile = world.tile(plan.x, plan.y);
if(tile == null || (plan.breaking && tile.block() == Blocks.air) || (!plan.breaking && ((tile.build != null && tile.build.rotation == plan.rotation) || !plan.block.rotate) && tile.block() == plan.block)){
if(tile == null || (plan.breaking && tile.block() == Blocks.air) || (!plan.breaking && ((tile.build != null && tile.build.rotation == plan.rotation) || !plan.block.rotate) &&
(tile.block() == plan.block || (plan.block != null && plan.block.isFloor() && plan.block == tile.floor())))){
it.remove();
}
}

View File

@@ -169,6 +169,10 @@ public class Build{
return false;
}
if(type.isFloor() && tile.floor == type){
return false;
}
if(!type.canPlaceOn(tile, team, rotation)){
return false;
}

View File

@@ -303,7 +303,9 @@ public class Tile implements Position, QuadTreeObject, Displayable{
public void setFloorUnder(Floor floor){
Block overlay = this.overlay;
setFloor(floor);
setOverlay(overlay);
if(this.overlay != overlay){
setOverlay(overlay);
}
}
/** Sets the block to air. */

View File

@@ -20,6 +20,7 @@ import mindustry.graphics.*;
import mindustry.logic.*;
import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.modules.*;
@@ -72,7 +73,12 @@ public class ConstructBlock extends Block{
float healthf = tile.build == null ? 1f : tile.build.healthf();
Seq<Building> prev = tile.build instanceof ConstructBuild co ? co.prevBuild : null;
tile.setBlock(block, team, rotation);
if(block instanceof Floor floor){
tile.setFloorUnder(floor);
tile.setBlock(Blocks.air);
}else{
tile.setBlock(block, team, rotation);
}
if(tile.build != null){
tile.build.health = block.health * healthf;