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

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

import com.hypixel.hytale.server.npc.asset.builder.Feature;
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.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.combat.SensorDamage;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderSensorBase;

public class BuilderSensorDamage extends BuilderSensorBase
{
    public static final String[] REQUIRE_ONE_OF;
    public static final String[] ANTECEDENT;
    public static final String[] SUBSEQUENT;
    protected boolean combatDamage;
    protected boolean friendlyDamage;
    protected boolean drowningDamage;
    protected boolean environmentDamage;
    protected boolean otherDamage;
    protected String targetSlot;
    
    @Nonnull
    @Override
    public SensorDamage build(@Nonnull final BuilderSupport builderSupport) {
        return new SensorDamage(this, builderSupport);
    }
    
    @Nonnull
    @Override
    public String getShortDescription() {
        return "Test if NPC suffered damage";
    }
    
    @Nonnull
    @Override
    public String getLongDescription() {
        return "Test if NPC suffered damage. A position is only returned when NPC suffered combat damage.";
    }
    
    @Nonnull
    @Override
    public BuilderDescriptorState getBuilderDescriptorState() {
        return BuilderDescriptorState.Stable;
    }
    
    @Nonnull
    @Override
    public Builder<Sensor> readConfig(@Nonnull final JsonElement data) {
        this.getBoolean(data, "Combat", v -> this.combatDamage = v, true, BuilderDescriptorState.Stable, "Test for combat damage", null);
        this.getBoolean(data, "Friendly", v -> this.friendlyDamage = v, false, BuilderDescriptorState.Stable, "Test for damage from usually disabled damage groups", null);
        this.getBoolean(data, "Drowning", v -> this.drowningDamage = v, false, BuilderDescriptorState.Stable, "Test for damage from drowning", null);
        this.getBoolean(data, "Environment", v -> this.environmentDamage = v, false, BuilderDescriptorState.Stable, "Test for damage from environment", null);
        this.getBoolean(data, "Other", v -> this.otherDamage = v, false, BuilderDescriptorState.Stable, "Test for other damage", null);
        this.getString(data, "TargetSlot", v -> this.targetSlot = v, null, StringNullOrNotEmptyValidator.get(), BuilderDescriptorState.Stable, "The slot to use for locking on the target if damage is taken. If omitted, target will not be locked", null);
        this.validateAny(BuilderSensorDamage.REQUIRE_ONE_OF, new boolean[] { this.combatDamage, this.drowningDamage, this.environmentDamage, this.otherDamage });
        this.validateBooleanImplicationAnyAntecedent(BuilderSensorDamage.ANTECEDENT, new boolean[] { this.targetSlot != null }, true, BuilderSensorDamage.SUBSEQUENT, new boolean[] { this.drowningDamage, this.environmentDamage, this.otherDamage }, false);
        this.provideFeature(Feature.AnyEntity);
        return this;
    }
    
    public boolean isCombatDamage() {
        return this.combatDamage;
    }
    
    public boolean isFriendlyDamage() {
        return this.friendlyDamage;
    }
    
    public boolean isDrowningDamage() {
        return this.drowningDamage;
    }
    
    public boolean isEnvironmentDamage() {
        return this.environmentDamage;
    }
    
    public boolean isOtherDamage() {
        return this.otherDamage;
    }
    
    public int getTargetSlot(@Nonnull final BuilderSupport support) {
        if (this.targetSlot == null) {
            return Integer.MIN_VALUE;
        }
        return support.getTargetSlot(this.targetSlot);
    }
    
    static {
        REQUIRE_ONE_OF = new String[] { "Combat", "Drowning", "Environment", "Other" };
        ANTECEDENT = new String[] { "TargetSlot" };
        SUBSEQUENT = new String[] { "Drowning", "Environment", "Other" };
    }
}
