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

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

import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import com.hypixel.hytale.math.vector.Vector3d;

public class Steering
{
    public static final Steering NULL;
    private final Vector3d translation;
    private double maxDistance;
    private Vector3d maxDistanceComponentSelector;
    private boolean hasTranslation;
    private float yaw;
    private boolean hasYaw;
    private float pitch;
    private boolean hasPitch;
    private float roll;
    private boolean hasRoll;
    private double relativeTurnSpeed;
    private boolean hasRelativeTurnSpeed;
    
    public Steering() {
        this.translation = new Vector3d();
        this.maxDistance = Double.MAX_VALUE;
    }
    
    @Nonnull
    public Steering clear() {
        this.clearTranslation();
        this.clearRotation();
        return this;
    }
    
    @Nonnull
    public Steering assign(@Nonnull final Steering other) {
        this.translation.assign(other.translation);
        this.maxDistance = other.maxDistance;
        this.maxDistanceComponentSelector = other.maxDistanceComponentSelector;
        this.hasTranslation = other.hasTranslation;
        this.yaw = other.yaw;
        this.hasYaw = other.hasYaw;
        this.pitch = other.pitch;
        this.hasPitch = other.hasPitch;
        this.relativeTurnSpeed = other.relativeTurnSpeed;
        this.hasRelativeTurnSpeed = other.hasRelativeTurnSpeed;
        return this;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final Steering steering = (Steering)o;
        return Double.compare(steering.maxDistance, this.maxDistance) == 0 && this.hasTranslation == steering.hasTranslation && Float.compare(steering.yaw, this.yaw) == 0 && this.hasYaw == steering.hasYaw && Float.compare(steering.pitch, this.pitch) == 0 && this.hasPitch == steering.hasPitch && Float.compare(steering.roll, this.roll) == 0 && this.hasRoll == steering.hasRoll && this.translation.equals(steering.translation) && Double.compare(steering.relativeTurnSpeed, this.relativeTurnSpeed) == 0 && this.hasRelativeTurnSpeed == steering.hasRelativeTurnSpeed && this.maxDistanceComponentSelector.equals(steering.maxDistanceComponentSelector);
    }
    
    @Override
    public int hashCode() {
        int result = this.translation.hashCode();
        final long temp = Double.doubleToLongBits(this.maxDistance);
        result = 31 * result + (int)(temp ^ temp >>> 32);
        result = 31 * result + this.maxDistanceComponentSelector.hashCode();
        result = 31 * result + (this.hasTranslation ? 1 : 0);
        result = 31 * result + ((this.yaw != 0.0f) ? Float.floatToIntBits(this.yaw) : 0);
        result = 31 * result + (this.hasYaw ? 1 : 0);
        result = 31 * result + ((this.pitch != 0.0f) ? Float.floatToIntBits(this.pitch) : 0);
        result = 31 * result + (this.hasPitch ? 1 : 0);
        result = 31 * result + ((this.roll != 0.0f) ? Float.floatToIntBits(this.roll) : 0);
        result = 31 * result + (this.hasRoll ? 1 : 0);
        return result;
    }
    
    @Nonnull
    public Steering clearTranslation() {
        this.translation.assign(Vector3d.ZERO);
        this.maxDistance = Double.MAX_VALUE;
        this.hasTranslation = false;
        return this;
    }
    
    @Nonnull
    public Steering clearRotation() {
        this.yaw = 0.0f;
        this.hasYaw = false;
        this.pitch = 0.0f;
        this.hasPitch = false;
        this.relativeTurnSpeed = 0.0;
        this.hasRelativeTurnSpeed = false;
        return this;
    }
    
    @Nonnull
    public Vector3d getTranslation() {
        return this.translation;
    }
    
    public double getX() {
        return this.translation.x;
    }
    
    @Nonnull
    public Steering setX(final double value) {
        this.hasTranslation = true;
        this.translation.x = value;
        return this;
    }
    
    public double getY() {
        return this.translation.y;
    }
    
    @Nonnull
    public Steering setY(final double value) {
        this.hasTranslation = true;
        this.translation.y = value;
        return this;
    }
    
