UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

51 lines (44 loc) 959 B
/** * Component representing logical attachment to another entity, when parent disappears - so does the child */ export class ParentEntity { /** * * @constructor */ constructor() { /** * Entity representing logical parent. * Must not be mutated (changed) while component is attached to a dataset * @type {number} */ this.entity = -1; } /** * * @param {number} entity * @returns {ParentEntity} */ static from(entity) { const r = new ParentEntity(); r.entity = entity; return r; } toJSON() { return { entity: this.entity, }; } fromJSON({ entity }) { this.entity = entity; } } /** * @readonly * @type {string} */ ParentEntity.typeName = "ParentEntity"; /** * * @type {boolean} */ ParentEntity.serializable = false;