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

package com.hypixel.hytale.server.npc.decisionmaker.core.conditions.base;

import com.hypixel.hytale.codec.validation.Validator;
import com.hypixel.hytale.codec.validation.Validators;
import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.Codec;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.decisionmaker.core.EvaluationContext;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.codec.builder.BuilderCodec;

public abstract class SimpleCondition extends Condition
{
    public static final BuilderCodec<SimpleCondition> ABSTRACT_CODEC;
    protected double falseValue;
    protected double trueValue;
    
    protected SimpleCondition() {
        this.falseValue = 0.0;
        this.trueValue = 1.0;
    }
    
    @Override
    public double calculateUtility(final int selfIndex, final ArchetypeChunk<EntityStore> archetypeChunk, final Ref<EntityStore> target, final CommandBuffer<EntityStore> commandBuffer, final EvaluationContext context) {
        return this.evaluate(selfIndex, archetypeChunk, target, commandBuffer, context) ? this.trueValue : this.falseValue;
    }
    
    @Override
    public int getSimplicity() {
        return 10;
    }
    
    protected abstract boolean evaluate(final int p0, final ArchetypeChunk<EntityStore> p1, final Ref<EntityStore> p2, final CommandBuffer<EntityStore> p3, final EvaluationContext p4);
    
    @Nonnull
    @Override
    public String toString() {
        return "SimpleCondition{falseValue=" + this.falseValue + ", trueValue=" + this.trueValue + "} " + super.toString();
    }
    
    static {
        ABSTRACT_CODEC = BuilderCodec.abstractBuilder(SimpleCondition.class, SimpleCondition.BASE_CODEC).appendInherited(new KeyedCodec<Double>("FalseValue", Codec.DOUBLE), (condition, d) -> condition.falseValue = d, condition -> condition.falseValue, (condition, parent) -> condition.falseValue = parent.falseValue).documentation("The utility value to use when the condition evaluates false.").addValidator((Validator<? super Double>)Validators.range(0.0, 1.0)).add().appendInherited(new KeyedCodec("TrueValue", Codec.DOUBLE), (condition, d) -> condition.trueValue = d, condition -> condition.trueValue, (condition, parent) -> condition.trueValue = parent.trueValue).documentation("The utility value to use when the condition evaluates true.").addValidator(Validators.range(0.0, 1.0)).add().build();
    }
}
