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

package com.hypixel.hytale.builtin.npccombatactionevaluator.conditions;

import com.hypixel.hytale.component.Holder;
import com.hypixel.hytale.server.npc.decisionmaker.core.EvaluationContext;
import com.hypixel.hytale.component.CommandBuffer;
import com.hypixel.hytale.component.Ref;
import javax.annotation.Nonnull;
import com.hypixel.hytale.component.ArchetypeChunk;
import com.hypixel.hytale.builtin.npccombatactionevaluator.memory.DamageMemory;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.npc.decisionmaker.core.conditions.base.ScaledCurveCondition;

public class RecentSustainedDamageCondition extends ScaledCurveCondition
{
    public static final BuilderCodec<RecentSustainedDamageCondition> CODEC;
    protected static final ComponentType<EntityStore, DamageMemory> DAMAGE_MEMORY_COMPONENT_TYPE;
    
    @Override
    protected double getInput(final int selfIndex, @Nonnull final ArchetypeChunk<EntityStore> archetypeChunk, final Ref<EntityStore> target, final CommandBuffer<EntityStore> commandBuffer, final EvaluationContext context) {
        final DamageMemory memory = archetypeChunk.getComponent(selfIndex, RecentSustainedDamageCondition.DAMAGE_MEMORY_COMPONENT_TYPE);
        return memory.getRecentDamage();
    }
    
    @Override
    public void setupNPC(@Nonnull final Holder<EntityStore> holder) {
        holder.ensureComponent(RecentSustainedDamageCondition.DAMAGE_MEMORY_COMPONENT_TYPE);
    }
    
    static {
        CODEC = BuilderCodec.builder(RecentSustainedDamageCondition.class, RecentSustainedDamageCondition::new, ScaledCurveCondition.ABSTRACT_CODEC).documentation("A scaled curve condition that returns a utility value based on damage taken since the combat action evaluator was last run.").build();
        DAMAGE_MEMORY_COMPONENT_TYPE = DamageMemory.getComponentType();
    }
}
