Skip to content

Commit

Permalink
Arrow for rotating of placed blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Acemany committed Oct 22, 2024
1 parent 24d0be2 commit 8d1cc42
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/src/io/acemany/mindustryV4/input/DesktopInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class DesktopInput extends InputHandler{
private PlaceMode mode;
/**Animation scale for line.*/
private float selectScale;
/**Is player about to rotate block right now*/
private boolean rotate = false;

public DesktopInput(Player player){
super(player);
Expand Down Expand Up @@ -67,11 +69,12 @@ void drawPlace(int x, int y, Block block, int rotation){

@Override
public boolean isDrawing(){
return mode != none || recipe != null;
return mode != none || recipe != null || rotate;
}

@Override
public void drawOutlined(){
Tile selected = tileAt(Gdx.input.getX(), Gdx.input.getY());
int cursorX = tileX(Gdx.input.getX());
int cursorY = tileY(Gdx.input.getY());

Expand Down Expand Up @@ -124,6 +127,20 @@ public void drawOutlined(){
recipe.result.drawPlace(cursorX, cursorY, rotation, validPlace(cursorX, cursorY, recipe.result, rotation));
}

if(rotate && !isPlacing()){
Block block = selected.block();
if(block != null && block.rotate && block.quickRotate){
Draw.reset();
rotation = selected.getRotation();
Draw.color(Palette.placeRotate);
Draw.grect("place-arrow", cursorX * tilesize + block.offset(),
cursorY * tilesize + block.offset(), rotation * 90 - 90);

Lines.square(selected.drawx(), selected.drawy(), block.size * tilesize / 2f - 1);
block.drawPlace(cursorX * tilesize, cursorY * tilesize, rotation, true);
}
}

Draw.reset();
}

Expand Down Expand Up @@ -250,7 +267,8 @@ void pollInput(){
}
}

if(Inputs.keyDown(section, "rotate_placed")){
rotate = Inputs.keyDown(section, "rotate_placed");
if(rotate){
if(selected != null && selected.block() != null && Math.abs(Inputs.getAxisTapped("rotate")) > 0 && selected.block().rotate && selected.block().quickRotate)
rotateBlock(player, selected, Inputs.getAxisTapped(section, "rotate") > 0);
}
Expand Down

0 comments on commit 8d1cc42

Please sign in to comment.