UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

43 lines (33 loc) 1.23 kB
import DatGuiController from "./DatGuiController.js"; import { clear } from "../../../../src/view/controller/dat/DatGuiUtils.js"; import { buildCombatUnitsValidator } from "../../../../../model/game/ecs/component/generator/army/GeneratedArmy.js"; import { extractFunctionBody } from "../../../../src/core/function/extractFunctionBody.js"; export class GeneratedArmyController extends DatGuiController { /** * * @constructor */ constructor() { super(); const self = this; const proxy = { validator: '' }; /** * * @param {GeneratedArmy} model */ function setModel(model) { const gui = self.gui; clear(gui); if (model !== null) { proxy.validator = extractFunctionBody(model.validator); self.addControl(model, 'value').name('Value'); self.addControl(proxy, 'validator').name('Validator').onChange(function () { model.validator = buildCombatUnitsValidator(proxy.validator); }); } } this.model.onChanged.add(setModel); } }