Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.2 kB
1
Indexable
Never
    public <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event)
    {
        String animation = this.getAnimation();
        //If we do have an Ability animation play that
        if (!animation.equals("base")) {
            int animationType = this.getAnimationType();
            ILoopType loopType;
            switch (animationType) {
                case 1: loopType = ILoopType.EDefaultLoopTypes.LOOP;
                    break;
                case 2: loopType = ILoopType.EDefaultLoopTypes.PLAY_ONCE;
                    break;
                case 3: loopType = ILoopType.EDefaultLoopTypes.HOLD_ON_LAST_FRAME;
                    break;
                default:
                    return PlayState.STOP;
            }
            event.getController().setAnimation(new AnimationBuilder().addAnimation(animation, loopType));
            return PlayState.CONTINUE;
        }
        //Else, do basic locomotion
        //Moving
        if (event.isMoving()) {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("moving", ILoopType.EDefaultLoopTypes.LOOP));
            return PlayState.CONTINUE;
        }
        //Death
        if ((this.dead || this.getHealth() < 0.01 || this.isDeadOrDying())) {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("death", ILoopType.EDefaultLoopTypes.HOLD_ON_LAST_FRAME));
            return PlayState.CONTINUE;
        }
        //Attacking
        //Check each possible attacking state, based off of a number of possible ones (nAttackingStates)
        //Find the attacking state, then perform corresponding animation
        for (int state = 1; state <= nAttackingStates; state++){
            if (this.getAttackingState() == state) {
                event.getController().setAnimation(new AnimationBuilder().addAnimation("attack_"+state, ILoopType.EDefaultLoopTypes.LOOP));
                return PlayState.CONTINUE;
            }
        }
        //Idle:
        event.getController().setAnimation(new AnimationBuilder().addAnimation("idle", ILoopType.EDefaultLoopTypes.LOOP));
        return PlayState.CONTINUE;
    }