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

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

import com.hypixel.hytale.server.npc.asset.builder.Feature;
import com.hypixel.hytale.server.npc.asset.builder.validators.StringNotEmptyValidator;
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.StringValidator;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.asset.builder.Builder;
import com.google.gson.JsonElement;
import com.hypixel.hytale.server.npc.instructions.Sensor;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import java.util.Set;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.corecomponents.world.SensorPath;
import com.hypixel.hytale.server.npc.asset.builder.holder.EnumHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.StringHolder;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderSensorBase;

public class BuilderSensorPath extends BuilderSensorBase
{
    protected final StringHolder name;
    protected final DoubleHolder range;
    protected final EnumHolder<SensorPath.PathType> pathType;
    
    public BuilderSensorPath() {
        this.name = new StringHolder();
        this.range = new DoubleHolder();
        this.pathType = new EnumHolder<SensorPath.PathType>();
    }
    
    @Nonnull
    @Override
    public String getShortDescription() {
        return "Find a path based on various criteria";
    }
    
    @Nonnull
    @Override
    public String getLongDescription() {
        return "Find a path based on various criteria. Provides the position of the nearest waypoint and the path itself";
    }
    
    @Override
    public void registerTags(@Nonnull final Set<String> tags) {
        super.registerTags(tags);
        tags.add("path");
    }
    
    @Nonnull
    @Override
    public Sensor build(@Nonnull final BuilderSupport builderSupport) {
        return new SensorPath(this, builderSupport);
    }
    
    @Nonnull
    @Override
    public Builder<Sensor> readConfig(@Nonnull final JsonElement data) {
        this.getString(data, "Path", this.name, null, null, BuilderDescriptorState.Stable, "The name of the path. If left blank, will find the nearest path", null);
        this.getDouble(data, "Range", this.range, 10.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "The range to test to nearest waypoint. 0 is unlimited", null);
        this.getEnum(data, "PathType", this.pathType, SensorPath.PathType.class, SensorPath.PathType.AnyPrefabPath, BuilderDescriptorState.Stable, "The type of path to search for", null);
        this.validateStringIfEnumIs(this.name, StringNotEmptyValidator.get(), this.pathType, SensorPath.PathType.WorldPath);
        this.provideFeature(Feature.Position);
        this.provideFeature(Feature.Path);
        return this;
    }
    
    @Nonnull
    @Override
    public BuilderDescriptorState getBuilderDescriptorState() {
        return BuilderDescriptorState.Stable;
    }
    
    public String getPath(@Nonnull final BuilderSupport support) {
        return this.name.get(support.getExecutionContext());
    }
    
    public double getRange(@Nonnull final BuilderSupport support) {
        return this.range.get(support.getExecutionContext());
    }
    
    public SensorPath.PathType getPathType(@Nonnull final BuilderSupport support) {
        return this.pathType.get(support.getExecutionContext());
    }
}
