import { assert } from "../../core/assert.js";
import { BaseProcess } from "../../core/process/BaseProcess.js";

export class EnginePlugin extends BaseProcess {

    /**
     *
     * @type {Class<EnginePlugin>[]}
     * @private
     */
    __dependencies = [];

    /**
     *
     * @type {Engine|null}
     */
    engine = null;

    attach() {
        /**
         * Must be unique for each plugin
         * @type {string}
         */
        this.id = "";

        /**
         *
         * @type {Engine}
         */
        this.engine = null;
    }

    /**
     *
     * @returns {Class<EnginePlugin>[]}
     */
    get dependencies() {
        return this.__dependencies;
    }

    /**
     *
     * @param {Engine} engine
     */
    initialize(engine) {
        assert.defined(engine, 'engine');
        assert.notNull(engine, 'engine');
        assert.equal(engine.isEngine, true, '.isEngine !== true');

        this.engine = engine;

        super.initialize();
    }

    finalize() {
        super.finalize();
    }


    /**
     *
     * @return {Promise}
     */
    async startup() {
        super.startup();

        return Promise.resolve();
    }


    /**
     *
     * @return {Promise}
     */
    async shutdown() {
        super.shutdown();

        return Promise.resolve();
    }
}
