UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

79 lines (63 loc) 2.06 kB
import DatGuiController from "./DatGuiController.js"; import { clear } from "../../../../src/view/controller/dat/DatGuiUtils.js"; import ButtonView from "../../../../src/view/elements/button/ButtonView.js"; import { FogOfWarRevealerSystem } from "../../../../src/engine/ecs/fow/FogOfWarRevealerSystem.js"; export class FogOfWarController extends DatGuiController { /** * @param {EntityManager} em * @constructor */ constructor(em) { super(); const self = this; this.addChild(new ButtonView({ action() { /** * * @type {FogOfWar} */ const fow = self.model.getValue(); fow.clear(); /** * * @type {FogOfWarRevealerSystem} */ const revealerSystem = em.getSystem(FogOfWarRevealerSystem); if (revealerSystem !== null) { revealerSystem.forceUpdate(); } }, name: 'Conceal All' })); this.addChild(new ButtonView({ action() { /** * * @type {FogOfWar} */ const fow = self.model.getValue(); fow.revealAll(); /** * * @type {FogOfWarRevealerSystem} */ const revealerSystem = em.getSystem(FogOfWarRevealerSystem); if (revealerSystem !== null) { revealerSystem.forceUpdate(); } }, name: 'Reveal All' })); /** * * @param {FogOfWar} model */ function setModel(model) { const gui = self.gui; clear(gui); if (model !== null) { } } this.model.onChanged.add(setModel); } }