Minor optimization

This commit is contained in:
Anuken
2020-09-13 14:30:31 -04:00
parent 48391219fd
commit f3921e3dcc
32 changed files with 111 additions and 116 deletions

View File

@@ -59,7 +59,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
public int rotation;
public boolean droppingItem;
public Group uiGroup;
public boolean isBuilding = true, buildWasAutoPaused = false;
public boolean isBuilding = true, buildWasAutoPaused = false, wasShooting = false;
public @Nullable UnitType controlledType;
public @Nullable Schematic lastSchematic;
@@ -353,6 +353,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
player.builder().updateBuilding(isBuilding);
}
if(player.shooting && !wasShooting && player.unit().hasWeapons()){
player.unit().type().weapons.first().noAmmoSound.at(player.unit());
}
wasShooting = player.shooting;
if(!player.dead()){
controlledType = player.unit().type();
}
@@ -1068,15 +1074,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
Draw.rect(Core.atlas.find("place-arrow"),
x * tilesize + block.offset + dx*trns,
y * tilesize + block.offset - 1 + dy*trns,
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
Core.atlas.find("place-arrow").width * Draw.scl,
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90);
Draw.color(!valid ? Pal.remove : Pal.accent);
Draw.rect(Core.atlas.find("place-arrow"),
x * tilesize + block.offset + dx*trns,
y * tilesize + block.offset + dy*trns,
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
Core.atlas.find("place-arrow").width * Draw.scl,
Core.atlas.find("place-arrow").height * Draw.scl, rotation * 90 - 90);
}
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){