mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-26 07:37:54 +07:00
Allow to replace previous build request in queue
This commit is contained in:
@ -193,11 +193,16 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
|||||||
|
|
||||||
/** Add another build requests to the queue, if it doesn't exist there yet. */
|
/** Add another build requests to the queue, if it doesn't exist there yet. */
|
||||||
default void addBuildRequest(BuildRequest place, boolean tail){
|
default void addBuildRequest(BuildRequest place, boolean tail){
|
||||||
|
BuildRequest replace = null;
|
||||||
for(BuildRequest request : buildQueue()){
|
for(BuildRequest request : buildQueue()){
|
||||||
if(request.x == place.x && request.y == place.y){
|
if(request.x == place.x && request.y == place.y){
|
||||||
return;
|
replace = request;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(replace != null){
|
||||||
|
buildQueue().remove(replace);
|
||||||
|
}
|
||||||
Tile tile = world.tile(place.x, place.y);
|
Tile tile = world.tile(place.x, place.y);
|
||||||
if(tile != null && tile.entity instanceof BuildEntity){
|
if(tile != null && tile.entity instanceof BuildEntity){
|
||||||
place.progress = tile.<BuildEntity>entity().progress;
|
place.progress = tile.<BuildEntity>entity().progress;
|
||||||
|
@ -708,7 +708,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
public boolean validPlace(int x, int y, Block type, int rotation, BuildRequest ignore){
|
public boolean validPlace(int x, int y, Block type, int rotation, BuildRequest ignore){
|
||||||
for(BuildRequest req : player.buildQueue()){
|
for(BuildRequest req : player.buildQueue()){
|
||||||
if(req != ignore && !req.breaking && req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2))){
|
if(req != ignore
|
||||||
|
&& !req.breaking
|
||||||
|
&& req.block.bounds(req.x, req.y, Tmp.r1).overlaps(type.bounds(x, y, Tmp.r2))
|
||||||
|
&& !(type.canReplace(req.block) && Tmp.r1.equals(Tmp.r2))
|
||||||
|
){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -720,6 +724,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void placeBlock(int x, int y, Block block, int rotation){
|
public void placeBlock(int x, int y, Block block, int rotation){
|
||||||
|
BuildRequest req = getRequest(x, y);
|
||||||
|
if(req != null){
|
||||||
|
player.buildQueue().remove(req);
|
||||||
|
}
|
||||||
player.addBuildRequest(new BuildRequest(x, y, rotation, block));
|
player.addBuildRequest(new BuildRequest(x, y, rotation, block));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user