@draug/engine 1.0.19 → 1.0.20

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.ts CHANGED
@@ -17,86 +17,53 @@ interface Logger {
17
17
  error(message: LogMessage): void;
18
18
  }
19
19
 
20
- interface IStorage<T extends object> {
20
+ declare class ComponentStorage<T extends object> {
21
+ private bits_;
22
+ private data_;
23
+ private entityIds_;
24
+ private indexMap_;
25
+ private pool_;
26
+ private id_;
27
+ private size_;
28
+ private cls;
29
+ constructor(cap: number | undefined, factory: () => T, cls: ClassType<T>);
30
+ bitmap(): Bitmap;
31
+ get id(): number;
32
+ _internalSetId(id: number): number;
21
33
  add(id: number, initFn?: (obj: T) => T): T;
22
34
  remove(id: number): void;
23
35
  get(id: number): T | null;
24
36
  tryGet(id: number): T;
37
+ writeComponentsToBuf(ids: ReadonlyArray<number>, out: T[]): number;
25
38
  has(id: number): boolean;
26
39
  size(): number;
27
40
  forEach(cb: (id: number) => void): void;
28
- bitmap(): Bitmap;
29
41
  }
30
42
 
31
- declare enum ComponentStorageType {
32
- COMPONENT_STORAGE = 1,
33
- SINGLETON_STORAGE = 2
34
- }
35
- type RegisterSingletoneComponentOptions<T extends object> = {
36
- storageType: ComponentStorageType.SINGLETON_STORAGE;
37
- factory: () => T;
38
- };
39
43
  type RegisterComponentStorageOptions<T extends object> = {
40
- storageType: ComponentStorageType.COMPONENT_STORAGE;
41
44
  factory?: () => T;
42
45
  };
43
- type RegisterComponentOptions<T extends object> = RegisterSingletoneComponentOptions<T> | RegisterComponentStorageOptions<T>;
46
+ type RegisterComponentOptions<T extends object> = RegisterComponentStorageOptions<T>;
44
47
  declare class ComponentAlreadyRegisteredError extends Error {
45
48
  constructor(component: ComponentType);
46
49
  }
47
50
  declare class ComponentsManager {
51
+ private readonly logger;
48
52
  private maxEntityCount;
49
53
  private readonly storages_;
50
54
  private currId_;
51
55
  private nextId;
52
- constructor(maxEntityCount?: number);
53
- register<T extends object>(component: ComponentType<T>, opts?: RegisterComponentOptions<T>): IStorage<T>;
56
+ constructor(logger: Logger, maxEntityCount?: number);
57
+ register<T extends object>(component: ComponentType<T>, opts?: RegisterComponentOptions<T>): ComponentStorage<T>;
54
58
  private createComponentStore;
55
- private createSingletonStore;
56
- getStorage<T extends object>(component: ComponentType<T>): IStorage<T>;
59
+ getStorage<T extends object>(component: ComponentType<T>): ComponentStorage<T>;
57
60
  getComponentId(ctor: ComponentType): number;
58
61
  }
59
62
 
60
- declare function Component(): ClassDecorator;
61
-
62
- declare class ComponentStorage<T extends object> implements IStorage<T> {
63
- private bits_;
64
- private data_;
65
- private entityIds_;
66
- private indexMap_;
67
- private pool_;
68
- private id_;
69
- private size_;
70
- private cls;
71
- constructor(cap: number | undefined, factory: () => T, cls: ClassType<T>);
72
- bitmap(): Bitmap;
73
- get id(): number;
74
- _internalSetId(id: number): number;
75
- add(id: number, initFn?: (obj: T) => T): T;
76
- remove(id: number): void;
77
- get(id: number): T | null;
78
- tryGet(id: number): T;
79
- writeComponentsToBuf(ids: ReadonlyArray<number>, out: T[]): number;
80
- has(id: number): boolean;
81
- size(): number;
82
- forEach(cb: (id: number) => void): void;
83
- }
84
-
85
- declare class SingletonStorage<T extends object> implements IStorage<T> {
86
- private factory;
87
- private value;
88
- private entityId;
89
- constructor(factory: () => T);
90
- bitmap(): Bitmap;
91
- add(id: number, initFn?: ((obj: T) => T) | undefined): T;
92
- remove(id: number): void;
93
- get(id: number): T | null;
94
- tryGet(id: number): T;
95
- has(id: number): boolean;
96
- size(): number;
97
- forEach(cb: (id: number) => void): void;
98
- private validateId;
99
- }
63
+ type ComponentOptions = {
64
+ name: string;
65
+ };
66
+ declare function Component(options: ComponentOptions): ClassDecorator;
100
67
 
101
68
  type EntityID = number;
102
69
  declare class UnregisteredComponentStorageError extends Error {
@@ -158,6 +125,14 @@ declare class EventBus {
158
125
  getBuffer<T>(key: EventKey<T>): EventBuffer<T>;
159
126
  }
160
127
 
128
+ type ResourceMetadata = {
129
+ name: string;
130
+ };
131
+ type ResourceParams = {
132
+ name: string;
133
+ };
134
+ declare function Resource(params: ResourceParams): ClassDecorator;
135
+ declare function getResourceMetadata(resource: Function): ResourceMetadata;
161
136
  declare class ResourcesManager {
162
137
  private readonly logger;
163
138
  private readonly items_;
@@ -205,12 +180,13 @@ declare class QueryManager {
205
180
  }
206
181
 
207
182
  type PluginID = string;
183
+ type PluginConstructor = ClassType<PluginBase>;
208
184
  type PluginDependencies = {
209
185
  components?: ComponentType[];
210
186
  resources?: ClassType<any>[];
211
187
  systems?: ClassType<SystemBase>[];
212
188
  plugins?: Array<{
213
- id: PluginID;
189
+ plugin: PluginConstructor;
214
190
  version?: string;
215
191
  }>;
216
192
  };
@@ -221,7 +197,7 @@ interface PluginMetadata {
221
197
  dependencies?: PluginDependencies;
222
198
  }
223
199
  declare function Plugin(metadata: PluginMetadata): ClassDecorator;
224
- declare function getPluginMetadata(plugin: ClassType<PluginBase>): PluginMetadata;
200
+ declare function getPluginMetadata(plugin: PluginConstructor): PluginMetadata;
225
201
  declare function isPlugin(ctor: Function): boolean;
226
202
  declare abstract class PluginBase {
227
203
  onPluginLoad?: () => void;
@@ -229,33 +205,33 @@ declare abstract class PluginBase {
229
205
  onAfterWorldInit?: (world: World) => void;
230
206
  }
231
207
  declare class PluginError extends Error {
232
- constructor(pluginId: string);
208
+ constructor(pluginId: PluginConstructor);
233
209
  }
234
210
  declare class ErrNotAPlugin extends Error {
235
211
  constructor(target: Function);
236
212
  }
237
213
  declare class ErrMissingPluginMetadata extends Error {
238
- constructor(plugin: ClassType<PluginBase>);
214
+ constructor(plugin: PluginConstructor);
239
215
  }
240
216
  declare class ErrUnknownPlugin extends PluginError {
241
- constructor(pluginId: string);
217
+ constructor(pluginId: PluginConstructor);
242
218
  }
243
219
  declare class ErrPluginNotInit extends PluginError {
244
- constructor(pluginId: string);
220
+ constructor(pluginId: PluginConstructor);
245
221
  }
246
222
  declare class PluginsManager {
247
223
  private readonly logger;
248
224
  private plugins_;
249
225
  private isInitiated_;
250
226
  constructor(logger: Logger);
251
- install<T extends ClassType<PluginBase>>(plugin: T, ...constructorProps: ConstructorParameters<T>): void;
227
+ install<T extends PluginConstructor>(plugin: T, ...constructorProps: ConstructorParameters<T>): void;
252
228
  build(): void;
253
229
  /**
254
230
  * @internal
255
231
  */
256
232
  __internal__onAfterWorldInit(world: World): void;
257
- getPluginMetadata(pluginOrId: ClassType<PluginBase> | PluginID): PluginMetadata;
258
- getPluginInstance<T extends PluginBase>(pluginOrId: ClassType<T> | PluginID): T;
233
+ getPluginMetadata(plugin: PluginConstructor): PluginMetadata;
234
+ getPluginInstance<T extends PluginBase>(plugin: ClassType<T>): T;
259
235
  private resolveId;
260
236
  }
261
237
 
@@ -312,6 +288,8 @@ declare class World {
312
288
  readonly plugins: PluginsManager;
313
289
  private readonly logger;
314
290
  private entityRefs_;
291
+ private updatesCount_;
292
+ get updatesCount(): number;
315
293
  constructor(params: WorldConstructor);
316
294
  getEntityRef(id: number): EntityRef;
317
295
  query(params: QueryParameters): number[];
@@ -364,12 +342,14 @@ type SystemMetadata = {
364
342
  */
365
343
  computeAfter?: Set<SystemCtor>;
366
344
  phase?: SystemPhase;
345
+ name: string;
367
346
  };
368
347
  type SystemDecoratorProps = {
369
348
  query: SystemMetadata['query'];
370
349
  requiredComponents?: ComponentType[];
371
350
  computeAfter?: SystemCtor[];
372
351
  phase?: SystemPhase;
352
+ name: SystemMetadata['name'];
373
353
  };
374
354
  declare function System(props: SystemDecoratorProps): ClassDecorator;
375
355
  declare function getSystemMetadata(system: SystemCtor): SystemMetadata;
@@ -513,4 +493,4 @@ declare class Engine {
513
493
  start(): void;
514
494
  }
515
495
 
516
- 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 };
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, LogLevel, type LogMessage, type Logger, Loop, ObjectPool, type PlatformLoop, Plugin, PluginBase, type PluginDependencies, PluginError, type PluginID, type PluginMetadata, PluginsManager, Resource, type ResourceMetadata, ResourcesManager, Runtime, type StepFunction, System, SystemBase, type SystemComputeContext, SystemError, type SystemInitContext, SystemPhase, SystemsManager, type TimeSource, UnregisteredComponentStorageError, VisitedState, World, type WorldCommand, createEventKey, entry, getPluginMetadata, getResourceMetadata, getSystemMetadata, isPlugin, isSystem, topologicalSort };
package/dist/index.js CHANGED
@@ -75,7 +75,8 @@ function System(props) {
75
75
  const requiredComponents = new Set(props.requiredComponents);
76
76
  const computeAfter = new Set(props.computeAfter);
77
77
  const phase = props.phase ?? 1 /* MAIN */;
78
- const metadata = { query, requiredComponents, computeAfter, phase };
78
+ const name = props.name ?? target.name;
79
+ const metadata = { query, requiredComponents, computeAfter, phase, name };
79
80
  systemTarget[SystemMetadataSymbol] = metadata;
80
81
  };
81
82
  }
@@ -121,7 +122,8 @@ var SystemsManager = class {
121
122
  this.requiredComponents_.add(c);
122
123
  for (const c of requiredComponents)
123
124
  this.requiredComponents_.add(c);
124
- this.logger.debug(() => `[Systems]: "${ctor.name}" was registered`);
125
+ const meta = getSystemMetadata(ctor);
126
+ this.logger.debug(() => `[Systems]: system "${meta.name}" was registered`);
125
127
  }
126
128
  build() {
127
129
  this.buildSystemsArray();
@@ -413,55 +415,41 @@ var ComponentStorage = class {
413
415
  }
414
416
  };
415
417
 
416
- // src/ecs/components/singleton-storage.ts
417
- var SingletonStorage = class {
418
- constructor(factory) {
419
- this.factory = factory;
420
- }
421
- factory;
422
- value = null;
423
- entityId = null;
424
- bitmap() {
425
- throw new Error("Singletone component cannot has a bitmap!");
426
- }
427
- add(id2, initFn) {
428
- if (this.value !== null)
429
- throw new Error("Singleton already initiated");
430
- this.entityId = id2;
431
- this.value = this.factory();
432
- initFn?.(this.value);
433
- return this.value;
434
- }
435
- remove(id2) {
436
- if (!this.validateId(id2))
437
- return;
438
- this.value = null;
439
- this.entityId = null;
440
- }
441
- get(id2) {
442
- if (!this.validateId(id2))
443
- return null;
444
- return this.value;
445
- }
446
- tryGet(id2) {
447
- if (!this.validateId(id2))
448
- throw new Error("[SingletoneStorage]: ID missmatch.");
449
- return this.value;
450
- }
451
- has(id2) {
452
- return this.validateId(id2);
453
- }
454
- size() {
455
- return this.value !== null ? 1 : 0;
456
- }
457
- forEach(cb) {
458
- if (this.entityId !== null)
459
- cb(this.entityId);
418
+ // src/ecs/components/utils.ts
419
+ var registry = /* @__PURE__ */ new Map();
420
+ var id = 0;
421
+ var ComponentMetadataSymbol = /* @__PURE__ */ Symbol("component");
422
+ function Component(options) {
423
+ return (target) => {
424
+ const metadata = {
425
+ name: options.name,
426
+ id: ++id
427
+ };
428
+ registry.set(target, metadata.id);
429
+ target[ComponentMetadataSymbol] = metadata;
430
+ };
431
+ }
432
+ function getComponentId(ctor) {
433
+ const id2 = registry.get(ctor);
434
+ if (id2 === void 0) {
435
+ throw new Error(`Component not registered: ${ctor.name}`);
460
436
  }
461
- validateId(id2) {
462
- return this.entityId !== null && id2 === this.entityId;
437
+ return id2;
438
+ }
439
+ var ErrNotComponent = class extends Error {
440
+ constructor(ctor) {
441
+ super(`Class ${ctor.name} is not a Component. Use @Component decorator to define components.`);
463
442
  }
464
443
  };
444
+ function getComponentMetadata(component) {
445
+ if (isComponent(component)) {
446
+ return component[ComponentMetadataSymbol];
447
+ }
448
+ throw new ErrNotComponent(component);
449
+ }
450
+ function isComponent(ctor) {
451
+ return ComponentMetadataSymbol in ctor;
452
+ }
465
453
 
466
454
  // src/ecs/components/manager.ts
467
455
  var ComponentAlreadyRegisteredError = class extends Error {
@@ -470,9 +458,11 @@ var ComponentAlreadyRegisteredError = class extends Error {
470
458
  }
471
459
  };
472
460
  var ComponentsManager = class {
473
- constructor(maxEntityCount = ECS_DEFAULTS.MAX_ENTITY_COUNT) {
461
+ constructor(logger, maxEntityCount = ECS_DEFAULTS.MAX_ENTITY_COUNT) {
462
+ this.logger = logger;
474
463
  this.maxEntityCount = maxEntityCount;
475
464
  }
465
+ logger;
476
466
  maxEntityCount;
477
467
  storages_ = /* @__PURE__ */ new Map();
478
468
  currId_ = 0;
@@ -482,19 +472,10 @@ var ComponentsManager = class {
482
472
  register(component, opts) {
483
473
  if (this.storages_.has(component))
484
474
  return this.storages_.get(component);
485
- let store;
486
- switch (opts?.storageType) {
487
- case 2 /* SINGLETON_STORAGE */:
488
- store = this.createSingletonStore(opts);
489
- break;
490
- case 1 /* COMPONENT_STORAGE */:
491
- store = this.createComponentStore(component, opts);
492
- break;
493
- default:
494
- store = this.createComponentStore(component, opts);
495
- break;
496
- }
475
+ const store = this.createComponentStore(component, opts);
497
476
  this.storages_.set(component, store);
477
+ const meta = getComponentMetadata(component);
478
+ this.logger.debug(() => `[Components]: Registered component "${meta.name}"`);
498
479
  return store;
499
480
  }
500
481
  createComponentStore(component, opts) {
@@ -503,12 +484,6 @@ var ComponentsManager = class {
503
484
  store._internalSetId(this.nextId());
504
485
  return store;
505
486
  }
506
- createSingletonStore(opts) {
507
- if (!opts?.factory) {
508
- throw new Error("For singletone storage provide factory is required!");
509
- }
510
- return new SingletonStorage(opts.factory);
511
- }
512
487
  getStorage(component) {
513
488
  const store = this.storages_.get(component);
514
489
  if (store === void 0)
@@ -520,24 +495,30 @@ var ComponentsManager = class {
520
495
  }
521
496
  };
522
497
 
523
- // src/ecs/components/utils.ts
524
- var registry = /* @__PURE__ */ new Map();
525
- var id = 0;
526
- function Component() {
498
+ // src/ecs/resources/resources.ts
499
+ var ResourceMetadataSymbol = /* @__PURE__ */ Symbol("resource");
500
+ function Resource(params) {
527
501
  return (target) => {
528
- if (registry.has(target)) return;
529
- registry.set(target, ++id);
502
+ const metadata = {
503
+ name: params.name
504
+ };
505
+ target[ResourceMetadataSymbol] = metadata;
530
506
  };
531
507
  }
532
- function getComponentId(ctor) {
533
- const id2 = registry.get(ctor);
534
- if (id2 === void 0) {
535
- throw new Error(`Component not registered: ${ctor.name}`);
508
+ var ErrNotResource = class extends Error {
509
+ constructor(ctor) {
510
+ super(`Class ${ctor.name} is not a Resource. Use @Resource decorator to define resources.`);
536
511
  }
537
- return id2;
512
+ };
513
+ function getResourceMetadata(resource) {
514
+ if (isResource(resource)) {
515
+ return resource[ResourceMetadataSymbol];
516
+ }
517
+ throw new ErrNotResource(resource);
518
+ }
519
+ function isResource(ctor) {
520
+ return ResourceMetadataSymbol in ctor;
538
521
  }
539
-
540
- // src/ecs/resources/resources.ts
541
522
  var ResourcesManager = class {
542
523
  constructor(logger) {
543
524
  this.logger = logger;
@@ -546,13 +527,15 @@ var ResourcesManager = class {
546
527
  items_ = /* @__PURE__ */ new Map();
547
528
  insert(type, value) {
548
529
  this.items_.set(type, value);
549
- this.logger.debug(() => `[Resources]: Inserted new Resource "${type.name}"`);
530
+ const metadata = getResourceMetadata(type);
531
+ this.logger.debug(() => `[Resources]: Inserted new Resource "${metadata.name}"`);
550
532
  return value;
551
533
  }
552
534
  get(type) {
553
535
  const value = this.items_.get(type);
536
+ const meta = getResourceMetadata(type);
554
537
  if (!value)
555
- throw new Error(`Resource of class ${type.name} does not exist!`);
538
+ throw new Error(`Resource of class ${meta.name} does not exist!`);
556
539
  return value;
557
540
  }
558
541
  getOrInsert(type, factory) {
@@ -564,7 +547,8 @@ var ResourcesManager = class {
564
547
  return value;
565
548
  }
566
549
  remove(type) {
567
- this.logger.debug(() => `[Resources]: Removed resource "${type.name}"`);
550
+ const meta = getResourceMetadata(type);
551
+ this.logger.debug(() => `[Resources]: Removed resource "${meta.name}"`);
568
552
  this.items_.delete(type);
569
553
  }
570
554
  };
@@ -598,7 +582,10 @@ var Commands = class {
598
582
  }
599
583
  };
600
584
  this.add(cmd);
601
- this.logger.debug(() => `[Commands.createEntity]: Created new entity with ID ${id2}. Linked components: [${entries.map((x) => x[0].name).join(", ")}]`);
585
+ this.logger.debug(() => {
586
+ const components = entries.map((x) => getComponentMetadata(x[0]).name).join(", ");
587
+ return `[Commands.createEntity]: Created new entity with ID ${id2}. Linked components: [${components}]`;
588
+ });
602
589
  return id2;
603
590
  }
604
591
  };
@@ -798,14 +785,14 @@ var PluginsManager = class {
798
785
  if (!isPlugin(plugin))
799
786
  throw new ErrMissingPluginMetadata(plugin);
800
787
  const metadata = getPluginMetadata(plugin);
801
- if (this.plugins_.has(metadata.id))
788
+ if (this.plugins_.has(plugin))
802
789
  return;
803
790
  const entry2 = {
804
791
  ctor: plugin,
805
792
  ctorParams: constructorProps,
806
793
  metadata
807
794
  };
808
- this.plugins_.set(metadata.id, entry2);
795
+ this.plugins_.set(plugin, entry2);
809
796
  this.logger.debug(() => `[Plugins]: Installed plugin ${metadata.name} (${metadata.version})`);
810
797
  }
811
798
  build() {
@@ -816,15 +803,15 @@ var PluginsManager = class {
816
803
  for (const id2 of this.plugins_.keys()) {
817
804
  nodes.set(id2, new DAGNode(id2));
818
805
  }
819
- for (const [id2, entry2] of this.plugins_) {
820
- const node = nodes.get(id2);
806
+ for (const [plugin, entry2] of this.plugins_) {
807
+ const node = nodes.get(plugin);
821
808
  const depPlugins = entry2.metadata.dependencies?.plugins ?? [];
822
809
  for (const dep of depPlugins) {
823
- const depNode = nodes.get(dep.id);
810
+ const depNode = nodes.get(dep.plugin);
824
811
  if (!depNode) {
825
- throw new ErrMissingPluginDependency(id2, dep.id);
812
+ throw new ErrMissingPluginDependency(plugin, dep.plugin);
826
813
  }
827
- node.vertices.push(depNode);
814
+ depNode.vertices.push(node);
828
815
  }
829
816
  }
830
817
  let sortedNodes;
@@ -854,20 +841,18 @@ var PluginsManager = class {
854
841
  p.instance?.onAfterWorldInit?.(world);
855
842
  }
856
843
  }
857
- getPluginMetadata(pluginOrId) {
858
- const id2 = this.resolveId(pluginOrId);
859
- const entry2 = this.plugins_.get(id2);
860
- if (!entry2) throw new ErrUnknownPlugin(id2);
844
+ getPluginMetadata(plugin) {
845
+ const entry2 = this.plugins_.get(plugin);
846
+ if (!entry2) throw new ErrUnknownPlugin(plugin);
861
847
  return entry2.metadata;
862
848
  }
863
- getPluginInstance(pluginOrId) {
849
+ getPluginInstance(plugin) {
850
+ const entry2 = this.plugins_.get(plugin);
851
+ if (!entry2) throw new ErrUnknownPlugin(plugin);
852
+ if (!entry2.instance) throw new ErrPluginNotInit(plugin);
864
853
  if (!this.isInitiated_) {
865
- throw new Error("Plugin instance is not initiated yet. Use PluginManager.build() before use plugins.");
854
+ throw new ErrPluginNotInit(plugin);
866
855
  }
867
- const id2 = this.resolveId(pluginOrId);
868
- const entry2 = this.plugins_.get(id2);
869
- if (!entry2) throw new ErrUnknownPlugin(id2);
870
- if (!entry2.instance) throw new ErrPluginNotInit(id2);
871
856
  return entry2.instance;
872
857
  }
873
858
  resolveId(pluginOrId) {
@@ -893,9 +878,13 @@ var World3 = class {
893
878
  plugins;
894
879
  logger;
895
880
  entityRefs_ = /* @__PURE__ */ new Map();
881
+ updatesCount_ = 0;
882
+ get updatesCount() {
883
+ return this.updatesCount_;
884
+ }
896
885
  constructor(params) {
897
886
  this.entities = new EntitiesManager(params.logger);
898
- this.components = new ComponentsManager(params.maxEntityCount ?? ECS_DEFAULTS.MAX_ENTITY_COUNT);
887
+ this.components = new ComponentsManager(params.logger, params.maxEntityCount ?? ECS_DEFAULTS.MAX_ENTITY_COUNT);
899
888
  this.systems = new SystemsManager(this, params.logger);
900
889
  this.events = new EventBus();
901
890
  this.resources = new ResourcesManager(params.logger);
@@ -941,6 +930,7 @@ var World3 = class {
941
930
  update(clock) {
942
931
  this.systems.update(clock.getTime());
943
932
  this.commands.flush(this);
933
+ this.updatesCount_++;
944
934
  }
945
935
  build() {
946
936
  this.plugins.build();
@@ -1235,9 +1225,9 @@ export {
1235
1225
  PluginBase,
1236
1226
  PluginError,
1237
1227
  PluginsManager,
1228
+ Resource,
1238
1229
  ResourcesManager,
1239
1230
  Runtime,
1240
- SingletonStorage,
1241
1231
  System,
1242
1232
  SystemBase,
1243
1233
  SystemError,
@@ -1249,6 +1239,7 @@ export {
1249
1239
  createEventKey,
1250
1240
  entry,
1251
1241
  getPluginMetadata,
1242
+ getResourceMetadata,
1252
1243
  getSystemMetadata,
1253
1244
  isPlugin,
1254
1245
  isSystem,