angry-pixel 2.1.5 → 2.1.6

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
@@ -708,6 +708,7 @@ type Component = Record<string, any>;
708
708
  */
709
709
  type ComponentType<T extends Component = Component> = {
710
710
  new (...args: any[]): T;
711
+ componentName?: string;
711
712
  };
712
713
  /**
713
714
  * This type represents a search result object containing an entity and its matching component.\
@@ -1817,6 +1818,12 @@ type IntervalOptions = {
1817
1818
  times?: number;
1818
1819
  /** Whether to execute the callback immediately before starting the interval timer */
1819
1820
  executeImmediately?: boolean;
1821
+ /** Entity reference to cancel the interval when the entity is disabled or destroyed */
1822
+ entityRef?: Entity;
1823
+ /** Component reference to cancel the interval when the component is disabled or destroyed */
1824
+ componentRef?: Component;
1825
+ /** Whether to use the time scale for the interval, default is TRUE */
1826
+ useTimeScale?: boolean;
1820
1827
  };
1821
1828
  /**
1822
1829
  * Manages the properties associated with time.\
@@ -1856,11 +1863,26 @@ type IntervalOptions = {
1856
1863
  * executeImmediately: true,
1857
1864
  * });
1858
1865
  *
1866
+ * // set an interval that will be cleared when the entity is destroyed
1867
+ * const intervalId = timeManager.setInterval({
1868
+ * callback: () => console.log("Will be called indefinitely!"),
1869
+ * delay: 1000,
1870
+ * entityRef: entity,
1871
+ * });
1872
+ *
1873
+ * // set an interval that will be cleared when the component is destroyed
1874
+ * const intervalId = timeManager.setInterval({
1875
+ * callback: () => console.log("Will be called indefinitely!"),
1876
+ * delay: 1000,
1877
+ * componentRef: component,
1878
+ * });
1879
+ *
1859
1880
  * // clear the interval with the given id
1860
1881
  * this.timeManager.clearInterval(intervalId);
1861
1882
  * ```
1862
1883
  */
