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

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

import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.modules.entity.EntityModule;
import com.hypixel.hytale.component.ComponentType;
import com.hypixel.hytale.server.core.modules.collision.CollisionResult;
import com.hypixel.hytale.protocol.MovementStates;
import javax.annotation.Nullable;
import com.hypixel.hytale.protocol.ChangeVelocityType;
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 KnockbackSimulation implements Component<EntityStore>
{
    public static final float KNOCKBACK_SIMULATION_TIME = 0.5f;
    public static final float BLEND_DELAY = 0.2f;
    private final Vector3d requestedVelocity;
    private final Vector3d clientLastPosition;
    private final Vector3d clientPosition;
    private final Vector3d relativeMovement;
    private final Vector3d simPosition;
    private final Vector3d simVelocity;
    @Nullable
    private ChangeVelocityType requestedVelocityChangeType;
    private MovementStates clientMovementStates;
    private float remainingTime;
    private boolean hadWishMovement;
    private boolean clientFinished;
    private boolean wasJumping;
    private int jumpCombo;
    private boolean wasOnGround;
    private float tickBuffer;
    private final Vector3d movementOffset;
    private final CollisionResult collisionResult;
    private final Vector3d checkPosition;
    private final Vector3d tempPosition;
    
    public KnockbackSimulation() {
        this.requestedVelocity = new Vector3d();
        this.clientLastPosition = new Vector3d();
        this.clientPosition = new Vector3d();
        this.relativeMovement = new Vector3d();
        this.simPosition = new Vector3d();
        this.simVelocity = new Vector3d();
        this.requestedVelocityChangeType = null;
        this.remainingTime = 0.5f;
        this.hadWishMovement = false;
        this.clientFinished = false;
        this.wasJumping = false;
        this.jumpCombo = 0;
        this.wasOnGround = false;
        this.tickBuffer = 0.0f;
        this.movementOffset = new Vector3d();
        this.collisionResult = new CollisionResult();
        this.checkPosition = new Vector3d();
        this.tempPosition = new Vector3d();
    }
    
    public static ComponentType<EntityStore, KnockbackSimulation> getComponentType() {
        return EntityModule.get().getKnockbackSimulationComponentType();
    }
    
    public float getTickBuffer() {
        return this.tickBuffer;
    }
    
    public void setTickBuffer(final float tickBuffer) {
        this.tickBuffer = tickBuffer;
    }
    
    @Nonnull
    public Vector3d getRequestedVelocity() {
        return this.requestedVelocity;
    }
    
    public void addRequestedVelocity(@Nonnull final Vector3d velocity) {
        if (this.requestedVelocityChangeType == null || this.requestedVelocityChangeType == ChangeVelocityType.Add) {
            this.requestedVelocityChangeType = ChangeVelocityType.Add;
        }
        this.requestedVelocity.add(velocity);
    }
    
    public void setRequestedVelocity(@Nonnull final Vector3d velocity) {
        if (this.requestedVelocityChangeType == null || this.requestedVelocityChangeType == ChangeVelocityType.Add) {
            this.requestedVelocityChangeType = ChangeVelocityType.Set;
        }
        this.requestedVelocity.assign(velocity);
    }
    
    @Nullable
    public ChangeVelocityType getRequestedVelocityChangeType() {
        return this.requestedVelocityChangeType;
    }
    
    public void setRequestedVelocityChangeType(final ChangeVelocityType requestedVelocityChangeType) {
        this.requestedVelocityChangeType = requestedVelocityChangeType;
    }
    
    @Nonnull
    public Vector3d getClientLastPosition() {
        return this.clientLastPosition;
    }
    
    @Nonnull
    public Vector3d getClientPosition() {
        return this.clientPosition;
    }
    
    @Nonnull
    public Vector3d getRelativeMovement() {
        return this.relativeMovement;
    }
    
    @Nonnull
    public Vector3d getSimPosition() {
        return this.simPosition;
    }
    
    @Nonnull
    public Vector3d getSimVelocity() {
        return this.simVelocity;
    }
    
    public float getRemainingTime() {
        return this.remainingTime;
    }
    
    public void setRemainingTime(final float remainingTime) {
        this.remainingTime = remainingTime;
    }
    
    public void reset() {
        this.remainingTime = 0.5f;
    }
    
    public boolean consumeWasJumping() {
        final boolean tmp = this.wasJumping;
        this.wasJumping = false;
        return tmp;
    }
    
    public void setWasJumping(final boolean wasJumping) {
        this.wasJumping = wasJumping;
    }
    
    public boolean hadWishMovement() {
        return this.hadWishMovement;
    }
    
    public void setHadWishMovement(final boolean hadWishMovement) {
        this.hadWishMovement = hadWishMovement;
    }
    
    public boolean isClientFinished() {
        return this.clientFinished;
    }
    
    public void setClientFinished(final boolean clientFinished) {
        this.clientFinished = clientFinished;
    }
    
    public int getJumpCombo() {
        return this.jumpCombo;
    }
    
    public void setJumpCombo(final int jumpCombo) {
        this.jumpCombo = jumpCombo;
    }
    
    public boolean wasOnGround() {
        return this.wasOnGround;
    }
    
    public void setWasOnGround(final boolean wasOnGround) {
        this.wasOnGround = wasOnGround;
    }
    
    public MovementStates getClientMovementStates() {
        return this.clientMovementStates;
    }
    
    public void setClientMovementStates(final MovementStates clientMovementStates) {
        this.clientMovementStates = clientMovementStates;
    }
    
    @Nonnull
    public Vector3d getMovementOffset() {
        return this.movementOffset;
    }
    
    @Nonnull
    public CollisionResult getCollisionResult() {
        return this.collisionResult;
    }
    
    @Nonnull
    public Vector3d getCheckPosition() {
        return this.checkPosition;
    }
    
    @Nonnull
    public Vector3d getTempPosition() {
        return this.tempPosition;
    }
    
    @Nonnull
    @Override
    public Component<EntityStore> clone() {
        final KnockbackSimulation simulation = new KnockbackSimulation();
        simulation.requestedVelocity.assign(this.requestedVelocity);
        return simulation;
    }
}
