/* jbox A JSON Component Version: 1.0 Docs: - jbox(tags=[]) - pack() json > jbox renders it's version in debug.inspect mode Currently Supported Components: - pos (Obtains X and Y) - health (Obtains current HP and maxHP) - scale (Obtains scale.X and scale.Y) - rotate (Obtains angle, in degrees) */ export function jbox(tags=[]) { return { id: "jbox", require: tags, inspect() { return "[jbox@v1.0]" }, pack() { let j = { jbox: "[jbox@v1.0]", comps: {}, }; for (let tag in tags) { switch (tag) { case "pos": { j.comps["pos"] = { x: this.pos.x, y: this.pos.y, } } case "health": { j.comps["health"] = { health: this.hp(), max_health: this.maxHP(), } } case "scale": { j.comps["scale"] = { x: this.scale.x, y: this.scale.y, } } case "rotate": { j.comps["rotate"] = { angle: this.angle, } } } } return j; } } } export default () => { return jbox }