angry-pixel 2.1.3 → 2.1.4

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
@@ -720,14 +720,6 @@ type SearchResult<T extends Component> = {
720
720
  entity: Entity;
721
721
  component: T;
722
722
  };
723
- /**
724
- * This type represents a search criteria object used to filter components when searching for entities.\
725
- * It defines a set of key-value pairs where the keys correspond to component properties\
726
- * and the values are the criteria to match against those properties.
727
- * @public
728
- * @category Entity-Component-System
729
- */
730
- type SearchCriteria = Record<string, any>;
731
723
  /**
732
724
  * This type represents an Entity Archetype, which defines a template for creating entities with a specific set of components.\
733
725
  * It specifies which components should be attached to the entity, whether the entity should be enabled/disabled,\
@@ -860,8 +852,8 @@ type SystemGroup = string | number | symbol;
860
852
  * const entityWithSprite = entityManager.getEntityForComponent(spriteRenderer);
861
853
  *
862
854
  * // Update component data
863
- * entityManager.updateComponentData(entity, Transform, {
864
- * position: new Vector2(200, 200)
855
+ * entityManager.updateComponentData(entity, Transform, (component) => {
856
+ * component.position = new Vector2(200, 200);
865
857
  * });
866
858
  *
867
859
  * // Create parent-child relationship
@@ -883,7 +875,7 @@ type SystemGroup = string | number | symbol;
883
875
  * // do something with the component and entity
884
876
  * })
885
877
  *
886
- * const searchResult = entityManager.search(Enemy, {status: "alive"});
878
+ * const searchResult = entityManager.search(Enemy, (component) => component.status === "alive");
887
879
  * searchResult.forEach(({component, entity}) => {
888
880
  * // do something with the component and entity
889
881
  * })
@@ -1159,14 +1151,16 @@ declare class EntityManager {
1159
1151
  * Updates the data of a component instance
1160
1152
  * @param entity The entity
1161
1153
  * @param componentType The component type
1162
- * @param data The data to update
1154
+ * @param updateCallback The callback to update the component
1163
1155
  * @public
1164
1156
  * @example
1165
1157
  * ```js
1166
- * entityManager.updateComponentData(entity, Transform, { position: new Vector2(100, 100) });
1158
+ * entityManager.updateComponentData(entity, Transform, (component) => {
1159
+ * component.position = new Vector2(100, 100);
1160
+ * });
1167
1161
  * ```
1168
1162
  */
1169
- updateComponentData<T extends Component = Component>(entity: Entity, componentType: ComponentType<T>, data: Partial<T>): void;
1163
+ updateComponentData<T extends Component = Component>(entity: Entity, componentType: ComponentType<T>, updateCallback: (component: T) => void): void;
1170
1164
  /**
1171
1165
  * Searches for and returns an entity for the component instance
1172
1166
  * @param component The component instance
@@ -1279,10 +1273,10 @@ declare class EntityManager {
1279
1273
  /**
1280
1274
  * Performs a search for entities given a component type.\
1281
1275
  * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
1282
- * 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.\
1276
+ * This search can be filtered by passing as a second argument a filter function.\
1283
1277
  * The third argument determines if disabled entities or components are included in the search result,\its default value is FALSE.
1284
1278
  * @param componentType The component class
1285
- * @param criteria The search criteria
1279
+ * @param filter The filter function
1286
1280
  * @param includeDisabled TRUE to incluide disabled entities and components, FALSE otherwise
1287
1281
  * @returns SearchResult
1288
1282
  * @public
@@ -1295,20 +1289,21 @@ declare class EntityManager {
1295
1289
  * ```
1296
1290
  * @example
1297
1291
  * ```js
1298
- * const searchResult = entityManager.search(Enemy, {status: "alive"});
1292
+ * const searchResult = entityManager.search(Enemy, (component) => component.status === "alive");
1299
1293
  * searchResult.forEach(({component, entity}) => {
1300
1294
  * // do something with the component and entity
1301
1295
  * })
1302
1296
  * ```
1303
1297
  * @example
1304
1298
  * ```js
1305
- * const searchResult = entityManager.search(Enemy, {status: "dead"}, true);
1299
+ * // include disabled entities and components
1300
+ * const searchResult = entityManager.search(Enemy, (component) => component.status === "dead", true);
1306
1301
  * searchResult.forEach(({component, entity}) => {
1307
1302
  * // do something with the component and entity
1308
1303
  * })
1309
1304
  * ```
1310
1305
  */
