angry-pixel 1.0.9 → 1.1.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.
Files changed (90) hide show
  1. package/lib/component/Animator.d.ts +4 -3
  2. package/lib/component/AudioPlayer.d.ts +6 -7
  3. package/lib/component/Camera.d.ts +1 -2
  4. package/lib/component/ComponentTypes.d.ts +3 -0
  5. package/lib/component/RigidBody.d.ts +12 -28
  6. package/lib/component/RigidBodyOld.d.ts +39 -0
  7. package/lib/component/Transform.d.ts +4 -5
  8. package/lib/component/collider/BallCollider.d.ts +27 -0
  9. package/lib/component/collider/BoxCollider.d.ts +35 -0
  10. package/lib/component/collider/Collider.d.ts +27 -0
  11. package/lib/component/collider/EdgeCollider.d.ts +34 -0
  12. package/lib/component/collider/PolygonCollider.d.ts +34 -0
  13. package/lib/component/collider/TilemapCollider.d.ts +17 -0
  14. package/lib/component/colliderComponent/PolygonCollider.d.ts +32 -0
  15. package/lib/component/colliderComponent/TriangleCollider.d.ts +32 -0
  16. package/lib/component/rendering/MaskRenderer.d.ts +30 -0
  17. package/lib/component/rendering/SpriteRenderer.d.ts +47 -0
  18. package/lib/component/rendering/TextRenderer.d.ts +50 -0
  19. package/lib/component/rendering/tilemap/CsvTilemapRenderer.d.ts +13 -0
  20. package/lib/component/rendering/tilemap/Tile.d.ts +7 -0
  21. package/lib/component/rendering/tilemap/TileData.d.ts +10 -0
  22. package/lib/component/rendering/tilemap/TiledTilemapRenderer.d.ts +48 -0
  23. package/lib/component/rendering/tilemap/TilemapRenderer.d.ts +74 -0
  24. package/lib/component/rendering/tilemap/Tileset.d.ts +25 -0
  25. package/lib/core/Component.d.ts +43 -88
  26. package/lib/core/Game.d.ts +10 -22
  27. package/lib/core/GameActor.d.ts +66 -0
  28. package/lib/core/GameObject.d.ts +57 -105
  29. package/lib/core/Scene.d.ts +6 -63
  30. package/lib/core/facades/GameObjectManagerFacade.d.ts +35 -25
  31. package/lib/core/facades/TimeManagerFacade.d.ts +1 -0
  32. package/lib/core/managers/GameObjectManager.d.ts +12 -11
  33. package/lib/core/managers/IterationManager copy.d.ts +42 -0
  34. package/lib/core/managers/IterationManager.d.ts +34 -16
  35. package/lib/core/managers/IterationManagerOld.d.ts +42 -0
  36. package/lib/core/managers/SceneManager.d.ts +5 -2
  37. package/lib/core/managers/TimeManager.d.ts +14 -8
  38. package/lib/gameObject/GameCamera.d.ts +2 -2
  39. package/lib/index.cjs.js +1 -1
  40. package/lib/index.d.ts +16 -13
  41. package/lib/index.esm.js +1 -1
  42. package/lib/index.js +1 -1
  43. package/lib/input/GamepadController.d.ts +17 -5
  44. package/lib/math/Rotation.d.ts +1 -4
  45. package/lib/math/Utils.d.ts +8 -2
  46. package/lib/physics/PhysicsManager.d.ts +24 -0
  47. package/lib/physics/PhysicsManagerOld2.d.ts +34 -0
  48. package/lib/physics/collision/ColliderData.d.ts +15 -0
  49. package/lib/physics/collision/CollisionManager.d.ts +21 -13
  50. package/lib/physics/collision/CollisionManagerOld.d.ts +27 -0
  51. package/lib/physics/collision/QuadTree.d.ts +16 -11
  52. package/lib/physics/collision/method/AABBMethod.d.ts +13 -0
  53. package/lib/physics/collision/method/CollisionMethod.d.ts +5 -0
  54. package/lib/physics/collision/method/SatMethod.d.ts +11 -0
  55. package/lib/physics/collision/resolver/AABBResolver.d.ts +5 -8
  56. package/lib/physics/collision/resolver/CircumferenceAABBResolver.d.ts +9 -0
  57. package/lib/physics/collision/resolver/CircumferenceCircumferenceResolver.d.ts +7 -0
  58. package/lib/physics/collision/resolver/CircumferencePolygonResolver.d.ts +23 -0
  59. package/lib/physics/collision/resolver/CircumferenceRectangleResolver.d.ts +9 -0
  60. package/lib/physics/collision/resolver/CircumferenceResolver.d.ts +7 -0
  61. package/lib/physics/collision/resolver/CollisionResolution.d.ts +6 -0
  62. package/lib/physics/collision/resolver/CollisionResolver.d.ts +10 -0
  63. package/lib/physics/collision/resolver/PolygonPolygonResolver.d.ts +15 -0
  64. package/lib/physics/collision/resolver/RectangleRectangleResolver.d.ts +11 -0
  65. package/lib/physics/collision/resolver/SatResolver.d.ts +10 -7
  66. package/lib/physics/collision/shape/Circumference.d.ts +18 -0
  67. package/lib/physics/collision/shape/Line.d.ts +19 -0
  68. package/lib/physics/collision/shape/Polygon.d.ts +31 -0
  69. package/lib/physics/collision/shape/Rectangle.d.ts +7 -11
  70. package/lib/physics/collision/shape/Shape.d.ts +13 -24
  71. package/lib/physics/collision-old/CollisionData.d.ts +8 -0
  72. package/lib/physics/collision-old/CollisionManager.d.ts +30 -0
  73. package/lib/physics/collision-old/QuadTree.d.ts +32 -0
  74. package/lib/physics/collision-old/collider/ICollider.d.ts +14 -0
  75. package/lib/physics/collision-old/collider/RectangleCollider.d.ts +32 -0
  76. package/lib/physics/collision-old/resolver/AABBResolver.d.ts +14 -0
  77. package/lib/physics/collision-old/resolver/ICollisionResolver.d.ts +5 -0
  78. package/lib/physics/collision-old/resolver/SatResolver.d.ts +14 -0
  79. package/lib/physics/collision-old/shape/Rectangle.d.ts +13 -0
  80. package/lib/physics/collision-old/shape/Shape.d.ts +28 -0
  81. package/lib/physics/rigodBody/RigidBodyData.d.ts +11 -0
  82. package/lib/physics/rigodBody/RigidBodyManager.d.ts +26 -0
  83. package/lib/rendering/CullingService.d.ts +0 -1
  84. package/lib/rendering/renderData/GeometricRenderData.d.ts +11 -6
  85. package/lib/rendering/renderData/RenderData.d.ts +3 -4
  86. package/lib/rendering/renderData/TextRenderData.d.ts +1 -1
  87. package/lib/rendering/renderData/TilemapRenderData.d.ts +7 -1
  88. package/lib/rendering/webGL/renderer/GeometricRenderer.d.ts +6 -7
  89. package/lib/rendering/webGL/renderer/MaskRenderer.d.ts +1 -1
  90. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ import { RenderComponent } from "../../../core/Component";
