@draug/engine 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -203,7 +203,7 @@ declare function Plugin(metadata: PluginMetadata): ClassDecorator;
203
203
  declare function getPluginMetadata(plugin: ClassType<PluginBase>): PluginMetadata;
204
204
  declare function isPlugin(ctor: Function): boolean;
205
205
  declare abstract class PluginBase {
206
- onPluginLoad?: (world: World) => void;
206
+ onPluginLoad?: () => void;
207
207
  onPluginUnload?: (world: World) => void;
208
208
  onAfterWorldInit?: (world: World) => void;
209
209
  }
@@ -227,11 +227,30 @@ declare class PluginsManager {
227
227
  private isInitiated_;
228
228
  install<T extends ClassType<PluginBase>>(plugin: T, ...constructorProps: ConstructorParameters<T>): void;
229
229
  build(): void;
230
+ __internal__onAfterWorldInit(world: World): void;
230
231
  getPluginMetadata(pluginOrId: ClassType<PluginBase> | PluginID): PluginMetadata;
231
232
  getPluginInstance<T extends PluginBase>(pluginOrId: ClassType<T> | PluginID): T;
232
233
  private resolveId;
233
234
  }
234
235
 
236
+ declare enum LogLevel {
237
+ Debug = 0,
238
+ Info = 1,
239
+ Warn = 2,
240
+ Error = 3
241
+ }
242
+ type LogMessage = () => string;
243
+ interface Logger {
244
+ debug(message: LogMessage): void;
245
+ info(message: LogMessage): void;
246
+ warn(message: LogMessage): void;
247
+ error(message: LogMessage): void;
248
+ }
249
+
250
+ type WorldConstructor = {
251
+ maxEntityCount?: number;
252
+ logger: Logger;
253
+ };
235
254
  declare class World {
236
255
  readonly entities: EntitiesManager;
237
256
  readonly components: ComponentsManager;
@@ -242,7 +261,7 @@ declare class World {
242
261
  readonly queries: QueryManager;
243
262
  readonly plugins: PluginsManager;
244
263
  private entityRefs_;
245
- constructor(maxEntityCount?: number);
264
+ constructor(params: WorldConstructor);
246
265
  getEntityRef(id: number): EntityRef;
247
266
  query(params: QueryParameters): number[];
248
267
  removeComponent<T extends object>(ref: EntityRef, component: ComponentType<T>): void;
@@ -310,11 +329,17 @@ type SystemCtor<T extends SystemBase = SystemBase> = ClassType<T>;
310
329
  */
311
330
  type SystemComputeContext = {
312
331
  /** Entity IDs from the query for this {@link SystemBase.compute} invocation. */
313
- entities: number[];
332
+ readonly entities: number[];
314
333
  /** ECS world instance. */
315
- world: World;
334
+ readonly world: World;
316
335
  /** Delta time (seconds or your engine's convention) since the previous update. */
317
- dt: number;
336
+ readonly dt: number;
337
+ /** Logger instance for debugging and diagnostics. */
338
+ readonly logger: Logger;
339
+ };
340
+ type SystemInitContext = {
341
+ world: World;
342
+ logger: Logger;
318
343
  };
319
344
  /**
320
345
  * Base class for ECS systems executed by {@link SystemsManager}.
@@ -328,15 +353,16 @@ declare abstract class SystemBase {
328
353
  * Logic for one systems pass: run for all entities in {@link SystemComputeContext.entities}.
329
354
  */
330
355
  abstract compute(ctx: SystemComputeContext): void;
331
- onInit?(world: World): void;
356
+ onInit?(ctx: SystemInitContext): void;
332
357
  }
333
358
  declare class SystemsManager {
334
359
  private readonly world;
360
+ private readonly logger;
335
361
  private systems_;
336
362
  private executionOrder_;
337
363
  private requiredComponents_;
338
364
  private dirty_;
339
- constructor(world: World);
365
+ constructor(world: World, logger: Logger);
340
366
  getRequiredComponents(): ComponentType[];
341
367
  register<T extends SystemBase>(sys: T): void;
342
368
  build(): void;
@@ -360,16 +386,49 @@ declare class Clock {
360
386
  tick(): void;
361
387
  }
362
388
 
363
- type StepFunction = (dt: number) => void;
364
- declare class GameLoop {
365
- private clock;
366
- private stepFn;
389
+ type StepFunction = (dt: number, world: World) => void;
390
+ type PlatformLoop = (callback: () => void) => void;
391
+ declare class Loop {
392
+ private readonly clock;
393
+ private readonly stepFn;
394
+ private readonly platformLoop;
367
395
  private running;
368
- constructor(clock: Clock, stepFn: StepFunction);
369
- start(platformLoop: (callback: () => void) => void): void;
396
+ constructor(clock: Clock, stepFn: StepFunction, platformLoop: PlatformLoop);
397
+ start(world: World): void;
370
398
  stop(): void;
371
399
  }
372
400
 
401
+ declare class Runtime {
402
+ private readonly loop;
403
+ constructor(loop: Loop);
404
+ run(world: World): void;
405
+ }
406
+
407
+ declare enum VisitedState {
408
+ Unvisited = 0,
409
+ Visiting = 1,
410
+ Visited = 2
411
+ }
412
+ declare class DAGNode<T> {
413
+ readonly data: T;
414
+ readonly vertices: DAGNode<T>[];
415
+ constructor(data: T, vertices?: DAGNode<T>[]);
416
+ }
417
+ declare class ErrDAGCycleDetected extends Error {
418
+ constructor();
419
+ }
420
+ declare function topologicalSort<T>(nodes: Iterable<DAGNode<T>>): DAGNode<T>[];
421
+
422
+ declare class ObjectPool<T extends object> {
423
+ private pool_;
424
+ private factory_;
425
+ private cursor_;
426
+ constructor(factory: () => T, initialSize?: number);
427
+ acquire(): T;
428
+ release(obj: T): void;
429
+ private grow;
430
+ }
431
+
373
432
  declare enum AssetState {
374
433
  NOT_READY = 1,
375
434
  LOADING = 2,
@@ -420,36 +479,18 @@ declare class AssetsManager {
420
479
  disposeAll(): void;
421
480
  }
422
481
 
423
- declare class Runtime {
424
- readonly world: World;
482
+ type EngineConstructor = {
483
+ loop: Loop;
484
+ logger?: Logger;
485
+ };
486
+ declare class Engine {
487
+ readonly runtime: Runtime;
425
488
  readonly assets: AssetsManager;
426
- constructor(world: World, assets: AssetsManager);
427
- update(dt: number): void;
428
- }
429
-
430
- declare enum VisitedState {
431
- Unvisited = 0,
432
- Visiting = 1,
433
- Visited = 2
434
- }
435
- declare class DAGNode<T> {
436
- readonly data: T;
437
- readonly vertices: DAGNode<T>[];
438
- constructor(data: T, vertices?: DAGNode<T>[]);
439
- }
440
- declare class ErrDAGCycleDetected extends Error {
441
- constructor();
442
- }
443
- declare function topologicalSort<T>(nodes: Iterable<DAGNode<T>>): DAGNode<T>[];
444
-
445
- declare class ObjectPool<T extends object> {
446
- private pool_;
447
- private factory_;
448
- private cursor_;
449
- constructor(factory: () => T, initialSize?: number);
450
- acquire(): T;
451
- release(obj: T): void;
452
- private grow;
489
+ readonly world: World;
490
+ readonly logger: Logger;
491
+ constructor(params: EngineConstructor);
492
+ init(): void;
493
+ start(): void;
453
494
  }
454
495
 
455
- export { Asset, type AssetDisposer, type AssetID, type AssetIDGenerator, type AssetLoader, AssetState, AssetStorage, AssetsManager, type ClassType, Clock, Commands, Component, ComponentAlreadyRegisteredError, type ComponentInitFn, ComponentStorage, type ComponentType, ComponentsManager, type CreateEntityComponentEntry, DAGNode, EntitiesManager, type EntityID, EntityMaskNotFoundError, EntityRef, ErrDAGCycleDetected, ErrMissingPluginMetadata, ErrMissingSystemMetadata, ErrNotAPlugin, ErrNotASystem, ErrPluginNotInit, ErrUnknownPlugin, EventBuffer, EventBus, GameLoop, type IStorage, ObjectPool, Plugin, PluginBase, type PluginDependencies, PluginError, type PluginID, type PluginMetadata, PluginsManager, ResourcesManager, Runtime, SingletonStorage, type StepFunction, System, SystemBase, type SystemComputeContext, SystemError, SystemPhase, SystemsManager, type TimeSource, UnregisteredComponentStorageError, VisitedState, World, type WorldCommand, createEventKey, entry, getPluginMetadata, getSystemMetadata, isPlugin, isSystem, topologicalSort };
496
+ export { Asset, type AssetDisposer, type AssetID, type AssetIDGenerator, type AssetLoader, AssetState, AssetStorage, AssetsManager, type ClassType, Clock, Commands, Component, ComponentAlreadyRegisteredError, type ComponentInitFn, ComponentStorage, type ComponentType, ComponentsManager, type CreateEntityComponentEntry, DAGNode, Engine, type EngineConstructor, EntitiesManager, type EntityID, EntityMaskNotFoundError, EntityRef, ErrDAGCycleDetected, ErrMissingPluginMetadata, ErrMissingSystemMetadata, ErrNotAPlugin, ErrNotASystem, ErrPluginNotInit, ErrUnknownPlugin, EventBuffer, EventBus, type IStorage, LogLevel, type LogMessage, type Logger, Loop, ObjectPool, type PlatformLoop, Plugin, PluginBase, type PluginDependencies, PluginError, type PluginID, type PluginMetadata, PluginsManager, ResourcesManager, Runtime, SingletonStorage, type StepFunction, System, SystemBase, type SystemComputeContext, SystemError, type SystemInitContext, SystemPhase, SystemsManager, type TimeSource, UnregisteredComponentStorageError, VisitedState, World, type WorldCommand, createEventKey, entry, getPluginMetadata, getSystemMetadata, isPlugin, isSystem, topologicalSort };
package/dist/index.d.ts CHANGED
@@ -203,7 +203,7 @@ declare function Plugin(metadata: PluginMetadata): ClassDecorator;
203
203
  declare function getPluginMetadata(plugin: ClassType<PluginBase>): PluginMetadata;
204
204
  declare function isPlugin(ctor: Function): boolean;
205
205
  declare abstract class PluginBase {
206
- onPluginLoad?: (world: World) => void;
206
+ onPluginLoad?: () => void;
207
207
  onPluginUnload?: (world: World) => void;
208
208
  onAfterWorldInit?: (world: World) => void;
209
209
  }
@@ -227,11 +227,30 @@ declare class PluginsManager {
227
227
  private isInitiated_;
228
228
  install<T extends ClassType<PluginBase>>(plugin: T, ...constructorProps: ConstructorParameters<T>): void;
229
229
  build(): void;
230
+ __internal__onAfterWorldInit(world: World): void;
230
231
  getPluginMetadata(pluginOrId: ClassType<PluginBase> | PluginID): PluginMetadata;
231
232
  getPluginInstance<T extends PluginBase>(pluginOrId: ClassType<T> | PluginID): T;
232
233
  private resolveId;
233
234
  }
234
235
 
236
+ declare enum LogLevel {
237
+ Debug = 0,
238
+ Info = 1,
239
+ Warn = 2,
240
+ Error = 3
241
+ }
242
+ type LogMessage = () => string;
243
+ interface Logger {
244
+ debug(message: LogMessage): void;
245
+ info(message: LogMessage): void;
246
+ warn(message: LogMessage): void;
247
+ error(message: LogMessage): void;
248
+ }
249
+
250
+ type WorldConstructor = {
251
+ maxEntityCount?: number;
252
+ logger: Logger;
253
+ };
235
254
  declare class World {
236
255
  readonly entities: EntitiesManager;
237
256
  readonly components: ComponentsManager;
@@ -242,7 +261,7 @@ declare class World {
242
261
  readonly queries: QueryManager;
243
262
  readonly plugins: PluginsManager;
244
263
  private entityRefs_;
245
- constructor(maxEntityCount?: number);
264
+ constructor(params: WorldConstructor);
246
265
  getEntityRef(id: number): EntityRef;
247
266
  query(params: QueryParameters): number[];
248
267
  removeComponent<T extends object>(ref: EntityRef, component: ComponentType<T>): void;
@@ -310,11 +329,17 @@ type SystemCtor<T extends SystemBase = SystemBase> = ClassType<T>;
310
329
  */
311
330
  type SystemComputeContext = {
312
331
  /** Entity IDs from the query for this {@link SystemBase.compute} invocation. */
313
- entities: number[];
332
+ readonly entities: number[];
314
333
  /** ECS world instance. */
315
- world: World;
334
+ readonly world: World;
316
335
  /** Delta time (seconds or your engine's convention) since the previous update. */
317
- dt: number;
336
+ readonly dt: number;
337
+ /** Logger instance for debugging and diagnostics. */
338
+ readonly logger: Logger;
339
+ };
340
+ type SystemInitContext = {
341
+ world: World;
342
+ logger: Logger;
318
343
  };
319
344
  /**
320
345
  * Base class for ECS systems executed by {@link SystemsManager}.
@@ -328,15 +353,16 @@ declare abstract class SystemBase {
328
353
  * Logic for one systems pass: run for all entities in {@link SystemComputeContext.entities}.
329
354
  */
330
355
  abstract compute(ctx: SystemComputeContext): void;
331
- onInit?(world: World): void;
356
+ onInit?(ctx: SystemInitContext): void;
332
357
  }
333
358
  declare class SystemsManager {
334
359
  private readonly world;
360
+ private readonly logger;
335
361
  private systems_;
336
362
  private executionOrder_;
337
363
  private requiredComponents_;
338
364
  private dirty_;
339
- constructor(world: World);
365
+ constructor(world: World, logger: Logger);
340
366
  getRequiredComponents(): ComponentType[];
341
367
  register<T extends SystemBase>(sys: T): void;
342
368
  build(): void;
@@ -360,16 +386,49 @@ declare class Clock {
360
386
  tick(): void;
361
387
  }
362
388
 
363
- type StepFunction = (dt: number) => void;
364
- declare class GameLoop {
365
- private clock;
366
- private stepFn;
389
+ type StepFunction = (dt: number, world: World) => void;
390
+ type PlatformLoop = (callback: () => void) => void;
391
+ declare class Loop {
392
+ private readonly clock;
393
+ private readonly stepFn;
394
+ private readonly platformLoop;
367
395
  private running;
368
- constructor(clock: Clock, stepFn: StepFunction);
369
- start(platformLoop: (callback: () => void) => void): void;
396
+ constructor(clock: Clock, stepFn: StepFunction, platformLoop: PlatformLoop);
397
+ start(world: World): void;
370
398
  stop(): void;
371
399
  }
372
400
 
401
+ declare class Runtime {
402
+ private readonly loop;
403
+ constructor(loop: Loop);
404
+ run(world: World): void;
405
+ }
406
+
407
+ declare enum VisitedState {
408
+ Unvisited = 0,
409
+ Visiting = 1,
410
+ Visited = 2
411
+ }
412
+ declare class DAGNode<T> {
413
+ readonly data: T;
414
+ readonly vertices: DAGNode<T>[];
415
+ constructor(data: T, vertices?: DAGNode<T>[]);
416
+ }
417
+ declare class ErrDAGCycleDetected extends Error {
418
+ constructor();
419
+ }
420
+ declare function topologicalSort<T>(nodes: Iterable<DAGNode<T>>): DAGNode<T>[];
421
+
422
+ declare class ObjectPool<T extends object> {
423
+ private pool_;
424
+ private factory_;
425
+ private cursor_;
426
+ constructor(factory: () => T, initialSize?: number);
427
+ acquire(): T;
428
+ release(obj: T): void;
429
+ private grow;
430
+ }
431
+
373
432
  declare enum AssetState {
374
433
  NOT_READY = 1,
375
434
  LOADING = 2,
@@ -420,36 +479,18 @@ declare class AssetsManager {
420
479
  disposeAll(): void;
421
480
  }
422
481
 
423
- declare class Runtime {
424
- readonly world: World;
482
+ type EngineConstructor = {
483
+ loop: Loop;
484
+ logger?: Logger;
485
+ };
486
+ declare class Engine {
487
+ readonly runtime: Runtime;
425
488
  readonly assets: AssetsManager;
426
- constructor(world: World, assets: AssetsManager);
427
- update(dt: number): void;
428
- }
429
-
430
- declare enum VisitedState {
431
- Unvisited = 0,
432
- Visiting = 1,
433
- Visited = 2
434
- }
435
- declare class DAGNode<T> {
436
- readonly data: T;
437
- readonly vertices: DAGNode<T>[];
438
- constructor(data: T, vertices?: DAGNode<T>[]);
439
- }
440
- declare class ErrDAGCycleDetected extends Error {
441
- constructor();
442
- }
443
- declare function topologicalSort<T>(nodes: Iterable<DAGNode<T>>): DAGNode<T>[];
444
-
445
- declare class ObjectPool<T extends object> {
446
- private pool_;
447
- private factory_;
448
- private cursor_;
449
- constructor(factory: () => T, initialSize?: number);
450
- acquire(): T;
451
- release(obj: T): void;
452
- private grow;
489
+ readonly world: World;
490
+ readonly logger: Logger;
491
+ constructor(params: EngineConstructor);
492
+ init(): void;
493
+ start(): void;
453
494
  }
454
495
 
455
- export { Asset, type AssetDisposer, type AssetID, type AssetIDGenerator, type AssetLoader, AssetState, AssetStorage, AssetsManager, type ClassType, Clock, Commands, Component, ComponentAlreadyRegisteredError, type ComponentInitFn, ComponentStorage, type ComponentType, ComponentsManager, type CreateEntityComponentEntry, DAGNode, EntitiesManager, type EntityID, EntityMaskNotFoundError, EntityRef, ErrDAGCycleDetected, ErrMissingPluginMetadata, ErrMissingSystemMetadata, ErrNotAPlugin, ErrNotASystem, ErrPluginNotInit, ErrUnknownPlugin, EventBuffer, EventBus, GameLoop, type IStorage, ObjectPool, Plugin, PluginBase, type PluginDependencies, PluginError, type PluginID, type PluginMetadata, PluginsManager, ResourcesManager, Runtime, SingletonStorage, type StepFunction, System, SystemBase, type SystemComputeContext, SystemError, SystemPhase, SystemsManager, type TimeSource, UnregisteredComponentStorageError, VisitedState, World, type WorldCommand, createEventKey, entry, getPluginMetadata, getSystemMetadata, isPlugin, isSystem, topologicalSort };
496
+ export { Asset, type AssetDisposer, type AssetID, type AssetIDGenerator, type AssetLoader, AssetState, AssetStorage, AssetsManager, type ClassType, Clock, Commands, Component, ComponentAlreadyRegisteredError, type ComponentInitFn, ComponentStorage, type ComponentType, ComponentsManager, type CreateEntityComponentEntry, DAGNode, Engine, type EngineConstructor, EntitiesManager, type EntityID, EntityMaskNotFoundError, EntityRef, ErrDAGCycleDetected, ErrMissingPluginMetadata, ErrMissingSystemMetadata, ErrNotAPlugin, ErrNotASystem, ErrPluginNotInit, ErrUnknownPlugin, EventBuffer, EventBus, type IStorage, LogLevel, type LogMessage, type Logger, Loop, ObjectPool, type PlatformLoop, Plugin, PluginBase, type PluginDependencies, PluginError, type PluginID, type PluginMetadata, PluginsManager, ResourcesManager, Runtime, SingletonStorage, type StepFunction, System, SystemBase, type SystemComputeContext, SystemError, type SystemInitContext, SystemPhase, SystemsManager, type TimeSource, UnregisteredComponentStorageError, VisitedState, World, type WorldCommand, createEventKey, entry, getPluginMetadata, getSystemMetadata, isPlugin, isSystem, topologicalSort };
package/dist/index.js CHANGED
@@ -94,10 +94,12 @@ function isSystem(ctor) {
94
94
  var SystemBase = class {
95
95
  };
96
96
  var SystemsManager = class {
97
- constructor(world) {
97
+ constructor(world, logger) {
98
98
  this.world = world;
99
+ this.logger = logger;
99
100
  }
100
101
  world;
102
+ logger;
101
103
  systems_ = /* @__PURE__ */ new Map();
102
104
  executionOrder_ = [];
103
105
  requiredComponents_ = /* @__PURE__ */ new Set();
@@ -121,9 +123,12 @@ var SystemsManager = class {
121
123
  this.requiredComponents_.add(c);
122
124
  }
123
125
  build() {
126
+ this.logger.info(() => "Building systems...");
124
127
  this.buildSystemsArray();
125
128
  for (const sys of this.systems_.values())
126
- sys.onInit?.(this.world);
129
+ sys.onInit?.({ world: this.world, logger: this.logger });
130
+ this.logger.info(() => "Systems sucessfully was built!");
131
+ this.dirty_ = false;
127
132
  }
128
133
  rebuild() {
129
134
  this.build();
@@ -141,7 +146,12 @@ var SystemsManager = class {
141
146
  for (const s of this.executionOrder_) {
142
147
  const { query } = getSystemMetadata(s.constructor);
143
148
  const entities = this.world.query(query);
144
- s.compute({ entities, world: this.world, dt });
149
+ s.compute({
150
+ world: this.world,
151
+ entities,
152
+ dt,
153
+ logger: this.logger
154
+ });
145
155
  }
146
156
  }
147
157
  buildSystemsArray() {
@@ -679,7 +689,7 @@ var QueryManager = class {
679
689
  }
680
690
  };
681
691
 
682
- // src/plugin/plugin.ts
692
+ // src/ecs/plugin/plugin.ts
683
693
  var PluginMetadataSymbol = /* @__PURE__ */ Symbol("plugin");
684
694
  function Plugin(metadata) {
685
695
  return (target) => {
@@ -787,10 +797,17 @@ var PluginsManager = class {
787
797
  for (const node of sortedNodes) {
788
798
  const entry2 = this.plugins_.get(node.data);
789
799
  const { ctor, ctorParams } = entry2;
790
- entry2.instance = new ctor(...ctorParams);
800
+ const instance = new ctor(...ctorParams);
801
+ entry2.instance = instance;
802
+ instance.onPluginLoad?.();
791
803
  }
792
804
  this.isInitiated_ = true;
793
805
  }
806
+ __internal__onAfterWorldInit(world) {
807
+ for (const p of this.plugins_.values()) {
808
+ p.instance?.onAfterWorldInit?.(world);
809
+ }
810
+ }
794
811
  getPluginMetadata(pluginOrId) {
795
812
  const id2 = this.resolveId(pluginOrId);
796
813
  const entry2 = this.plugins_.get(id2);
@@ -820,17 +837,24 @@ var PluginsManager = class {
820
837
 
821
838
  // src/ecs/world.ts
822
839
  var World3 = class {
823
- entities = new EntitiesManager();
824
- components = new ComponentsManager();
825
- systems = new SystemsManager(this);
826
- events = new EventBus();
827
- resources = new ResourcesManager();
828
- commands = new Commands(this);
829
- queries = new QueryManager(this);
830
- plugins = new PluginsManager();
840
+ entities;
841
+ components;
842
+ systems;
843
+ events;
844
+ resources;
845
+ commands;
846
+ queries;
847
+ plugins;
831
848
  entityRefs_ = /* @__PURE__ */ new Map();
832
- constructor(maxEntityCount = ECS_DEFAULTS.MAX_ENTITY_COUNT) {
833
- this.components = new ComponentsManager(maxEntityCount);
849
+ constructor(params) {
850
+ this.components = new ComponentsManager(params.maxEntityCount ?? ECS_DEFAULTS.MAX_ENTITY_COUNT);
851
+ this.systems = new SystemsManager(this, params.logger);
852
+ this.entities = new EntitiesManager();
853
+ this.events = new EventBus();
854
+ this.resources = new ResourcesManager();
855
+ this.commands = new Commands(this);
856
+ this.queries = new QueryManager(this);
857
+ this.plugins = new PluginsManager();
834
858
  }
835
859
  getEntityRef(id2) {
836
860
  let ref = this.entityRefs_.get(id2);
@@ -875,6 +899,17 @@ var World3 = class {
875
899
  }
876
900
  };
877
901
 
902
+ // src/runtime/runtime.ts
903
+ var Runtime = class {
904
+ constructor(loop) {
905
+ this.loop = loop;
906
+ }
907
+ loop;
908
+ run(world) {
909
+ this.loop.start(world);
910
+ }
911
+ };
912
+
878
913
  // src/runtime/clock.ts
879
914
  var Clock = class {
880
915
  constructor(timeSource_) {
@@ -900,43 +935,32 @@ var Clock = class {
900
935
  }
901
936
  };
902
937
 
903
- // src/runtime/game-loop.ts
904
- var GameLoop = class {
905
- constructor(clock, stepFn) {
938
+ // src/runtime/loop.ts
939
+ var Loop = class {
940
+ constructor(clock, stepFn, platformLoop) {
906
941
  this.clock = clock;
907
942
  this.stepFn = stepFn;
943
+ this.platformLoop = platformLoop;
908
944
  }
909
945
  clock;
910
946
  stepFn;
947
+ platformLoop;
911
948
  running = false;
912
- start(platformLoop) {
949
+ start(world) {
913
950
  this.running = true;
914
951
  const loop = () => {
915
952
  if (!this.running) return;
916
953
  this.clock.tick();
917
- this.stepFn(this.clock.dt);
918
- platformLoop(loop);
954
+ this.stepFn(this.clock.dt, world);
955
+ this.platformLoop(loop);
919
956
  };
920
- platformLoop(loop);
957
+ this.platformLoop(loop);
921
958
  }
922
959
  stop() {
923
960
  this.running = false;
924
961
  }
925
962
  };
926
963
 
927
- // src/runtime/runtime.ts
928
- var Runtime = class {
929
- constructor(world, assets) {
930
- this.world = world;
931
- this.assets = assets;
932
- }
933
- world;
934
- assets;
935
- update(dt) {
936
- this.world.update(dt);
937
- }
938
- };
939
-
940
964
  // src/assets/assets.ts
941
965
  var AssetState = /* @__PURE__ */ ((AssetState2) => {
942
966
  AssetState2[AssetState2["NOT_READY"] = 1] = "NOT_READY";
@@ -1082,6 +1106,46 @@ var AssetsManager = class {
1082
1106
  Array.from(this.storages_.values(), (s) => s.clearAll());
1083
1107
  }
1084
1108
  };
1109
+
1110
+ // src/logger/logger.ts
1111
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
1112
+ LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
1113
+ LogLevel2[LogLevel2["Info"] = 1] = "Info";
1114
+ LogLevel2[LogLevel2["Warn"] = 2] = "Warn";
1115
+ LogLevel2[LogLevel2["Error"] = 3] = "Error";
1116
+ return LogLevel2;
1117
+ })(LogLevel || {});
1118
+ var NoopLogger = class {
1119
+ debug() {
1120
+ }
1121
+ info() {
1122
+ }
1123
+ warn() {
1124
+ }
1125
+ error() {
1126
+ }
1127
+ };
1128
+
1129
+ // src/engine.ts
1130
+ var Engine = class {
1131
+ runtime;
1132
+ assets = new AssetsManager();
1133
+ world;
1134
+ logger;
1135
+ constructor(params) {
1136
+ this.runtime = new Runtime(params.loop);
1137
+ this.logger = params.logger ?? new NoopLogger();
1138
+ this.world = new World3({
1139
+ logger: this.logger
1140
+ });
1141
+ }
1142
+ init() {
1143
+ this.world.build();
1144
+ }
1145
+ start() {
1146
+ this.runtime.run(this.world);
1147
+ }
1148
+ };
1085
1149
  export {
1086
1150
  Asset,
1087
1151
  AssetState,
@@ -1094,6 +1158,7 @@ export {
1094
1158
  ComponentStorage,
1095
1159
  ComponentsManager,
1096
1160
  DAGNode,
1161
+ Engine,
1097
1162
  EntitiesManager,
1098
1163
  EntityMaskNotFoundError,
1099
1164
  EntityRef,
@@ -1106,7 +1171,8 @@ export {
1106
1171
  ErrUnknownPlugin,
1107
1172
  EventBuffer,
1108
1173
  EventBus,
1109
- GameLoop,
1174
+ LogLevel,
1175
+ Loop,
1110
1176
  ObjectPool,
1111
1177
  Plugin,
1112
1178
  PluginBase,