1311
- search<T extends Component>(componentType: ComponentType<T>, criteria?: SearchCriteria, includeDisabled?: boolean): SearchResult<T>[];
1306
+ search<T extends Component>(componentType: ComponentType<T>, filter?: (component: T, entity?: Entity) => boolean, includeDisabled?: boolean): SearchResult<T>[];
1312
1307
  /**
1313
1308
  * Performs a search for entities given a component type.\
1314
1309
  * This method returns a collection of objects of type SearchResult, which has the entity found, and the instance of the component.\
@@ -1326,6 +1321,7 @@ declare class EntityManager {
1326
1321
  * ```
1327
1322
  * @example
1328
1323
  * ```js
1324
+ * // include disabled entities and components
1329
1325
  * const searchResult = entityManager.search(Enemy, true);
1330
1326
  * searchResult.forEach(({component, entity}) => {
1331
1327
  * // do something with the component and entity
@@ -3135,7 +3131,7 @@ declare enum RenderDataType {
3135
3131
  Mask = 3,
3136
3132
  Geometric = 4,
3137
3133
  Video = 5,
3138
- Shadow = 6
3134
+ Darkness = 6
3139
3135
  }
3140
3136
  interface CameraData {
3141
3137
  depth: number;
@@ -3170,7 +3166,7 @@ interface MaskRenderData extends RenderData {
3170
3166
  opacity: number;
3171
3167
  }
3172
3168
 
3173
- interface ShadowRenderData extends RenderData {
3169
+ interface DarknessRenderData extends RenderData {
3174
3170
  color: string;
3175
3171
  height: number;
3176
3172
  opacity: number;
@@ -3409,8 +3405,8 @@ interface LightRendererOptions {
3409
3405
  * The LightRenderer component is used to render a light effect on the screen.\
3410
3406
  * It supports a circular light source with a specified radius and intensity.\
3411
3407
  * The light can be optionally smoothed for a softer edge effect.\
3412
- * This component requires a ShadowRenderer component to be present in the scene to function properly,
3413
- * as it works by illuminating areas within the shadow map.\
3408
+ * This component requires a DarknessRenderer component to be present in the scene to function properly,
3409
+ * as it works by illuminating areas within the darkness mask.\
3414
3410
  * @public
3415
3411
  * @category Components
3416
3412
  * @example
@@ -3428,7 +3424,7 @@ declare class LightRenderer {
3428
3424
  radius: number;
3429
3425
  /** Smooth */
3430
3426
  smooth: boolean;
3431
- /** Shadow render layer */
3427
+ /** Darkness render layer */
3432
3428
  layer: string;
3433
3429
  /** Light intensitry between 0 and 1 */
3434
3430
  intensity: number;
@@ -3559,12 +3555,12 @@ declare class MaskRenderer {
3559
3555
  }
3560
3556
 
3561
3557
  /**
3562
- * ShadowRenderer component configuration
3558
+ * DarknessRenderer component configuration
3563
3559
  * @public
3564
3560
  * @category Components Configuration
3565
3561
  * @example
3566
3562
  * ```js
3567
- * const shadowRenderer = new ShadowRenderer({
3563
+ * const darknessRenderer = new DarknessRenderer({
3568
3564
  * width: 100,
3569
3565
  * height: 50,
3570
3566
  * color: "#000000",
@@ -3573,7 +3569,7 @@ declare class MaskRenderer {
3573
3569
  * });
3574
3570
  * ```
3575
3571
  */
3576
- interface ShadowRendererOptions {
3572
+ interface DarknessRendererOptions {
3577
3573
  width: number;
3578
3574
  height: number;
3579
3575
  color: string;
@@ -3581,15 +3577,15 @@ interface ShadowRendererOptions {
3581
3577
  layer: string;
3582
3578
  }
3583
3579
  /**
3584
- * The ShadowRenderer component is used to render a shadow effect on the screen.\
3585
- * It supports a rectangular shadow with configurable width, height, color, opacity, and render layer.\
3586
- * This component works in conjunction with LightRenderer components in the scene - the shadow will
3587
- * block and be affected by any lights that intersect with it.\
3580
+ * The DarknessRenderer component is used to render a darkness effect on the screen.\
3581
+ * It supports a rectangular darkness mask with configurable width, height, color, opacity, and render layer.\
3582
+ * This component works in conjunction with LightRenderer components in the scene - the darkness will
3583
+ * block and be affected by any lights that intersect with it.
3588
3584
  * @public
3589
3585
  * @category Components
3590
3586
  * @example
3591
3587
  * ```js
3592
- * const shadowRenderer = new ShadowRenderer({
3588
+ * const darknessRenderer = new DarknessRenderer({
3593
3589
  * width: 100,
3594
3590
  * height: 50,
3595
3591
  * color: "#000000",
@@ -3598,22 +3594,22 @@ interface ShadowRendererOptions {
3598
3594
  * });
3599
3595
  * ```
3600
3596
  */
3601
- declare class ShadowRenderer {
3602
- /** Shadow width */
3597
+ declare class DarknessRenderer {
3598
+ /** Darkness rectangle width */
3603
3599
  width: number;
3604
- /** Shadow height */
3600
+ /** Darkness height */
3605
3601
  height: number;
3606
- /** Shadow color */
3602
+ /** Darkness color */
3607
3603
  color: string;
3608
- /** Shadow opacity between 0 and 1 */
3604
+ /** Darkness opacity between 0 and 1 */
3609
3605
  opacity: number;
3610
3606
  /** The render layer */
3611
3607
  layer: string;
3612
3608
  /** @internal */
3613
3609
  _boundingBox: Rectangle;
3614
3610
  /** @internal */
3615
- _renderData: ShadowRenderData;
3616
- constructor(options?: Partial<ShadowRendererOptions>);
3611
+ _renderData: DarknessRenderData;
3612
+ constructor(options?: Partial<DarknessRendererOptions>);
3617
3613
  }
3618
3614
 
3619
3615
  /**
@@ -4788,4 +4784,4 @@ declare const BuiltInDependencyIdentifiers: {
4788
4784
  TimeManager: symbol;
4789
4785
  };
4790
4786
 
4791
- export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, type AudioPlayerState, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, BuiltInDependencyIdentifiers, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, type DependencyName, type DependencyType, type DisabledComponent, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, 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, Scene, SceneManager, type SceneType, type SearchCriteria, type SearchResult, ShadowRenderer, type ShadowRendererOptions, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, 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, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, disableComponent, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };
4787
+ export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerAction, type AudioPlayerOptions, type AudioPlayerState, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, BuiltInDependencyIdentifiers, 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, type DisabledComponent, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, 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, Scene, SceneManager, type SceneType, type SearchResult, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, 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, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, disableComponent, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };