Minor command AI improvements
This commit is contained in:
@@ -256,10 +256,10 @@ public class AIController implements UnitController{
|
||||
}
|
||||
|
||||
public void moveTo(Position target, float circleLength, float smooth){
|
||||
moveTo(target, circleLength, smooth, unit.isFlying());
|
||||
moveTo(target, circleLength, smooth, unit.isFlying(), null);
|
||||
}
|
||||
|
||||
public void moveTo(Position target, float circleLength, float smooth, boolean keepDistance){
|
||||
public void moveTo(Position target, float circleLength, float smooth, boolean keepDistance, @Nullable Vec2 offset){
|
||||
if(target == null) return;
|
||||
|
||||
vec.set(target).sub(unit);
|
||||
@@ -267,6 +267,7 @@ public class AIController implements UnitController{
|
||||
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((unit.dst(target) - circleLength) / smooth, -1f, 1f);
|
||||
|
||||
vec.setLength(unit.speed() * length);
|
||||
|
||||
if(length < -0.5f){
|
||||
if(keepDistance){
|
||||
vec.rotate(180f);
|
||||
@@ -277,6 +278,11 @@ public class AIController implements UnitController{
|
||||
vec.setZero();
|
||||
}
|
||||
|
||||
if(offset != null){
|
||||
vec.add(offset);
|
||||
vec.setLength(unit.speed() * length);
|
||||
}
|
||||
|
||||
//do not move when infinite vectors are used.
|
||||
if(vec.isNaN() || vec.isInfinite()) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user