import { Assets } from "pixi.js";
export class AvatarActionManager {
    constructor(_defaultAction) {
        this._defaultAction = _defaultAction;
        this._avatarActionsLib = Assets.get("figures/actions");
        this._avatarPartSetsLib = Assets.get("figures/partsets");
    }
    filterActions(actions, partType) {
        return actions
            .filter((action) => {
            const actionDefinition = this._avatarActionsLib[action];
            return actionDefinition !== undefined
                && this._avatarPartSetsLib.activePartSets[actionDefinition.activepartset].includes(partType);
        });
    }
    sortActions(actions) {
        if (actions.length === 0)
            return [this._defaultAction];
        return actions.sort((a, b) => {
            const actionDefinitionA = this._avatarActionsLib[a];
            const actionDefinitionB = this._avatarActionsLib[b];
            if (Number(actionDefinitionA.precedence) < Number(actionDefinitionB.precedence))
                return -1;
            if (Number(actionDefinitionA.precedence) > Number(actionDefinitionB.precedence))
                return 1;
            return 0;
        });
    }
    getActionDefinition(action) {
        return this._avatarActionsLib[action];
    }
    get defaultAction() {
        return this._defaultAction;
    }
    get definitions() {
        return this._avatarActionsLib;
    }
    get partSets() {
        return this._avatarPartSetsLib;
    }
}
//# sourceMappingURL=AvatarActionManager.js.map