All files / src/controller/input inputController.js

100% Statements 20/20
100% Branches 2/2
100% Functions 9/9
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37  1x 1x 1x     10x 10x 10x     11x 11x     4x     2x 2x 1x 1x       2x 2x     1x     1x     1x  
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InputController = void 0;
const objectStates_1 = require("../../environment/objectStates");
class InputController {
    constructor(engineCore, inputReceiver) {
        this._engineCore = engineCore;
        this._inputReceiver = inputReceiver;
        this._inputTypes = new Map();
    }
    add(inputName, inputType) {
        this._inputTypes.set(inputName, inputType);
        inputType.initialize(this._engineCore, this._inputReceiver);
    }
    get(inputName) {
        return this._inputTypes.get(inputName);
    }
    remove(inputName) {
        const type = this._inputTypes.get(inputName);
        if (type) {
            (0, objectStates_1.tryDestroy)(type);
            this._inputTypes.delete(inputName);
        }
    }
    clear() {
        this._inputTypes.forEach(type => (0, objectStates_1.tryDestroy)(type));
        this._inputTypes.clear();
    }
    refresh() {
        this._inputTypes.forEach(type => (0, objectStates_1.tryRefresh)(type));
    }
    destroy() {
        this.clear();
    }
}
exports.InputController = InputController;