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
@@ -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);
}
}