mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-15 15:20:57 -08:00
Make patrol stance pursue targets
This commit is contained in:
parent
4cf9d54c3d
commit
a7f38ac2a6
4 changed files with 19 additions and 6 deletions
|
|
@ -82,6 +82,15 @@ public class CommandAI extends AIController{
|
|||
commandTarget(target, false);
|
||||
}
|
||||
|
||||
//pursue the target for patrol, keeping the current position
|
||||
if(stance == UnitStance.patrol && target != null && attackTarget == null){
|
||||
//commanding a target overwrites targetPos, so add it to the queue
|
||||
if(targetPos != null){
|
||||
commandQueue.add(targetPos.cpy());
|
||||
}
|
||||
commandTarget(target, false);
|
||||
}
|
||||
|
||||
//remove invalid targets
|
||||
if(commandQueue.any()){
|
||||
commandQueue.removeAll(e -> e instanceof Healthc h && !h.isValid());
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ public class DesktopInput extends InputHandler{
|
|||
}
|
||||
|
||||
//validate commanding units
|
||||
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid());
|
||||
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid() || u.team != player.team());
|
||||
|
||||
if(commandMode && !scene.hasField() && !scene.hasDialog()){
|
||||
if(input.keyTap(Binding.select_all_units)){
|
||||
|
|
|
|||
|
|
@ -1096,10 +1096,16 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
|
||||
//draw command overlay UI
|
||||
for(Unit unit : selectedUnits){
|
||||
if(unit.isFlying() != flying) continue;
|
||||
|
||||
CommandAI ai = unit.command();
|
||||
Position lastPos = ai.attackTarget != null ? ai.attackTarget : ai.targetPos;
|
||||
|
||||
if(flying && ai.attackTarget != null && ai.currentCommand().drawTarget){
|
||||
Drawf.target(ai.attackTarget.getX(), ai.attackTarget.getY(), 6f, Pal.remove);
|
||||
}
|
||||
|
||||
if(unit.isFlying() != flying) continue;
|
||||
|
||||
//draw target line
|
||||
if(ai.targetPos != null && ai.currentCommand().drawTarget){
|
||||
Position lineDest = ai.attackTarget != null ? ai.attackTarget : ai.targetPos;
|
||||
|
|
@ -1135,9 +1141,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
//Lines.poly(unit.x, unit.y, sides, rad + 1.5f);
|
||||
Draw.reset();
|
||||
|
||||
if(ai.attackTarget != null && ai.currentCommand().drawTarget){
|
||||
Drawf.target(ai.attackTarget.getX(), ai.attackTarget.getY(), 6f, Pal.remove);
|
||||
}
|
||||
|
||||
|
||||
if(lastPos == null){
|
||||
lastPos = unit;
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||
}
|
||||
|
||||
//validate commanding units
|
||||
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid());
|
||||
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid() || u.team != player.team());
|
||||
|
||||
if(!commandMode){
|
||||
commandBuildings.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue