Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 51x 51x 51x 51x 4x | import { EntityManager, EntityBuilder } from "../../entity-manager";
import { CHART } from "../components";
import { DEFAULT_CHART_SIZE } from "../types";
import { Slice } from "../slice";
import type { EditorContext } from "../editor-context";
import type { ProjectFile } from "../../project-format";
export class ProjectSlice extends Slice {
static readonly sliceKey = "project";
readonly entityManager: EntityManager;
constructor(ctx: EditorContext, project: ProjectFile) {
super(ctx);
this.entityManager = EntityManager.from(project.entities);
// Guarantee: at least one chart always exists
const charts = this.entityManager.entitiesWithComponent(CHART);
if (charts.length === 0) {
this.entityManager.insert(
new EntityBuilder().with(CHART, { name: "Main Chart", size: DEFAULT_CHART_SIZE }).build(),
);
}
}
}
|