angry-pixel 2.3.7 → 2.4.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.
- package/README.md +7 -10
- package/lib/index.cjs.js +1 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +90 -82
- package/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -771,11 +771,24 @@ type Archetype = {
|
|
|
771
771
|
/** Whether the entity starts enabled. Defaults to `true`. Set to `false` to disable the entity on creation. */
|
|
772
772
|
enabled?: boolean;
|
|
773
773
|
};
|
|
774
|
+
/**
|
|
775
|
+
* Options for the `removeAllEntities` method of the EntityManager
|
|
776
|
+
* @public
|
|
777
|
+
* @category Entity-Component-System
|
|
778
|
+
* @example
|
|
779
|
+
* ```js
|
|
780
|
+
* entityManager.removeAllEntities({ preserveEntitiesWithComponent: DontDestroy });
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
type RemoveAllEntitiesOptions = {
|
|
784
|
+
/** The entities that have a component of this type are preserved instead of being removed */
|
|
785
|
+
preserveEntitiesWithComponent: ComponentType;
|
|
786
|
+
};
|
|
774
787
|
/**
|
|
775
788
|
* This interface defines the core structure for system classes in the ECS architecture.\
|
|
776
789
|
* Systems contain the game logic that operates on entities and their components.\
|
|
777
790
|
* Dependencies like EntityManager can be injected using dependency injection decorators.\
|
|
778
|
-
* Systems must implement onUpdate()
|
|
791
|
+
* Systems must implement onUpdate().
|
|
779
792
|
* @public
|
|
780
793
|
* @category Entity-Component-System
|
|
781
794
|
* @example
|
|
@@ -792,26 +805,6 @@ type Archetype = {
|
|
|
792
805
|
* ```
|
|
793
806
|
*/
|
|
794
807
|
interface System {
|
|
795
|
-
/**
|
|
796
|
-
* This method is called the first time the system is enabled
|
|
797
|
-
* @public
|
|
798
|
-
*/
|
|
799
|
-
onCreate?(): void;
|
|
800
|
-
/**
|
|
801
|
-
* This method is called when the system is destroyed
|
|
802
|
-
* @public
|
|
803
|
-
*/
|
|
804
|
-
onDestroy?(): void;
|
|
805
|
-
/**
|
|
806
|
-
* This method is called when the system is disabled
|
|
807
|
-
* @public
|
|
808
|
-
*/
|
|
809
|
-
onDisabled?(): void;
|
|
810
|
-
/**
|
|
811
|
-
* This method is called when the system is enabled
|
|
812
|
-
* @public
|
|
813
|
-
*/
|
|
814
|
-
onEnabled?(): void;
|
|
815
808
|
/**
|
|
816
809
|
* This method is called once every frame
|
|
817
810
|
* @public
|
|
@@ -988,18 +981,18 @@ declare class EntityManager {
|
|
|
988
981
|
removeEntity(entity: Entity): void;
|
|
989
982
|
/**
|
|
990
983
|
* Removes all Entities and all their Components
|
|
991
|
-
* @param
|
|
984
|
+
* @param options Optional options object. See {@link RemoveAllEntitiesOptions}
|
|
992
985
|
* @public
|
|
993
986
|
* @example
|
|
994
987
|
* ```js
|
|
995
988
|
* // Remove all entities
|
|
996
989
|
* entityManager.removeAllEntities();
|
|
997
990
|
*
|
|
998
|
-
* // Remove all entities except those that have a
|
|
999
|
-
* entityManager.removeAllEntities(
|
|
991
|
+
* // Remove all entities except those that have a component of type DontDestroy
|
|
992
|
+
* entityManager.removeAllEntities({ preserveEntitiesWithComponent: DontDestroy });
|
|
1000
993
|
* ```
|
|
1001
994
|
*/
|
|
1002
|
-
removeAllEntities(
|
|
995
|
+
removeAllEntities(options?: RemoveAllEntitiesOptions): void;
|
|
1003
996
|
/**
|
|
1004
997
|
* If the Entity exists, returns TRUE, otherwise it returns FALSE
|
|
1005
998
|
* @param entity
|
|
@@ -1463,8 +1456,7 @@ declare class SystemManager {
|
|
|
1463
1456
|
*/
|
|
1464
1457
|
groupHasSystems(group: SystemGroup): boolean;
|
|
1465
1458
|
/**
|
|
1466
|
-
* Enables a system by its type
|
|
1467
|
-
* 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.
|
|
1459
|
+
* Enables a system by its type.
|
|
1468
1460
|
* @param systemType The system class
|
|
1469
1461
|
* @public
|
|
1470
1462
|
* @example
|
|
@@ -1474,8 +1466,7 @@ declare class SystemManager {
|
|
|
1474
1466
|
*/
|
|
1475
1467
|
enableSystem(systemType: SystemType): void;
|
|
1476
1468
|
/**
|
|
1477
|
-
* Disables a system by its type
|
|
1478
|
-
* The method `onDisabled` of the system will be called.
|
|
1469
|
+
* Disables a system by its type.
|
|
1479
1470
|
* @param systemType The system class
|
|
1480
1471
|
* @public
|
|
1481
1472
|
* @example
|
|
@@ -1493,7 +1484,6 @@ declare class SystemManager {
|
|
|
1493
1484
|
setExecutionOrder(systemType: SystemType, position: number): void;
|
|
1494
1485
|
/**
|
|
1495
1486
|
* Removes a system by its type.
|
|
1496
|
-
* The method `onDestroy` of the system will be called.
|
|
1497
1487
|
* @param systemType The system class
|
|
1498
1488
|
* @internal
|
|
1499
1489
|
*/
|
|
@@ -1575,13 +1565,16 @@ interface Collision {
|
|
|
1575
1565
|
* playerCollider,
|
|
1576
1566
|
* "enemy"
|
|
1577
1567
|
* );
|
|
1578
|
-
*
|
|
1579
|
-
* // Get all current collisions
|
|
1580
|
-
* const allCollisions = collisionRepository.findAll();
|
|
1581
1568
|
* ```
|
|
1582
1569
|
*/
|
|
1583
1570
|
declare class CollisionRepository {
|
|
1571
|
+
private collisionPool;
|
|
1572
|
+
private collisionPoolIndex;
|
|
1584
1573
|
private collisions;
|
|
1574
|
+
private step;
|
|
1575
|
+
private findCache;
|
|
1576
|
+
/** @internal */
|
|
1577
|
+
private updateCache;
|
|
1585
1578
|
/**
|
|
1586
1579
|
* Searches for and returns a collection of collisions for the given collider
|
|
1587
1580
|
* @param collider The local collider
|
|
@@ -1596,15 +1589,22 @@ declare class CollisionRepository {
|
|
|
1596
1589
|
*/
|
|
1597
1590
|
findCollisionsForColliderAndLayer(collider: Collider, layer: string): Collision[];
|
|
1598
1591
|
/**
|
|
1599
|
-
* Returns
|
|
1600
|
-
*
|
|
1601
|
-
*
|
|
1592
|
+
* Returns the raw collisions of the current physics step, for engine systems that need every collision at once.
|
|
1593
|
+
* - Each pair of colliding shapes is stored once, not once per side: the shape that detected the collision is
|
|
1594
|
+
* the local one. Check both `localEntity` and `remoteEntity` (and negate `resolution.direction` for the
|
|
1595
|
+
* remote side) to find every collision of an entity.
|
|
1596
|
+
* - The collisions are pooled: the objects and the array are reused on the next physics step. Read them
|
|
1597
|
+
* synchronously and do not keep references to them.
|
|
1598
|
+
*
|
|
1599
|
+
* Use `findCollisionsForCollider` or `findCollisionsForColliderAndLayer` instead when querying the collisions of
|
|
1600
|
+
* a single collider: they return copies, already oriented with that collider as the local one.
|
|
1601
|
+
* @internal
|
|
1602
1602
|
*/
|
|
1603
|
-
|
|
1603
|
+
getCollisions(): Collision[];
|
|
1604
1604
|
/** @internal */
|
|
1605
|
-
persist(
|
|
1605
|
+
persist(localEntity: Entity, localCollider: Collider, remoteEntity: Entity, remoteCollider: Collider, { direction, penetration }: CollisionResolution): void;
|
|
1606
1606
|
/** @internal */
|
|
1607
|
-
|
|
1607
|
+
clear(): void;
|
|
1608
1608
|
}
|
|
1609
1609
|
|
|
1610
1610
|
/**
|
|
@@ -1738,7 +1738,7 @@ interface AudioSource {
|
|
|
1738
1738
|
declare class AssetManager {
|
|
1739
1739
|
private readonly audioContext;
|
|
1740
1740
|
private readonly assets;
|
|
1741
|
-
constructor(audioContext: AudioContext |
|
|
1741
|
+
constructor(audioContext: AudioContext | undefined);
|
|
1742
1742
|
/**
|
|
1743
1743
|
* Returns TRUE if the assets are loaded
|
|
1744
1744
|
* @returns TRUE or FALSE
|
|
@@ -1755,9 +1755,9 @@ declare class AssetManager {
|
|
|
1755
1755
|
* Loads an audio asset
|
|
1756
1756
|
* @param url The asset URL
|
|
1757
1757
|
* @param name The asset name [optional]
|
|
1758
|
-
* @returns The {@link AudioSource} (with its `buffer` populated asynchronously), or `
|
|
1758
|
+
* @returns The {@link AudioSource} (with its `buffer` populated asynchronously), or `undefined` if no AudioContext is available.
|
|
1759
1759
|
*/
|
|
1760
|
-
loadAudio(url: string, name?: string): AudioSource |
|
|
1760
|
+
loadAudio(url: string, name?: string): AudioSource | undefined;
|
|
1761
1761
|
private decodeAudioBuffer;
|
|
1762
1762
|
/**
|
|
1763
1763
|
* Loads a font asset
|
|
@@ -2056,15 +2056,16 @@ declare class SceneManager {
|
|
|
2056
2056
|
/**
|
|
2057
2057
|
* Loads a scene
|
|
2058
2058
|
* @param name The name of the scene
|
|
2059
|
-
* @param
|
|
2059
|
+
* @param options Optional options object. See {@link LoadSceneOptions}
|
|
2060
2060
|
* @public
|
|
2061
2061
|
*/
|
|
2062
|
-
loadScene(name: string,
|
|
2062
|
+
loadScene(name: string, options?: LoadSceneOptions): void;
|
|
2063
2063
|
/**
|
|
2064
2064
|
* Loads the opening scene
|
|
2065
|
+
* @param options Optional options object. See {@link LoadSceneOptions}
|
|
2065
2066
|
* @public
|
|
2066
2067
|
*/
|
|
2067
|
-
loadOpeningScene(): void;
|
|
2068
|
+
loadOpeningScene(options?: LoadSceneOptions): void;
|
|
2068
2069
|
/**
|
|
2069
2070
|
* Returns true if the scene is loading
|
|
2070
2071
|
* @public
|
|
@@ -2077,8 +2078,22 @@ declare class SceneManager {
|
|
|
2077
2078
|
get sceneLoadedThisFrame(): boolean;
|
|
2078
2079
|
/** @internal */
|
|
2079
2080
|
update(): void;
|
|
2080
|
-
|
|
2081
|
+
/** @internal */
|
|
2082
|
+
destroyCurrentScene(): void;
|
|
2081
2083
|
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Options for the `loadScene` and `loadOpeningScene` methods of the SceneManager
|
|
2086
|
+
* @public
|
|
2087
|
+
* @category Managers
|
|
2088
|
+
* @example
|
|
2089
|
+
* ```js
|
|
2090
|
+
* this.sceneManager.loadScene("Level2", { preserveEntitiesWithComponent: DontDestroy });
|
|
2091
|
+
* ```
|
|
2092
|
+
*/
|
|
2093
|
+
type LoadSceneOptions = {
|
|
2094
|
+
/** The entities that have a component of this type are preserved across the scene transition */
|
|
2095
|
+
preserveEntitiesWithComponent: ComponentType;
|
|
2096
|
+
};
|
|
2082
2097
|
/**
|
|
2083
2098
|
* This type represents a scene class
|
|
2084
2099
|
* @public
|
|
@@ -2102,14 +2117,12 @@ type SceneType<T extends Scene = Scene> = {
|
|
|
2102
2117
|
* this.assetManager.loadImage("image.png");
|
|
2103
2118
|
* }
|
|
2104
2119
|
*
|
|
2105
|
-
*
|
|
2106
|
-
* this.systems
|
|
2120
|
+
* setup() {
|
|
2121
|
+
* this.systems = [
|
|
2107
2122
|
* SomeSystem,
|
|
2108
2123
|
* AnotherSystem
|
|
2109
|
-
*
|
|
2110
|
-
* }
|
|
2124
|
+
* ];
|
|
2111
2125
|
*
|
|
2112
|
-
* createEntities() {
|
|
2113
2126
|
* this.entityManager.createEntity([
|
|
2114
2127
|
* SomeComponent,
|
|
2115
2128
|
* AnotherComponent
|
|
@@ -2123,33 +2136,16 @@ declare abstract class Scene {
|
|
|
2123
2136
|
protected readonly assetManager: AssetManager;
|
|
2124
2137
|
systems: SystemType[];
|
|
2125
2138
|
constructor(entityManager: EntityManager, assetManager: AssetManager);
|
|
2126
|
-
/**
|
|
2127
|
-
* Override this method to register the systems that will be executed in the scene
|
|
2128
|
-
* @public
|
|
2129
|
-
*/
|
|
2130
|
-
registerSystems(): void;
|
|
2131
2139
|
/**
|
|
2132
2140
|
* Override this method to load the assets needed for the scene
|
|
2133
2141
|
* @public
|
|
2134
2142
|
*/
|
|
2135
2143
|
loadAssets(): void;
|
|
2136
2144
|
/**
|
|
2137
|
-
* Override this method to create the entities
|
|
2138
|
-
* @public
|
|
2139
|
-
*/
|
|
2140
|
-
createEntities(): void;
|
|
2141
|
-
/**
|
|
2142
|
-
* Adds a system to the scene
|
|
2143
|
-
* @param system The system to add
|
|
2145
|
+
* Override this method to create the entities and register the systems that will be executed in the scene
|
|
2144
2146
|
* @public
|
|
2145
2147
|
*/
|
|
2146
|
-
|
|
2147
|
-
/**
|
|
2148
|
-
* Adds multiple systems to the scene
|
|
2149
|
-
* @param systems The systems to add
|
|
2150
|
-
* @public
|
|
2151
|
-
*/
|
|
2152
|
-
protected addSystems(systems: SystemType[]): void;
|
|
2148
|
+
setup(): void;
|
|
2153
2149
|
}
|
|
2154
2150
|
|
|
2155
2151
|
/**
|
|
@@ -5229,13 +5225,14 @@ declare class InputManager {
|
|
|
5229
5225
|
|
|
5230
5226
|
/**
|
|
5231
5227
|
* Abstract base class for creating game systems with commonly needed dependencies injected.\
|
|
5232
|
-
* Provides access to the following core managers and services
|
|
5233
|
-
* - EntityManager: For managing game entities and components
|
|
5234
|
-
* -
|
|
5235
|
-
* -
|
|
5236
|
-
* -
|
|
5237
|
-
* -
|
|
5238
|
-
* -
|
|
5228
|
+
* Provides access to the following core managers and services:
|
|
5229
|
+
* - EntityManager: For managing game entities and components
|
|
5230
|
+
* - SystemManager: For managing game systems
|
|
5231
|
+
* - AssetManager: For loading and managing game resources
|
|
5232
|
+
* - SceneManager: For controlling scene transitions and state
|
|
5233
|
+
* - TimeManager: For handling game timing and delta time
|
|
5234
|
+
* - InputManager: For processing keyboard, mouse and touch input
|
|
5235
|
+
* - CollisionRepository: For physics and collision detection
|
|
5239
5236
|
* - GameConfig: For accessing game configuration settings
|
|
5240
5237
|
* @public
|
|
5241
5238
|
* @category Core
|
|
@@ -5250,17 +5247,28 @@ declare class InputManager {
|
|
|
5250
5247
|
*/
|
|
5251
5248
|
declare abstract class GameSystem implements System {
|
|
5252
5249
|
protected readonly entityManager: EntityManager;
|
|
5250
|
+
protected readonly systemManager: SystemManager;
|
|
5253
5251
|
protected readonly assetManager: AssetManager;
|
|
5254
5252
|
protected readonly sceneManager: SceneManager;
|
|
5255
5253
|
protected readonly timeManager: TimeManager;
|
|
5256
5254
|
protected readonly inputManager: InputManager;
|
|
5257
5255
|
protected readonly collisionRepository: CollisionRepository;
|
|
5258
5256
|
protected readonly gameConfig: GameConfig;
|
|
5257
|
+
/**
|
|
5258
|
+
* This method is called once every frame
|
|
5259
|
+
* @public
|
|
5260
|
+
*/
|
|
5259
5261
|
onUpdate(): void;
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5262
|
+
/**
|
|
5263
|
+
* This method is called when the scene finishes loading, after its entities have been created
|
|
5264
|
+
* @public
|
|
5265
|
+
*/
|
|
5266
|
+
onSceneLoaded(): void;
|
|
5267
|
+
/**
|
|
5268
|
+
* This method is called when the scene is destroyed, before its entities are removed
|
|
5269
|
+
* @public
|
|
5270
|
+
*/
|
|
5271
|
+
onSceneDestroyed(): void;
|
|
5264
5272
|
}
|
|
5265
5273
|
|
|
5266
5274
|
/**
|
|
@@ -5419,4 +5427,4 @@ declare const SYMBOLS: {
|
|
|
5419
5427
|
TimeManager: symbol;
|
|
5420
5428
|
};
|
|
5421
5429
|
|
|
5422
|
-
export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerOptions, type AudioSource, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, DarknessRenderer, type DarknessRendererOptions, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, GeometricRenderer, type GeometricRendererOptions, GeometricShape, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, type PlaySfxOptions, Polygon, PolygonCollider, type PolygonColliderOptions, type PropertyKey, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, SYMBOLS, Scene, SceneManager, type SceneType, type SearchResult, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, type System, type SystemGroup, SystemManager, type SystemType, TextAlignment, TextRenderer, type TextRendererOptions, TileAnimation, type TileAnimationOptions, type TiledChunk, type TiledGroupLayer, type TiledLayer, type TiledObject, type TiledObjectBlueprint, type TiledObjectFactory, type TiledObjectLayer, type TiledObjectProperties, type TiledProperty, type TiledTileAnimationFrame, type TiledTilemap, type TiledTileset, type TiledTilesetTile, 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, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };
|
|
5430
|
+
export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerOptions, type AudioSource, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, DarknessRenderer, type DarknessRendererOptions, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, GeometricRenderer, type GeometricRendererOptions, GeometricShape, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, type LoadSceneOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, type PlaySfxOptions, Polygon, PolygonCollider, type PolygonColliderOptions, type PropertyKey, Rectangle, type RemoveAllEntitiesOptions, RigidBody, type RigidBodyOptions, RigidBodyType, SYMBOLS, Scene, SceneManager, type SceneType, type SearchResult, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, type System, type SystemGroup, SystemManager, type SystemType, TextAlignment, TextRenderer, type TextRendererOptions, TileAnimation, type TileAnimationOptions, type TiledChunk, type TiledGroupLayer, type TiledLayer, type TiledObject, type TiledObjectBlueprint, type TiledObjectFactory, type TiledObjectLayer, type TiledObjectProperties, type TiledProperty, type TiledTileAnimationFrame, type TiledTilemap, type TiledTileset, type TiledTilesetTile, 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, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };
|