UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

49 lines (37 loc) 952 B
import { computeStringHash } from "../../../core/primitives/strings/computeStringHash.js"; /** * Localized tooltip. {@link TooltipComponent.key} is used to look up the localized text. * Requires {@link TooltipComponentSystem} to be registered in the {@link EntityManager}. */ export class TooltipComponent { /** * Localization key. * @type {string} */ key = ''; hash() { return computeStringHash(this.key); } /** * * @param {TooltipComponent} other * @return {boolean} */ equals(other) { return this.key === other.key; } toJSON() { return { key: this.key }; } fromJSON({ key }) { this.key = key; } static fromJSON(json) { const r = new TooltipComponent(); r.fromJSON(json); return r; } } TooltipComponent.typeName = 'Tooltip';