@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
66 lines (54 loc) • 1.56 kB
JavaScript
import { Transform } from "../../../../ecs/transform/Transform.js";
import { EntityBlueprint } from "../../../../ecs/EntityBlueprint.js";
export class EntityPathMarkerDefinition {
constructor() {
/**
*
* @type {EntityBlueprint}
*/
this.blueprint = null;
/**
* Transform will be applied to every marker
* @type {Transform}
*/
this.transform = new Transform();
/**
* Align along the path
* @type {boolean}
*/
this.align = true;
}
/**
*
* @param blueprint
* @param transform
* @param align
* @returns {EntityPathMarkerDefinition}
*/
static from({
blueprint,
transform = new Transform(),
align = true
}) {
const r = new EntityPathMarkerDefinition();
r.align = align;
r.transform.copy(transform);
r.blueprint = blueprint;
return r;
}
/**
*
* @param {Object} json
* @param {ModuleRegistry} registry
*/
fromJSON({ blueprint, transform = {}, align = true }, registry) {
this.blueprint = EntityBlueprint.fromJSON(blueprint, registry);
this.transform.fromJSON(transform);
this.align = align;
}
static fromJSON(json, registry) {
const r = new EntityPathMarkerDefinition();
r.fromJSON(json, registry);
return r;
}
}