mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-05 00:17:33 +07:00
Bugfixes
This commit is contained in:
parent
d6412bf19c
commit
0adc2811bb
@ -124,7 +124,9 @@ public class MapEditor{
|
|||||||
if(drawBlock.isMultiblock()){
|
if(drawBlock.isMultiblock()){
|
||||||
x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1);
|
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);
|
y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1);
|
||||||
tile(x, y).setBlock(drawBlock, drawTeam, 0);
|
if(!hasOverlap(x, y)){
|
||||||
|
tile(x, y).setBlock(drawBlock, drawTeam, 0);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||||
|
|
||||||
@ -152,6 +154,33 @@ public class MapEditor{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasOverlap(int x, int y){
|
||||||
|
Tile tile = world.tile(x, y);
|
||||||
|
//allow direct replacement of blocks of the same size
|
||||||
|
if(tile != null && tile.isCenter() && tile.block() != drawBlock && tile.block().size == drawBlock.size){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//else, check for overlap
|
||||||
|
int offsetx = -(drawBlock.size - 1) / 2;
|
||||||
|
int offsety = -(drawBlock.size - 1) / 2;
|
||||||
|
for(int dx = 0; dx < drawBlock.size; dx++){
|
||||||
|
for(int dy = 0; dy < drawBlock.size; dy++){
|
||||||
|
int worldx = dx + offsetx + x;
|
||||||
|
int worldy = dy + offsety + y;
|
||||||
|
if(!(worldx == x && worldy == y)){
|
||||||
|
Tile other = world.tile(worldx, worldy);
|
||||||
|
|
||||||
|
if(other != null && other.block().isMultiblock()){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void drawCircle(int x, int y, Cons<Tile> drawer){
|
public void drawCircle(int x, int y, Cons<Tile> drawer){
|
||||||
for(int rx = -brushSize; rx <= brushSize; rx++){
|
for(int rx = -brushSize; rx <= brushSize; rx++){
|
||||||
for(int ry = -brushSize; ry <= brushSize; ry++){
|
for(int ry = -brushSize; ry <= brushSize; ry++){
|
||||||
|
@ -49,9 +49,9 @@ public class Schematic implements Publishable, Comparable<Schematic>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public @NonNull CoreBlock findCore(){
|
public @NonNull CoreBlock findCore(){
|
||||||
CoreBlock block = (CoreBlock)tiles.find(s -> s.block instanceof CoreBlock).block;
|
Stile tile = tiles.find(s -> s.block instanceof CoreBlock);
|
||||||
if(block == null) throw new IllegalArgumentException("Schematic is missing a core!");
|
if(tile == null) throw new IllegalArgumentException("Schematic is missing a core!");
|
||||||
return block;
|
return (CoreBlock)tile.block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String name(){
|
public String name(){
|
||||||
|
@ -50,13 +50,13 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
public final OverlayFragment frag = new OverlayFragment();
|
public final OverlayFragment frag = new OverlayFragment();
|
||||||
|
|
||||||
public Block block;
|
public @Nullable Block block;
|
||||||
public boolean overrideLineRotation;
|
public boolean overrideLineRotation;
|
||||||
public int rotation;
|
public int rotation;
|
||||||
public boolean droppingItem;
|
public boolean droppingItem;
|
||||||
public Group uiGroup;
|
public Group uiGroup;
|
||||||
public boolean isShooting, isBuilding = true, buildWasAutoPaused = false;
|
public boolean isShooting, isBuilding = true, buildWasAutoPaused = false;
|
||||||
public UnitType controlledType;
|
public @Nullable UnitType controlledType;
|
||||||
|
|
||||||
protected @Nullable Schematic lastSchematic;
|
protected @Nullable Schematic lastSchematic;
|
||||||
protected GestureDetector detector;
|
protected GestureDetector detector;
|
||||||
@ -510,7 +510,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
if(request.block.saveConfig && request.block.lastConfig != null){
|
if(request.block.saveConfig && request.block.lastConfig != null){
|
||||||
Object conf = request.config;
|
Object conf = request.config;
|
||||||
request.config = block.lastConfig;
|
request.config = request.block.lastConfig;
|
||||||
request.block.drawRequestConfig(request, allRequests());
|
request.block.drawRequestConfig(request, allRequests());
|
||||||
request.config = conf;
|
request.config = conf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user