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

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

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.hypixel.hytale.protocol.AnimationSlot;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Component;

public class ActiveAnimationComponent implements Component<EntityStore>
{
    private final String[] activeAnimations;
    private boolean isNetworkOutdated;
    
    public static ComponentType<EntityStore, ActiveAnimationComponent> getComponentType() {
        return EntityModule.get().getActiveAnimationComponentType();
    }
    
    public ActiveAnimationComponent() {
        this.activeAnimations = new String[AnimationSlot.VALUES.length];
        this.isNetworkOutdated = false;
    }
    
    public ActiveAnimationComponent(final String[] activeAnimations) {
        this.activeAnimations = new String[AnimationSlot.VALUES.length];
        this.isNetworkOutdated = false;
        System.arraycopy(activeAnimations, 0, this.activeAnimations, 0, activeAnimations.length);
    }
    
    public String[] getActiveAnimations() {
        return this.activeAnimations;
    }
    
    public void setPlayingAnimation(final AnimationSlot slot, @Nullable final String animation) {
        if (this.activeAnimations[slot.ordinal()] != null && this.activeAnimations[slot.ordinal()].equals(animation)) {
            return;
        }
        this.activeAnimations[slot.ordinal()] = animation;
    }
    
    public boolean consumeNetworkOutdated() {
        final boolean temp = this.isNetworkOutdated;
        this.isNetworkOutdated = false;
        return temp;
    }
    
    @Nonnull
    @Override
    public Component<EntityStore> clone() {
        return new ActiveAnimationComponent(this.activeAnimations);
    }
}
