/**
 * Generic script component. Will execute code supplied in the constructor.
 * Requires {@link ScriptSystem} to be registered on {@link EntityManager}.
 *
 * Prefer to use {@link BehaviorComponent} instead, as it's a more flexible solution.
 * `BehaviorComponent.from(ActionBehavior.from(function(){...}))` is equivalent to `new Script(function(){...})`
 *
 */
class Script {
    /**
     *
     * @param {function|function[]} [options]
     * @constructor
     */
    constructor(options) {
        if (options instanceof Array) {
            this.scripts = options;
        } else if (typeof options === "function") {
            this.scripts = [options];
        } else {
            this.scripts = [];
        }
    }
}

Script.typeName = "Script";
Script.serializable = false;

export default Script;
