public void setCurrentAnimation(int index) {
        if (index < 0 || index >= animations.size()) {
            throw new IndexOutOfBoundsException();
        }
        currentState = animations.get(index);
        currentState.reset();
    }