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

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

import javax.annotation.Nonnull;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentType;
import it.unimi.dsi.fastutil.ints.IntList;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Component;

public class AudioComponent implements Component<EntityStore>
{
    private IntList soundEventIds;
    private boolean isNetworkOutdated;
    
    public static ComponentType<EntityStore, AudioComponent> getComponentType() {
        return EntityModule.get().getAudioComponentType();
    }
    
    public AudioComponent() {
        this.soundEventIds = new IntArrayList();
        this.isNetworkOutdated = true;
    }
    
    public AudioComponent(final IntList soundEventIds) {
        this.soundEventIds = new IntArrayList();
        this.isNetworkOutdated = true;
        this.soundEventIds = soundEventIds;
    }
    
    public int[] getSoundEventIds() {
        return this.soundEventIds.toIntArray();
    }
    
    public void addSound(final int soundIndex) {
        this.soundEventIds.add(soundIndex);
        this.isNetworkOutdated = true;
    }
    
    public boolean consumeNetworkOutdated() {
        final boolean temp = this.isNetworkOutdated;
        this.isNetworkOutdated = false;
        return temp;
    }
    
    @Nonnull
    @Override
    public Component<EntityStore> clone() {
        return new AudioComponent(new IntArrayList(this.soundEventIds));
    }
}
