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

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

import com.hypixel.hytale.server.npc.asset.builder.Builder;
import com.hypixel.hytale.server.npc.asset.builder.Feature;
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.validators.DoubleSingleValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleArrayValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSequenceValidator;
import com.google.gson.JsonElement;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.instructions.BodyMotion;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.corecomponents.movement.BodyMotionTeleport;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderBodyMotionBase;

public class BuilderBodyMotionTeleport extends BuilderBodyMotionBase
{
    public static final double[] DEFAULT_OFFSET_RADIUS;
    protected double[] offsetRadius;
    protected double maxYOffset;
    protected float sector;
    protected BodyMotionTeleport.Orientation orientation;
    
    @Nonnull
    @Override
    public String getShortDescription() {
        return "Teleport NPC to a position given by a sensor";
    }
    
    @Nonnull
    @Override
    public String getLongDescription() {
        return "Teleport NPC to a position given by a sensor or to a random position nearby with an optional minimum offset up to a maximum offset";
    }
    
    @Nonnull
    @Override
    public BodyMotion build(final BuilderSupport builderSupport) {
        return new BodyMotionTeleport(this);
    }
    
    @Nonnull
    @Override
    public BuilderDescriptorState getBuilderDescriptorState() {
        return BuilderDescriptorState.Experimental;
    }
    
    @Nonnull
    @Override
    public BuilderBodyMotionTeleport readConfig(@Nonnull final JsonElement data) {
        this.getDoubleRange(data, "OffsetRange", v -> this.offsetRadius = v, BuilderBodyMotionTeleport.DEFAULT_OFFSET_RADIUS, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, Double.MAX_VALUE), BuilderDescriptorState.Experimental, "The minimum and maximum offset the NPC can be spawned from the target position", null);
        this.getDouble(data, "MaxYOffset", v -> this.maxYOffset = v, 5.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Experimental, "Maximum vertical offset from the target position in case of terrain obstacles", null);
        this.getFloat(data, "OffsetSector", v -> this.sector = v, 0.0f, DoubleRangeValidator.between(0.0, 360.0), BuilderDescriptorState.Experimental, "The sector around the target in which to teleport to", "The sector around the target in which to teleport to. The origin point is directly between the target and the NPC teleporting");
        this.getEnum(data, "Orientation", v -> this.orientation = v, BodyMotionTeleport.Orientation.class, BodyMotionTeleport.Orientation.Unchanged, BuilderDescriptorState.Experimental, "The direction to face after teleporting", null);
        this.requireFeature(Feature.AnyPosition);
        this.requireFeatureIf("Orientation", BodyMotionTeleport.Orientation.UseTarget, this.orientation, Feature.AnyEntity);
        return this;
    }
    
    public double[] getOffsetRadius() {
        return this.offsetRadius;
    }
    
    public double getMaxYOffset() {
        return this.maxYOffset;
    }
    
    public float getSectorRadians() {
        return 0.017453292f * this.sector;
    }
    
    public BodyMotionTeleport.Orientation getOrientation() {
        return this.orientation;
    }
    
    static {
        DEFAULT_OFFSET_RADIUS = new double[] { 0.0, 0.0 };
    }
}
