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

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

import com.hypixel.hytale.server.npc.asset.builder.validators.StringValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.StringNullOrNotEmptyValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleArrayValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSequenceValidator;
import com.hypixel.hytale.server.npc.instructions.Sensor;
import com.hypixel.hytale.server.npc.asset.builder.Builder;
import com.google.gson.JsonElement;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.corecomponents.world.SensorLight;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import com.hypixel.hytale.server.npc.asset.builder.holder.NumberArrayHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.StringHolder;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderSensorBase;

public class BuilderSensorLight extends BuilderSensorBase
{
    public static final double[] FULL_LIGHT_RANGE;
    protected final StringHolder useTargetSlot;
    protected final NumberArrayHolder lightRange;
    protected final NumberArrayHolder skyLightRange;
    protected final NumberArrayHolder sunlightRange;
    protected final NumberArrayHolder redLightRange;
    protected final NumberArrayHolder greenLightRange;
    protected final NumberArrayHolder blueLightRange;
    
    public BuilderSensorLight() {
        this.useTargetSlot = new StringHolder();
        this.lightRange = new NumberArrayHolder();
        this.skyLightRange = new NumberArrayHolder();
        this.sunlightRange = new NumberArrayHolder();
        this.redLightRange = new NumberArrayHolder();
        this.greenLightRange = new NumberArrayHolder();
        this.blueLightRange = new NumberArrayHolder();
    }
    
    @Nonnull
    @Override
    public SensorLight build(@Nonnull final BuilderSupport builderSupport) {
        return new SensorLight(this, builderSupport);
    }
    
    @Nonnull
    @Override
    public String getShortDescription() {
        return "Check the light levels of the block an entity is standing on";
    }
    
    @Nonnull
    @Override
    public String getLongDescription() {
        return "Check the light levels of the block an entity is standing on. Can test light intensity, sky light or block channel levels.";
    }
    
    @Nonnull
    @Override
    public BuilderDescriptorState getBuilderDescriptorState() {
        return BuilderDescriptorState.Stable;
    }
    
    @Nonnull
    @Override
    public Builder<Sensor> readConfig(@Nonnull final JsonElement data) {
        this.getDoubleRange(data, "LightRange", this.lightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The light intensity percentage range", null);
        this.getDoubleRange(data, "SkyLightRange", this.skyLightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The sky light percentage range", null);
        this.getDoubleRange(data, "SunlightRange", this.sunlightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The sunlight percentage range", null);
        this.getDoubleRange(data, "RedLightRange", this.redLightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The red light percentage range", null);
        this.getDoubleRange(data, "GreenLightRange", this.greenLightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The green light percentage range", null);
        this.getDoubleRange(data, "BlueLightRange", this.blueLightRange, BuilderSensorLight.FULL_LIGHT_RANGE, DoubleSequenceValidator.betweenWeaklyMonotonic(0.0, 100.0), BuilderDescriptorState.Stable, "The blue light percentage range", null);
        this.getString(data, "UseTargetSlot", this.useTargetSlot, null, StringNullOrNotEmptyValidator.get(), BuilderDescriptorState.Stable, "A target slot to check. If omitted, will check self", null);
        return this;
    }
    
    public int getUsedTargetSlot(@Nonnull final BuilderSupport support) {
        final String slot = this.useTargetSlot.get(support.getExecutionContext());
        if (slot == null) {
            return Integer.MIN_VALUE;
        }
        return support.getTargetSlot(slot);
    }
    
    public double[] getLightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.lightRange.get(builderSupport.getExecutionContext());
    }
    
    public double[] getSkyLightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.skyLightRange.get(builderSupport.getExecutionContext());
    }
    
    public double[] getSunlightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.sunlightRange.get(builderSupport.getExecutionContext());
    }
    
    public double[] getRedLightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.redLightRange.get(builderSupport.getExecutionContext());
    }
    
    public double[] getGreenLightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.greenLightRange.get(builderSupport.getExecutionContext());
    }
    
    public double[] getBlueLightRange(@Nonnull final BuilderSupport builderSupport) {
        return this.blueLightRange.get(builderSupport.getExecutionContext());
    }
    
    static {
        FULL_LIGHT_RANGE = new double[] { 0.0, 100.0 };
    }
}
