From 2f8f27faae111eb859a62848f5a809fc8d220597 Mon Sep 17 00:00:00 2001 From: Gaston Morixe Date: Thu, 24 Oct 2024 10:11:40 -0400 Subject: [PATCH] Update engine.ts --- src/engine.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/engine.ts b/src/engine.ts index 3f19f25..01a0667 100644 --- a/src/engine.ts +++ b/src/engine.ts @@ -10,9 +10,18 @@ export class AnimationEngine { addSystem(system: System) { this.systems.push(system); - } + } - update() { + private prepare() { + // Prepare all systems + this.systems.forEach((system) => { + if(system.prepare) { + system.prepare(this.entities); + } + }); + } + + private update() { // let anyActive = false; // Update all systems, but only for active entities @@ -61,6 +70,7 @@ export class AnimationEngine { // Start the loop on initialization start() { + this.prepare(); this.loop(); } }