diff --git a/e2e/part-main.test.ts b/e2e/part-main.test.ts index d4666d1..bb6052b 100644 --- a/e2e/part-main.test.ts +++ b/e2e/part-main.test.ts @@ -229,5 +229,12 @@ describe("part-main schematic", () => { 'import { exampleSystem } from "../../../client/systems/example.system"', ); }); + + it("should create a entityId reserved component", () => { + const content = tree.readContent("/my-app/.nanoforge/editor/client/main.ts"); + expect(content).toContain( + 'registry.addComponent(player, { name: "__RESERVED_entityId", entityId: "player" });', + ); + }); }); }); diff --git a/src/utils/main/main.generator.ts b/src/utils/main/main.generator.ts index 010f74b..b45636c 100644 --- a/src/utils/main/main.generator.ts +++ b/src/utils/main/main.generator.ts @@ -180,6 +180,11 @@ export class MainGenerator { `registry.addComponent(${entity.id}, new ${componentName}(${params.join(", ")}));`, ); }); + if (this.editor) { + this.writeLine( + `registry.addComponent(${entity.id}, { name: "__RESERVED_entityId", entityId: "${entity.id}" });`, + ); + } this.endSection(); }