Search in sources :

Example 1 with IBonusJumpAbility

use of com.lying.variousoddities.species.abilities.IBonusJumpAbility in project VariousOddities by Lyinginbedmon.

the class Abilities method updateBonusJumpAbilities.

public void updateBonusJumpAbilities() {
    if (this.entity == null || !this.entity.isAlive())
        return;
    List<Ability> bonusJumps = Lists.newArrayList();
    this.cachedAbilities.values().forEach((ability) -> {
        if (ability instanceof IBonusJumpAbility)
            bonusJumps.add(ability);
    });
    boolean noneValid = true;
    for (Ability ability : bonusJumps) {
        if (!ability.passive() && !ability.isActive())
            continue;
        IBonusJumpAbility jump = (IBonusJumpAbility) ability;
        // Start and/or increment jump timer
        if (jump.isValid(this.entity, this.entity.getEntityWorld()) && (this.currentJumpType == null || this.currentJumpType == jump.jumpType())) {
            this.currentJumpType = jump.jumpType();
            if (!canBonusJump)
                if (bonusJumpTimer++ >= jump.getRate()) {
                    canBonusJump = true;
                    bonusJumpTimer = 0;
                    markDirty();
                }
            noneValid = false;
            break;
        }
    }
    if (bonusJumps.isEmpty() || noneValid) {
        canBonusJump = false;
        bonusJumpTimer = -(Reference.Values.TICKS_PER_SECOND / 2);
        currentJumpType = null;
        markDirty();
        return;
    }
}
Also used : Ability(com.lying.variousoddities.species.abilities.Ability) IBonusJumpAbility(com.lying.variousoddities.species.abilities.IBonusJumpAbility) ICompoundAbility(com.lying.variousoddities.species.abilities.ICompoundAbility) IBonusJumpAbility(com.lying.variousoddities.species.abilities.IBonusJumpAbility)

Aggregations

Ability (com.lying.variousoddities.species.abilities.Ability)1 IBonusJumpAbility (com.lying.variousoddities.species.abilities.IBonusJumpAbility)1 ICompoundAbility (com.lying.variousoddities.species.abilities.ICompoundAbility)1