RTS unit control improvements/fixes
This commit is contained in:
@@ -932,6 +932,7 @@ setting.logichints.name = Logic Hints
|
|||||||
setting.backgroundpause.name = Pause In Background
|
setting.backgroundpause.name = Pause In Background
|
||||||
setting.buildautopause.name = Auto-Pause Building
|
setting.buildautopause.name = Auto-Pause Building
|
||||||
setting.doubletapmine.name = Double-Tap to Mine
|
setting.doubletapmine.name = Double-Tap to Mine
|
||||||
|
setting.commandmodehold.name = Hold For Command Mode
|
||||||
setting.modcrashdisable.name = Disable Mods On Startup Crash
|
setting.modcrashdisable.name = Disable Mods On Startup Crash
|
||||||
setting.animatedwater.name = Animated Surfaces
|
setting.animatedwater.name = Animated Surfaces
|
||||||
setting.animatedshields.name = Animated Shields
|
setting.animatedshields.name = Animated Shields
|
||||||
|
|||||||
@@ -374,6 +374,10 @@ public class ErekirTechTree{
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
nodeProduce(Liquids.arkycite, () -> {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
nodeProduce(Items.thorium, () -> {
|
nodeProduce(Items.thorium, () -> {
|
||||||
nodeProduce(Items.carbide, () -> {
|
nodeProduce(Items.carbide, () -> {
|
||||||
nodeProduce(Items.surgeAlloy, () -> {
|
nodeProduce(Items.surgeAlloy, () -> {
|
||||||
|
|||||||
@@ -242,7 +242,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
if(!locked && block == null && !scene.hasField() &&
|
if(!locked && block == null && !scene.hasField() &&
|
||||||
//disable command mode when player unit can boost and command mode binding is the same
|
//disable command mode when player unit can boost and command mode binding is the same
|
||||||
!(!player.dead() && player.unit().type.canBoost && keybinds.get(Binding.command_mode).key == keybinds.get(Binding.boost).key)){
|
!(!player.dead() && player.unit().type.canBoost && keybinds.get(Binding.command_mode).key == keybinds.get(Binding.boost).key)){
|
||||||
commandMode = input.keyDown(Binding.command_mode);
|
if(settings.getBool("commandmodehold")){
|
||||||
|
commandMode = input.keyDown(Binding.command_mode);
|
||||||
|
}else if(input.keyTap(Binding.command_mode)){
|
||||||
|
commandMode = !commandMode;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
commandMode = false;
|
commandMode = false;
|
||||||
}
|
}
|
||||||
@@ -652,26 +656,12 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
//click: select a single unit
|
//click: select a single unit
|
||||||
if(button == KeyCode.mouseLeft){
|
if(button == KeyCode.mouseLeft){
|
||||||
Unit unit = selectedCommandUnit(input.mouseWorldX(), input.mouseWorldY());
|
if(count >= 2){
|
||||||
Building build = world.buildWorld(input.mouseWorldX(), input.mouseWorldY());
|
selectTypedUnits();
|
||||||
if(unit != null){
|
|
||||||
if(selectedUnits.contains(unit)){
|
|
||||||
selectedUnits.remove(unit);
|
|
||||||
}else{
|
|
||||||
selectedUnits.clear();
|
|
||||||
selectedUnits.add(unit);
|
|
||||||
}
|
|
||||||
commandBuild = null;
|
|
||||||
}else{
|
}else{
|
||||||
//deselect
|
tapCommandUnit();
|
||||||
selectedUnits.clear();
|
|
||||||
|
|
||||||
if(build != null && build.team == player.team() && build.block.commandable){
|
|
||||||
commandBuild = (commandBuild == build ? null : build);
|
|
||||||
}else{
|
|
||||||
commandBuild = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.tap(x, y, count, button);
|
return super.tap(x, y, count, button);
|
||||||
|
|||||||
@@ -725,6 +725,43 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void selectTypedUnits(){
|
||||||
|
if(commandMode){
|
||||||
|
Unit unit = selectedCommandUnit(input.mouseWorldX(), input.mouseWorldY());
|
||||||
|
if(unit != null){
|
||||||
|
selectedUnits.clear();
|
||||||
|
camera.bounds(Tmp.r1);
|
||||||
|
selectedUnits.addAll(selectedCommandUnits(Tmp.r1.x, Tmp.r1.y, Tmp.r1.width, Tmp.r1.height, u -> u.type == unit.type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tapCommandUnit(){
|
||||||
|
if(commandMode){
|
||||||
|
|
||||||
|
Unit unit = selectedCommandUnit(input.mouseWorldX(), input.mouseWorldY());
|
||||||
|
Building build = world.buildWorld(input.mouseWorldX(), input.mouseWorldY());
|
||||||
|
if(unit != null){
|
||||||
|
if(selectedUnits.contains(unit)){
|
||||||
|
selectedUnits.remove(unit);
|
||||||
|
}else{
|
||||||
|
selectedUnits.clear();
|
||||||
|
selectedUnits.add(unit);
|
||||||
|
}
|
||||||
|
commandBuild = null;
|
||||||
|
}else{
|
||||||
|
//deselect
|
||||||
|
selectedUnits.clear();
|
||||||
|
|
||||||
|
if(build != null && build.team == player.team() && build.block.commandable){
|
||||||
|
commandBuild = (commandBuild == build ? null : build);
|
||||||
|
}else{
|
||||||
|
commandBuild = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void commandTap(float screenX, float screenY){
|
public void commandTap(float screenX, float screenY){
|
||||||
if(commandMode){
|
if(commandMode){
|
||||||
//right click: move to position
|
//right click: move to position
|
||||||
@@ -1434,15 +1471,19 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
return tmpUnits.min(u -> !u.inFogTo(player.team()), u -> u.dst(x, y) - u.hitSize/2f);
|
return tmpUnits.min(u -> !u.inFogTo(player.team()), u -> u.dst(x, y) - u.hitSize/2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Seq<Unit> selectedCommandUnits(float x, float y, float w, float h){
|
public Seq<Unit> selectedCommandUnits(float x, float y, float w, float h, Boolf<Unit> predicate){
|
||||||
var tree = player.team().data().tree();
|
var tree = player.team().data().tree();
|
||||||
tmpUnits.clear();
|
tmpUnits.clear();
|
||||||
float rad = 4f;
|
float rad = 4f;
|
||||||
tree.intersect(Tmp.r1.set(x - rad/2f, y - rad/2f, rad*2f + w, rad*2f + h).normalize(), tmpUnits);
|
tree.intersect(Tmp.r1.set(x - rad/2f, y - rad/2f, rad*2f + w, rad*2f + h).normalize(), tmpUnits);
|
||||||
tmpUnits.removeAll(u -> !u.isCommandable());
|
tmpUnits.removeAll(u -> !u.isCommandable() || !predicate.get(u));
|
||||||
return tmpUnits;
|
return tmpUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Seq<Unit> selectedCommandUnits(float x, float y, float w, float h){
|
||||||
|
return selectedCommandUnits(x, y, w, h, u -> true);
|
||||||
|
}
|
||||||
|
|
||||||
public void remove(){
|
public void remove(){
|
||||||
Core.input.removeProcessor(this);
|
Core.input.removeProcessor(this);
|
||||||
group.remove();
|
group.remove();
|
||||||
|
|||||||
@@ -649,6 +649,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}else if(commandMode && selectedUnits.size > 0){
|
}else if(commandMode && selectedUnits.size > 0){
|
||||||
//handle selecting units with command mode
|
//handle selecting units with command mode
|
||||||
commandTap(x, y);
|
commandTap(x, y);
|
||||||
|
}else if(commandMode){
|
||||||
|
tapCommandUnit();
|
||||||
}else{
|
}else{
|
||||||
//control units
|
//control units
|
||||||
if(count == 2){
|
if(count == 2){
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class CrashSender{
|
|||||||
}catch(Throwable ignored){}
|
}catch(Throwable ignored){}
|
||||||
|
|
||||||
//don't create crash logs for custom builds, as it's expected
|
//don't create crash logs for custom builds, as it's expected
|
||||||
if(Version.build == -1 || (OS.username.equals("anuke") && !"steam".equals(Version.modifier))){
|
if(OS.username.equals("anuke") && !"steam".equals(Version.modifier)){
|
||||||
ret();
|
ret();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ public class SettingsMenuDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
game.checkPref("doubletapmine", false);
|
game.checkPref("doubletapmine", false);
|
||||||
|
game.checkPref("commandmodehold", false);
|
||||||
|
|
||||||
if(!ios){
|
if(!ios){
|
||||||
game.checkPref("modcrashdisable", true);
|
game.checkPref("modcrashdisable", true);
|
||||||
|
|||||||
Reference in New Issue
Block a user