SteeringForcePursue.java
package com.hypixel.hytale.server.npc.movement.steeringforces;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.npc.movement.Steering;
import javax.annotation.Nonnull;
public class SteeringForcePursue extends SteeringForceWithTarget {
private double stopDistance;
private double slowdownDistance;
private double falloff;
private double invFalloff;
private double squaredStopDistance;
private double squaredSlowdownDistance;
private double distanceDelta;
public SteeringForcePursue() {
this(20.0, 25.0);
}
public SteeringForcePursue(double stopDistance, double slowdownDistance) {
this.falloff = 3.0;
this.invFalloff = 1.0 / this.falloff;
this.setDistances(stopDistance, slowdownDistance);
}
{
.stopDistance = stop;
.slowdownDistance = slowdown;
.squaredStopDistance = stop * stop;
.squaredSlowdownDistance = slowdown * slowdown;
.distanceDelta = slowdown - stop;
}
{
(.compute(output)) {
output.setTranslation(.targetPosition);
output.getTranslation();
translation.subtract(.selfPosition);
translation.squaredLength();
(distanceSquared <= .squaredStopDistance) {
output.clear();
;
} {
Math.sqrt(distanceSquared);
(distanceSquared >= .squaredSlowdownDistance) {
translation.scale( / distance);
output.clearRotation();
;
} {
Math.pow((distance - .stopDistance) / .distanceDelta, .invFalloff);
translation.setLength(scale);
output.clearRotation();
;
}
}
} {
;
}
}
{
.stopDistance;
}
{
.setDistances(.getSlowdownDistance(), stopDistance);
}
{
.slowdownDistance;
}
{
.setDistances(slowdownDistance, .getStopDistance());
}
{
.falloff;
}
{
.falloff = falloff;
.invFalloff = / falloff;
}
}