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()){ while(it.hasNext()){
BuildPlan plan = it.next(); BuildPlan plan = it.next();
Tile tile = world.tile(plan.x, plan.y); 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(); it.remove();
} }
} }

View File

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

View File

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

View File

@@ -20,6 +20,7 @@ import mindustry.graphics.*;
import mindustry.logic.*; import mindustry.logic.*;
import mindustry.type.*; import mindustry.type.*;
import mindustry.world.*; import mindustry.world.*;
import mindustry.world.blocks.environment.*;
import mindustry.world.blocks.storage.CoreBlock.*; import mindustry.world.blocks.storage.CoreBlock.*;
import mindustry.world.modules.*; import mindustry.world.modules.*;
@@ -72,7 +73,12 @@ public class ConstructBlock extends Block{
float healthf = tile.build == null ? 1f : tile.build.healthf(); float healthf = tile.build == null ? 1f : tile.build.healthf();
Seq<Building> prev = tile.build instanceof ConstructBuild co ? co.prevBuild : null; 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){ if(tile.build != null){
tile.build.health = block.health * healthf; tile.build.health = block.health * healthf;

View File

@@ -25,4 +25,4 @@ org.gradle.caching=true
#used for slow jitpack builds; TODO see if this actually works #used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
archash=eb3b8bdd10 archash=a0bdca954b