<commit_before>/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (<EMAIL>).
 * See LICENSE for details.
 */

package com.almasb.fxgl.entity.action;

import com.almasb.fxgl.entity.component.Component;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

/**
 * @author <NAME> (<EMAIL>)
 */
public final class ActionComponent extends Component {

    private static final Action IDLE = new IdleAction();

    private ObservableList<Action> actions = FXCollections.observableArrayList();

    private Action currentAction = IDLE;

    @Override
    public void onUpdate(double tpf) {
        if (currentAction.isCancelled()) {
            clearActions();
        }

        if (currentAction.isComplete()) {
            removeCurrentAction();
        } else {
            currentAction.onUpdate(tpf);
        }
    }

    @Override
    public void onRemoved() {
        clearActions();
    }

    public ObservableList<Action> actionsProperty() {
        return FXCollections.unmodifiableObservableList(actions);
    }

    public Action getCurrentAction() {
        return currentAction;
    }
<commit_msg>fixed IDLE action<commit_after>/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (<EMAIL>).
 * See LICENSE for details.
 */

package com.almasb.fxgl.entity.action;

import com.almasb.fxgl.entity.component.Component;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;

/**
 * @author <NAME> (<EMAIL>)
 */
public final class ActionComponent extends Component {

    private final Action IDLE = new IdleAction();

    private ObservableList<Action> actions = FXCollections.observableArrayList();

    private Action currentAction = IDLE;

    @Override
    public void onUpdate(double tpf) {
        if (currentAction.isCancelled()) {
            clearActions();
        }

        if (currentAction.isComplete()) {
            removeCurrentAction();
        } else {
            currentAction.onUpdate(tpf);
        }
    }

    @Override
    public void onRemoved() {
        clearActions();
    }

    public ObservableList<Action> actionsProperty() {
        return FXCollections.unmodifiableObservableList(actions);
    }

    public Action getCurrentAction() {
        return currentAction;
    }

{'fraction_non_alphanumeric': 0.10390725633319021, 'fraction_numerical': 0.0, 'mean_word_length': 2.8833333333333333, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3230781', 'n_tokens_mistral': 663, 'n_tokens_neox': 634, 'n_words': 155}