From 36735c7e2e46824afbccb7124ff26585159aa5d3 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 21 Mar 2025 14:03:08 +0100 Subject: [PATCH] fix(ecs): rename createEntity to spawnEnity --- example/pong/src/index.ts | 12 ++++++------ packages/ecs/src/ecs-library.ts | 2 +- packages/ecs/test/ecs-library.spec.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/example/pong/src/index.ts b/example/pong/src/index.ts index e853ee5f..1b97b6cb 100644 --- a/example/pong/src/index.ts +++ b/example/pong/src/index.ts @@ -31,7 +31,7 @@ export const main = async (options: IRunOptions) => { await app.init(options); - const ball = ecsLibrary.createEntity(); + const ball = ecsLibrary.spawnEntity(); ecsLibrary.addComponent(ball, new Velocity(0.04, 0)); ecsLibrary.addComponent(ball, new Position(0.5, 0)); ecsLibrary.addComponent(ball, new Bounce()); @@ -45,7 +45,7 @@ export const main = async (options: IRunOptions) => { ), ); - const bg = ecsLibrary.createEntity(); + const bg = ecsLibrary.spawnEntity(); ecsLibrary.addComponent( bg, new RectangleComponent( @@ -57,7 +57,7 @@ export const main = async (options: IRunOptions) => { ), ); - const topWall = ecsLibrary.createEntity(); + const topWall = ecsLibrary.spawnEntity(); ecsLibrary.addComponent( topWall, new RectangleComponent( @@ -69,7 +69,7 @@ export const main = async (options: IRunOptions) => { ecsLibrary.addComponent(topWall, new Position(-1.8, 0.91)); ecsLibrary.addComponent(topWall, new Hitbox(3.6, 0.1)); - const botWall = ecsLibrary.createEntity(); + const botWall = ecsLibrary.spawnEntity(); ecsLibrary.addComponent( botWall, new RectangleComponent( @@ -81,7 +81,7 @@ export const main = async (options: IRunOptions) => { ecsLibrary.addComponent(botWall, new Position(-1.8, -1)); ecsLibrary.addComponent(botWall, new Hitbox(3.6, 0.1)); - const player1 = ecsLibrary.createEntity(); + const player1 = ecsLibrary.spawnEntity(); ecsLibrary.addComponent(player1, new Position(-1.8, -0.3)); ecsLibrary.addComponent(player1, new Velocity(0, 0.1)); ecsLibrary.addComponent(player1, new Hitbox(0.1, 0.5)); @@ -95,7 +95,7 @@ export const main = async (options: IRunOptions) => { ), ); - const player2 = ecsLibrary.createEntity(); + const player2 = ecsLibrary.spawnEntity(); ecsLibrary.addComponent(player2, new Position(1.7, -0.3)); ecsLibrary.addComponent(player2, new Velocity(0, 0.1)); ecsLibrary.addComponent(player2, new Hitbox(0.1, 0.5)); diff --git a/packages/ecs/src/ecs-library.ts b/packages/ecs/src/ecs-library.ts index f38588cf..d697b38c 100644 --- a/packages/ecs/src/ecs-library.ts +++ b/packages/ecs/src/ecs-library.ts @@ -36,7 +36,7 @@ export class ECSLibrary extends BaseComponentSystemLibrary { this.registry.addComponent(entity, component); } - createEntity(): Entity { + spawnEntity(): Entity { return this.registry.spawnEntity(); } diff --git a/packages/ecs/test/ecs-library.spec.ts b/packages/ecs/test/ecs-library.spec.ts index daf7b53b..0f13ba77 100644 --- a/packages/ecs/test/ecs-library.spec.ts +++ b/packages/ecs/test/ecs-library.spec.ts @@ -40,13 +40,13 @@ describe("ECSLibrary", () => { }); test("init and spawn entity", async () => { - const entity = ecs.createEntity(); + const entity = ecs.spawnEntity(); expect(entity).toBeDefined(); expect(entity.getId()).toBe(0); }); test("add component to entity", async () => { - const entity = ecs.createEntity(); + const entity = ecs.spawnEntity(); const pos = new Position(1, 2); ecs.addComponent(entity, pos); const components = ecs.getComponents(Position);