Fixed commanded units attacking invalid targets

This commit is contained in:
Anuken
2023-09-18 23:18:55 -04:00
parent 844894f584
commit 66ad4e1798
4 changed files with 26 additions and 5 deletions
+13 -2
View File
@@ -387,8 +387,19 @@ public class DesktopInput extends InputHandler{
cursorType = ui.drillCursor;
}
if(commandMode && selectedUnits.any() && ((cursor.build != null && !cursor.build.inFogTo(player.team()) && cursor.build.team != player.team()) || (selectedEnemyUnit(input.mouseWorldX(), input.mouseWorldY()) != null))){
cursorType = ui.targetCursor;
if(commandMode && selectedUnits.any()){
boolean canAttack = (cursor.build != null && !cursor.build.inFogTo(player.team()) && cursor.build.team != player.team());
if(!canAttack){
var unit = selectedEnemyUnit(input.mouseWorldX(), input.mouseWorldY());
if(unit != null){
canAttack = selectedUnits.contains(u -> u.canTarget(unit));
}
}
if(canAttack){
cursorType = ui.targetCursor;
}
}
if(getPlan(cursor.x, cursor.y) != null && mode == none){