Minor fixes / Desktop detach camera hotkey

This commit is contained in:
Anuken 2024-09-19 20:37:22 -04:00
parent ab39291626
commit bd1f750673
4 changed files with 37 additions and 11 deletions

View File

@ -1042,7 +1042,7 @@ public class UnitTypes{
status = StatusEffects.blasted;
statusDuration = 60f;
damage = splashDamage * 0.7f;
damage = splashDamage * 0.5f;
}};
}});
}};

View File

@ -74,6 +74,7 @@ public class Control implements ApplicationListener, Loadable{
ui.showInfo("@mods.initfailed");
});
}
checkAutoUnlocks();
});
Events.on(StateChangeEvent.class, event -> {

View File

@ -81,6 +81,7 @@ public enum Binding implements KeyBind{
block_select_10(KeyCode.num0),
zoom(new Axis(KeyCode.scroll), "view"),
detach_camera(KeyCode.unset),
menu(Vars.android ? KeyCode.back : KeyCode.escape),
fullscreen(KeyCode.f11),
pause(KeyCode.space),

View File

@ -226,18 +226,31 @@ public class DesktopInput extends InputHandler{
boolean locked = locked();
boolean panCam = false;
float camSpeed = (!Core.input.keyDown(Binding.boost) ? panSpeed : panBoostSpeed) * Time.delta;
boolean detached = settings.getBool("detach-camera", false);
if(input.keyDown(Binding.pan) && !scene.hasField() && !scene.hasDialog()){
panCam = true;
panning = true;
if(!scene.hasField() && !scene.hasDialog()){
if(input.keyTap(Binding.detach_camera)){
settings.put("detach-camera", detached = !detached);
if(!detached){
panning = false;
}
}
if(input.keyDown(Binding.pan)){
panCam = true;
panning = true;
}
if((Math.abs(Core.input.axis(Binding.move_x)) > 0 || Math.abs(Core.input.axis(Binding.move_y)) > 0 || input.keyDown(Binding.mouse_move))){
panning = false;
}
}
if((Math.abs(Core.input.axis(Binding.move_x)) > 0 || Math.abs(Core.input.axis(Binding.move_y)) > 0 || input.keyDown(Binding.mouse_move)) && (!scene.hasField())){
panning = false;
}
panning |= detached;
if(!locked){
if(((player.dead() || state.isPaused()) && !ui.chatfrag.shown()) && !scene.hasField() && !scene.hasDialog()){
if(((player.dead() || state.isPaused() || detached) && !ui.chatfrag.shown()) && !scene.hasField() && !scene.hasDialog()){
if(input.keyDown(Binding.mouse_move)){
panCam = true;
}
@ -859,9 +872,20 @@ public class DesktopInput extends InputHandler{
float ya = Core.input.axis(Binding.move_y);
boolean boosted = (unit instanceof Mechc && unit.isFlying());
movement.set(xa, ya).nor().scl(speed);
if(Core.input.keyDown(Binding.mouse_move)){
movement.add(input.mouseWorld().sub(player).scl(1f / 25f * speed)).limit(speed);
if(settings.getBool("detach-camera")){
Vec2 targetPos = camera.position;
movement.set(targetPos).sub(player).limit(speed);
if(player.within(targetPos, 15f)){
movement.setZero();
unit.vel.approachDelta(Vec2.ZERO, unit.speed() * unit.type().accel / 2f);
}
}else{
movement.set(xa, ya).nor().scl(speed);
if(Core.input.keyDown(Binding.mouse_move)){
movement.add(input.mouseWorld().sub(player).scl(1f / 25f * speed)).limit(speed);
}
}
float mouseAngle = Angles.mouseAngle(unit.x, unit.y);