package me.hammerle.supersnuvi.entity.components;

import me.hammerle.supersnuvi.entity.Entity;

public class DefaultMovement extends Movement
{
    private final IJump jump;
    
    public DefaultMovement(Entity ent, IJump jump) 
    {
        super(ent);
        this.jump = jump;
    }

    @Override
    public boolean jump() 
    {
        if(ent.isOnGround())
        {
            ent.setNoGround();
            ent.setMotionY(ent.getMotionY() + getJumpPower());
            return true;
        }
        return false;
    }

    @Override
    public double getJumpPower() 
    {
        return jump.getJumpPower(ent) * ent.getMovementPenalty().getFactor();
    }
}