1863
1884
  declare class TimeManager {
1885
+ private readonly entityManager;
1864
1886
  /** @internal */
1865
1887
  readonly fixedGameFramerate: number;
1866
1888
  /** @internal */
@@ -1894,7 +1916,7 @@ declare class TimeManager {
1894
1916
  get physicsDeltaTime(): number;
1895
1917
  /** The browser delta time affected by time scale. */
1896
1918
  get renderDeltaTime(): number;
1897
- constructor({ physicsFramerate }: GameConfig);
1919
+ constructor({ physicsFramerate }: GameConfig, entityManager: EntityManager);
1898
1920
  /** @internal */
1899
1921
  updateForRender(time: number): void;
1900
1922
  /** @internal */
@@ -1903,11 +1925,13 @@ declare class TimeManager {
1903
1925
  updateForPhysics(time: number): void;
1904
1926
  /** @internal */
1905
1927
  updateIntervals(): void;
1928
+ private intervalHealthCheck;
1906
1929
  /**
1907
1930
  * Sets a timer which executes a function repeatedly at a fixed time interval.\
1908
1931
  * If `times` is provided, the interval will be cleared after the function has been called that many times.\
1909
1932
  * But if `times` is not provided, the interval will continue until it is cleared.\
1910
1933
  * If `executeImmediately` is set to true, the function will be called immediately after the interval is set.\
1934
+ * If `useTimeScale` is set to false, the interval will use the unscaled delta time.\
1911
1935
  * Intervals are cleared when loading a new scene.
1912
1936
  * @param intervalOptions
1913
1937
  * @returns intervalId
@@ -1935,7 +1959,7 @@ declare class TimeManager {
1935
1959
  * });
1936
1960
  * ```
1937
1961
  */
1938
- setInterval({ callback, delay, times, executeImmediately }: IntervalOptions): number;
1962
+ setInterval({ callback, delay, times, executeImmediately, entityRef, componentRef, useTimeScale, }: IntervalOptions): number;
1939
1963
  /**
1940
1964
  * Clears the interval with the given id.
1941
1965
  * @param intervalId
@@ -2236,17 +2260,26 @@ interface AnimatorOptions {
2236
2260
  * ```
2237
2261
  */
2238
2262
  declare class Animator {
2263
+ /** The animations to play. */
2239
2264
  animations: Map<string, Animation>;
2265
+ /** The animation to play. */
2240
2266
  animation: string;
2267
+ /** The speed of the animation. */
2241
2268
  speed: number;
2269
+ /** TRUE If the animation should reset to the first frame when the animation is stopped, FALSE otherwise. */
2242
2270
  reset: boolean;
2271
+ /** TRUE If the animation is playing, FALSE otherwise. */
2243
2272
  playing: boolean;
2273
+ /** The current frame of the animation. */
2244
2274
  currentFrame: number;
2275
+ /** The current time of the animation. */
2245
2276
  currentTime: number;
2246
2277
  /** @internal */
2247
2278
  _currentAnimation: string;
2248
2279
  /** @internal */
2249
2280
  _assetsReady: boolean;
2281
+ /** @internal */
2282
+ static componentName: string;
2250
2283
  constructor(options?: Partial<AnimatorOptions>);
2251
2284
  }
2252
2285
  /**
@@ -2413,6 +2446,8 @@ declare class AudioPlayer {
2413
2446
  _currentAudioSource: HTMLAudioElement;
2414
2447
  _playPromisePendind: boolean;
2415
2448
  _playAfterUserInput: boolean;
2449
+ /** @internal */
2450
+ static componentName: string;
2416
2451
  constructor(options?: Partial<AudioPlayerOptions>);
2417
2452
  /**
2418
2453
  * Play the audio source.
@@ -2505,6 +2540,8 @@ declare class Button {
2505
2540
  onClick: () => void;
2506
2541
  /** Function executed when the button is pressed */
2507
2542
  onPressed: () => void;
2543
+ /** @internal */
2544
+ static componentName: string;
2508
2545
  constructor(options?: Partial<ButtonOptions>);
2509
2546
  }
2510
2547
  /**
@@ -2560,8 +2597,12 @@ interface TiledWrapperOptions {
2560
2597
  * ```
2561
2598
  */
2562
2599
  declare class TiledWrapper {
2600
+ /** The tilemap to render. */
2563
2601
  tilemap: TiledTilemap | string;
2602
+ /** The layer to render. */
2564
2603
  layerToRender: string;
2604
+ /** @internal */
2605
+ static componentName: string;
2565
2606
  constructor(options?: Partial<TiledWrapperOptions>);
2566
2607
  }
2567
2608
  /**
@@ -2724,6 +2765,8 @@ declare class Transform {
2724
2765
  _awake: boolean;
2725
2766
  /** @internal */
2726
2767
  _parent: Transform;
2768
+ /** @internal */
2769
+ static componentName: string;
2727
2770
  constructor(options?: Partial<TransformOptions>);
2728
2771
  }
2729
2772
 
@@ -2785,6 +2828,8 @@ declare class BallCollider implements Collider {
2785
2828
  ignoreCollisionsWithLayers: string[];
2786
2829
  /** @internal */
2787
2830
  shapes: Shape[];
2831
+ /** @internal */
2832
+ static componentName: string;
2788
2833
  constructor(options?: Partial<BallColliderOptions>);
2789
2834
  }
2790
2835
 
@@ -2858,6 +2903,8 @@ declare class BoxCollider implements Collider {
2858
2903
  ignoreCollisionsWithLayers: string[];
2859
2904
  /** @internal */
2860
2905
  shapes: Shape[];
2906
+ /** @internal */
2907
+ static componentName: string;
2861
2908
  constructor(options?: Partial<BoxColliderOptions>);
2862
2909
  }
2863
2910
 
@@ -2924,6 +2971,8 @@ declare class EdgeCollider implements Collider {
2924
2971
  ignoreCollisionsWithLayers: string[];
2925
2972
  /** @internal */
2926
2973
  shapes: Shape[];
2974
+ /** @internal */
2975
+ static componentName: string;
2927
2976
  constructor(options?: Partial<EdgeColliderOptions>);
2928
2977
  }
2929
2978
 
@@ -2992,6 +3041,8 @@ declare class PolygonCollider implements Collider {
2992
3041
  ignoreCollisionsWithLayers: string[];
2993
3042
  /** @internal */
2994
3043
  shapes: Shape[];
3044
+ /** @internal */
3045
+ static componentName: string;
2995
3046
  constructor(options?: Partial<PolygonColliderOptions>);
2996
3047
  }
2997
3048
 
@@ -3125,6 +3176,8 @@ declare class RigidBody {
3125
3176
  * @public
3126
3177
  */
3127
3178
  acceleration: Vector2;
3179
+ /** @internal */
3180
+ static componentName: string;
3128
3181
  constructor(options?: Partial<RigidBodyOptions>);
3129
3182
  }
3130
3183
 
@@ -3188,6 +3241,8 @@ declare class TilemapCollider implements Collider {
3188
3241
  physics: boolean;
3189
3242
  /** @internal */
3190
3243
  shapes: Shape[];
3244
+ /** @internal */
3245
+ static componentName: string;
3191
3246
  constructor(options?: Partial<TilemapColliderOptions>);
3192
3247
  }
3193
3248
 
@@ -3445,6 +3500,8 @@ declare class Camera {
3445
3500
  debug: boolean;
3446
3501
  /** @internal */
3447
3502
  _renderData: CameraData;
3503
+ /** @internal */
3504
+ static componentName: string;
3448
3505
  constructor(options?: Partial<CameraOptions>);
3449
3506
  }
3450
3507
 
@@ -3497,6 +3554,8 @@ declare class LightRenderer {
3497
3554
  intensity: number;
3498
3555
  /** @internal */
3499
3556
  _boundingBox: Rectangle;
3557
+ /** @internal */
3558
+ static componentName: string;
3500
3559
  constructor(options?: Partial<LightRendererOptions>);
3501
3560
  }
3502
3561
 
@@ -3618,6 +3677,8 @@ declare class MaskRenderer {
3618
3677
  layer: string;
3619
3678
  /** @internal */
3620
3679
  _renderData: MaskRenderData;
3680
+ /** @internal */
3681
+ static componentName: string;
3621
3682
  constructor(options?: Partial<MaskRendererOptions>);
3622
3683
  }
3623
3684
 
@@ -3676,6 +3737,8 @@ declare class DarknessRenderer {
3676
3737
  _boundingBox: Rectangle;
3677
3738
  /** @internal */
3678
3739
  _renderData: DarknessRenderData;
3740
+ /** @internal */
3741
+ static componentName: string;
3679
3742
  constructor(options?: Partial<DarknessRendererOptions>);
3680
3743
  }
3681
3744
 
@@ -3787,6 +3850,8 @@ declare class SpriteRenderer {
3787
3850
  tiled: Vector2;
3788
3851
  /** @internal */
3789
3852
  _renderData: SpriteRenderData;
3853
+ /** @internal */
3854
+ static componentName: string;
3790
3855
  constructor(options?: Partial<SpriteRendererOptions>);
3791
3856
  }
3792
3857
 
@@ -3997,6 +4062,8 @@ declare class TextRenderer {
3997
4062
  width: number;
3998
4063
  /** @internal */
3999
4064
  _renderData: TextRenderData;
4065
+ /** @internal */
4066
+ static componentName: string;
4000
4067
  constructor(options?: Partial<TextRendererOptions>);
4001
4068
  }
4002
4069
 
@@ -4110,6 +4177,8 @@ declare class TilemapRenderer {
4110
4177
  _processed: boolean;
4111
4178
  /** @internal */
4112
4179
  _renderData: TilemapRenderData[];
4180
+ /** @internal */
4181
+ static componentName: string;
4113
4182
  constructor(options?: Partial<TilemapRendererOptions>);
4114
4183
  }
4115
4184
  /**
@@ -4264,6 +4333,8 @@ declare class VideoRenderer {
4264
4333
  _playPromisePendind: boolean;
4265
4334
  /** @internal */
4266
4335
  _renderData: VideoRenderData;
4336
+ /** @internal */
4337
+ static componentName: string;
4267
4338
  constructor(options?: Partial<VideoRendererOptions>);
4268
4339
  /**
4269
4340
  * Play the video source.