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

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

import com.hypixel.hytale.server.npc.asset.builder.validators.RelationalOperator;
import com.hypixel.hytale.server.npc.asset.builder.validators.IntSingleValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleRangeValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleValidator;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator;
import com.hypixel.hytale.server.npc.instructions.BodyMotion;
import com.hypixel.hytale.server.npc.asset.builder.Builder;
import com.google.gson.JsonElement;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.npc.corecomponents.movement.BodyMotionWanderBase;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import com.hypixel.hytale.server.npc.asset.builder.holder.IntHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.FloatHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderBodyMotionBase;

public abstract class BuilderBodyMotionWanderBase extends BuilderBodyMotionBase
{
    protected final DoubleHolder minWalkTime;
    protected final DoubleHolder maxWalkTime;
    protected final FloatHolder minHeadingChange;
    protected final FloatHolder maxHeadingChange;
    protected final BooleanHolder relaxHeadingChange;
    protected final DoubleHolder relativeSpeed;
    protected final DoubleHolder minMoveDistance;
    protected final DoubleHolder stopDistance;
    protected final BooleanHolder isAvoidingBlockDamage;
    protected final BooleanHolder isRelaxedMoveConstraints;
    protected final IntHolder testsPerTick;
    protected final DoubleHolder desiredAltitudeWeight;
    
    public BuilderBodyMotionWanderBase() {
        this.minWalkTime = new DoubleHolder();
        this.maxWalkTime = new DoubleHolder();
        this.minHeadingChange = new FloatHolder();
        this.maxHeadingChange = new FloatHolder();
        this.relaxHeadingChange = new BooleanHolder();
        this.relativeSpeed = new DoubleHolder();
        this.minMoveDistance = new DoubleHolder();
        this.stopDistance = new DoubleHolder();
        this.isAvoidingBlockDamage = new BooleanHolder();
        this.isRelaxedMoveConstraints = new BooleanHolder();
        this.testsPerTick = new IntHolder();
        this.desiredAltitudeWeight = new DoubleHolder();
    }
    
    @Nullable
    @Override
    public BodyMotionWanderBase build(@Nonnull final BuilderSupport builderSupport) {
        builderSupport.setRequireLeashPosition();
        return null;
    }
    
    @Nonnull
    @Override
    public Builder<BodyMotion> readCommonConfig(@Nonnull final JsonElement data) {
        super.readCommonConfig(data);
        this.getDouble(data, "MinWalkTime", this.minWalkTime, 2.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Stable, "Minimum time to wander for a segment.", null);
        this.getDouble(data, "MaxWalkTime", this.maxWalkTime, 4.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Maximum time to wander for a segment.", null);
        this.getFloat(data, "MinHeadingChange", this.minHeadingChange, 0.0, DoubleRangeValidator.between(0.0, 180.0), BuilderDescriptorState.Stable, "Approximate minimum heading change between segments", null);
        this.getFloat(data, "MaxHeadingChange", this.maxHeadingChange, 90.0, DoubleRangeValidator.between(0.0, 180.0), BuilderDescriptorState.Stable, "Approximate maximum heading change between segments", null);
        this.getBoolean(data, "RelaxHeadingChange", this.relaxHeadingChange, true, BuilderDescriptorState.Stable, "Allow other directions when preferred directions blocked", null);
        this.getDouble(data, "RelativeSpeed", this.relativeSpeed, 0.5, DoubleRangeValidator.fromExclToIncl(0.0, 2.0), BuilderDescriptorState.Stable, "Relative wander speed", null);
        this.getDouble(data, "MinMoveDistance", this.minMoveDistance, 0.5, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Minimum distance to move in a segment", null);
        this.getDouble(data, "StopDistance", this.stopDistance, 0.5, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "Distance to stop at target", null);
        this.getInt(data, "TestsPerTick", this.testsPerTick, 1, IntSingleValidator.greater0(), BuilderDescriptorState.Stable, "Direction tests per tick", null);
        this.getBoolean(data, "AvoidBlockDamage", this.isAvoidingBlockDamage, true, BuilderDescriptorState.Stable, "Should avoid environmental damage from blocks", null);
        this.getBoolean(data, "RelaxedMoveConstraints", this.isRelaxedMoveConstraints, false, BuilderDescriptorState.Stable, "NPC can do movements like wading (depends on motion controller type)", null);
        this.getDouble(data, "DesiredAltitudeWeight", this.desiredAltitudeWeight, -1.0, DoubleRangeValidator.between(-1.0, 1.0), BuilderDescriptorState.Stable, "How much this NPC prefers being within the desired height range", "How much this NPC prefers being within the desired height range. 0 means it doesn't care much, 1 means it will do its best to get there fast. Values below 0 mean the default in the motion controller will be used.");
        this.validateDoubleRelation(this.minWalkTime, RelationalOperator.LessEqual, this.maxWalkTime);
        this.validateFloatRelation(this.minHeadingChange, RelationalOperator.LessEqual, this.maxHeadingChange);
        return this;
    }
    
    public double getMinWalkTime(@Nonnull final BuilderSupport support) {
        return this.minWalkTime.get(support.getExecutionContext());
    }
    
    public double getMaxWalkTime(@Nonnull final BuilderSupport support) {
        return this.maxWalkTime.get(support.getExecutionContext());
    }
    
    public float getMinHeadingChange(@Nonnull final BuilderSupport support) {
        return this.minHeadingChange.get(support.getExecutionContext());
    }
    
    public float getMaxHeadingChange(@Nonnull final BuilderSupport support) {
        return this.maxHeadingChange.get(support.getExecutionContext());
    }
    
    public boolean isRelaxHeadingChange(@Nonnull final BuilderSupport support) {
        return this.relaxHeadingChange.get(support.getExecutionContext());
    }
    
    public double getRelativeSpeed(@Nonnull final BuilderSupport support) {
        return this.relativeSpeed.get(support.getExecutionContext());
    }
    
    public double getMinMoveDistance(@Nonnull final BuilderSupport support) {
        return this.minMoveDistance.get(support.getExecutionContext());
    }
    
    public double getStopDistance(@Nonnull final BuilderSupport support) {
        return this.stopDistance.get(support.getExecutionContext());
    }
    
    public boolean isAvoidingBlockDamage(@Nonnull final BuilderSupport support) {
        return this.isAvoidingBlockDamage.get(support.getExecutionContext());
    }
    
    public boolean isRelaxedMoveConstraints(@Nonnull final BuilderSupport support) {
        return this.isRelaxedMoveConstraints.get(support.getExecutionContext());
    }
    
    public int getTestsPerTick(@Nonnull final BuilderSupport support) {
        return this.testsPerTick.get(support.getExecutionContext());
    }
    
    public double getDesiredAltitudeWeight(@Nonnull final BuilderSupport support) {
        return this.desiredAltitudeWeight.get(support.getExecutionContext());
    }
}