2
+ import { RenderManager } from "../../../rendering/RenderManager";
3
+ import { Vector2 } from "../../../math/Vector2";
4
+ import { Tileset } from "./Tileset";
5
+ import { TileData } from "./TileData";
6
+ import { Tile } from "./Tile";
7
+ import { TilemapRenderData, TileRenderData } from "../../../rendering/renderData/TilemapRenderData";
8
+ import { InitOptions } from "../../../core/GameActor";
9
+ export declare type Flip = {
10
+ h: boolean;
11
+ v: boolean;
12
+ };
13
+ export declare type Offset = {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ export declare type RenderOrder = "center" | "right-down" | "right-up" | "left-down" | "left-right";
18
+ export declare type LayerToProcess = {
19
+ layer: string;
20
+ alpha: number;
21
+ tintColor: string;
22
+ };
23
+ export declare type TileToProcess = {
24
+ layer: string;
25
+ tile: Tile;
26
+ col: number;
27
+ row: number;
28
+ flip: Flip;
29
+ offset: Offset;
30
+ };
31
+ export interface TilemapRendererOptions extends InitOptions {
32
+ tileset: Tileset;
33
+ renderOrder?: RenderOrder;
34
+ smooth?: boolean;
35
+ textureCorrection?: number;
36
+ tileScale?: Vector2;
37
+ }
38
+ export declare abstract class TilemapRenderer extends RenderComponent {
39
+ readonly allowMultiple: boolean;
40
+ tileset: Tileset;
41
+ renderOrder: RenderOrder;
42
+ smooth: boolean;
43
+ textureCorrection: number;
44
+ tileScale: Vector2;
45
+ protected tileWidth: number;
46
+ protected tileHeight: number;
47
+ protected orientation: Vector2;
48
+ protected renderManager: RenderManager;
49
+ protected tilemapProcessed: boolean;
50
+ protected renderData: Map<string, TilemapRenderData>;
51
+ private cols;
52
+ private rows;
53
+ protected _width: number;
54
+ protected _height: number;
55
+ protected tiles: TileData[];
56
+ protected _realWidth: number;
57
+ protected _realHeight: number;
58
+ private cacheV2;
59
+ protected init(config: TilemapRendererOptions): void;
60
+ protected start(): void;
61
+ protected update(): void;
62
+ protected abstract processTilemap(): void;
63
+ protected processLayer(data: LayerToProcess): void;
64
+ protected processTile(data: TileToProcess): void;
65
+ private addTileToRenderData;
66
+ private updateSizeInfo;
67
+ private updatePosition;
68
+ protected addTileData(tileRenderData: TileRenderData): void;
69
+ get width(): number;
70
+ get height(): number;
71
+ get realWidth(): number;
72
+ get realHeight(): number;
73
+ get tilesData(): TileData[];
74
+ }
@@ -0,0 +1,25 @@
1
+ import { Vector2 } from "../../../math/Vector2";
2
+ import { Tile } from "./Tile";
3
+ export interface TilesetConfig {
4
+ image: HTMLImageElement;
5
+ tileWidth: number;
6
+ tileHeight: number;
7
+ gridWidth: number;
8
+ gridHeight: number;
9
+ offset?: Vector2;
10
+ spacing?: Vector2;
11
+ }
12
+ export declare class Tileset {
13
+ image: HTMLImageElement;
14
+ tileWidth: number;
15
+ tileHeight: number;
16
+ gridWidth: number;
17
+ gridHeight: number;
18
+ offset: Vector2;
19
+ tileSpacing: Vector2;
20
+ private _tiles;
21
+ constructor(config: TilesetConfig);
22
+ private generateTiles;
23
+ getTile(index: number): Tile | null;
24
+ get tiles(): Tile[];
25
+ }
@@ -1,130 +1,85 @@
1
- import { GameObjectFactory } from "./managers/GameObjectManager";
2
1
  import { GameObject } from "./GameObject";
3
2
  import { Scene } from "./Scene";
4
- export declare abstract class Component {
5
- private sceneManager;
6
- private gameObjectManager;
3
+ import { FrameEvent } from "./managers/IterationManager";
4
+ import { GameActor } from "./GameActor";
5
+ export declare type ComponentClass<T extends Component = Component> = new (gameObject: GameObject, name?: string) => T;
6
+ export declare abstract class Component extends GameActor {
7
+ private readonly sceneManager;
7
8
  readonly id: string;
8
- allowMultiple: boolean;
9
- type: string;
10
- name: string;
11
- gameObject: GameObject;
9
+ readonly name: string;
10
+ readonly gameObject: GameObject;
11
+ readonly allowMultiple: boolean;
12
12
  private _active;
13
- private started;
14
- constructor();
15
- protected get updateEvent(): string;
13
+ constructor(gameObject: GameObject, name?: string);
16
14
  get active(): boolean;
15
+ set active(active: boolean);
17
16
  /**
18
- * If the component become inactive, will stop its execution
19
- *
20
- * @param active TRUE or FALSE
17
+ * This method is called when the active state changes.
21
18
  */
22
- setActive(active: boolean): void;
23
- protected gameLoopEventHandler: (event: Event) => void;
24
- /**
25
- * This method is only ever called once.
26
- * Recommended for GameObject cration.
27
- */
28
- init(): void;
29
- /**
30
- * This method is only ever called once
31
- */
32
- protected start(): void;
33
- /**
34
- * This method is called on every frame.
35
- */
36
- protected update(): void;
19
+ protected onActiveChange(): void;
37
20
  /**
38
21
  * @returns The current loaded scene
39
22
  */
40
23
  protected getCurrentScene<T extends Scene>(): T;
41
24
  /**
42
- * @param gameObjectFactory The factory function for the game object
43
- * @param name The name of the game object, this must not be used by another game object
44
- * @returns The added game object
45
- */
46
- protected addGameObject<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
47
- /**
48
- * @param name The name of the component to find
49
- * @returns The found component
50
- */
51
- protected getComponentByName<T extends Component>(name: string): T;
52
- /**
53
- * @param type The type of the component to find
54
- * @returns The found component
25
+ * @returns The GameObject to which this component is attached
55
26
  */
56
- protected getComponentByType<T extends Component>(type: string): T;
27
+ protected getGameObject<T extends GameObject>(): T;
57
28
  /**
58
- * @param type The type of the components to find
29
+ * Returns all the components in the game object.
59
30
  * @returns The found components
60
31
  */
61
- protected getComponentsByType<T extends Component>(type: string): T[];
32
+ getComponents(): Component[];
62
33
  /**
63
- * @param name The name of the game object to find
64
- * @returns The found game object
65
- */
66
- protected findGameObjectByName<T extends GameObject>(name: string): T;
67
- /**
68
- * @param tag The tag of the game objects to find
69
- * @returns The found game objects
34
+ * Returns all the components for the given class in the game object.
35
+ * @param componentClass The class of the components
36
+ * @returns The found components
70
37
  */
71
- protected findGameObjectsByTag(tag: string): GameObject[];
38
+ getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
72
39
  /**
73
- * @param tag The tag of the game object to find
74
- * @returns The found game object
40
+ * Returns the first component found for the given class, or undefined otherwise.
41
+ * @param componentClass The class of the component
42
+ * @returns The found component
75
43
  */
76
- protected findGameObjectByTag<T extends GameObject>(tag: string): T;
44
+ getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
77
45
  /**
78
- * Destroy one game objects by its name
79
- * @param name The name of the game object
46
+ * Returns the first component found for the given name, or undefined otherwise.
47
+ * @param name The name of the component
48
+ * @returns The found component
80
49
  */
81
- protected destroyGameObjectByName(name: string): void;
50
+ getComponent<T extends Component>(name: string): T;
82
51
  /**
83
- * Destroy the game objects
84
- * @param gameObject The game object to destory
52
+ * Returns TRUE if the game object has a component for the given class, or FALSE otherwise
53
+ * @param componentClass The class of the component to find
54
+ * @returns boolean
85
55
  */
86
- protected destroyGameObject(gameObject: GameObject): void;
56
+ hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
87
57
  /**
88
58
  * @param name The name of the component to find
89
- * @returns TRUE or FALSE
90
- */
91
- hasComponentOfName(name: string): boolean;
92
- /**
93
- * @param type The type of the component to find
94
- * @returns TRUE or FALSE
95
- */
96
- hasComponentOfType(type: string): boolean;
97
- /**
98
- * @param name The name of the component to remove
99
- */
100
- removeComponentByName(name: string): void;
101
- /**
102
- * @param type The tyepe of the component to remove
103
- */
104
- removeComponentByType(type: string): void;
105
- /**
106
- * @description NOTE: Do not call this method. Use GameObject.setComponentActive instead.
59
+ * @returns boolean
107
60
  */
108
- destroy(): void;
61
+ hasComponent(name: string): boolean;
62
+ removeComponent(component: Component): void;
63
+ protected _destroy(): void;
109
64
  }
110
65
  export declare abstract class EngineComponent extends Component {
111
- protected get updateEvent(): string;
66
+ protected readonly updateEvent: FrameEvent;
112
67
  }
113
68
  export declare abstract class ColliderComponent extends Component {
114
- protected get updateEvent(): string;
69
+ protected readonly updateEvent: FrameEvent;
115
70
  }
116
71
  export declare abstract class PhysicsComponent extends Component {
117
- protected get updateEvent(): string;
72
+ protected readonly updateEvent: FrameEvent;
118
73
  }
119
74
  export declare abstract class TransformComponent extends Component {
120
- protected get updateEvent(): string;
75
+ protected readonly updateEvent: FrameEvent;
121
76
  }
122
77
  export declare abstract class PreRenderComponent extends Component {
123
- protected get updateEvent(): string;
78
+ protected readonly updateEvent: FrameEvent;
124
79
  }
125
80
  export declare abstract class CameraComponent extends Component {
126
- protected get updateEvent(): string;
81
+ protected readonly updateEvent: FrameEvent;
127
82
  }
128
83
  export declare abstract class RenderComponent extends Component {
129
- protected get updateEvent(): string;
84
+ protected readonly updateEvent: FrameEvent;
130
85
  }
@@ -1,7 +1,8 @@
1
- import { SceneConstructor as SceneFactory } from "../core/managers/SceneManager";
1
+ import { SceneClass } from "../core/managers/SceneManager";
2
2
  import { Container } from "../utils/Container";
3
3
  import { Rectangle } from "../math/Rectangle";
4
4
  import { Vector2 } from "../math/Vector2";
5
+ import { CollisionMatrix } from "../physics/collision/CollisionManager";
5
6
  export declare const container: Container;
6
7
  export interface GameConfig {
7
8
  containerNode: HTMLElement | null;
@@ -9,8 +10,6 @@ export interface GameConfig {
9
10
  gameHeight?: number;
10
11
  debugEnabled?: boolean;
11
12
  canvasColor?: string;
12
- context2d?: Context2DConfig;
13
- gameFrameRate?: number;
14
13
  physicsFramerate?: number;
15
14
  spriteDefaultScale?: Vector2 | null;
16
15
  collisions?: {
@@ -18,27 +17,18 @@ export interface GameConfig {
18
17
  quadTreeBounds?: Rectangle | null;
19
18
  quadMaxLevel?: number;
20
19
  collidersPerQuad?: number;
20
+ collisionMatrix?: CollisionMatrix;
21
21
  };
22
22
  }
23
- export declare enum Context2DConfig {
24
- Default = "default",
25
- Disabled = "disabled",
26
- Fallback = "fallback"
27
- }
28
23
  export declare enum CollisionMethodConfig {
29
24
  AABB = "aabb",
30
25
  SAT = "sat"
31
26
  }
32
27
  export declare class Game {
33
28
  private sceneManager;
34
- private renderManager;
35
29
  private iterationManager;
36
30
  private _config;
37
- private _running;
38
- private _stop;
39
- private frameRequestId;
40
31
  constructor(config: GameConfig);
41
- private errorEventHandler;
42
32
  private setupManagers;
43
33
  /**
44
34
  * @returns GameConfig
@@ -51,11 +41,11 @@ export declare class Game {
51
41
  /**
52
42
  * Add a scene to the game
53
43
  *
44
+ * @param sceneClass the class of the scene
54
45
  * @param name The name of the scene
55
- * @param sceneFactory The factory funciton for the escene
56
- * @param openingScene If this is the opening scene, set TRUE, FALSE instead
46
+ * @param openingScene [default FALSE] If this is the opening scene, set TRUE, FALSE instead
57
47
  */
58
- addScene(name: string, sceneFactory: SceneFactory, openingScene?: boolean): void;
48
+ addScene(sceneClass: SceneClass, name: string, openingScene?: boolean): void;
59
49
  /**
60
50
  * Run the game
61
51
  */
@@ -64,14 +54,12 @@ export declare class Game {
64
54
  * Stop the game
65
55
  */
66
56
  stop(): void;
67
- private gameLoop;
68
57
  /**
69
- * Pauses the game loop
58
+ * Pauses the game
70
59
  */
71
- pauseLoop(): void;
60
+ pause(): void;
72
61
  /**
73
- * Resumes the paused game loop
62
+ * Resumes the paused game
74
63
  */
75
- resumeLoop(): void;
76
- private requestAnimationFrame;
64
+ resume(): void;
77
65
  }
@@ -0,0 +1,66 @@
1
+ import { GameObject, GameObjectClass } from "./GameObject";
2
+ import { GameObjectManager } from "./managers/GameObjectManager";
3
+ import { FrameEvent } from "./managers/IterationManager";
4
+ export interface InitOptions {
5
+ [key: string]: unknown;
6
+ }
7
+ export declare abstract class GameActor {
8
+ protected readonly gameObjectManager: GameObjectManager;
9
+ protected readonly updateEvent: FrameEvent;
10
+ private started;
11
+ dispatch(event: FrameEvent, options?: InitOptions): void;
12
+ /**
13
+ * This method is called after instantiation (recommended for the creation of game objects).
14
+ */
15
+ protected init?(options?: InitOptions): void;
16
+ /**
17
+ * This method is called only once on the first available frame.
18
+ */
19
+ protected start?(): void;
20
+ /**
21
+ * This method is called on every frame.
22
+ */
23
+ protected update?(): void;
24
+ /**
25
+ * This method is called before destruction.
26
+ */
27
+ protected onDestroy?(): void;
28
+ /**
29
+ * Adds a new game object to the scene.
30
+ * @param gameObjectClass The game object class
31
+ * @param options [optional] This options will be passed to the init method
32
+ * @param name [optional] The name of the game object
33
+ * @returns The added game object
34
+ * @returns
35
+ */
36
+ protected addGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, name?: string): T;
37
+ /**
38
+ * Returns all the game objects in the scene.
39
+ * @returns The found game objects
40
+ */
41
+ protected findGameObjects(): GameObject[];
42
+ /**
43
+ * Returns the first game object found for the given class, or undefined otherwise.
44
+ * @param gameObjectClass The game object class to find
45
+ * @returns The found game object
46
+ */
47
+ findGameObject<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
48
+ /**
49
+ * Returns the first game object found for the given name, or undefined otherwise.
50
+ * @param name The name of the game object to find
51
+ * @returns The found game object
52
+ */
53
+ findGameObject<T extends GameObject>(name: string): T;
54
+ /**
55
+ * Returns a collection of game objects found for the given tag
56
+ * @param tag The tag of the game objects to find
57
+ * @returns The found game objects
58
+ */
59
+ protected findGameObjectsByTag<T extends GameObject>(tag: string): T[];
60
+ /**
61
+ * Destroy the given game object
62
+ * @param gameObject The game object to destory
63
+ */
64
+ protected destroyGameObject(gameObject: GameObject): void;
65
+ protected abstract _destroy(): void;
66
+ }
@@ -1,131 +1,102 @@
1
- import { Component } from "./Component";
1
+ import { Component, ComponentClass } from "./Component";
2
2
  import { Transform } from "../component/Transform";
3
- import { GameObjectFactory } from "../core/managers/GameObjectManager";
3
+ import { RigidBody } from "../component/RigidBody";
4
4
  import { Scene } from "./Scene";
5
+ import { GameActor, InitOptions } from "./GameActor";
5
6
  export declare const LAYER_DEFAULT = "Default";
6
- export declare type ComponentFactory = () => Component;
7
- export declare class GameObject {
7
+ export declare type GameObjectClass<T extends GameObject = GameObject> = new (name?: string, parent?: GameObject) => T;
8
+ export declare class GameObject extends GameActor {
8
9
  readonly id: string;
9
- name: string;
10
+ readonly name: string;
10
11
  tag: string;
11
12
  layer: string;
12
13
  ui: boolean;
13
14
  keep: boolean;
15
+ parent: GameObject | null;
14
16
  private _active;
15
- private _parent;
16
- private started;
17
17
  private sceneManager;
18
- private gameObjectManager;
19
18
  private components;
20
- private inactiveComponents;
21
- private inactiveChildren;
22
- constructor();
23
- get transform(): Transform;
19
+ private activeComponentsCache;
20
+ private activeChildrenCache;
21
+ constructor(name?: string, parent?: GameObject);
24
22
  get active(): boolean;
25
- get parent(): GameObject;
26
- set parent(parent: GameObject | null);
27
- private gameLoopEventHandler;
28
- /**
29
- * This method is only ever called once.
30
- * Recommended for GameObject cration.
31
- */
32
- init(): void;
33
- /**
34
- * This method is only ever called once.
35
- */
36
- protected start(): void;
23
+ set active(active: boolean);
24
+ private updateComponentsActiveStatus;
25
+ private updateChildrenActiveStatus;
26
+ get transform(): Transform;
27
+ get rigidBody(): RigidBody;
37
28
  /**
38
- * This method is called on every frame.
29
+ * This method is called when the active state changes.
39
30
  */
40
- protected update(): void;
31
+ protected onActiveChange(): void;
41
32
  /**
42
33
  * @returns The current loaded scene
43
34
  */
44
35
  protected getCurrentScene<T extends Scene>(): T;
45
36
  /**
46
- * @param gameObjectFactory The factory function for the game object
47
- * @param name The name of the game object, this must not be used by another game object
48
- * @returns The added game object
49
- */
50
- protected addGameObject<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
51
- /**
52
- * @param name The name of the game object to find
53
- * @returns The found game object
54
- */
55
- protected findGameObjectByName<T extends GameObject>(name: string): T;
56
- /**
57
- * @param tag The tag of the game objects to find
58
- * @returns The found game objects
59
- */
60
- protected findGameObjectsByTag(tag: string): GameObject[];
61
- /**
62
- * @param tag The tag of the game object to find
63
- * @returns The found game object
64
- */
65
- protected findGameObjectByTag<T extends GameObject>(tag: string): T;
66
- /**
67
- * Add a components to the game obejct
68
- *
69
- * @param componentFactory The factory function for the component
70
- * @param name (optional) The name of the component, this must not be used by another component
37
+ * Add a component to the game obejct
38
+ * @param componentClass The class of the component
39
+ * @param options [optional] The options passed to the init method of the component
40
+ * @param name [optional] The name of the component
71
41
  * @returns The added component
72
42
  */
73
- addComponent<T extends Component>(componentFactory: ComponentFactory, name?: string | null): T;
43
+ addComponent<ComponentType extends Component = Component, OptionsType extends InitOptions = InitOptions>(componentClass: ComponentClass<ComponentType>, options?: OptionsType, name?: string): ComponentType;
74
44
  private checkMultipleComponent;
75
45
  /**
76
- * @returns All the added components
46
+ * Returns all the components in the game object.
47
+ * @returns The found components
77
48
  */
78
49
  getComponents(): Component[];
79
50
  /**
80
- * @param name The name of the component to find
81
- * @returns The found component
82
- */
83
- getComponentByName<T extends Component>(name: string): T;
84
- /**
85
- * @param type The type of the component to find
86
- * @returns The found component
87
- */
88
- getComponentByType<T extends Component>(type: string): T;
89
- /**
90
- * @param type The type of the components to find
51
+ * Returns all the components for the given class in the game object.
52
+ * @param componentClass The class of the components
91
53
  * @returns The found components
92
54
  */
93
- getComponentsByType<T extends Component>(type: string): T[];
94
- /**
95
- * @param name The name of the component to find
96
- * @returns TRUE or FALSE
97
- */
98
- hasComponentOfName(name: string): boolean;
55
+ getComponents<T extends Component>(componentClass: ComponentClass<T>): T[];
99
56
  /**
100
- * @param type The type of the component to find
101
- * @returns TRUE or FALSE
57
+ * Returns the first component found for the given class, or undefined otherwise.
58
+ * @param componentClass The class of the component
59
+ * @returns The found component
102
60
  */
103
- hasComponentOfType(type: string): boolean;
61
+ getComponent<T extends Component>(componentClass: ComponentClass<T>): T;
104
62
  /**
105
- * @param name The name of the component to remove
63
+ * Returns the first component found for the given name, or undefined otherwise.
64
+ * @param name The name of the component
65
+ * @returns The found component
106
66
  */
107
- removeComponentByName(name: string): void;
67
+ getComponent<T extends Component>(name: string): T;
108
68
  /**
109
- * @param type The tyepe of the component to remove
69
+ * Returns TRUE if the game object has a component for the given class, or FALSE otherwise
70
+ * @param componentClass The class of the component to find
71
+ * @returns boolean
110
72
  */
111
- removeComponentByType(type: string): void;
73
+ hasComponent<T extends Component>(componentClass: ComponentClass<T>): boolean;
112
74
  /**
113
- * Remove all added components
75
+ * @param name The name of the component to find
76
+ * @returns boolean
114
77
  */
115
- removeComponents(): void;
78
+ hasComponent(name: string): boolean;
79
+ removeComponent(component: Component): void;
116
80
  /**
117
81
  * Add a child game object.
118
- *
119
- * @param gameObjectFactory The factory of the child game object
120
- * @param name The name of the child game object, this must not be used by another game object
82
+ * @param gameObjectClass The class of the child game object
83
+ * @param options [optional] This options will be passed to the init method
84
+ * @param name [optional] The name of the game object
121
85
  * @returns The added child game object
122
86
  */
123
- addChild<T extends GameObject>(gameObjectFactory: GameObjectFactory, name: string): T;
87
+ addChild<T extends GameObject>(gameObjectClass: GameObjectClass<T>, options?: InitOptions, name?: string): T;
124
88
  /**
125
89
  * @returns The children game objects
126
90
  */
127
- getChildren(): GameObject[];
91
+ getChildren<T extends GameObject>(): T[];
128
92
  /**
93
+ * Returns the first child found for the given class, or undefined otherwise.
94
+ * @param gameObjectClass The class of the child game object to find
95
+ * @returns The found child game object
96
+ */
97
+ getChild<T extends GameObject>(gameObjectClass: GameObjectClass<T>): T;
98
+ /**
99
+ * Returns the first child found for the given name, or undefined otherwise.
129
100
  * @param name The name of the child game object to find
130
101
  * @returns The found child game object
131
102
  */
@@ -134,25 +105,6 @@ export declare class GameObject {
134
105
  * Destroy all the children game objects
135
106
  */
136
107
  destroyChildren(): void;
137
- /**
138
- * If the object become inactive, every component and child game object will stop their execution.
139
- *
140
- * @param active TRUE or FALE
141
- */
142
- setActive(active: boolean): void;
143
- private updateInactiveCache;
144
- /**
145
- * Destroy one game objects by its name
146
- * @param name The name of the game object
147
- */
148
- destroyGameObjectByName(name: string): void;
149
- /**
150
- * Destroy the game objects
151
- * @param gameObject The game object to destory
152
- */
153
- destroyGameObject(gameObject: GameObject): void;
154
- /**
155
- * @description NOTE: do not use this method. Use GameObject.destroyGameObject or Scene.destroyGameObject instead.
156
- */
157
- destroy(): void;
108
+ protected _destroy(): void;
109
+ private destroyComponents;
158
110
  }