In-game editor UI improvements

This commit is contained in:
Anuken
2024-10-03 14:44:33 -04:00
parent 24daa1e933
commit 15ca672179
15 changed files with 230 additions and 24 deletions
+5
View File
@@ -920,6 +920,11 @@ public class Block extends UnlockableContent implements Senseable{
placeBegan(tile, previous);
}
/** Called when building of this block ends. */
public void placeEnded(Tile tile, @Nullable Unit builder){
}
/** Called right before building of this block begins. */
public void beforePlaceBegan(Tile tile, Block previous){
+4 -4
View File
@@ -199,6 +199,10 @@ public class Build{
if(tile == null) return false;
if(!type.canPlaceOn(tile, team, rotation)){
return false;
}
//floors have different checks
if(type.isFloor()){
return type.isOverlay() ? tile.overlay() != type : tile.floor() != type;
@@ -213,10 +217,6 @@ public class Build{
return false;
}
if(!type.canPlaceOn(tile, team, rotation)){
return false;
}
int offsetx = -(type.size - 1) / 2;
int offsety = -(type.size - 1) / 2;
@@ -110,6 +110,8 @@ public class ConstructBlock extends Block{
if(shouldPlay()) block.placeSound.at(tile, block.placePitchChange ? calcPitch(true) : 1f);
}
block.placeEnded(tile, builder);
Events.fire(new BlockBuildEndEvent(tile, builder, team, false, config));
}
@@ -0,0 +1,51 @@
package mindustry.world.blocks.environment;
import arc.graphics.g2d.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.world.*;
public class RemoveOre extends OverlayFloor{
public RemoveOre(String name){
super(name);
allowRectanglePlacement = true;
placeEffect = Fx.rotateBlock;
instantBuild = true;
ignoreBuildDarkness = true;
placeableLiquid = true;
inEditor = false;
variants = 0;
}
@Override
public void drawPlan(BuildPlan plan, Eachable<BuildPlan> list, boolean valid, float alpha){
Draw.reset();
Draw.alpha(alpha * (valid ? 1f : 0.2f));
float prevScale = Draw.scl;
Draw.scl *= plan.animScale;
drawPlanRegion(plan, list);
Draw.scl = prevScale;
Draw.reset();
}
@Override
public boolean canPlaceOn(Tile tile, Team team, int rotation){
return tile.overlay() != Blocks.air;
}
@Override
public boolean canReplace(Block other){
return true;
}
@Override
public void placeEnded(Tile tile, @Nullable Unit builder){
tile.setOverlay(Blocks.air);
}
}
@@ -0,0 +1,50 @@
package mindustry.world.blocks.environment;
import arc.graphics.g2d.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.units.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.world.*;
public class RemoveWall extends Block{
public RemoveWall(String name){
super(name);
allowRectanglePlacement = true;
placeEffect = Fx.rotateBlock;
instantBuild = true;
ignoreBuildDarkness = true;
placeableLiquid = true;
inEditor = false;
}
@Override
public void drawPlan(BuildPlan plan, Eachable<BuildPlan> list, boolean valid, float alpha){
Draw.reset();
Draw.alpha(alpha * (valid ? 1f : 0.2f));
float prevScale = Draw.scl;
Draw.scl *= plan.animScale;
drawPlanRegion(plan, list);
Draw.scl = prevScale;
Draw.reset();
}
@Override
public boolean canPlaceOn(Tile tile, Team team, int rotation){
return tile.block() != Blocks.air;
}
@Override
public boolean canReplace(Block other){
return other != Blocks.air && !other.synthetic();
}
@Override
public void placeEnded(Tile tile, @Nullable Unit builder){
tile.setBlock(Blocks.air);
}
}