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

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

import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.Codec;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.codec.builder.BuilderCodec;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Component;

public class EntityScaleComponent implements Component<EntityStore>
{
    public static final BuilderCodec<EntityScaleComponent> CODEC;
    private float scale;
    private boolean isNetworkOutdated;
    
    public static ComponentType<EntityStore, EntityScaleComponent> getComponentType() {
        return EntityModule.get().getEntityScaleComponentType();
    }
    
    private EntityScaleComponent() {
        this.scale = 1.0f;
        this.isNetworkOutdated = true;
    }
    
    public EntityScaleComponent(final float scale) {
        this.scale = 1.0f;
        this.isNetworkOutdated = true;
        this.scale = scale;
    }
    
    public float getScale() {
        return this.scale;
    }
    
    public void setScale(final float scale) {
        this.scale = scale;
        this.isNetworkOutdated = true;
    }
    
    public boolean consumeNetworkOutdated() {
        final boolean temp = this.isNetworkOutdated;
        this.isNetworkOutdated = false;
        return temp;
    }
    
    @Nonnull
    @Override
    public Component<EntityStore> clone() {
        return new EntityScaleComponent(this.scale);
    }
    
    static {
        CODEC = BuilderCodec.builder(EntityScaleComponent.class, EntityScaleComponent::new).addField(new KeyedCodec<Float>("Scale", Codec.FLOAT), (o, scale) -> o.scale = scale, o -> o.scale).build();
    }
}