    public double getZ() {
        return this.translation.z;
    }
    
    @Nonnull
    public Steering setZ(final double value) {
        this.hasTranslation = true;
        this.translation.z = value;
        return this;
    }
    
    @Nonnull
    public Steering setTranslation(@Nonnull final Vector3d translation) {
        this.hasTranslation = true;
        this.translation.assign(translation);
        return this;
    }
    
    @Nonnull
    public Steering setTranslation(final double x, final double y, final double z) {
        this.hasTranslation = true;
        this.translation.assign(x, y, z);
        return this;
    }
    
    @Nonnull
    public Steering setTranslationRelativeSpeed(final double relativeSpeed) {
        this.translation.setLength(relativeSpeed);
        return this;
    }
    
    @Nonnull
    public Steering scaleTranslation(final double speedFactor) {
        this.translation.scale(speedFactor);
        return this;
    }
    
    @Nonnull
    public Steering ensureMinTranslation(final double relativeSpeed) {
        if (this.translation.squaredLength() < relativeSpeed * relativeSpeed && this.translation.squaredLength() > 0.0) {
            this.translation.setLength(relativeSpeed);
        }
        return this;
    }
    
    public double getMaxDistance() {
        return this.maxDistance;
    }
    
    public void setMaxDistance(final double maxDistance) {
        this.maxDistance = maxDistance;
    }
    
    public void clearMaxDistance() {
        this.setMaxDistance(Double.MAX_VALUE);
    }
    
    public Vector3d getMaxDistanceComponentSelector() {
        return this.maxDistanceComponentSelector;
    }
    
    public void setMaxDistanceComponentSelector(final Vector3d maxDistanceComponentSelector) {
        this.maxDistanceComponentSelector = maxDistanceComponentSelector;
    }
    
    public void clearMaxDistanceComponentSelector() {
        this.setMaxDistanceComponentSelector(null);
    }
    
    public float getYaw() {
        return this.yaw;
    }
    
    @Nonnull
    public Steering setYaw(final float angle) {
        this.yaw = angle;
        this.hasYaw = true;
        return this;
    }
    
    public void clearYaw() {
        this.hasYaw = false;
    }
    
    public float getPitch() {
        return this.pitch;
    }
    
    @Nonnull
    public Steering setPitch(final float angle) {
        this.pitch = angle;
        this.hasPitch = true;
        return this;
    }
    
    public void clearPitch() {
        this.hasPitch = false;
    }
    
    public float getRoll() {
        return this.roll;
    }
    
    @Nonnull
    public Steering setRoll(final float angle) {
        this.roll = angle;
        this.hasRoll = true;
        return this;
    }
    
    public void clearRoll() {
        this.hasRoll = false;
    }
    
    @Nonnull
    public Steering setRelativeTurnSpeed(final double relativeTurnSpeed) {
        this.relativeTurnSpeed = relativeTurnSpeed;
        this.hasRelativeTurnSpeed = true;
        return this;
    }
    
    public boolean hasTranslation() {
        return this.hasTranslation;
    }
    
    public boolean hasYaw() {
        return this.hasYaw;
    }
    
    public boolean hasPitch() {
        return this.hasPitch;
    }
    
    public boolean hasRoll() {
        return this.hasRoll;
    }
    
    public double getSpeed() {
        if (!this.hasTranslation()) {
            return 0.0;
        }
        return this.translation.length();
    }
    
    public double getRelativeTurnSpeed() {
        if (!this.hasRelativeTurnSpeed) {
            return 1.0;
        }
        return this.relativeTurnSpeed;
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "Steering{translation=" + String.valueOf(this.translation) + ", hasTranslation=" + this.hasTranslation + ", yaw=" + this.yaw + ", hasYaw=" + this.hasYaw + ", pitch=" + this.pitch + ", hasPitch=" + this.hasPitch + ", roll=" + this.roll + ", hasRoll=" + this.hasRoll + ", relativeTurnSpeed=" + this.relativeTurnSpeed + ", hasRelativeTurnSpeed=" + this.hasRelativeTurnSpeed;
    }
    
    static {
        NULL = new Steering().clear();
    }
}
