@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
35 lines (29 loc) • 732 B
JavaScript
import { assert } from "../../core/assert.js";
export class InteractionCommandSet {
constructor() {
/**
*
* @type {Object<InteractionCommand>}
*/
this.commands = {};
}
/**
*
* @param {InteractionCommand} command
*/
add(command) {
if (this.getCommandById(command.id) !== undefined) {
throw new Error(`Command with id='${command.id}' already exists`);
}
this.commands[command.id] = command;
}
/**
*
* @param {string} id
* @returns {InteractionCommand}
*/
getCommandById(id) {
assert.isString(id, 'id');
return this.commands[id];
}
}