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

package com.hypixel.hytale.server.core.entity.knockback;

import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentType;
import it.unimi.dsi.fastutil.doubles.DoubleArrayList;
import it.unimi.dsi.fastutil.doubles.DoubleList;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.core.modules.splitvelocity.VelocityConfig;
import com.hypixel.hytale.protocol.ChangeVelocityType;
import javax.annotation.Nonnull;
import com.hypixel.hytale.math.vector.Vector3d;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Component;

public class KnockbackComponent implements Component<EntityStore>
{
    @Nonnull
    private Vector3d velocity;
    private ChangeVelocityType velocityType;
    @Nullable
    private VelocityConfig velocityConfig;
    @Nonnull
    private DoubleList modifiers;
    private float duration;
    private float timer;
    
    public KnockbackComponent() {
        this.velocityType = ChangeVelocityType.Add;
        this.modifiers = new DoubleArrayList();
    }
    
    public static ComponentType<EntityStore, KnockbackComponent> getComponentType() {
        return EntityModule.get().getKnockbackComponentType();
    }
    
    @Nonnull
    public Vector3d getVelocity() {
        return this.velocity;
    }
    
    public void setVelocity(@Nonnull final Vector3d velocity) {
        this.velocity = velocity;
    }
    
    public ChangeVelocityType getVelocityType() {
        return this.velocityType;
    }
    
    public void setVelocityType(final ChangeVelocityType velocityType) {
        this.velocityType = velocityType;
    }
    
    @Nullable
    public VelocityConfig getVelocityConfig() {
        return this.velocityConfig;
    }
    
    public void setVelocityConfig(@Nullable final VelocityConfig velocityConfig) {
        this.velocityConfig = velocityConfig;
    }
    
    public void addModifier(final double modifier) {
        this.modifiers.add(modifier);
    }
    
    public void applyModifiers() {
        for (int i = 0; i < this.modifiers.size(); ++i) {
            this.velocity.scale(this.modifiers.getDouble(i));
        }
        this.modifiers.clear();
    }
    
    public float getDuration() {
        return this.duration;
    }
    
    public void setDuration(final float duration) {
        this.duration = duration;
    }
    
    public float getTimer() {
        return this.timer;
    }
    
    public void incrementTimer(final float time) {
        this.timer += time;
    }
    
    public void setTimer(final float time) {
        this.timer = time;
    }
    
    @Nonnull
    @Override
    public Component<EntityStore> clone() {
        final KnockbackComponent component = new KnockbackComponent();
        component.velocity = this.velocity;
        component.velocityType = this.velocityType;
        component.velocityConfig = this.velocityConfig;
        component.duration = this.duration;
        component.timer = this.timer;
        return component;
    }
}
