From 7c73ae948eb5e3efe6170094fd0c04eff55049af Mon Sep 17 00:00:00 2001 From: Tchips46 Date: Wed, 25 Mar 2026 17:02:26 +0900 Subject: [PATCH 1/2] feat(editor): add component holding entity id --- e2e/part-main.test.ts | 7 +++++++ src/utils/main/main.generator.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/e2e/part-main.test.ts b/e2e/part-main.test.ts index d4666d1..0a7c941 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 entity_id reserved component", () => { + const content = tree.readContent("/my-app/.nanoforge/editor/client/main.ts"); + expect(content).toContain( + 'registry.addComponent(player, { name: "__RESERVED_ENTITY_ID", entity_id: "player" });', + ); + }); }); }); diff --git a/src/utils/main/main.generator.ts b/src/utils/main/main.generator.ts index 010f74b..d76e4c6 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_ENTITY_ID", entity_id: "${entity.id}" });`, + ); + } this.endSection(); } From b4306d7fc75cf1f0b5e6c86ac0310b7f5cb77944 Mon Sep 17 00:00:00 2001 From: Tchips46 Date: Thu, 26 Mar 2026 08:59:48 +0900 Subject: [PATCH 2/2] fix(editor): entityId case --- e2e/part-main.test.ts | 4 ++-- src/utils/main/main.generator.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/part-main.test.ts b/e2e/part-main.test.ts index 0a7c941..bb6052b 100644 --- a/e2e/part-main.test.ts +++ b/e2e/part-main.test.ts @@ -230,10 +230,10 @@ describe("part-main schematic", () => { ); }); - it("should create a entity_id reserved component", () => { + 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_ENTITY_ID", entity_id: "player" });', + '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 d76e4c6..b45636c 100644 --- a/src/utils/main/main.generator.ts +++ b/src/utils/main/main.generator.ts @@ -182,7 +182,7 @@ export class MainGenerator { }); if (this.editor) { this.writeLine( - `registry.addComponent(${entity.id}, { name: "__RESERVED_ENTITY_ID", entity_id: "${entity.id}" });`, + `registry.addComponent(${entity.id}, { name: "__RESERVED_entityId", entityId: "${entity.id}" });`, ); } this.endSection();