@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
66 lines (57 loc) • 1.32 kB
JavaScript
import { assert } from "../../../../core/assert.js";
import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
export class InputBinding {
/**
*
* @type {string}
*/
path = "";
/**
*
* @type {string}
*/
event = "";
/**
*
* @param {string} path
* @param {string} event
*/
set(path, event) {
assert.isString(path, "path");
assert.isString(event, "event");
this.path = path;
this.event = event;
}
/**
*
* @param {InputBinding} other
* @returns {boolean}
*/
equals(other) {
return this.event === other.event
&& this.path === other.path;
}
/**
*
* @return {number}
*/
hash() {
return computeStringHash(this.event) ^ computeStringHash(this.path);
}
/**
*
* @param {BinaryBuffer} buffer
*/
toBinaryBuffer(buffer) {
buffer.writeUTF8String(this.path);
buffer.writeUTF8String(this.event);
}
/**
*
* @param {BinaryBuffer} buffer
*/
fromBinaryBuffer(buffer) {
this.path = buffer.readUTF8String();
this.event = buffer.readUTF8String();
}
}