Skip to content

Commit 241726d

Browse files
authored
Merge pull request #28 from NanoForge-dev/fix/ecs-lib/rename-ts-binding-to-match-wasm
fix(ecs): rename createEntity to spawnEnity
2 parents e9a8c7d + 36735c7 commit 241726d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

example/pong/src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const main = async (options: IRunOptions) => {
3131

3232
await app.init(options);
3333

34-
const ball = ecsLibrary.createEntity();
34+
const ball = ecsLibrary.spawnEntity();
3535
ecsLibrary.addComponent(ball, new Velocity(0.04, 0));
3636
ecsLibrary.addComponent(ball, new Position(0.5, 0));
3737
ecsLibrary.addComponent(ball, new Bounce());
@@ -45,7 +45,7 @@ export const main = async (options: IRunOptions) => {
4545
),
4646
);
4747

48-
const bg = ecsLibrary.createEntity();
48+
const bg = ecsLibrary.spawnEntity();
4949
ecsLibrary.addComponent(
5050
bg,
5151
new RectangleComponent(
@@ -57,7 +57,7 @@ export const main = async (options: IRunOptions) => {
5757
),
5858
);
5959

60-
const topWall = ecsLibrary.createEntity();
60+
const topWall = ecsLibrary.spawnEntity();
6161
ecsLibrary.addComponent(
6262
topWall,
6363
new RectangleComponent(
@@ -69,7 +69,7 @@ export const main = async (options: IRunOptions) => {
6969
ecsLibrary.addComponent(topWall, new Position(-1.8, 0.91));
7070
ecsLibrary.addComponent(topWall, new Hitbox(3.6, 0.1));
7171

72-
const botWall = ecsLibrary.createEntity();
72+
const botWall = ecsLibrary.spawnEntity();
7373
ecsLibrary.addComponent(
7474
botWall,
7575
new RectangleComponent(
@@ -81,7 +81,7 @@ export const main = async (options: IRunOptions) => {
8181
ecsLibrary.addComponent(botWall, new Position(-1.8, -1));
8282
ecsLibrary.addComponent(botWall, new Hitbox(3.6, 0.1));
8383

84-
const player1 = ecsLibrary.createEntity();
84+
const player1 = ecsLibrary.spawnEntity();
8585
ecsLibrary.addComponent(player1, new Position(-1.8, -0.3));
8686
ecsLibrary.addComponent(player1, new Velocity(0, 0.1));
8787
ecsLibrary.addComponent(player1, new Hitbox(0.1, 0.5));
@@ -95,7 +95,7 @@ export const main = async (options: IRunOptions) => {
9595
),
9696
);
9797

98-
const player2 = ecsLibrary.createEntity();
98+
const player2 = ecsLibrary.spawnEntity();
9999
ecsLibrary.addComponent(player2, new Position(1.7, -0.3));
100100
ecsLibrary.addComponent(player2, new Velocity(0, 0.1));
101101
ecsLibrary.addComponent(player2, new Hitbox(0.1, 0.5));

packages/ecs/src/ecs-library.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class ECSLibrary extends BaseComponentSystemLibrary {
3636
this.registry.addComponent(entity, component);
3737
}
3838

39-
createEntity(): Entity {
39+
spawnEntity(): Entity {
4040
return this.registry.spawnEntity();
4141
}
4242

packages/ecs/test/ecs-library.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ describe("ECSLibrary", () => {
4040
});
4141

4242
test("init and spawn entity", async () => {
43-
const entity = ecs.createEntity();
43+
const entity = ecs.spawnEntity();
4444
expect(entity).toBeDefined();
4545
expect(entity.getId()).toBe(0);
4646
});
4747

4848
test("add component to entity", async () => {
49-
const entity = ecs.createEntity();
49+
const entity = ecs.spawnEntity();
5050
const pos = new Position(1, 2);
5151
ecs.addComponent(entity, pos);
5252
const components = ecs.getComponents(Position);

0 commit comments

Comments
 (0)