import { SystemPriority } from '../EntityComponentSystem';
import { System, SystemType } from '../EntityComponentSystem/System';
import { ActionsComponent } from './ActionsComponent';
export class ActionsSystem extends System {
    constructor(world) {
        super();
        this.world = world;
        this.systemType = SystemType.Update;
        this.priority = SystemPriority.Higher;
        this._actions = [];
        this.query = this.world.query([ActionsComponent]);
        this.query.entityAdded$.subscribe((e) => this._actions.push(e.get(ActionsComponent)));
        this.query.entityRemoved$.subscribe((e) => {
            const action = e.get(ActionsComponent);
            const index = this._actions.indexOf(action);
            if (index > -1) {
                this._actions.splice(index, 1);
            }
        });
    }
    update(delta) {
        for (const actions of this._actions) {
            actions.update(delta);
        }
    }
}
//# sourceMappingURL=ActionsSystem.js.map