Attack command support, still no pathfinding

This commit is contained in:
Anuken
2022-02-08 20:55:21 -05:00
parent d1eae2d1a2
commit c3c0b95024
6 changed files with 62 additions and 10 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ public class ControlPathfinder implements Runnable{
//}
for(var entry : requests){
entry.value.update(maxUpdate / requests.size);
}
}
+19 -3
View File
@@ -7,29 +7,45 @@ import mindustry.gen.*;
public class CommandAI extends AIController{
public @Nullable Vec2 targetPos;
public @Nullable Teamc attackTarget;
@Override
public void updateUnit(){
updateVisuals();
updateTargeting();
//TODO
if(attackTarget != null){
if(targetPos == null) targetPos = new Vec2();
targetPos.set(attackTarget);
}
if(targetPos != null){
//if(unit.isFlying()){
moveTo(targetPos, 5f);
//}
moveTo(targetPos, attackTarget != null ? unit.type.range - 10f : 5f);
if(unit.isFlying()){
unit.lookAt(targetPos);
}else{
faceTarget();
}
}else if(target != null){
faceTarget();
}
}
@Override
public Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground){
return attackTarget == null ? super.findMainTarget(x, y, range, air, ground) : attackTarget;
}
public void commandPosition(Vec2 pos){
targetPos = pos;
attackTarget = null;
}
public void commandTarget(Teamc moveTo){
//TODO
attackTarget = moveTo;
}
}