dacha 0.16.0 → 0.17.0

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.
Files changed (134) hide show
  1. package/build/contrib/components/animatable/index.d.ts +26 -0
  2. package/build/contrib/components/animatable/index.js +28 -3
  3. package/build/contrib/components/audio-source/index.d.ts +35 -0
  4. package/build/contrib/components/audio-source/index.js +35 -0
  5. package/build/contrib/components/behaviors/index.d.ts +19 -0
  6. package/build/contrib/components/behaviors/index.js +23 -1
  7. package/build/contrib/components/bitmap-text/index.d.ts +46 -0
  8. package/build/contrib/components/bitmap-text/index.js +46 -0
  9. package/build/contrib/components/camera/index.d.ts +23 -0
  10. package/build/contrib/components/camera/index.js +23 -0
  11. package/build/contrib/components/collider/index.d.ts +31 -0
  12. package/build/contrib/components/collider/index.js +31 -0
  13. package/build/contrib/components/keyboard-control/index.d.ts +39 -0
  14. package/build/contrib/components/keyboard-control/index.js +39 -0
  15. package/build/contrib/components/mouse-control/index.d.ts +50 -0
  16. package/build/contrib/components/mouse-control/index.js +50 -0
  17. package/build/contrib/components/pixi-view/index.d.ts +38 -0
  18. package/build/contrib/components/pixi-view/index.js +38 -0
  19. package/build/contrib/components/rigid-body/index.d.ts +37 -0
  20. package/build/contrib/components/rigid-body/index.js +37 -0
  21. package/build/contrib/components/shape/index.d.ts +61 -0
  22. package/build/contrib/components/shape/index.js +61 -0
  23. package/build/contrib/components/sprite/index.d.ts +55 -2
  24. package/build/contrib/components/sprite/index.js +55 -3
  25. package/build/contrib/components/transform/index.d.ts +87 -20
  26. package/build/contrib/components/transform/index.js +131 -53
  27. package/build/contrib/components/transform/local-point.d.ts +11 -0
  28. package/build/contrib/components/transform/local-point.js +24 -0
  29. package/build/contrib/components/transform/local-transform.d.ts +25 -0
  30. package/build/contrib/components/transform/local-transform.js +39 -0
  31. package/build/contrib/components/transform/world-position.d.ts +9 -0
  32. package/build/contrib/components/transform/world-position.js +42 -0
  33. package/build/contrib/components/transform/world-scale.d.ts +9 -0
  34. package/build/contrib/components/transform/world-scale.js +34 -0
  35. package/build/contrib/components/transform/world-transform.d.ts +25 -0
  36. package/build/contrib/components/transform/world-transform.js +45 -0
  37. package/build/contrib/events/index.d.ts +173 -0
  38. package/build/contrib/events/index.js +104 -0
  39. package/build/contrib/systems/animator/index.d.ts +8 -0
  40. package/build/contrib/systems/animator/index.js +8 -0
  41. package/build/contrib/systems/audio-system/index.d.ts +7 -0
  42. package/build/contrib/systems/audio-system/index.js +7 -0
  43. package/build/contrib/systems/behavior-system/system.d.ts +9 -1
  44. package/build/contrib/systems/behavior-system/system.js +22 -11
  45. package/build/contrib/systems/behavior-system/types.d.ts +24 -0
  46. package/build/contrib/systems/behavior-system/types.js +7 -0
  47. package/build/contrib/systems/camera-system/service.d.ts +7 -0
  48. package/build/contrib/systems/camera-system/service.js +7 -0
  49. package/build/contrib/systems/camera-system/system.d.ts +7 -0
  50. package/build/contrib/systems/camera-system/system.js +7 -0
  51. package/build/contrib/systems/game-stats-meter/index.d.ts +10 -0
  52. package/build/contrib/systems/game-stats-meter/index.js +10 -0
  53. package/build/contrib/systems/keyboard-control-system/index.d.ts +10 -0
  54. package/build/contrib/systems/keyboard-control-system/index.js +10 -0
  55. package/build/contrib/systems/keyboard-input-system/index.d.ts +10 -0
  56. package/build/contrib/systems/keyboard-input-system/index.js +14 -2
  57. package/build/contrib/systems/mouse-control-system/index.d.ts +10 -0
  58. package/build/contrib/systems/mouse-control-system/index.js +10 -0
  59. package/build/contrib/systems/mouse-input-system/index.d.ts +11 -0
  60. package/build/contrib/systems/mouse-input-system/index.js +12 -1
  61. package/build/contrib/systems/physics-system/index.d.ts +9 -0
  62. package/build/contrib/systems/physics-system/index.js +9 -0
  63. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-box-geometry.js +9 -10
  64. package/build/contrib/systems/physics-system/subsystems/collision-detection/geometry-builders/build-circle-geometry.js +4 -4
  65. package/build/contrib/systems/physics-system/subsystems/collision-detection/index.js +5 -5
  66. package/build/contrib/systems/physics-system/subsystems/collision-detection/reorientation-checkers/check-transform.js +5 -5
  67. package/build/contrib/systems/physics-system/subsystems/collision-detection/types.d.ts +2 -2
  68. package/build/contrib/systems/physics-system/subsystems/constraint-solver/index.js +4 -4
  69. package/build/contrib/systems/physics-system/subsystems/physics/index.js +2 -2
  70. package/build/contrib/systems/renderer/actor-render-tree.d.ts +33 -0
  71. package/build/contrib/systems/renderer/actor-render-tree.js +188 -0
  72. package/build/contrib/systems/renderer/assets/index.d.ts +20 -0
  73. package/build/contrib/systems/renderer/assets/index.js +104 -0
  74. package/build/contrib/systems/renderer/assets/utils.d.ts +5 -0
  75. package/build/contrib/systems/renderer/assets/utils.js +42 -0
  76. package/build/contrib/systems/renderer/builders/bitmap-text-builder/index.d.ts +12 -4
  77. package/build/contrib/systems/renderer/builders/bitmap-text-builder/index.js +10 -51
  78. package/build/contrib/systems/renderer/builders/builder.d.ts +6 -4
  79. package/build/contrib/systems/renderer/builders/pixi-view-builder/index.d.ts +4 -3
  80. package/build/contrib/systems/renderer/builders/pixi-view-builder/index.js +2 -12
  81. package/build/contrib/systems/renderer/builders/shape-builder/index.d.ts +5 -4
  82. package/build/contrib/systems/renderer/builders/shape-builder/index.js +5 -45
  83. package/build/contrib/systems/renderer/builders/sprite-builder/index.d.ts +9 -8
  84. package/build/contrib/systems/renderer/builders/sprite-builder/index.js +12 -47
  85. package/build/contrib/systems/renderer/consts.d.ts +2 -0
  86. package/build/contrib/systems/renderer/consts.js +10 -0
  87. package/build/contrib/systems/renderer/renderer.d.ts +10 -12
  88. package/build/contrib/systems/renderer/renderer.js +37 -164
  89. package/build/contrib/systems/renderer/service/index.d.ts +43 -3
  90. package/build/contrib/systems/renderer/service/index.js +63 -14
  91. package/build/contrib/systems/renderer/service/utils.d.ts +3 -0
  92. package/build/contrib/systems/renderer/service/utils.js +14 -0
  93. package/build/contrib/systems/renderer/sort/sort-by-x-axis.js +2 -2
  94. package/build/contrib/systems/renderer/sort/sort-by-y-axis.js +2 -2
  95. package/build/contrib/systems/renderer/types.d.ts +4 -6
  96. package/build/contrib/systems/renderer/utils.d.ts +1 -5
  97. package/build/contrib/systems/renderer/utils.js +3 -41
  98. package/build/contrib/systems/ui-bridge/index.d.ts +11 -0
  99. package/build/contrib/systems/ui-bridge/index.js +11 -0
  100. package/build/contrib/utils/coordinates-projection.js +4 -4
  101. package/build/engine/actor/actor-query.d.ts +72 -0
  102. package/build/engine/actor/actor-query.js +57 -0
  103. package/build/engine/actor/actor.d.ts +71 -0
  104. package/build/engine/actor/actor.js +92 -4
  105. package/build/engine/component/component.js +5 -7
  106. package/build/engine/engine.d.ts +6 -0
  107. package/build/engine/engine.js +6 -0
  108. package/build/engine/entity/entity.d.ts +54 -0
  109. package/build/engine/entity/entity.js +48 -0
  110. package/build/engine/event-target/event-target.d.ts +47 -0
  111. package/build/engine/event-target/event-target.js +47 -0
  112. package/build/engine/event-target/types.d.ts +9 -0
  113. package/build/engine/events/index.d.ts +224 -2
  114. package/build/engine/events/index.js +112 -0
  115. package/build/engine/math-lib/index.d.ts +1 -0
  116. package/build/engine/math-lib/index.js +1 -0
  117. package/build/engine/math-lib/math/ops.d.ts +108 -0
  118. package/build/engine/math-lib/math/ops.js +91 -6
  119. package/build/engine/math-lib/matrix/index.d.ts +22 -0
  120. package/build/engine/math-lib/matrix/index.js +112 -0
  121. package/build/engine/math-lib/vector/ops.d.ts +98 -3
  122. package/build/engine/math-lib/vector/ops.js +89 -9
  123. package/build/engine/math-lib/vector/vector2.d.ts +33 -0
  124. package/build/engine/math-lib/vector/vector2.js +33 -0
  125. package/build/engine/scene/scene.d.ts +22 -0
  126. package/build/engine/scene/scene.js +23 -2
  127. package/build/engine/system/system.d.ts +88 -0
  128. package/build/engine/system/system.js +52 -0
  129. package/build/engine/world/index.d.ts +27 -0
  130. package/build/engine/world/index.js +27 -0
  131. package/build/index.docs.d.ts +13 -0
  132. package/build/index.docs.js +13 -0
  133. package/build/types/global.d.ts +10 -4
  134. package/package.json +3 -1
