angry-pixel 2.0.0 → 2.0.2

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/lib/index.d.ts CHANGED
@@ -1,6 +1,16 @@
1
+ /**
2
+ * This type represents a dependency class
3
+ * @public
4
+ * @category Core
5
+ */
1
6
  type DependencyType = {
2
7
  new (...args: any[]): any;
3
8
  };
9
+ /**
10
+ * This type represents a dependency name
11
+ * @public
12
+ * @category Core
13
+ */
4
14
  type DependencyName = string | symbol;
5
15
  type PropertyKey = string | symbol;
6
16
  declare class Container {
@@ -11,7 +21,40 @@ declare class Container {
11
21
  get<T>(name: DependencyName): T;
12
22
  has(name: DependencyName): boolean;
13
23
  }
24
+ /**
25
+ * Decorator to identify a class as an injectable dependency
26
+ * @param name the name to identify the dependency
27
+ * @public
28
+ * @category Decorators
29
+ * @example
30
+ * ```typescript
31
+ * @injectable("SomeDependency")
32
+ * class SomeDependency {}
33
+ * ```
34
+ */
14
35
  declare function injectable(name: DependencyName): (target: DependencyType) => void;
36
+ /**
37
+ * Decorator to identify a property, or constructor argument, as a dependency to be injected
38
+ * @param name the name to identify the dependency
39
+ * @public
40
+ * @category Decorators
41
+ * @example
42
+ * ```typescript
43
+ * class SomeClass {
44
+ * private anotherDependency: DependencyType;
45
+ *
46
+ * constructor(@inject("AnotherDependency") anotherDependency: DependencyType) {
47
+ * this.anotherDependency = anotherDependency;
48
+ * }
49
+ * }
50
+ * ```
51
+ * @example
52
+ * ```typescript
53
+ * class SomeClass {
54
+ * @inject("AnotherDependency") private anotherDependency: DependencyType;
55
+ * }
56
+ * ```
57
+ */
15
58
  declare function inject(name: DependencyName): (target: any, propertyKey: PropertyKey, parameterIndex?: number) => void;
16
59
 
17
60
  /**
@@ -329,6 +372,7 @@ declare const range: (start: number, end: number, steps?: number) => number[];
329
372
  */
330
373
  declare const between: (value: number, min: number, max: number) => boolean;
331
374
 
375
+ /** @internal */
332
376
  interface Shape {
333
377
  boundingBox: Rectangle;
334
378
  collider: number;
@@ -344,6 +388,7 @@ interface Shape {
344
388
  vertices: Vector2[];
345
389
  updateCollisions: boolean;
346
390
  }
391
+ /** @internal */
347
392
  declare class Polygon implements Shape {
348
393
  rotation: number;
349
394
  boundingBox: Rectangle;
@@ -362,6 +407,7 @@ declare class Polygon implements Shape {
362
407
  set vertexModel(vertexModel: Vector2[]);
363
408
  constructor(vertexModel: Vector2[], rotation?: number);
364
409
  }
410
+ /** @internal */
365
411
  declare class Circumference implements Shape {
366
412
  radius: number;
367
413
  boundingBox: Rectangle;
@@ -391,8 +437,21 @@ declare enum BroadPhaseMethods {
391
437
  SpartialGrid = 1
392
438
  }
393
439
 
440
+ /**
441
+ * Contains information about the collision
442
+ * @public
443
+ * @category Collisions
444
+ */
394
445
  interface CollisionResolution {
446
+ /**
447
+ * Intersection between both colliders expressed in pixels
448
+ * @public
449
+ */
395
450
  penetration: number;
451
+ /**
452
+ * Collision direction
453
+ * @public
454
+ */
396
455
  direction: Vector2;
397
456
  }
398
457
 
@@ -408,105 +467,587 @@ declare enum CollisionMethods {
408
467
  SAT = 1
409
468
  }
410
469
 
470
+ /**
471
+ * Interface implemented by the collider components
472
+ * @public
473
+ * @category Collisions
474
+ */
411
475
  interface Collider {
476
+ /** Ignores collisions with layers in the array */
412
477
  ignoreCollisionsWithLayers: string[];
478
+ /** Collision layer*/
413
479
  layer: string;
480
+ /** X-Y axis offset */
414
481
  offset: Vector2;
482
+ /** TRUE if this collider interact with rigid bodies */
415
483
  physics: boolean;
484
+ /** @internal */
416
485
  shapes: Shape[];
417
486
  }
418
487
 
488
+ /**
489
+ * This type an unique identifier of an Entity
490
+ * @public
491
+ * @category Core
492
+ */
419
493
  type Entity = number;
494
+ /**
495
+ * This type represents an instance of a component
496
+ * @public
497
+ * @category Core
498
+ */
420
499
  type Component = {
421
500
  [key: string]: any;
422
501
  };
502
+ /**
503
+ * This type represents a component class
504
+ * @public
505
+ * @category Core
506
+ */
423
507
  type ComponentType<T extends Component = Component> = {
424
508
  new (...args: any[]): T;
425
509
  };
510
+ /**
511
+ * This type represents a search result object
512
+ * @public
513
+ * @category Core
514
+ */
426
515
  type SearchResult<T extends Component> = {
427
516
  entity: Entity;
428
517
  component: T;
429
518
  };
519
+ /**
520
+ * This type represents a search criteria object
521
+ * @public
522
+ * @category Core
523
+ */
430
524
  type SearchCriteria = {
431
525
  [key: string]: any;
432
526
  };
527
+ /**
528
+ * The EntityManager manages the entities and components.\
529
+ * It provides the necessary methods for reading and writing entities and components.
530
+ * @public
531
+ * @category Core
532
+ */
433
533
  declare class EntityManager {
434
534
  private lastEntityId;
435
535
  private lastComponentTypeId;
436
536
  private components;
437
537
  private disabledEntities;
438
538
  private disabledComponents;
539
+ /**
540
+ * Creates an entity without component
541
+ * @return The created Entity
542
+ * @public
543
+ * @example
544
+ * ```js
545
+ * const entity = entityManager.createEntity();
546
+ * ```
547
+ */
439
548
  createEntity(): Entity;
549
+ /**
550
+ * Creates an Entity based on a collection of Component instances and ComponentTypes
551
+ * @param components A collection of component instances and component classes
552
+ * @return The created Entity
553
+ * @public
554
+ * @example
555
+ * ```js
556
+ * const entity = entityManager.createEntity([
557
+ * new Transform({position: new Vector2(100, 100)}),
558
+ * SpriteRenderer
559
+ * ]);
560
+ * ```
561
+ */
440
562
  createEntity(components: Array<ComponentType | Component>): Entity;
563
+ /**
564
+ * Creates multiple entities based on an array of component collections
565
+ * @param components An array of collections of component instances and component classes
566
+ * @return An array with the created entities, in the same order of the collections of components
567
+ * @public
568
+ * @example
569
+ * ```js
570
+ * const parent = [
571
+ * new Transform({position: new Vector2(100, 100)}),
572
+ * SpriteRenderer
573
+ * ];
574
+ *
575
+ * const child = [
576
+ * new Transform({parent: parent[0]}),
577
+ * SpriteRenderer
578
+ * ];
579
+ *
580
+ * const entity = entityManager.createEntities([parent, child]);
581
+ * ```
582
+ */
583
+ createEntities(componentsList: Component[][]): Entity[];
584
+ /**
585
+ * Removes an Entity and all its Components
586
+ * @param entity The entity to remove
587
+ * @public
588
+ * @example
589
+ * ```js
590
+ * entityManager.removeEntity(entity);
591
+ * ```
592
+ */
441
593
  removeEntity(entity: Entity): void;
594
+ /**
595
+ * Removes all Entities and all their Components
596
+ * @public
597
+ * @example
598
+ * ```js
599
+ * entityManager.removeAllEntities();
600
+ * ```
601
+ */
442
602
  removeAllEntities(): void;
603
+ /**
604
+ * Returns TRUE if the Entity is enabled, otherwise it returns FALSE
605
+ * @param entity The entity to verify
606
+ * @returns boolean
607
+ * @public
608
+ * @example
609
+ * ```js
610
+ * const entityEnabled = entityManager.isEntityEnabled(entity);
611
+ * ```
612
+ */
443
613
  isEntityEnabled(entity: Entity): boolean;
614
+ /**
615
+ * Enables an Entity
616
+ * @param entity The entity to be enabled
617
+ * @public
618
+ * @example
619
+ * ```js
620
+ * entityManager.enableEntity(entity);
621
+ * ```
622
+ */
444
623
  enableEntity(entity: Entity): void;
624
+ /**
625
+ * Disables an Entity
626
+ * @param entity The entity to be disabled
627
+ * @public
628
+ * @example
629
+ * ```js
630
+ * entityManager.disableEntity(entity);
631
+ * ```
632
+ */
445
633
  disableEntity(entity: Entity): void;
634
+ /**
635
+ * Disable all Entities that have a component of the given type
636
+ * @param componentType The class of the component
637
+ * @public
638
+ * @example
639
+ * ```js
640
+ * entityManager.disableEntitiesByComponent(SpriteRenderer);
641
+ * ```
642
+ */
446
643
  disableEntitiesByComponent(componentType: ComponentType): void;
644
+ /**
645
+ * Enable all Entities that have a component of the given type
646
+ * @param componentType The class of the component
647
+ * @public
648
+ * @example
649
+ * ```js
650
+ * entityManager.enableEntitiesByComponent(SpriteRenderer);
651
+ * ```
652
+ */
447
653
  enableEntitiesByComponent(componentType: ComponentType): void;
654
+ /**
655
+ * Adds a component to the entity
656
+ * @param entity The Entity to which the component will be added
657
+ * @param componentType The class of the component
658
+ * @returns The instance of the component
659
+ * @public
660
+ * @example
661
+ * ```js
662
+ * const spriteRenderer = entityManager.addComponent(entity, SpriteRenderer);
663
+ * ```
664
+ */
448
665
  addComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): T;
666
+ /**
667
+ * Adds an instance of a component to an entity
668
+ * @param entity The Entity to which the component will be added
669
+ * @param component The instance of the component
670
+ * @returns The instance of the component
671
+ * @public
672
+ * @example
673
+ * ```js
674
+ * const spriteRenderer = new SpriteRenderer();
675
+ * entityManager.addComponent(entity, spriteRenderer);
676
+ * ```
677
+ */
449
678
  addComponent<T extends Component>(entity: Entity, component: T): T;
679
+ /**
680
+ * Returns TRUE if the Entity has a component of the given type, otherwise it returns FALSE.
681
+ * @param entity The entity to verify
682
+ * @param componentType The class of the component
683
+ * @returns boolean
684
+ * @public
685
+ * @example
686
+ * ```js
687
+ * const hasSpriteRenderer = entityManager.hasComponent(entity, SpriteRenderer);
688
+ * ```
689
+ */
450
690
  hasComponent(entity: Entity, componentType: ComponentType): boolean;
691
+ /**
692
+ * Returns the component of the given type belonging to the entity
693
+ * @param entity The entity
694
+ * @param componentType The class of the component
695
+ * @returns The instance of the component
696
+ * @public
697
+ * @example
698
+ * ```js
699
+ * const spriteRenderer = entityManager.getComponent(entity, SpriteRenderer);
700
+ * ```
701
+ */
451
702
  getComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): T;
703
+ /**
704
+ * Returns all the component belonging to the entity
705
+ * @param entity The entity
706
+ * @returns A collection of component instances
707
+ * @public
708
+ * @example
709
+ * ```js
710
+ * const components = entityManager.getComponents(entity);
711
+ * ```
712
+ */
452
713
  getComponents(entity: Entity): Component[];
714
+ /**
715
+ * Searches for and returns an entity for the component instance
716
+ * @param component The component instance
717
+ * @returns The found Entity
718
+ * @public
719
+ * @example
720
+ * ```js
721
+ * const entity = entityManager.getEntityForComponent(spriteRenderer);
722
+ * ```
723
+ */
453
724
  getEntityForComponent(component: Component): Entity;
725
+ /**
726
+ * Removes the component instance from its Entity
727
+ * @param component The component instance
728
+ * @public
729
+ * @example
730
+ * ```js
731
+ * entityManager.removeComponent(spriteRenderer)
732
+ * ```
733
+ */
454
734
  removeComponent(component: Component): void;
735
+ /**
736
+ * Removes a component from the entity according to the given type
737
+ * @param entity The target entity
738
+ * @param componentType The component class
739
+ * @public
740
+ * @example
741
+ * ```js
742
+ * entityManager.removeComponent(entity, SriteRenderer)
743
+ * ```
744
+ */
455
745
  removeComponent(entity: Entity, componentType: ComponentType): void;
746
+ /**
747
+ * Returns TRUE if the component is enabled, otherwise it returns FALSE
748
+ * @param component The component instance
749
+ * @returns boolean
750
+ * @public
751
+ * @example
752
+ * ```js
753
+ * entityManager.isComponentEnabled(spriteRenderer)
754
+ * ```
755
+ */
456
756
  isComponentEnabled(component: Component): boolean;
757
+ /**
758
+ * Returns TRUE if the component is enabled, otherwise it returns FALSE
759
+ * @param entity The target entity
760
+ * @param componentType The component class
761
+ * @returns boolean
762
+ * @public
763
+ * @example
764
+ * ```js
765
+ * entityManager.isComponentEnabled(entity, SpriteRenderer)
766
+ * ```
767
+ */
457
768
  isComponentEnabled<T extends Component>(entity: Entity, componentType: ComponentType<T>): boolean;
769
+ /**
770
+ * Disables a component instance
771
+ * @param component The component instance
772
+ * @public
773
+ * @example
774
+ * ```js
775
+ * entityManager.disableComponent(spriteRenderer);
776
+ * ```
777
+ */
458
778
  disableComponent(component: Component): void;
779
+ /**
780
+ * Disables a component by its entity and type
781
+ * @param entity The target entity
782
+ * @param componentType The component class
783
+ * @public
784
+ * @example
785
+ * ```js
786
+ * entityManager.disableComponent(entity, SpriteRenderer);
787
+ * ```
788
+ */
459
789
  disableComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): void;
790
+ /**
791
+ * Enables a component instance
792
+ * @param component The component instance
793
+ * @public
794
+ * @example
795
+ * ```js
796
+ * entityManager.enableComponent(spriteRenderer);
797
+ * ```
798
+ */
460
799
  enableComponent(component: Component): void;
800
+ /**
801
+ * Enables a component by its entity and type
802
+ * @param entity The target entity
803
+ * @param componentType The component class
804
+ * @public
805
+ * @example
806
+ * ```js
807
+ * entityManager.enableComponent(entity, SpriteRenderer);
808
+ * ```
809
+ */
461
810
  enableComponent<T extends Component>(entity: Entity, componentType: ComponentType<T>): void;
811
+ /**
812
+ * Performs a search for entities given a component type.\
813
+ * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
814
+ * This search can be filtered by passing as a second argument an instance of SearchCriteria, which performs a match between the attributes of the component and the given value.\
815
+ * The third argument determines if disabled entities or components are included in the search result,\its default value is FALSE.
816
+ * @param componentType The component class
817
+ * @param criteria The search criteria
818
+ * @param includeDisabled TRUE to incluide disabled entities and components, FALSE otherwise
819
+ * @returns SearchResult
820
+ * @public
821
+ * @example
822
+ * ```js
823
+ * const searchResult = entityManager.search(SpriteRenderer);
824
+ * searchResult.forEach(({component, entity}) => {
825
+ * // do something with the component and entity
826
+ * })
827
+ * ```
828
+ * @example
829
+ * ```js
830
+ * const searchResult = entityManager.search(Enemy, {status: "alive"});
831
+ * searchResult.forEach(({component, entity}) => {
832
+ * // do something with the component and entity
833
+ * })
834
+ * ```
835
+ */
462
836
  search<T extends Component>(componentType: ComponentType<T>, criteria?: SearchCriteria, includeDisabled?: boolean): SearchResult<T>[];
837
+ /**
838
+ * Performs an entity search given a collection of component types.\
839
+ * The entities found must have an instance of all the given component types.\
840
+ * This method returns a collection of Entities.
841
+ * @param componentTypes A collection of component classes
842
+ * @returns A collection of entities
843
+ * @public
844
+ * @example
845
+ * ```js
846
+ * const entities = entityManager.searchEntitiesByComponents([Transform, SpriteRenderer, Animator]);
847
+ * ```
848
+ */
463
849
  searchEntitiesByComponents(componentTypes: ComponentType[]): Entity[];
464
850
  private getComponentTypeId;
465
851
  }
466
852
 
853
+ /**
854
+ * This interface is used for the creation of system classes. You will have to inject the dependencies you need manully.
855
+ * @public
856
+ * @category Core
857
+ * @example
858
+ * ```typescript
859
+ * class PlayerSystem implements System {
860
+ * @inject(Symbols.EntityManager) private readonly entityManager: EntityManager;
861
+ *
862
+ * public onUpdate() {
863
+ * this.entityManager.search(Player).forEach(({component, entity}) => {
864
+ * // do somethng
865
+ * });
866
+ * }
867
+ * }
868
+ * ```
869
+ */
467
870
  interface System {
871
+ /**
872
+ * This method is called the first time the system is enabled
873
+ * @public
874
+ */
468
875
  onCreate?(): void;
876
+ /**
877
+ * This method is called when the system is destroyed
878
+ * @public
879
+ */
469
880
  onDestroy?(): void;
881
+ /**
882
+ * This method is called when the system is disabled
883
+ * @public
884
+ */
470
885
  onDisabled?(): void;
886
+ /**
887
+ * This method is called when the system is enabled
888
+ * @public
889
+ */
471
890
  onEnabled?(): void;
891
+ /**
892
+ * This method is called once every frame
893
+ * @public
894
+ */
472
895
  onUpdate(): void;
473
896
  }
897
+ /**
898
+ * This type represents a system class
899
+ * @public
900
+ * @category Core
901
+ */
474
902
  type SystemType<T extends System = System> = {
475
903
  new (...args: any[]): T;
476
904
  };
905
+ /** @internal */
477
906
  type SystemGroup = string | number | symbol;
907
+ /**
908
+ * The SystemManager manages the systems.\
909
+ * It provides the necessary methods for reading and writing systems.
910
+ * @public
911
+ * @category Core
912
+ */
478
913
  declare class SystemManager {
479
914
  private systems;
915
+ /**
916
+ * @param systemType The system class
917
+ * @returns the systen index
918
+ */
480
919
  private findSystemIndex;
920
+ /**
921
+ * Adds a new system instance linked to a group
922
+ * @param system The system instance
923
+ * @param group The system group
924
+ * @internal
925
+ */
481
926
  addSystem(system: System, group: SystemGroup): void;
927
+ /**
928
+ * Returns TRUE if it has a system of the given type, otherwise it returns FALSE
929
+ * @param systemType The system class
930
+ * @returns boolean
931
+ * @public
932
+ * @example
933
+ * ```js
934
+ * const hasPlayerSystem = systemManager.hasSystem(PlayerSystem);
935
+ * ```
936
+ */
482
937
  hasSystem(systemType: SystemType): boolean;
938
+ /**
939
+ * Returns a system instance for the given type
940
+ * @param systemType The system class
941
+ * @returns The system instance
942
+ * @internal
943
+ */
483
944
  getSystem<T extends System>(systemType: SystemType<T>): T;
945
+ /**
946
+ * Enables a system by its type.\
947
+ * The method `onEnabled` of the system will be called. If the system is enabled for the first time, the method `onCreate` will also be called.
948
+ * @param systemType The system class
949
+ * @public
950
+ * @example
951
+ * ```js
952
+ * systemManager.enableSystem(PlayerSystem);
953
+ * ```
954
+ */
484
955
  enableSystem(systemType: SystemType): void;
956
+ /**
957
+ * Disables a system by its type.\
958
+ * The method `onDisabled` of the system will be called.
959
+ * @param systemType The system class
960
+ * @public
961
+ * @example
962
+ * ```js
963
+ * systemManager.disableSystem(PlayerSystem);
964
+ * ```
965
+ */
485
966
  disableSystem(systemType: SystemType): void;
967
+ /**
968
+ * Set the execution priority of a system.
969
+ * @param systemType The system class
970
+ * @param position the priority number
971
+ * @internal
972
+ */
486
973
  setExecutionOrder(systemType: SystemType, position: number): void;
974
+ /**
975
+ * Removes a system by its type.
976
+ * The method `onDestroy` of the system will be called.
977
+ * @param systemType The system class
978
+ * @internal
979
+ */
487
980
  removeSystem(systemType: SystemType): void;
981
+ /**
982
+ * Call the method onUpdate for systems belonging to the given group
983
+ * @param group The system group
984
+ * @internal
985
+ */
488
986
  update(group: SystemGroup): void;
489
987
  }
490
988
 
491
989
  /**
492
- * Represent a collision. It contains the colliders involved and the resolution data.
493
- * @category Components
990
+ * Represent a collision. It contains the colliders involved, the entities, and the resolution data.
991
+ * @category Collisions
494
992
  * @public
495
993
  */
496
994
  interface Collision {
995
+ /**
996
+ * The local collider component
997
+ * @public
998
+ */
497
999
  localCollider: Collider;
1000
+ /**
1001
+ * The local entity
1002
+ * @public
1003
+ */
498
1004
  localEntity: Entity;
1005
+ /**
1006
+ * The remote collider component
1007
+ * @public
1008
+ */
499
1009
  remoteCollider: Collider;
1010
+ /**
1011
+ * The remote collider
1012
+ * @public
1013
+ */
500
1014
  remoteEntity: Entity;
1015
+ /**
1016
+ * Contains the information about the collision
1017
+ * @public
1018
+ */
501
1019
  resolution: CollisionResolution;
502
1020
  }
503
1021
 
1022
+ /**
1023
+ * The CollisionRepository has the necessary methods to perform queries on the current collisions
1024
+ * @public
1025
+ * @category Collisions
1026
+ */
504
1027
  declare class CollisionRepository {
505
1028
  private collisions;
1029
+ /**
1030
+ * Searches for and returns a collection of collisions for the given collider
1031
+ * @param collider The local collider
1032
+ * @returns A collection of collisions
1033
+ */
506
1034
  findCollisionsForCollider(collider: Collider): Collision[];
1035
+ /**
1036
+ * Searches for and returns a collection of collisions for the given collider and layer
1037
+ * @param collider The local collider
1038
+ * @param layer The collision layer
1039
+ * @returns A collection of collisions
1040
+ */
507
1041
  findCollisionsForColliderAndLayer(collider: Collider, layer: string): Collision[];
1042
+ /**
1043
+ * Returns all the collisions
1044
+ * @public
1045
+ * @returns A collection of collisions
1046
+ */
508
1047
  findAll(): Collision[];
1048
+ /** @internal */
509
1049
  persist(collision: Collision): void;
1050
+ /** @internal */
510
1051
  removeAll(): void;
511
1052
  }
512
1053
 
@@ -517,6 +1058,31 @@ declare class CollisionRepository {
517
1058
  */
518
1059
  type CollisionMatrix = [string, string][];
519
1060
 
1061
+ /**
1062
+ * Game configuration options
1063
+ * @public
1064
+ * @category Config
1065
+ * @example
1066
+ * ```js
1067
+ * const gameConfig = {
1068
+ * containerNode: document.getElementById("app"),
1069
+ * width: 1920,
1070
+ * height: 1080,
1071
+ * debugEnabled: false,
1072
+ * canvasColor: "#000000",
1073
+ * physicsFramerate: 180,
1074
+ * headless: false,
1075
+ * collisions: {
1076
+ * collisionMatrix: [
1077
+ * ["layer1", "layer2"],
1078
+ * ["layer1", "layer3"],
1079
+ * ],
1080
+ * collisionMethod: CollisionMethods.SAT,
1081
+ * collisionBroadPhaseMethod: BroadPhaseMethods.SpartialGrid,
1082
+ * }
1083
+ * };
1084
+ * ```
1085
+ */
520
1086
  interface GameConfig {
521
1087
  /** HTML element where the game will be created */
522
1088
  containerNode: HTMLElement;
@@ -546,7 +1112,7 @@ interface GameConfig {
546
1112
  };
547
1113
  }
548
1114
 
549
- declare class SystemFactory {
1115
+ declare class CreateSystemService {
550
1116
  private readonly container;
551
1117
  private readonly systemManager;
552
1118
  private lastSystemTypeId;
@@ -585,7 +1151,6 @@ declare class AssetManager {
585
1151
  /**
586
1152
  * Loads an image asset
587
1153
  * @param url The asset URL
588
- * @param preloadTexture Creates the texture to be rendered at load time [optional]
589
1154
  * @returns The HTML Image element created
590
1155
  */
591
1156
  loadImage(url: string): HTMLImageElement;
@@ -635,9 +1200,39 @@ declare class AssetManager {
635
1200
  private createAsset;
636
1201
  }
637
1202
 
1203
+ /**
1204
+ * This type represents a scene class
1205
+ * @public
1206
+ * @category Core
1207
+ */
638
1208
  type SceneType<T extends Scene = Scene> = {
639
1209
  new (entityManager: EntityManager, assetManager: AssetManager): T;
640
1210
  };
1211
+ /**
1212
+ * Base class for all game scenes
1213
+ * @public
1214
+ * @category Core
1215
+ * @example
1216
+ * ```js
1217
+ * class GameScene extends Scene {
1218
+ * systems = [
1219
+ * SomeSystem,
1220
+ * AnotherSystem
1221
+ * ];
1222
+ *
1223
+ * loadAssets() {
1224
+ * this.assetManager.loadImage("image.png");
1225
+ * }
1226
+ *
1227
+ * setup() {
1228
+ * this.entityManager.createEntity([
1229
+ * SomeComponent,
1230
+ * AnotherComponent
1231
+ * ]);
1232
+ * }
1233
+ * }
1234
+ * ```
1235
+ */
641
1236
  declare abstract class Scene {
642
1237
  protected readonly entityManager: EntityManager;
643
1238
  protected readonly assetManager: AssetManager;
@@ -646,6 +1241,15 @@ declare abstract class Scene {
646
1241
  loadAssets(): void;
647
1242
  setup(): void;
648
1243
  }
1244
+ /**
1245
+ * Manges the loading of the scenes.
1246
+ * @public
1247
+ * @category Managers
1248
+ * @example
1249
+ * ```js
1250
+ * this.sceneManager.loadScene("MainScene");
1251
+ * ```
1252
+ */
649
1253
  declare class SceneManager {
650
1254
  private readonly systemManager;
651
1255
  private readonly systemFactory;
@@ -656,7 +1260,8 @@ declare class SceneManager {
656
1260
  private currentSceneName;
657
1261
  private sceneNameToBeLoaded;
658
1262
  private loadingScene;
659
- constructor(systemManager: SystemManager, systemFactory: SystemFactory, entityManager: EntityManager, assetManager: AssetManager);
1263
+ /** @internal */
1264
+ constructor(systemManager: SystemManager, systemFactory: CreateSystemService, entityManager: EntityManager, assetManager: AssetManager);
660
1265
  addScene(sceneType: SceneType, name: string, openingScene?: boolean): void;
661
1266
  loadScene(name: string): void;
662
1267
  loadOpeningScene(): void;
@@ -726,7 +1331,7 @@ declare class Game {
726
1331
  /**
727
1332
  * Add a new instance to be used as dependency
728
1333
  *
729
- * @param dependency The dependency instance
1334
+ * @param dependencyInstance The dependency instance
730
1335
  * @param name The name for the dependecy
731
1336
  */
732
1337
  addDependencyInstance(dependencyInstance: any, name: DependencyName): void;
@@ -740,14 +1345,20 @@ declare class Game {
740
1345
  stop(): void;
741
1346
  }
742
1347
 
743
- /** @category Components */
1348
+ /**
1349
+ * @public
1350
+ * @category Components
1351
+ */
744
1352
  interface AnimatorOptions {
745
1353
  animations: Map<string, Animation>;
746
1354
  animation: string;
747
1355
  speed: number;
748
1356
  playing: boolean;
749
1357
  }
750
- /** @category Components */
1358
+ /**
1359
+ * @public
1360
+ * @category Components
1361
+ */
751
1362
  declare class Animator {
752
1363
  animations: Map<string, Animation>;
753
1364
  animation: string;
@@ -760,7 +1371,10 @@ declare class Animator {
760
1371
  _currentAnimation: string;
761
1372
  constructor(options?: Partial<AnimatorOptions>);
762
1373
  }
763
- /** @category Components */
1374
+ /**
1375
+ * @public
1376
+ * @category Components
1377
+ */
764
1378
  declare class Animation {
765
1379
  image: HTMLImageElement | HTMLImageElement[];
766
1380
  slice: AnimationSlice;
@@ -769,21 +1383,30 @@ declare class Animation {
769
1383
  loop: boolean;
770
1384
  constructor(options?: Partial<Animation>);
771
1385
  }
772
- /** @category Components */
1386
+ /**
1387
+ * @public
1388
+ * @category Components
1389
+ */
773
1390
  type AnimationSlice = {
774
1391
  size: Vector2;
775
1392
  offset: Vector2;
776
1393
  padding: Vector2;
777
1394
  };
778
1395
 
779
- /** @category Components */
1396
+ /**
1397
+ * @public
1398
+ * @category Components
1399
+ */
780
1400
  interface AudioPlayerOptions {
781
1401
  action: AudioPlayerAction;
782
1402
  audioSource: HTMLAudioElement;
783
1403
  loop: boolean;
784
1404
  volume: number;
785
1405
  }
786
- /** @category Components */
1406
+ /**
1407
+ * @public
1408
+ * @category Components
1409
+ */
787
1410
  declare class AudioPlayer {
788
1411
  action: AudioPlayerAction;
789
1412
  audioSource: HTMLAudioElement;
@@ -794,9 +1417,16 @@ declare class AudioPlayer {
794
1417
  _currentAudio: string;
795
1418
  constructor(options?: Partial<AudioPlayerOptions>);
796
1419
  }
1420
+ /**
1421
+ * @public
1422
+ * @category Components
1423
+ */
797
1424
  type AudioPlayerAction = "stop" | "play" | "pause";
798
1425
 
799
- /** @category Components */
1426
+ /**
1427
+ * @public
1428
+ * @category Components
1429
+ */
800
1430
  interface ButtonOptions {
801
1431
  shape: ButtonShape;
802
1432
  width: number;
@@ -807,7 +1437,10 @@ interface ButtonOptions {
807
1437
  onClick: () => void;
808
1438
  onPressed: () => void;
809
1439
  }
810
- /** @category Components */
1440
+ /**
1441
+ * @public
1442
+ * @category Components
1443
+ */
811
1444
  declare class Button {
812
1445
  /** The shape of the button */
813
1446
  shape: ButtonShape;
@@ -829,34 +1462,52 @@ declare class Button {
829
1462
  onPressed: () => void;
830
1463
  constructor(options?: Partial<ButtonOptions>);
831
1464
  }
832
- /** @category Components */
1465
+ /**
1466
+ * @public
1467
+ * @category Components
1468
+ */
833
1469
  declare enum ButtonShape {
834
1470
  Rectangle = 0,
835
1471
  Circumference = 1
836
1472
  }
837
1473
 
838
- /** @category Components */
1474
+ /**
1475
+ * @public
1476
+ * @category Components
1477
+ */
839
1478
  declare class Children {
840
1479
  entities: Entity[];
841
1480
  }
842
1481
 
843
- /** @category Components */
1482
+ /**
1483
+ * @public
1484
+ * @category Components
1485
+ */
844
1486
  declare class Parent {
845
1487
  entity: Entity;
846
1488
  }
847
1489
 
848
- /** @category Components */
1490
+ /**
1491
+ * @public
1492
+ * @category Components
1493
+ */
849
1494
  interface TiledWrapperOptions {
850
1495
  tilemap: TiledTilemap;
851
1496
  layerToRender: string;
852
1497
  }
853
- /** @category Components */
1498
+ /**
1499
+ * @public
1500
+ * @category Components
1501
+ */
854
1502
  declare class TiledWrapper {
855
1503
  tilemap: TiledTilemap;
856
1504
  layerToRender: string;
857
1505
  constructor(options?: Partial<TiledWrapperOptions>);
858
1506
  }
859
- /** @category Components */
1507
+ /**
1508
+ * @public
1509
+ * @category Components
1510
+ */
860
1511
  interface TiledTilemap {
861
1512
  width: number;
862
1513
  height: number;
@@ -870,7 +1521,10 @@ interface TiledTilemap {
870
1521
  tileheight: number;
871
1522
  properties?: TiledProperty[];
872
1523
  }
873
- /** @category Components */
1524
+ /**
1525
+ * @public
1526
+ * @category Components
1527
+ */
874
1528
  interface TiledChunk {
875
1529
  data: number[];
876
1530
  x: number;
@@ -879,7 +1533,10 @@ interface TiledChunk {
879
1533
  height: number;
880
1534
  type?: string;
881
1535
  }
882
- /** @category Components */
1536
+ /**
1537
+ * @public
1538
+ * @category Components
1539
+ */
883
1540
  interface TiledLayer {
884
1541
  name: string;
885
1542
  id: number;
@@ -899,7 +1556,10 @@ interface TiledLayer {
899
1556
  tintcolor?: string;
900
1557
  properties?: TiledProperty[];
901
1558
  }
902
- /** @category Components */
1559
+ /**
1560
+ * @public
1561
+ * @category Components
1562
+ */
903
1563
  interface TiledObjectLayer {
904
1564
  draworder: string;
905
1565
  id: number;
@@ -912,7 +1572,10 @@ interface TiledObjectLayer {
912
1572
  y: number;
913
1573
  properties?: TiledProperty[];
914
1574
  }
915
- /** @category Components */
1575
+ /**
1576
+ * @public
1577
+ * @category Components
1578
+ */
916
1579
  interface TiledObject {
917
1580
  gid: number;
918
1581
  height: number;
@@ -926,14 +1589,20 @@ interface TiledObject {
926
1589
  y: number;
927
1590
  properties?: TiledProperty[];
928
1591
  }
929
- /** @category Components */
1592
+ /**
1593
+ * @public
1594
+ * @category Components
1595
+ */
930
1596
  interface TiledProperty {
931
1597
  name: string;
932
1598
  type: "int" | "bool" | "float" | "color" | "string";
933
1599
  value: number | string | boolean;
934
1600
  }
935
1601
 
936
- /** @category Components */
1602
+ /**
1603
+ * @public
1604
+ * @category Components
1605
+ */
937
1606
  interface TransformOptions {
938
1607
  position: Vector2;
939
1608
  scale: Vector2;
@@ -943,7 +1612,10 @@ interface TransformOptions {
943
1612
  localScale: Vector2;
944
1613
  localRotation: number;
945
1614
  }
946
- /** @category Components */
1615
+ /**
1616
+ * @public
1617
+ * @category Components
1618
+ */
947
1619
  declare class Transform {
948
1620
  /** Position relative to the zero point of the simulated world, or relative to the parent if it has one */
949
1621
  position: Vector2;
@@ -969,6 +1641,21 @@ declare class Transform {
969
1641
  constructor(options?: Partial<TransformOptions>);
970
1642
  }
971
1643
 
1644
+ /**
1645
+ * Configuration object for BallCollider creation
1646
+ * @public
1647
+ * @category Components
1648
+ * @example
1649
+ * ```js
1650
+ * const ballCollider = new BallCollider({
1651
+ * radius: 16,
1652
+ * offset: new Vector2(),
1653
+ * layer: "CollisionLayer",
1654
+ * physics: true,
1655
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1656
+ * });
1657
+ * ```
1658
+ */
972
1659
  interface BallColliderOptions {
973
1660
  /** Circumference radius */
974
1661
  radius: number;
@@ -985,6 +1672,16 @@ interface BallColliderOptions {
985
1672
  * Circumference shaped collider for 2d collisions.
986
1673
  * @public
987
1674
  * @category Components
1675
+ * @example
1676
+ * ```js
1677
+ * const ballCollider = new BallCollider({
1678
+ * radius: 16,
1679
+ * offset: new Vector2(),
1680
+ * layer: "CollisionLayer",
1681
+ * physics: true,
1682
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1683
+ * });
1684
+ * ```
988
1685
  */
989
1686
  declare class BallCollider implements Collider {
990
1687
  /** Circumference radius */
@@ -1002,6 +1699,23 @@ declare class BallCollider implements Collider {
1002
1699
  constructor(options?: Partial<BallColliderOptions>);
1003
1700
  }
1004
1701
 
1702
+ /**
1703
+ * Configuration object for BoxCollider creation
1704
+ * @public
1705
+ * @category Components
1706
+ * @example
1707
+ * ```js
1708
+ * const boxCollider = new BoxCollider({
1709
+ * width: 16,
1710
+ * height: 16,
1711
+ * rotation: 0,
1712
+ * offset: new Vector2(),
1713
+ * layer: "CollisionLayer",
1714
+ * physics: true,
1715
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1716
+ * });
1717
+ * ```
1718
+ */
1005
1719
  interface BoxColliderOptions {
1006
1720
  /** Collision layer*/
1007
1721
  layer: string;
@@ -1022,6 +1736,18 @@ interface BoxColliderOptions {
1022
1736
  * Rectangle shaped collider for 2d collisions.
1023
1737
  * @public
1024
1738
  * @category Components
1739
+ * @example
1740
+ * ```js
1741
+ * const boxCollider = new BoxCollider({
1742
+ * width: 16,
1743
+ * height: 16,
1744
+ * rotation: 0,
1745
+ * offset: new Vector2(),
1746
+ * layer: "CollisionLayer",
1747
+ * physics: true,
1748
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1749
+ * });
1750
+ * ```
1025
1751
  */
1026
1752
  declare class BoxCollider implements Collider {
1027
1753
  /** Collision layer*/
@@ -1043,6 +1769,22 @@ declare class BoxCollider implements Collider {
1043
1769
  constructor(options?: Partial<BoxColliderOptions>);
1044
1770
  }
1045
1771
 
1772
+ /**
1773
+ * Configuration object for EdgeCollider creation
1774
+ * @public
1775
+ * @category Components
1776
+ * @example
1777
+ * ```js
1778
+ * const edgeCollider = new EdgeCollider({
1779
+ * vertexModel: [new Vector2(0, 16), new Vector2(16, 16)],
1780
+ * rotation: 0,
1781
+ * offset: new Vector2(),
1782
+ * layer: "CollisionLayer",
1783
+ * physics: true,
1784
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1785
+ * });
1786
+ * ```
1787
+ */
1046
1788
  interface EdgeColliderOptions {
1047
1789
  /** Collection of 2d vectors representing the vertices of the collider */
1048
1790
  vertexModel: Vector2[];
@@ -1061,6 +1803,16 @@ interface EdgeColliderOptions {
1061
1803
  * Collider composed of lines defined by its vertices, for 2d collisions.
1062
1804
  * @public
1063
1805
  * @category Components
1806
+ * @example
1807
+ * ```js
1808
+ * const edgeCollider = new EdgeCollider({
1809
+ * vertexModel: [new Vector2(0, 16), new Vector2(16, 16)],
1810
+ * offset: new Vector2(),
1811
+ * layer: "CollisionLayer",
1812
+ * physics: true,
1813
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1814
+ * });
1815
+ * ```
1064
1816
  */
1065
1817
  declare class EdgeCollider implements Collider {
1066
1818
  /** Collection of 2d vectors representing the vertices of the collider */
@@ -1080,6 +1832,22 @@ declare class EdgeCollider implements Collider {
1080
1832
  constructor(options?: Partial<EdgeColliderOptions>);
1081
1833
  }
1082
1834
 
1835
+ /**
1836
+ * Configuration object for PolygonCollider creation
1837
+ * @public
1838
+ * @category Components
1839
+ * @example
1840
+ * ```js
1841
+ * const polygonCollider = new PolygonCollider({
1842
+ * vertexModel: [new Vector2(0, 16), new Vector2(16, 16), new Vector2(16, 0), new Vector2(0, 0)],
1843
+ * rotation: 0,
1844
+ * offset: new Vector2(),
1845
+ * layer: "CollisionLayer",
1846
+ * physics: true,
1847
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1848
+ * });
1849
+ * ```
1850
+ */
1083
1851
  interface PolygonColliderOptions {
1084
1852
  /** Collection of 2d vectors representing the vertices of the collider */
1085
1853
  vertexModel: Vector2[];
@@ -1098,6 +1866,17 @@ interface PolygonColliderOptions {
1098
1866
  * Polygon shaped Collider for 2d collisions. Only convex polygons are allowed.
1099
1867
  * @public
1100
1868
  * @category Components
1869
+ * @example
1870
+ * ```js
1871
+ * const polygonCollider = new PolygonCollider({
1872
+ * vertexModel: [new Vector2(0, 16), new Vector2(16, 16), new Vector2(16, 0), new Vector2(0, 0)],
1873
+ * rotation: 0,
1874
+ * offset: new Vector2(),
1875
+ * layer: "CollisionLayer",
1876
+ * physics: true,
1877
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
1878
+ * });
1879
+ * ```
1101
1880
  */
1102
1881
  declare class PolygonCollider implements Collider {
1103
1882
  /** Collection of 2d vectors representing the vertices of the collider */
@@ -1119,7 +1898,7 @@ declare class PolygonCollider implements Collider {
1119
1898
 
1120
1899
  /**
1121
1900
  * The type of the rigid body to create:
1122
- * - Dynamic: This type of body is affected by gravity and velopcity.
1901
+ * - Dynamic: This type of body is affected by gravity and velocity.
1123
1902
  * - Static: This type of body is immovable, is unaffected by velocity and gravity.
1124
1903
  * @category Components
1125
1904
  * @public
@@ -1128,20 +1907,114 @@ declare enum RigidBodyType {
1128
1907
  Dynamic = 0,
1129
1908
  Static = 1
1130
1909
  }
1910
+ /**
1911
+ * RigidBody configuration options
1912
+ * @public
1913
+ * @category Components
1914
+ * @example
1915
+ * ```js
1916
+ const rigidBody = new RigidBody({
1917
+ rigidBodyType: RigidBodyType.Dynamic,
1918
+ gravity: 10,
1919
+ velocity: new Vector2(1, 0),
1920
+ acceleration: new Vector2(1, 0)
1921
+ });
1922
+ * ```
1923
+ * @example
1924
+ * ```js
1925
+ const rigidBody = new RigidBody({
1926
+ rigidBodyType: RigidBodyType.Static,
1927
+ });
1928
+ * ```
1929
+ */
1131
1930
  interface RigidBodyOptions {
1931
+ /**
1932
+ * The type of the rigid body to create:
1933
+ * - Dynamic: This type of body is affected by gravity and velocity.
1934
+ * - Static: This type of body is immovable, is unaffected by velocity and gravity.
1935
+ * @public
1936
+ */
1132
1937
  type: RigidBodyType;
1938
+ /**
1939
+ * Velocity applied to the x-axis and y-axis expressed in pixels per second. Only for Dynamic bodies
1940
+ * @public
1941
+ */
1133
1942
  velocity: Vector2;
1943
+ /**
1944
+ * Gravity expressed in pixels per second squared. Only for Dynamic bodies
1945
+ * @public
1946
+ */
1134
1947
  gravity: number;
1948
+ /**
1949
+ * Acceleration expressed in pixels per second squared. Only for Dynamic bodies
1950
+ * @public
1951
+ */
1135
1952
  acceleration: Vector2;
1136
1953
  }
1954
+ /**
1955
+ * The RigidBody component puts the entity under simulation of the physics engine, where it will interact with other objects that have a RigidBody.\
1956
+ * There are two types of bodies:
1957
+ * - Dynamic = This type of body is affected by gravity, can be velocity-applied and collides with other rigid bodies.
1958
+ * - Static = This type of body is immovable, no velocity can be applied to it and it is not affected by gravity. It is the body type that consumes the least processing resources.
1959
+ * @public
1960
+ * @category Components
1961
+ * @example
1962
+ * ```js
1963
+ const rigidBody = new RigidBody({
1964
+ rigidBodyType: RigidBodyType.Dynamic,
1965
+ gravity: 10,
1966
+ velocity: new Vector2(1, 0),
1967
+ acceleration: new Vector2(1, 0)
1968
+ });
1969
+ * ```
1970
+ * @example
1971
+ * ```js
1972
+ const rigidBody = new RigidBody({
1973
+ rigidBodyType: RigidBodyType.Static,
1974
+ });
1975
+ * ```
1976
+ */
1137
1977
  declare class RigidBody {
1978
+ /**
1979
+ * The type of the rigid body to create:
1980
+ * - Dynamic: This type of body is affected by gravity and velocity.
1981
+ * - Static: This type of body is immovable, is unaffected by velocity and gravity.
1982
+ * @public
1983
+ */
1138
1984
  type: RigidBodyType;
1985
+ /**
1986
+ * Velocity applied to the x-axis and y-axis expressed in pixels per second. Only for Dynamic bodies
1987
+ * @public
1988
+ */
1139
1989
  velocity: Vector2;
1990
+ /**
1991
+ * Gravity expressed in pixels per second squared. Only for Dynamic bodies
1992
+ * @public
1993
+ */
1140
1994
  gravity: number;
1995
+ /**
1996
+ * Acceleration expressed in pixels per second squared. Only for Dynamic bodies
1997
+ * @public
1998
+ */
1141
1999
  acceleration: Vector2;
1142
2000
  constructor(options?: Partial<RigidBodyOptions>);
1143
2001
  }
1144
2002
 
2003
+ /**
2004
+ * Configuration object for TilemapCollider creation
2005
+ * @public
2006
+ * @category Components
2007
+ * @example
2008
+ * ```js
2009
+ * const tilemapCollider = new TilemapCollider({
2010
+ * composite: true,
2011
+ * offset: new Vector2(),
2012
+ * layer: "CollisionLayer",
2013
+ * physics: true,
2014
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
2015
+ * });
2016
+ * ```
2017
+ */
1145
2018
  interface TilemapColliderOptions {
1146
2019
  /** Generate colliders that represent the outer lines of the tile map */
1147
2020
  composite: boolean;
@@ -1154,6 +2027,22 @@ interface TilemapColliderOptions {
1154
2027
  /** TRUE if this collider interact with rigid bodies */
1155
2028
  physics: boolean;
1156
2029
  }
2030
+ /**
2031
+ * Generates rectangle colliders for the map edge tiles (or lines if composite is TRUE).\
2032
+ * **Limitations:** At the moment, it is not possible to modify the shape of the collider once it has been generated.
2033
+ * @public
2034
+ * @category Components
2035
+ * @example
2036
+ * ```js
2037
+ * const tilemapCollider = new TilemapCollider({
2038
+ * composite: true,
2039
+ * offset: new Vector2(),
2040
+ * layer: "CollisionLayer",
2041
+ * physics: true,
2042
+ * ignoreCollisionsWithLayer: ["IgnoredLayer"]
2043
+ * });
2044
+ * ```
2045
+ */
1157
2046
  declare class TilemapCollider implements Collider {
1158
2047
  /** Generate colliders that represent the outer lines of the tile map */
1159
2048
  composite: boolean;
@@ -1218,10 +2107,27 @@ interface ShadowRenderData extends RenderData {
1218
2107
  width: number;
1219
2108
  lights: Light[];
1220
2109
  }
2110
+ /**
2111
+ * Represents a light source
2112
+ * @internal
2113
+ * @example
2114
+ * ```js
2115
+ * const light = {
2116
+ * position: new Vector2(10, 10),
2117
+ * radius: 32,
2118
+ * smooth: true,
2119
+ * intensity: 0.7,
2120
+ * }
2121
+ * ```
2122
+ */
1221
2123
  interface Light {
2124
+ /** The position of the light source */
1222
2125
  position: Vector2;
2126
+ /** The radius of the light source */
1223
2127
  radius: number;
2128
+ /** If it's TRUE the light will gradually disappear away from the origin point, if FALSE the light will be constant over its entire area. */
1224
2129
  smooth: boolean;
2130
+ /** The intensity of the light, between 0 and 1 */
1225
2131
  intensity: number;
1226
2132
  }
1227
2133
 
@@ -1340,6 +2246,11 @@ interface VideoRenderData extends RenderData {
1340
2246
  tintColor?: string;
1341
2247
  }
1342
2248
 
2249
+ /**
2250
+ * Default render layer
2251
+ * @public
2252
+ * @category Components
2253
+ */
1343
2254
  declare const defaultRenderLayer = "Default";
1344
2255
  /**
1345
2256
  * @public
@@ -1964,6 +2875,7 @@ declare class GamepadController {
1964
2875
  */
1965
2876
  vibrate(duration?: number, weakMagnitude?: number, strongMagnitude?: number, startDelay?: number): void;
1966
2877
  }
2878
+ /** @internal */
1967
2879
  type VibrationInput = {
1968
2880
  duration: number;
1969
2881
  weakMagnitude: number;
@@ -2124,10 +3036,19 @@ declare class TouchScreen {
2124
3036
  interactions: TouchInteraction[];
2125
3037
  }
2126
3038
 
3039
+ /**
3040
+ * Manages the input sources: Keyboard, Mouse, Gamepad, TouchScreen.
3041
+ * @public
3042
+ * @category Managers
3043
+ */
2127
3044
  declare class InputManager {
3045
+ /** Manages mouse information. */
2128
3046
  readonly keyboard: Keyboard;
3047
+ /** Manages keyboard information. */
2129
3048
  readonly mouse: Mouse;
3049
+ /** Manages touch screen information. */
2130
3050
  readonly touchScreen: TouchScreen;
3051
+ /** Manages gamepads information. */
2131
3052
  readonly gamepads: GamepadController[];
2132
3053
  constructor();
2133
3054
  }
@@ -2189,6 +3110,20 @@ declare class TimeManager {
2189
3110
  updateForPhysics(time: number): void;
2190
3111
  }
2191
3112
 
3113
+ /**
3114
+ * Abstract class which can be used to create Systems.\
3115
+ * It includes the following dependencies: EntityManager, AssetManager, SceneManager, TimeManager, InputManager, CollisionRepository.
3116
+ * @public
3117
+ * @category Core
3118
+ * @example
3119
+ * ```javascript
3120
+ * class SomeSystem extends GameSystem {
3121
+ * onUpdate() {
3122
+ * const result = this.entityManager.search(SomeComponent);
3123
+ * }
3124
+ * }
3125
+ * ```
3126
+ */
2192
3127
  declare abstract class GameSystem implements System {
2193
3128
  protected readonly entityManager: EntityManager;
2194
3129
  protected readonly assetManager: AssetManager;
@@ -2199,10 +3134,48 @@ declare abstract class GameSystem implements System {
2199
3134
  onUpdate(): void;
2200
3135
  }
2201
3136
 
3137
+ /**
3138
+ * Decorator to indicate that the target system will run in the game logic loop.
3139
+ * @public
3140
+ * @category Decorators
3141
+ * @example
3142
+ * ```typescript
3143
+ * @gameLogicSystem()
3144
+ * class SomeSystem {
3145
+ * }
3146
+ * ```
3147
+ */
2202
3148
  declare function gameLogicSystem(): (target: SystemType) => void;
3149
+ /**
3150
+ * Decorator to indicate that the target system will run in the physics loop.
3151
+ * @public
3152
+ * @category Decorators
3153
+ * @example
3154
+ * ```typescript
3155
+ * @gamePhysicsSystem()
3156
+ * class SomeSystem {
3157
+ * }
3158
+ * ```
3159
+ */
2203
3160
  declare function gamePhysicsSystem(): (target: SystemType) => void;
3161
+ /**
3162
+ * Decorator to indicate that the target system will be executed at the begining of the render loop.
3163
+ * @public
3164
+ * @category Decorators
3165
+ * @example
3166
+ * ```typescript
3167
+ * @gamePreRenderSystem()
3168
+ * class SomeSystem {
3169
+ * }
3170
+ * ```
3171
+ */
2204
3172
  declare function gamePreRenderSystem(): (target: SystemType) => void;
2205
3173
 
3174
+ /**
3175
+ * Symbols to be used as dependency identifiers
3176
+ * @public
3177
+ * @category Config
3178
+ */
2206
3179
  declare const Symbols: {
2207
3180
  AssetManager: symbol;
2208
3181
  CanvasElement: symbol;
@@ -2215,4 +3188,4 @@ declare const Symbols: {
2215
3188
  TimeManager: symbol;
2216
3189
  };
2217
3190
 
2218
- export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, Keyboard, type Light, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, defaultRenderLayer, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, randomFloat, randomInt, range };
3191
+ export { Animation, type AnimationSlice, Animator, type AnimatorOptions, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, Children, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, InputManager, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, Parent, Polygon, PolygonCollider, type PolygonColliderOptions, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, Symbols, type System, type SystemGroup, SystemManager, type SystemType, TextOrientation, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, defaultRenderLayer, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, randomFloat, randomInt, range };