A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix: ensure spawned entity commands are finalized on flush
esenginead0df137249a
diff --git a/sdk/src/commands.ts b/sdk/src/commands.tsindex 8e1e6963a..f70ab6b38 100644--- a/sdk/src/commands.ts+++ b/sdk/src/commands.ts@@ -120,7 +120,7 @@ export class EntityCommands {return this.entityRef_.entity;}- private finalize(): void {+ finalize(): void {if (this.isNew_) {this.commands_.spawnImmediate(this.components_, this.entityRef_);this.isNew_ = false;@@ -136,6 +136,7 @@ export class CommandsInstance {private readonly world_: World;private readonly resources_: ResourceStorage;private pending_: Command[] = [];+ private spawned_: EntityCommands[] = [];constructor(world: World, resources: ResourceStorage) {this.world_ = world;@@ -143,7 +144,9 @@ export class CommandsInstance {}spawn(): EntityCommands {- return new EntityCommands(this, null);+ const ec = new EntityCommands(this, null);+ this.spawned_.push(ec);+ return ec;}entity(entity: Entity): EntityCommands {@@ -182,6 +185,11 @@ export class CommandsInstance {}flush(): void {+ for (const ec of this.spawned_) {+ ec.finalize();+ }+ this.spawned_ = [];+for (const cmd of this.pending_) {this.executeCommand(cmd);}