// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.npc.movement.steeringforces;

import com.hypixel.hytale.math.random.RandomExtra;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.movement.Steering;
import com.hypixel.hytale.server.core.modules.physics.util.PhysicsMath;
import com.hypixel.hytale.math.vector.Vector3d;

public class SteeringForceWander implements SteeringForce
{
    private double time;
    private double turnInterval;
    private double jitter;
    private final Vector3d velocity;
    
    public SteeringForceWander() {
        this.jitter = 0.5;
        this.velocity = new Vector3d(0.0, 0.0, -1.0);
        this.setTurnTime(5.0);
        this.jitter = 0.5;
    }
    
    public void setTurnTime(final double t) {
        this.turnInterval = 0.0;
        this.time = this.turnInterval;
    }
    
    public void updateTime(final double dt) {
        this.time += dt;
    }
    
    public void setHeading(final float heading) {
        this.velocity.x = PhysicsMath.headingX(heading);
        this.velocity.z = PhysicsMath.headingZ(heading);
    }
    
    @Override
    public boolean compute(@Nonnull final Steering output) {
        if (this.time < this.turnInterval) {
            final Vector3d velocity = this.velocity;
            velocity.x += RandomExtra.randomBinomial() * this.jitter;
            final Vector3d velocity2 = this.velocity;
            velocity2.z += RandomExtra.randomBinomial() * this.jitter;
            this.velocity.normalize();
        }
        output.clearRotation();
        return true;
    }
}