@@ -3,10 +3,36 @@ import { IndividualState } from './individual-state';
3
3
  import { GroupState } from './group-state';
4
4
  import type { AnimatableConfig } from './types';
5
5
  export type { AnimatableConfig };
6
+ /**
7
+ * Animatable component for managing animations.
8
+ *
9
+ * It provides a state machine for an actor to manage its animations.
10
+ * Each state can have a set of transitions to other states,
11
+ * and each transition describes a set of conditions to check before the transition is triggered.
12
+ *
13
+ * State consists of a timeline of frames where each frame represents a snapshot of the actor's state.
14
+ * Frames allow to update any actor's component values.
15
+ * It can be used for example to update the sprite's current frame.
16
+ *
17
+ * In addition to individual states, it supports group states.
18
+ * Group states allow to avoid repeating the states with the same set of transitions,
19
+ * but slightly different frames.
20
+ * For instance, it can be used to describe a character state like "idle",
21
+ * "run" or "jump" from different angles.
22
+ *
23
+ * It is better to use an editor to create the animatable component
24
+ * since it has a quite complex structure.
25
+ *
26
+ * @category Components
27
+ */
6
28
  export declare class Animatable extends Component {
29
+ /** States of the animatable component */
7
30
  states: (IndividualState | GroupState)[];
31
+ /** Initial state of the animatable component */
8
32
  initialState: string;
33
+ /** Current state of the animatable component */
9
34
  currentState?: IndividualState | GroupState;
35
+ /** Duration of the current state relative to the total duration of the timeline */
10
36
  duration: number;
11
37
  constructor(config: AnimatableConfig);
12
38
  setCurrentState(currentState: string): void;
@@ -1,16 +1,41 @@
1
1
  import { Component } from '../../../engine/component';
2
2
  import { IndividualState } from './individual-state';
3
3
  import { GroupState } from './group-state';
4
+ /**
5
+ * Animatable component for managing animations.
6
+ *
7
+ * It provides a state machine for an actor to manage its animations.
8
+ * Each state can have a set of transitions to other states,
9
+ * and each transition describes a set of conditions to check before the transition is triggered.
10
+ *
11
+ * State consists of a timeline of frames where each frame represents a snapshot of the actor's state.
12
+ * Frames allow to update any actor's component values.
13
+ * It can be used for example to update the sprite's current frame.
14
+ *
15
+ * In addition to individual states, it supports group states.
16
+ * Group states allow to avoid repeating the states with the same set of transitions,
17
+ * but slightly different frames.
18
+ * For instance, it can be used to describe a character state like "idle",
19
+ * "run" or "jump" from different angles.
20
+ *
21
+ * It is better to use an editor to create the animatable component
22
+ * since it has a quite complex structure.
23
+ *
24
+ * @category Components
25
+ */
4
26
  export class Animatable extends Component {
27
+ /** States of the animatable component */
5
28
  states;
29
+ /** Initial state of the animatable component */
6
30
  initialState;
31
+ /** Current state of the animatable component */
7
32
  currentState;
33
+ /** Duration of the current state relative to the total duration of the timeline */
8
34
  duration;
9
35
  constructor(config) {
10
36
  super();
11
- const { initialState, states = [], } = config;
12
- this.states = states
13
- .reduce((acc, state) => {
37
+ const { initialState, states = [] } = config;
38
+ this.states = states.reduce((acc, state) => {
14
39
  const { type } = state;
15
40
  if (type === 'individual') {
16
41
  acc.push(new IndividualState(state));
@@ -6,12 +6,47 @@ export interface AudioSourceConfig {
6
6
  volume: number;
7
7
  autoplay: boolean;
8
8
  }
9
+ /**
10
+ * AudioSource component for playing audio.
11
+ *
12
+ * It handles the playing of audio for an actor.
13
+ * It allows to play audio files and control the volume and looping of the audio.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Create an audio source
18
+ * const audioSource = new AudioSource({
19
+ * src: 'assets/audio/some-sound.mp3',
20
+ * group: 'master',
21
+ * looped: false,
22
+ * volume: 1,
23
+ * autoplay: false,
24
+ * });
25
+ *
26
+ * // Add to actor
27
+ * actor.setComponent(audioSource);
28
+ *
29
+ * // Modify properties
30
+ * audioSource.volume = 0.5; // Set volume to 50%
31
+ *
32
+ * // Play the audio
33
+ * actor.dispatchEvent(PlayAudio);
34
+ * ```
35
+ *
36
+ * @category Components
37
+ */
9
38
  export declare class AudioSource extends Component {
39
+ /** Path to the audio asset */
10
40
  src: string;
41
+ /** Group of the audio, used to combine audio sources together and control them at once */
11
42
  group: string;
43
+ /** Whether the audio is looped */
12
44
  looped: boolean;
45
+ /** Volume of the audio, from 0 to 1 */
13
46
  volume: number;
47
+ /** Whether the audio is autoplayed on scene enter or after actor is added to scene */
14
48
  autoplay: boolean;
49
+ /** Whether the audio is playing now */
15
50
  playing: boolean;
16
51
  constructor(config: AudioSourceConfig);
17
52
  clone(): AudioSource;
@@ -1,10 +1,45 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * AudioSource component for playing audio.
4
+ *
5
+ * It handles the playing of audio for an actor.
6
+ * It allows to play audio files and control the volume and looping of the audio.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create an audio source
11
+ * const audioSource = new AudioSource({
12
+ * src: 'assets/audio/some-sound.mp3',
13
+ * group: 'master',
14
+ * looped: false,
15
+ * volume: 1,
16
+ * autoplay: false,
17
+ * });
18
+ *
19
+ * // Add to actor
20
+ * actor.setComponent(audioSource);
21
+ *
22
+ * // Modify properties
23
+ * audioSource.volume = 0.5; // Set volume to 50%
24
+ *
25
+ * // Play the audio
26
+ * actor.dispatchEvent(PlayAudio);
27
+ * ```
28
+ *
29
+ * @category Components
30
+ */
2
31
  export class AudioSource extends Component {
32
+ /** Path to the audio asset */
3
33
  src;
34
+ /** Group of the audio, used to combine audio sources together and control them at once */
4
35
  group;
36
+ /** Whether the audio is looped */
5
37
  looped;
38
+ /** Volume of the audio, from 0 to 1 */
6
39
  volume;
40
+ /** Whether the audio is autoplayed on scene enter or after actor is added to scene */
7
41
  autoplay;
42
+ /** Whether the audio is playing now */
8
43
  playing;
9
44
  constructor(config) {
10
45
  super();
@@ -6,6 +6,25 @@ interface BehaviorConfig {
6
6
  export interface BehaviorsConfig {
7
7
  list: BehaviorConfig[];
8
8
  }
9
+ /**
10
+ * Behaviors component for managing a list of behaviors.
11
+ *
12
+ * Behavior is a script that allows to add custom game logic to an actor,
13
+ * such as movement, AI or any other custom logic.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Create a behaviors component
18
+ * const behaviors = new Behaviors({
19
+ * list: [{ name: 'some-script', options: {} }],
20
+ * });
21
+ *
22
+ * // Add to actor
23
+ * actor.setComponent(behaviors);
24
+ * ```
25
+ *
26
+ * @category Components
27
+ */
9
28
  export declare class Behaviors extends Component {
10
29
  list: BehaviorConfig[];
11
30
  constructor(config: BehaviorsConfig);
@@ -1,4 +1,23 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * Behaviors component for managing a list of behaviors.
4
+ *
5
+ * Behavior is a script that allows to add custom game logic to an actor,
6
+ * such as movement, AI or any other custom logic.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a behaviors component
11
+ * const behaviors = new Behaviors({
12
+ * list: [{ name: 'some-script', options: {} }],
13
+ * });
14
+ *
15
+ * // Add to actor
16
+ * actor.setComponent(behaviors);
17
+ * ```
18
+ *
19
+ * @category Components
20
+ */
2
21
  export class Behaviors extends Component {
3
22
  list;
4
23
  constructor(config) {
@@ -8,7 +27,10 @@ export class Behaviors extends Component {
8
27
  }
9
28
  clone() {
10
29
  return new Behaviors({
11
- list: this.list.map(({ name, options }) => ({ name, options: { ...options } })),
30
+ list: this.list.map(({ name, options }) => ({
31
+ name,
32
+ options: { ...options },
33
+ })),
12
34
  });
13
35
  }
14
36
  }
@@ -18,17 +18,63 @@ export interface BitmapTextConfig {
18
18
  sortingLayer: string;
19
19
  sortCenter: [number, number];
20
20
  }
21
+ /**
22
+ * BitmapText component for rendering text using a bitmap font.
23
+ *
24
+ * It handles text representation of an actor using a bitmap font.
25
+ * It uses an asset file in the format of a bitmap font (.fnt and .xml are supported) to render text.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Create a bitmap text
30
+ * const bitmapText = new BitmapText({
31
+ * text: 'Greetings traveller!',
32
+ * font: 'assets/fonts/some-pixel-font.fnt',
33
+ * fontSize: 24,
34
+ * align: 'center',
35
+ * color: '#000',
36
+ * opacity: 1,
37
+ * blending: 'normal',
38
+ * disabled: false,
39
+ * sortingLayer: 'text',
40
+ * sortCenter: [0, 0],
41
+ * });
42
+ *
43
+ * // Add to actor
44
+ * actor.setComponent(bitmapText);
45
+ *
46
+ * // Modify properties
47
+ * bitmapText.text = 'Stay a while and listen!';
48
+ * ```
49
+ *
50
+ * @category Components
51
+ */
21
52
  export declare class BitmapText extends Component {
53
+ /** Text to render */
22
54
  text: string;
55
+ /** Path to the font asset */
23
56
  font: string;
57
+ /** Size of the text */
24
58
  fontSize: number;
59
+ /** Alignment of the text
60
+ * - left - Align text to the left edge
61
+ * - center - Center text horizontally
62
+ * - right - Align text to the right edge
63
+ */
25
64
  align: TextAlign;
65
+ /** Color of the text */
26
66
  color: string;
67
+ /** Opacity of the text */
27
68
  opacity: number;
69
+ /** Blending mode of the text */
28
70
  blending: BlendingMode;
71
+ /** Whether the text is disabled */
29
72
  disabled: boolean;
73
+ /** Sorting layer of the text */
30
74
  sortingLayer: string;
75
+ /** Center point of the text */
31
76
  sortCenter: [number, number];
77
+ /** Internal rendering data */
32
78
  renderData?: RenderData;
33
79
  constructor(config: BitmapTextConfig);
34
80
  clone(): BitmapText;
@@ -1,15 +1,61 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * BitmapText component for rendering text using a bitmap font.
4
+ *
5
+ * It handles text representation of an actor using a bitmap font.
6
+ * It uses an asset file in the format of a bitmap font (.fnt and .xml are supported) to render text.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a bitmap text
11
+ * const bitmapText = new BitmapText({
12
+ * text: 'Greetings traveller!',
13
+ * font: 'assets/fonts/some-pixel-font.fnt',
14
+ * fontSize: 24,
15
+ * align: 'center',
16
+ * color: '#000',
17
+ * opacity: 1,
18
+ * blending: 'normal',
19
+ * disabled: false,
20
+ * sortingLayer: 'text',
21
+ * sortCenter: [0, 0],
22
+ * });
23
+ *
24
+ * // Add to actor
25
+ * actor.setComponent(bitmapText);
26
+ *
27
+ * // Modify properties
28
+ * bitmapText.text = 'Stay a while and listen!';
29
+ * ```
30
+ *
31
+ * @category Components
32
+ */
2
33
  export class BitmapText extends Component {
34
+ /** Text to render */
3
35
  text;
36
+ /** Path to the font asset */
4
37
  font;
38
+ /** Size of the text */
5
39
  fontSize;
40
+ /** Alignment of the text
41
+ * - left - Align text to the left edge
42
+ * - center - Center text horizontally
43
+ * - right - Align text to the right edge
44
+ */
6
45
  align;
46
+ /** Color of the text */
7
47
  color;
48
+ /** Opacity of the text */
8
49
  opacity;
50
+ /** Blending mode of the text */
9
51
  blending;
52
+ /** Whether the text is disabled */
10
53
  disabled;
54
+ /** Sorting layer of the text */
11
55
  sortingLayer;
56
+ /** Center point of the text */
12
57
  sortCenter;
58
+ /** Internal rendering data */
13
59
  renderData;
14
60
  constructor(config) {
15
61
  super();
@@ -3,10 +3,33 @@ export interface CameraConfig {
3
3
  zoom: number;
4
4
  current: boolean;
5
5
  }
6
+ /**
7
+ * Camera component for defining how a scene should be viewed.
8
+ *
9
+ * Camera component marks an actor as the possible camera to view the scene.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Create a camera
14
+ * const camera = new Camera({
15
+ * zoom: 2,
16
+ * current: true,
17
+ * });
18
+ * ```
19
+ *
20
+ * // Add to actor
21
+ * actor.setComponent(camera);
22
+ *
23
+ * @category Components
24
+ */
6
25
  export declare class Camera extends Component {
26
+ /** Zoom of the camera */
7
27
  zoom: number;
28
+ /** Whether the camera is the current camera. Only one camera can be the current camera. */
8
29
  current: boolean;
30
+ /** Size of the game window in the x axis in pixels */
9
31
  windowSizeX: number;
32
+ /** Size of the game window in the y axis in pixels */
10
33
  windowSizeY: number;
11
34
  constructor(config: CameraConfig);
12
35
  clone(): Camera;
@@ -1,8 +1,31 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * Camera component for defining how a scene should be viewed.
4
+ *
5
+ * Camera component marks an actor as the possible camera to view the scene.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Create a camera
10
+ * const camera = new Camera({
11
+ * zoom: 2,
12
+ * current: true,
13
+ * });
14
+ * ```
15
+ *
16
+ * // Add to actor
17
+ * actor.setComponent(camera);
18
+ *
19
+ * @category Components
20
+ */
2
21
  export class Camera extends Component {
22
+ /** Zoom of the camera */
3
23
  zoom;
24
+ /** Whether the camera is the current camera. Only one camera can be the current camera. */
4
25
  current;
26
+ /** Size of the game window in the x axis in pixels */
5
27
  windowSizeX;
28
+ /** Size of the game window in the y axis in pixels */
6
29
  windowSizeY;
7
30
  constructor(config) {
8
31
  super();
@@ -7,6 +7,37 @@ export interface ColliderConfig {
7
7
  sizeY?: number;
8
8
  radius?: number;
9
9
  }
10
+ /**
11
+ * Collider component for defining collision boundaries.
12
+ *
13
+ * Collider component defines the collision shape for an actor. It's used by the
14
+ * physics system to detect collisions between actors.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * // Create a box collider
19
+ * const boxCollider = new Collider({
20
+ * type: 'box',
21
+ * centerX: 0,
22
+ * centerY: 0,
23
+ * sizeX: 64,
24
+ * sizeY: 64
25
+ * });
26
+ *
27
+ * // Create a circle collider
28
+ * const circleCollider = new Collider({
29
+ * type: 'circle',
30
+ * centerX: 0,
31
+ * centerY: 0,
32
+ * radius: 32
33
+ * });
34
+ *
35
+ * // Add to actor
36
+ * actor.setComponent(boxCollider);
37
+ * ```
38
+ *
39
+ * @category Components
40
+ */
10
41
  export declare class Collider extends Component {
11
42
  type: 'box' | 'circle';
12
43
  centerX: number;
@@ -1,4 +1,35 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * Collider component for defining collision boundaries.
4
+ *
5
+ * Collider component defines the collision shape for an actor. It's used by the
6
+ * physics system to detect collisions between actors.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a box collider
11
+ * const boxCollider = new Collider({
12
+ * type: 'box',
13
+ * centerX: 0,
14
+ * centerY: 0,
15
+ * sizeX: 64,
16
+ * sizeY: 64
17
+ * });
18
+ *
19
+ * // Create a circle collider
20
+ * const circleCollider = new Collider({
21
+ * type: 'circle',
22
+ * centerX: 0,
23
+ * centerY: 0,
24
+ * radius: 32
25
+ * });
26
+ *
27
+ * // Add to actor
28
+ * actor.setComponent(boxCollider);
29
+ * ```
30
+ *
31
+ * @category Components
32
+ */
2
33
  export class Collider extends Component {
3
34
  type;
4
35
  centerX;
@@ -19,8 +19,47 @@ export interface KeyboardEventBindConfig {
19
19
  export interface KeyboardControlConfig extends Record<string, unknown> {
20
20
  inputEventBindings: KeyboardEventBindConfig[];
21
21
  }
22
+ /**
23
+ * KeyboardControl component for handling keyboard input events.
24
+ *
25
+ * KeyboardControl component handles the keyboard input events for an actor.
26
+ * It can be used to bind keyboard events to game actions.
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Create a keyboard control
31
+ * const keyboardControl = new KeyboardControl({
32
+ * inputEventBindings: [
33
+ * {
34
+ * key: 'KeyW',
35
+ * pressed: true,
36
+ * keepEmit: true,
37
+ * eventType: 'RUN',
38
+ * attrs: [
39
+ * {
40
+ * name: 'angle',
41
+ * type: 'number',
42
+ * value: 270,
43
+ * },
44
+ * ],
45
+ * },
46
+ * ],
47
+ * });
48
+ *
49
+ * // Add to actor
50
+ * actor.setComponent(keyboardControl);
51
+ * ```
52
+ *
53
+ * @category Components
54
+ */
22
55
  export declare class KeyboardControl extends Component {
56
+ /** Input event bindings */
23
57
  inputEventBindings: InputEventBindings;
58
+ /**
59
+ * Creates a new KeyboardControl component.
60
+ *
61
+ * @param config - Configuration for the keyboard control
62
+ */
24
63
  constructor(config: KeyboardControlConfig);
25
64
  clone(): KeyboardControl;
26
65
  }
@@ -1,6 +1,45 @@
1
1
  import { Component } from '../../../engine/component';
2
+ /**
3
+ * KeyboardControl component for handling keyboard input events.
4
+ *
5
+ * KeyboardControl component handles the keyboard input events for an actor.
6
+ * It can be used to bind keyboard events to game actions.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Create a keyboard control
11
+ * const keyboardControl = new KeyboardControl({
12
+ * inputEventBindings: [
13
+ * {
14
+ * key: 'KeyW',
15
+ * pressed: true,
16
+ * keepEmit: true,
17
+ * eventType: 'RUN',
18
+ * attrs: [
19
+ * {
20
+ * name: 'angle',
21
+ * type: 'number',
22
+ * value: 270,
23
+ * },
24
+ * ],
25
+ * },
26
+ * ],
27
+ * });
28
+ *
29
+ * // Add to actor
30
+ * actor.setComponent(keyboardControl);
31
+ * ```
32
+ *
33
+ * @category Components
34
+ */
2
35
  export class KeyboardControl extends Component {
36
+ /** Input event bindings */
3
37
  inputEventBindings;
38
+ /**
39
+ * Creates a new KeyboardControl component.
40
+ *
41
+ * @param config - Configuration for the keyboard control
42
+ */
4
43
  constructor(config) {
5
44
  super();
6
45
  const { inputEventBindings } = config;
@@ -14,8 +14,58 @@ export interface MouseEventBindConfig {
14
14
  export interface MouseControlConfig {
15
15
  inputEventBindings: MouseEventBindConfig[];
16
16
  }
17
+ /**
18
+ * MouseControl component for handling mouse input events.
19
+ *
20
+ * Handles the mouse input events for an actor.
21
+ * It can be used to bind mouse events to game actions.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // Create a mouse control
26
+ * const mouseControl = new MouseControl({
27
+ * inputEventBindings: [
28
+ * {
29
+ * event: 'mousedown',
30
+ * button: 0,
31
+ * eventType: 'ATTACK',
32
+ * attrs: [
33
+ * {
34
+ * name: 'type',
35
+ * type: 'string',
36
+ * value: 'lightAttack',
37
+ * },
38
+ * ],
39
+ * },
40
+ * {
41
+ * event: 'mousedown',
42
+ * button: 2,
43
+ * eventType: 'ATTACK',
44
+ * attrs: [
45
+ * {
46
+ * name: 'type',
47
+ * type: 'string',
48
+ * value: 'heavyAttack',
49
+ * },
50
+ * ],
51
+ * },
52
+ * ],
53
+ * });
54
+ *
55
+ * // Add to actor
56
+ * actor.setComponent(mouseControl);
57
+ * ```
58
+ *
59
+ * @category Components
60
+ */
17
61
  export declare class MouseControl extends Component {
62
+ /** Input event bindings */
18
63
  inputEventBindings: InputEventBindings;
64
+ /**
65
+ * Creates a new MouseControl component.
66
+ *
67
+ * @param config - Configuration for the mouse control
68
+ */
19
69
  constructor(config: MouseControlConfig);
20
70
  clone(): MouseControl;
21
71
  }