From c5c8d646f7ece06747b0d48f40f6c37077463d98 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 28 May 2020 12:16:35 -0400 Subject: [PATCH] Cleanup --- core/src/mindustry/ai/types/FlyingAI.java | 2 +- core/src/mindustry/ai/types/FormationAI.java | 2 +- core/src/mindustry/ai/types/GroundAI.java | 7 ++----- core/src/mindustry/entities/comp/VelComp.java | 2 +- core/src/mindustry/input/DesktopInput.java | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/core/src/mindustry/ai/types/FlyingAI.java b/core/src/mindustry/ai/types/FlyingAI.java index ee52aa3bae..d360fbff2e 100644 --- a/core/src/mindustry/ai/types/FlyingAI.java +++ b/core/src/mindustry/ai/types/FlyingAI.java @@ -11,7 +11,7 @@ public class FlyingAI extends AIController{ @Override public void update(){ - if(!unit.vel().isZero(0.01f)){ + if(unit.moving()){ unit.rotation(unit.vel().angle()); } diff --git a/core/src/mindustry/ai/types/FormationAI.java b/core/src/mindustry/ai/types/FormationAI.java index ff8300580d..f29188f902 100644 --- a/core/src/mindustry/ai/types/FormationAI.java +++ b/core/src/mindustry/ai/types/FormationAI.java @@ -34,7 +34,7 @@ public class FormationAI extends AIController implements FormationMember{ if(leader.isShooting()){ unit.aimLook(leader.aimX(), leader.aimY()); }else{ - if(!unit.vel().isZero(0.001f)){ + if(!unit.moving()){ unit.lookAt(unit.vel().angle()); }else{ unit.lookAt(leader.rotation()); diff --git a/core/src/mindustry/ai/types/GroundAI.java b/core/src/mindustry/ai/types/GroundAI.java index 4169a21aec..a8f16f4057 100644 --- a/core/src/mindustry/ai/types/GroundAI.java +++ b/core/src/mindustry/ai/types/GroundAI.java @@ -17,11 +17,6 @@ public class GroundAI extends AIController{ if(Units.invalidateTarget(target, unit.team(), unit.x(), unit.y(), Float.MAX_VALUE)){ target = null; - - //TODO this is hacky, cleanup - if(unit instanceof Mechc && unit.moving()){ - unit.lookAt(((Mechc)unit).baseRotation()); - } } if(retarget()){ @@ -51,6 +46,8 @@ public class GroundAI extends AIController{ if(unit.type().hasWeapons()){ unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed)); } + }else if(unit.moving()){ + unit.lookAt(unit.vel().angle()); } unit.controlWeapons(rotate, shoot); diff --git a/core/src/mindustry/entities/comp/VelComp.java b/core/src/mindustry/entities/comp/VelComp.java index c6869f3204..6e3a31c76b 100644 --- a/core/src/mindustry/entities/comp/VelComp.java +++ b/core/src/mindustry/entities/comp/VelComp.java @@ -22,7 +22,7 @@ abstract class VelComp implements Posc{ } boolean moving(){ - return !vel.isZero(0.001f); + return !vel.isZero(0.01f); } void move(float cx, float cy){ diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 7c3d438db0..9315df8525 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -563,7 +563,7 @@ public class DesktopInput extends InputHandler{ if(aimCursor){ unit.lookAt(mouseAngle); }else{ - if(!unit.vel().isZero(0.01f)){ + if(unit.moving()){ unit.lookAt(unit.vel().angle()); } }