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

package com.hypixel.hytale.server.core.modules.entity.stamina;

import javax.annotation.Nonnull;
import com.hypixel.hytale.component.ResourceType;
import java.util.concurrent.atomic.AtomicInteger;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Resource;

public class SprintStaminaRegenDelay implements Resource<EntityStore>
{
    private static final AtomicInteger ASSET_VALIDATION_STATE;
    protected int statIndex;
    protected float statValue;
    protected int validationState;
    
    public static ResourceType<EntityStore, SprintStaminaRegenDelay> getResourceType() {
        return StaminaModule.get().getSprintRegenDelayResourceType();
    }
    
    public SprintStaminaRegenDelay() {
        this.statIndex = 0;
        this.validationState = SprintStaminaRegenDelay.ASSET_VALIDATION_STATE.get() - 1;
    }
    
    public SprintStaminaRegenDelay(@Nonnull final SprintStaminaRegenDelay other) {
        this.statIndex = 0;
        this.validationState = SprintStaminaRegenDelay.ASSET_VALIDATION_STATE.get() - 1;
        this.statIndex = other.statIndex;
        this.statValue = other.statValue;
        this.validationState = other.validationState;
    }
    
    public int getIndex() {
        return this.statIndex;
    }
    
    public float getValue() {
        return this.statValue;
    }
    
    public boolean validate() {
        return this.validationState == SprintStaminaRegenDelay.ASSET_VALIDATION_STATE.get();
    }
    
    public boolean hasDelay() {
        return this.statIndex != 0 && this.statValue < 0.0f;
    }
    
    public void markEmpty() {
        this.update(0, 0.0f);
    }
    
    public void update(final int statIndex, final float statValue) {
        this.statIndex = statIndex;
        this.statValue = statValue;
        this.validationState = SprintStaminaRegenDelay.ASSET_VALIDATION_STATE.get();
    }
    
    @Nonnull
    @Override
    public Resource<EntityStore> clone() {
        return new SprintStaminaRegenDelay(this);
    }
    
    @Nonnull
    @Override
    public String toString() {
        return "SprintStaminaRegenDelay{statIndex=" + this.statIndex + ", statValue=" + this.statValue + ", validationState=" + this.validationState;
    }
    
    public static void invalidateResources() {
        SprintStaminaRegenDelay.ASSET_VALIDATION_STATE.incrementAndGet();
    }
    
    static {
        ASSET_VALIDATION_STATE = new AtomicInteger(0);
    }
}
