diff --git a/e2e/part-main.test.ts b/e2e/part-main.test.ts index 253e850..0709afc 100644 --- a/e2e/part-main.test.ts +++ b/e2e/part-main.test.ts @@ -25,7 +25,9 @@ const clientSave: Save = { ], components: [{ name: "ExampleComponent", path: "./components/example.component" }], systems: [{ name: "exampleSystem", path: "./systems/example.system" }], - entities: [{ id: "player", components: [{ name: "ExampleComponent", params: ['"test"', "5"] }] }], + entities: [ + { id: "player", components: [{ name: "ExampleComponent", paramsValues: ['"test"', "5"] }] }, + ], }; const serverSave: Save = { @@ -202,7 +204,7 @@ describe("part-main schematic", () => { it("should use entity params from editor save", () => { const content = tree.readContent("/my-app/.nanoforge/editor/client/main.ts"); - expect(content).toContain("options.editor.save.entities[0].components[0].params[0]"); + expect(content).toContain("options.editor.save.entities[0].components[0].paramsValues[0]"); }); it("should import components and systems with relative path to root", () => { diff --git a/src/utils/main/main-functions.spec.ts b/src/utils/main/main-functions.spec.ts index a045f1a..21eeec5 100644 --- a/src/utils/main/main-functions.spec.ts +++ b/src/utils/main/main-functions.spec.ts @@ -84,7 +84,7 @@ describe("generateMain", () => { entities: [ { id: "player", - components: [{ name: "Position", params: ["0", "0"] }], + components: [{ name: "Position", paramsValues: ["0", "0"] }], }, ], }; diff --git a/src/utils/main/main.generator.spec.ts b/src/utils/main/main.generator.spec.ts index 5a186b2..0942aec 100644 --- a/src/utils/main/main.generator.spec.ts +++ b/src/utils/main/main.generator.spec.ts @@ -136,8 +136,8 @@ describe("MainGenerator", () => { { id: "player", components: [ - { name: "Position", params: ["0", "0"] }, - { name: "Velocity", params: ["1"] }, + { name: "Position", paramsValues: ["0", "0"] }, + { name: "Velocity", paramsValues: ["1"] }, ], }, ]; diff --git a/src/utils/main/main.generator.ts b/src/utils/main/main.generator.ts index 49d6377..ba08860 100644 --- a/src/utils/main/main.generator.ts +++ b/src/utils/main/main.generator.ts @@ -160,12 +160,12 @@ export class MainGenerator { private generateEntity(entity: SaveEntity, entityIndex: number): void { this.writeLine(`const ${entity.id} = registry.spawnEntity();`); - entity.components.forEach(({ name, params: rawParams }, componentIndex) => { + entity.components.forEach(({ name, paramsValues }, componentIndex) => { const params = !this.editor - ? rawParams - : rawParams.map( + ? paramsValues + : paramsValues.map( (_param, index) => - `options.editor.save.entities[${entityIndex}].components[${componentIndex}].params[${index}]`, + `options.editor.save.entities[${entityIndex}].components[${componentIndex}].paramsValues[${index}]`, ); this.writeLine(`registry.addComponent(${entity.id}, new ${name}(${params.join(", ")}));`); }); diff --git a/src/utils/main/save.type.ts b/src/utils/main/save.type.ts index 94371ad..4521886 100644 --- a/src/utils/main/save.type.ts +++ b/src/utils/main/save.type.ts @@ -17,6 +17,7 @@ export interface SaveLibrary { export interface SaveComponent { name: string; path: string; + paramsNames: string[]; } export interface SaveSystem { @@ -28,7 +29,7 @@ export interface SaveEntity { id: string; components: { name: string; - params: string[]; + paramsValues: string[]; }[]; }