react-simple-game-engine 0.1.60 → 0.1.63

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 (40) hide show
  1. package/lib/classes/animations/animation.d.ts +14 -0
  2. package/lib/classes/animations/avatar.animation.d.ts +16 -0
  3. package/lib/classes/animations/color.animation.d.ts +9 -0
  4. package/lib/classes/camera.d.ts +14 -0
  5. package/lib/classes/entities/circle.entity.d.ts +15 -0
  6. package/lib/classes/entities/entity-sult.d.ts +34 -0
  7. package/lib/classes/entities/entity.d.ts +55 -0
  8. package/lib/classes/entities/rect.entity.d.ts +17 -0
  9. package/lib/classes/logic-component.d.ts +16 -0
  10. package/lib/classes/p5.d.ts +11 -0
  11. package/lib/classes/particle-system.d.ts +30 -0
  12. package/lib/classes/particle.d.ts +35 -0
  13. package/lib/classes/prefab.d.ts +7 -0
  14. package/lib/classes/saver.d.ts +11 -0
  15. package/lib/classes/scene-management.d.ts +22 -0
  16. package/lib/classes/scene.d.ts +75 -0
  17. package/lib/classes/sound-watcher.d.ts +16 -0
  18. package/lib/classes/sound.d.ts +14 -0
  19. package/lib/classes/sprites/avatar.sprite.d.ts +20 -0
  20. package/lib/classes/sprites/color.sprite.d.ts +7 -0
  21. package/lib/classes/sprites/sprite.d.ts +26 -0
  22. package/lib/classes/watcher.d.ts +11 -0
  23. package/lib/classes/world-management.d.ts +28 -0
  24. package/lib/decorators/scene-tag.decor.d.ts +6 -0
  25. package/lib/decorators/scene-ui.decor.d.ts +7 -0
  26. package/lib/decorators/sound-from.decor.d.ts +6 -0
  27. package/lib/decorators/sprite-from.decor.d.ts +4 -0
  28. package/lib/export-enums.d.ts +5 -0
  29. package/lib/export-interfaces.d.ts +4 -0
  30. package/lib/export-types.d.ts +53 -0
  31. package/lib/index.d.ts +25 -0
  32. package/lib/ui-components/SceneRunner.d.ts +14 -0
  33. package/lib/ui-components/ScenesProcess.d.ts +9 -0
  34. package/lib/ui-components/Sketch.d.ts +12 -0
  35. package/lib/{utilities.js → utilities.d.ts} +1 -0
  36. package/lib/utils.d.ts +8 -0
  37. package/package.json +4 -5
  38. package/lib/export-enums.js +0 -5
  39. package/lib/export-interfaces.js +0 -1
  40. package/lib/export-types.js +0 -1
@@ -0,0 +1,14 @@
1
+ import { Sprite } from "../sprites/sprite";
2
+ export declare abstract class AnimationSprite<S extends Sprite<any>> {
3
+ protected currentFrame: number;
4
+ protected _isRunning: boolean;
5
+ protected timeCounter: number;
6
+ delatime: number;
7
+ sprite: S;
8
+ set isRunning(_isRunning: boolean);
9
+ abstract initial(params: any): void;
10
+ draw(): void;
11
+ protected abstract checkFrameMax(): boolean;
12
+ protected abstract onDraw(): void;
13
+ }
14
+ //# sourceMappingURL=animation.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { AvatarSprite } from "../sprites/avatar.sprite";
2
+ import { AnimationSprite } from "./animation";
3
+ declare type Offset = {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ };
9
+ export declare class AvatarAnimationSprite extends AnimationSprite<AvatarSprite> {
10
+ private offset;
11
+ initial({ x, y, width, height }: Partial<Offset>): void;
12
+ protected checkFrameMax(): boolean;
13
+ onDraw(): void;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=avatar.animation.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ColorSprite } from "../sprites/color.sprite";
2
+ import { AnimationSprite } from "./animation";
3
+ export declare class ColorAnimationSprite extends AnimationSprite<ColorSprite> {
4
+ private colors;
5
+ initial(colors: ColorSprite["source"][]): void;
6
+ protected checkFrameMax(): boolean;
7
+ protected onDraw(): void;
8
+ }
9
+ //# sourceMappingURL=color.animation.d.ts.map
@@ -0,0 +1,14 @@
1
+ export declare class Camera {
2
+ private _width;
3
+ private _height;
4
+ x: number;
5
+ y: number;
6
+ scaleX: number;
7
+ scaleY: number;
8
+ constructor(_width: number, _height: number);
9
+ get width(): number;
10
+ get height(): number;
11
+ set width(width: number);
12
+ set height(height: number);
13
+ }
14
+ //# sourceMappingURL=camera.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { Body } from "matter-js";
2
+ import { CreateBodyDefine, EntityInitial } from "../../export-types";
3
+ import { Entity } from "./entity";
4
+ export declare class CircleEntity<P extends Record<string, any> = Record<string, any>> extends Entity<P> {
5
+ radius: number;
6
+ onSpriteWidthHeightBinding(): {
7
+ width: number;
8
+ height: number;
9
+ };
10
+ protected onInitial(): EntityInitial<this>;
11
+ protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
12
+ radius: number;
13
+ }>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
14
+ }
15
+ //# sourceMappingURL=circle.entity.d.ts.map
@@ -0,0 +1,34 @@
1
+ import { Initialler } from "../../export-interfaces";
2
+ import { Camera } from "../camera";
3
+ import { LogicComponent } from "../logic-component";
4
+ import { Scene } from "../scene";
5
+ import { WorldManagement } from "../world-management";
6
+ export declare abstract class EntitySult<P = any> implements Initialler<P> {
7
+ camera: Camera;
8
+ readonly id: string;
9
+ private _layerIndex;
10
+ private _name;
11
+ private _scene;
12
+ private _worldManagement;
13
+ private _children;
14
+ private _parent?;
15
+ abstract update(): void;
16
+ abstract draw(): void;
17
+ get children(): EntitySult<any>[];
18
+ get layerIndex(): number;
19
+ get name(): string;
20
+ set layerIndex(_layerIndex: number);
21
+ set name(_name: string);
22
+ get parent(): EntitySult<any> | undefined;
23
+ get scene(): Scene<any>;
24
+ get worldManagement(): WorldManagement;
25
+ addChild(target: EntitySult | LogicComponent<EntitySult>): void;
26
+ removeChild(entity: EntitySult): void;
27
+ unChild(entity: EntitySult): void;
28
+ getProperty<T>(name: string): T;
29
+ preInitial(worldManagement: WorldManagement): void;
30
+ active(worldManagement: WorldManagement): void;
31
+ onActive(): void;
32
+ initial(params: P): void;
33
+ }
34
+ //# sourceMappingURL=entity-sult.d.ts.map
@@ -0,0 +1,55 @@
1
+ import Matter from "matter-js";
2
+ import { Sprite } from "../sprites/sprite";
3
+ import { CreateBodyDefine, EntityInitial, EntityPrepare, MasterBody } from "../../export-types";
4
+ import { EntitySult } from "./entity-sult";
5
+ import { LogicComponent } from "../logic-component";
6
+ import { Sound } from "../sound";
7
+ declare type TimerJobListener = () => void;
8
+ declare type TerminateOptions = {
9
+ duration?: number;
10
+ effect: EntitySult | LogicComponent<EntitySult>;
11
+ };
12
+ export declare abstract class Entity<P extends Record<string, any> = Record<string, any>> extends EntitySult<EntityInitial<Entity>> {
13
+ private _body;
14
+ private _sprite;
15
+ private _props;
16
+ private timerJobListeners;
17
+ private isTerminate;
18
+ enabledGravity: boolean;
19
+ sound?: Sound;
20
+ set sprite(sprite: Sprite<any>);
21
+ get sprite(): Sprite<any>;
22
+ get position(): Matter.Vector;
23
+ get body(): MasterBody;
24
+ get props(): P;
25
+ /**
26
+ * @param {TerminateOptions} options
27
+ * #duration: time to disappear from the world in seconds, default: 0.2 seconds
28
+ * #effect: effect to showing on duration time
29
+ * @void
30
+ */
31
+ terminate(options?: TerminateOptions): void;
32
+ /**
33
+ * @param {number} interval in seconds
34
+ * @param {TimerJobListener} job function that run per #interval
35
+ * @void
36
+ */
37
+ onTimer(interval: number, job: TimerJobListener, defaultRun?: boolean): () => void;
38
+ createBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): MasterBody;
39
+ protected abstract onCreateBody(transform: CreateBodyDefine["transform"], options?: CreateBodyDefine["bodyOptions"]): Matter.Body;
40
+ initial({ transform, sprite: spriteComponent, bodyOptions, props, ...params }: EntityInitial<this>): void;
41
+ protected abstract onInitial(): EntityInitial<this>;
42
+ protected onPrepare(): EntityPrepare<this>;
43
+ update(): void;
44
+ onUpdate(): void;
45
+ draw(): void;
46
+ abstract onSpriteWidthHeightBinding(): {
47
+ width: number;
48
+ height: number;
49
+ };
50
+ onCollision(target: Entity): void;
51
+ onCollisionEnd(target: Entity): void;
52
+ onCollisionActive(target: Entity): void;
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { Body } from "matter-js";
2
+ import { CreateBodyDefine, EntityInitial } from "../../export-types";
3
+ import { Entity } from "./entity";
4
+ export declare class RectEntity<P extends Record<string, any> = any> extends Entity<P> {
5
+ width: number;
6
+ height: number;
7
+ onSpriteWidthHeightBinding(): {
8
+ width: number;
9
+ height: number;
10
+ };
11
+ protected onInitial(): EntityInitial<this>;
12
+ protected onCreateBody({ x, y, ...transform }: NonNullable<CreateBodyDefine<{
13
+ width?: number;
14
+ height?: number;
15
+ }>["transform"]>, options?: CreateBodyDefine["bodyOptions"]): Body;
16
+ }
17
+ //# sourceMappingURL=rect.entity.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { Initialler } from "../export-interfaces";
2
+ import { Configable, Configation } from "../export-types";
3
+ import { WorldManagement } from "./world-management";
4
+ export declare class LogicComponent<C extends Initialler = Initialler> {
5
+ private readonly configale;
6
+ private readonly _isPrefab?;
7
+ private _worldManagement;
8
+ layerIndex: number;
9
+ constructor(configale: Configable<C>, _isPrefab?: boolean | undefined);
10
+ get isPrefab(): boolean | undefined;
11
+ set worldManagement(_worldManagement: WorldManagement);
12
+ output({ worldManagement, ...targetParams }?: {
13
+ worldManagement?: WorldManagement;
14
+ } & Configation<C>): C;
15
+ }
16
+ //# sourceMappingURL=logic-component.d.ts.map
@@ -0,0 +1,11 @@
1
+ import p5 from "p5";
2
+ declare type ItemWithPercent<I> = [I, number];
3
+ declare type LastItem<I> = [I];
4
+ export declare type Collection<I> = [...ItemWithPercent<I>[], LastItem<I>];
5
+ export declare class P5 extends p5 {
6
+ running: boolean;
7
+ constructor(sketch: (p5: P5) => void);
8
+ choose<I = any>(collection: Collection<I>): I;
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=p5.d.ts.map
@@ -0,0 +1,30 @@
1
+ import p5 from "p5";
2
+ import { Particle, ParticleInitialParams } from "./particle";
3
+ import { EntitySult } from "./entities/entity-sult";
4
+ declare type ParticleClass = {
5
+ new (...args: ConstructorParameters<typeof Particle>): Particle;
6
+ };
7
+ declare type ParticleOptions = Omit<ParticleInitialParams, "vec" | "angle" | "camera"> & {
8
+ x?: number;
9
+ y?: number;
10
+ };
11
+ declare type ParticleSystemInitialParams = {
12
+ particleClass?: ParticleClass;
13
+ particleOptions?: ParticleOptions;
14
+ quantityPerFrame?: number;
15
+ vecWeight?: number;
16
+ forces?: p5.Vector[];
17
+ };
18
+ export declare class ParticleSystem extends EntitySult<ParticleSystemInitialParams> {
19
+ private particles;
20
+ private forces;
21
+ private particleOptions;
22
+ private particleClass;
23
+ quantityPerFrame: number;
24
+ vecWeight: number;
25
+ initial({ forces, particleOptions, ...params }: ParticleSystemInitialParams): void;
26
+ update(): void;
27
+ draw(): void;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=particle-system.d.ts.map
@@ -0,0 +1,35 @@
1
+ import p5 from "p5";
2
+ import { Initialler } from "../export-interfaces";
3
+ import { Avatar, Color } from "../export-types";
4
+ import { Camera } from "./camera";
5
+ export declare type ParticleInitialParams = {
6
+ vec?: p5.Vector;
7
+ angle?: number;
8
+ sprite?: Avatar;
9
+ color?: Color;
10
+ size?: number;
11
+ lifetime?: number;
12
+ camera: Camera;
13
+ forceSpriteSize?: boolean;
14
+ };
15
+ export declare class Particle extends p5.Vector implements Initialler<ParticleInitialParams> {
16
+ private vec;
17
+ private acc;
18
+ private angle;
19
+ camera: Camera;
20
+ sprite?: Avatar;
21
+ color: Color;
22
+ size: number;
23
+ lifetimeRemain: number;
24
+ private forceSpriteSize;
25
+ private _lifetime;
26
+ set lifetime(lifetime: number);
27
+ get lifetime(): number;
28
+ initial({ vec, ...params }: ParticleInitialParams): void;
29
+ applyForce(force: p5.Vector): void;
30
+ isDead(): boolean;
31
+ update(): void;
32
+ draw(): void;
33
+ onDraw(_: Color): void;
34
+ }
35
+ //# sourceMappingURL=particle.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { Configable } from "../export-types";
2
+ import { EntitySult } from "./entities/entity-sult";
3
+ import { LogicComponent } from "./logic-component";
4
+ export declare class Prefab<C extends EntitySult = EntitySult> extends LogicComponent<C> {
5
+ constructor(configale: Configable<C>);
6
+ }
7
+ //# sourceMappingURL=prefab.d.ts.map
@@ -0,0 +1,11 @@
1
+ declare type Typed = never | undefined | BooleanConstructor | StringConstructor | NumberConstructor;
2
+ declare type ValueType<V extends any = undefined, T extends Typed = Typed> = V extends undefined ? T extends BooleanConstructor ? boolean : T extends StringConstructor ? string : T extends NumberConstructor ? number : V : V;
3
+ declare class _Saver {
4
+ private store;
5
+ constructor();
6
+ set<V extends any = any>(key: string, value: V): void;
7
+ get<V extends any = undefined, T extends Typed = Typed>(key: string, type?: T): ValueType<V, T>;
8
+ }
9
+ export declare const Saver: _Saver;
10
+ export {};
11
+ //# sourceMappingURL=saver.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { Scene } from "./scene";
2
+ export declare type SceneClass = {
3
+ new (): Scene;
4
+ tag?: string;
5
+ };
6
+ declare type ChangeSceneListener = (scene: Scene) => void;
7
+ export declare class SceneManagement {
8
+ private Scenes;
9
+ private _currentScene;
10
+ private changeSceneListener;
11
+ static getTag(Scene: SceneClass): string | undefined;
12
+ constructor(Scenes: SceneClass[]);
13
+ get currentScene(): Scene<any>;
14
+ onChangeScene(func: ChangeSceneListener): void;
15
+ canNext(): boolean;
16
+ next(): void;
17
+ replay(): void;
18
+ gotoScene(tag: string): void;
19
+ private startScene;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=scene-management.d.ts.map
@@ -0,0 +1,75 @@
1
+ /// <reference types="p5" />
2
+ import { ComponentType } from "react";
3
+ import { Camera } from "./camera";
4
+ import { LogicComponent } from "./logic-component";
5
+ import { SceneManagement } from "./scene-management";
6
+ import { EntitySult } from "./entities/entity-sult";
7
+ import { Prefab } from "./prefab";
8
+ import { Sound } from "./sound";
9
+ import { Avatar, GetSoundOptions, SoundDecor, SoundManagement, SpriteDecor } from "../export-types";
10
+ import { SoundType } from "../export-enums";
11
+ declare type SoundOptionsChangeListener<O extends SoundType> = (options: SoundManagement[O]) => void;
12
+ declare type LoadAssetsListener = (loadedAssets: boolean) => void;
13
+ declare type EntityPropsChangeListener<V = any> = (value: V) => void;
14
+ export declare abstract class Scene<UIP = any> {
15
+ static soundsDecor: SoundDecor[];
16
+ static spritesDecor: SpriteDecor[];
17
+ private ui;
18
+ private worldManagement;
19
+ private _loadedAssets;
20
+ private loadAssetsListener;
21
+ private readonly entityPropsChangeListeners;
22
+ private readonly soundBackgroundOptionsChangeListeners;
23
+ private readonly soundOnceOptionsChangeListeners;
24
+ private readonly prefabs;
25
+ readonly sounds: Sound[];
26
+ readonly sprites: Avatar[];
27
+ assetsDelay: number;
28
+ tag: string;
29
+ manager: SceneManagement;
30
+ readonly sessionId: string;
31
+ abstract getComponents(camera: Camera): LogicComponent<EntitySult>[];
32
+ constructor();
33
+ get UI(): ComponentType<UIP>;
34
+ get UIProps(): UIP;
35
+ get soundBackgroundOptions(): SoundManagement[SoundType.BACKGROUND];
36
+ get soundOnceOptions(): SoundManagement[SoundType.ONCE];
37
+ set soundBackgroundOptions(options: Partial<SoundManagement[SoundType.BACKGROUND]>);
38
+ set soundOnceOptions(options: Partial<SoundManagement[SoundType.ONCE]>);
39
+ onSoundOnceOptionsChange(func: SoundOptionsChangeListener<SoundType.ONCE>): () => void;
40
+ onSoundBackgroundOptionsChange(func: SoundOptionsChangeListener<SoundType.BACKGROUND>): () => void;
41
+ private bootSoundOptions;
42
+ protected getSoundOptions(): GetSoundOptions;
43
+ protected onBorn(): void;
44
+ protected getUIProps(): UIP;
45
+ get loadedAssets(): boolean;
46
+ private set loadedAssets(value);
47
+ emitEntityPropsChange<V = any>(name: string, value: V): void;
48
+ onEntityPropsChange<V = any>(name: string, func: EntityPropsChangeListener<V>): () => void;
49
+ onLoadAssetNotify(func: LoadAssetsListener): void;
50
+ destructor(): void;
51
+ switchToScene(tag: string): void;
52
+ private loadSprites;
53
+ private loadSounds;
54
+ createSprites(...srcables: (string | {
55
+ src: string;
56
+ })[]): Promise<import("p5").Image[]>;
57
+ createSounds(...srcables: (string | {
58
+ src: string;
59
+ volumn?: number;
60
+ type?: SoundType;
61
+ })[]): Promise<Sound[]>;
62
+ mapSprites(...srcs: string[]): Promise<void>;
63
+ mapSounds(...srcs: string[]): Promise<void>;
64
+ loadAssets(delay?: number): Promise<void>;
65
+ onLoadAssets(): Promise<void>;
66
+ getPrefab<C extends EntitySult>(Class: {
67
+ new (...args: any[]): Prefab<C>;
68
+ }): Prefab<C>;
69
+ bootstrap(camera: Camera): void;
70
+ protected onDraw(): void;
71
+ protected onUpdate(): void;
72
+ action(): void;
73
+ }
74
+ export {};
75
+ //# sourceMappingURL=scene.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from "react";
2
+ import { SoundType } from "../export-enums";
3
+ import { SoundManagement } from "../export-types";
4
+ import { Scene } from "./scene";
5
+ declare type SoundOnceWatcherProps = {
6
+ scene: Scene;
7
+ children: (value: SoundManagement[SoundType.ONCE]) => ReactNode;
8
+ };
9
+ export declare function SoundOnceWatcher({ scene, children }: SoundOnceWatcherProps): JSX.Element;
10
+ declare type SoundBackgroundWatcherProps = {
11
+ scene: Scene;
12
+ children: (value: SoundManagement[SoundType.BACKGROUND]) => ReactNode;
13
+ };
14
+ export declare function SoundBackgroundWatcher({ scene, children, }: SoundBackgroundWatcherProps): JSX.Element;
15
+ export {};
16
+ //# sourceMappingURL=sound-watcher.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { SoundType } from "../export-enums";
2
+ import { SoundManagement } from "../export-types";
3
+ export declare class Sound {
4
+ private readonly type;
5
+ static Management: SoundManagement;
6
+ readonly native: HTMLAudioElement;
7
+ constructor(type?: SoundType);
8
+ get volumn(): number;
9
+ set volumn(vol: number);
10
+ playNow(): Promise<void>;
11
+ stop(): Promise<void>;
12
+ play(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=sound.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { Avatar } from "../../export-types";
2
+ import { GetInitialParams, Sprite } from "./sprite";
3
+ declare type SpriteOffet = {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ index: number;
9
+ };
10
+ declare type AvatarGetInitialParams<S extends AvatarSprite> = GetInitialParams<S> & {
11
+ offset?: Partial<SpriteOffet>;
12
+ };
13
+ export declare class AvatarSprite extends Sprite<Avatar | undefined | null> {
14
+ private _offset;
15
+ get offset(): SpriteOffet;
16
+ onDraw(): void;
17
+ initial(params?: AvatarGetInitialParams<this>): void;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=avatar.sprite.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { Color } from "../../export-types";
2
+ import { Sprite } from "./sprite";
3
+ export declare class ColorSprite extends Sprite<Color> {
4
+ constructor();
5
+ onDraw(): void;
6
+ }
7
+ //# sourceMappingURL=color.sprite.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { Avatar, Color } from "../../export-types";
2
+ import { AnimationSprite } from "../animations/animation";
3
+ import { Entity } from "../entities/entity";
4
+ import { LogicComponent } from "../logic-component";
5
+ export declare type SourceType = Avatar | Color | undefined | null;
6
+ export declare type GetInitialParams<S extends Sprite<any> = any> = {
7
+ source?: S["source"];
8
+ animation?: LogicComponent<AnimationSprite<S>>;
9
+ };
10
+ export declare abstract class Sprite<SpriteType extends SourceType> {
11
+ source: SpriteType;
12
+ private _entity;
13
+ private _width;
14
+ private _height;
15
+ private _animation;
16
+ set animation(ani: AnimationSprite<this>);
17
+ get animation(): AnimationSprite<this>;
18
+ set entity(entity: Entity);
19
+ get entity(): Entity;
20
+ get width(): number;
21
+ get height(): number;
22
+ draw(): void;
23
+ abstract onDraw(): void;
24
+ initial(params?: GetInitialParams<this>): void;
25
+ }
26
+ //# sourceMappingURL=sprite.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ import { Scene } from "./scene";
3
+ declare type WatcherProps<IV> = {
4
+ scene: Scene;
5
+ names: string | string[];
6
+ initialValues: IV;
7
+ children: (value: IV) => ReactNode;
8
+ };
9
+ export declare function Watcher<IV extends Record<string, any> = Record<string, any>>({ scene, names: _names, children, initialValues, }: WatcherProps<IV>): JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=watcher.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { Engine } from "matter-js";
2
+ import { Camera } from "./camera";
3
+ import { Scene } from "./scene";
4
+ import { EntitySult } from "./entities/entity-sult";
5
+ export declare class WorldManagement {
6
+ private _camera;
7
+ private _scene;
8
+ private readonly entitiesHash;
9
+ private readonly entitiesPool;
10
+ private readonly entitiesName;
11
+ private _engine;
12
+ constructor(_camera: Camera, _scene: Scene);
13
+ get engine(): Engine;
14
+ get camera(): Camera;
15
+ get scene(): Scene<any>;
16
+ private iterateEntities;
17
+ private joinPool;
18
+ private outPool;
19
+ destructor(): void;
20
+ changeEntityLayerIndex(entity: EntitySult, newIndex: number): void;
21
+ changeEntityName(entity: EntitySult, newName: string): void;
22
+ getEntity<T extends EntitySult = EntitySult>(name: string): T;
23
+ addEntity(entity: EntitySult): void;
24
+ removeEntity(entity: EntitySult): void;
25
+ update(): void;
26
+ draw(): void;
27
+ }
28
+ //# sourceMappingURL=world-management.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { Scene } from "../classes/scene";
2
+ export declare function SceneTag(tag: string): (target: {
3
+ tag?: string;
4
+ new (): Scene;
5
+ }) => void;
6
+ //# sourceMappingURL=scene-tag.decor.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { ComponentType } from "react";
2
+ import { Scene } from "../classes/scene";
3
+ export declare function SceneUI(ui: ComponentType<any>): (target: {
4
+ ui?: ComponentType<any>;
5
+ new (): Scene;
6
+ }) => void;
7
+ //# sourceMappingURL=scene-ui.decor.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { SoundType } from "../export-enums";
2
+ export declare function SoundFrom(srcable?: string | {
3
+ src?: string;
4
+ volumn?: number;
5
+ }, type?: SoundType): (target: any, propertyKey: string) => void;
6
+ //# sourceMappingURL=sound-from.decor.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare function SpriteFrom(srcable?: string | {
2
+ src?: string;
3
+ }): (target: any, propertyKey: string) => void;
4
+ //# sourceMappingURL=sprite-from.decor.d.ts.map
@@ -0,0 +1,5 @@
1
+ export declare enum SoundType {
2
+ ONCE = 0,
3
+ BACKGROUND = 1
4
+ }
5
+ //# sourceMappingURL=export-enums.d.ts.map
@@ -0,0 +1,4 @@
1
+ export interface Initialler<P = any> {
2
+ initial: (params: P) => void;
3
+ }
4
+ //# sourceMappingURL=export-interfaces.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { Entity } from "./classes/entities/entity";
2
+ import { Sprite } from "./classes/sprites/sprite";
3
+ import type { Body, IChamferableBodyDefinition } from "matter-js";
4
+ import { Initialler } from "./export-interfaces";
5
+ import { Sound } from "./classes/sound";
6
+ import { SoundType } from "./export-enums";
7
+ export type { Collection } from "./classes/p5";
8
+ export declare type Avatar = ReturnType<import("./classes/p5").P5["loadImage"]>;
9
+ export declare type Color = [number, number, number, number?];
10
+ export declare type EntityPrepare<E extends Entity> = EntityInitial<E>;
11
+ export declare type MasterBody = Body & {
12
+ entity: Entity;
13
+ };
14
+ export declare type CreateBodyDefine<E extends Record<string, any> = Record<string, any>> = {
15
+ transform?: {
16
+ x?: number;
17
+ y?: number;
18
+ } & E;
19
+ bodyOptions?: IChamferableBodyDefinition;
20
+ };
21
+ declare type TransformArgs<E extends Entity> = Parameters<E["onCreateBody"]>[0];
22
+ declare type BodyOptionsArgs<E extends Entity> = Parameters<E["onCreateBody"]>[1];
23
+ export declare type EntityInitial<E extends Entity> = {
24
+ transform?: TransformArgs<E>;
25
+ bodyOptions?: BodyOptionsArgs<E>;
26
+ sprite?: import("./classes/logic-component").LogicComponent<Sprite<any>>;
27
+ sound?: Sound;
28
+ enabledGravity?: boolean;
29
+ name?: string;
30
+ props?: Partial<E["props"]>;
31
+ };
32
+ export declare type Configation<C extends Initialler> = Parameters<C["initial"]>[0];
33
+ export declare type Configable<C extends Initialler = Initialler> = {
34
+ new (): C;
35
+ } | [{
36
+ new (): C;
37
+ }, Configation<C>];
38
+ export declare type SoundManagement = Record<SoundType, {
39
+ canPlay: boolean;
40
+ loop: boolean;
41
+ }>;
42
+ export declare type SoundDecor = {
43
+ propertyKey: string;
44
+ src?: string;
45
+ type: SoundType;
46
+ volumn?: number;
47
+ };
48
+ export declare type SpriteDecor = {
49
+ propertyKey: string;
50
+ src?: string;
51
+ };
52
+ export declare type GetSoundOptions = DeepPartial<SoundManagement>;
53
+ //# sourceMappingURL=export-types.d.ts.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ export { Saver } from "./classes/saver";
2
+ export { Sound } from "./classes/sound";
3
+ export { P5 } from "./classes/p5";
4
+ export { ParticleSystem } from "./classes/particle-system";
5
+ export { Particle } from "./classes/particle";
6
+ export { AnimationSprite } from "./classes/animations/animation";
7
+ export { AvatarAnimationSprite } from "./classes/animations/avatar.animation";
8
+ export { ColorAnimationSprite } from "./classes/animations/color.animation";
9
+ export { Entity } from "./classes/entities/entity";
10
+ export { CircleEntity } from "./classes/entities/circle.entity";
11
+ export { RectEntity } from "./classes/entities/rect.entity";
12
+ export { Prefab } from "./classes/prefab";
13
+ export { LogicComponent } from "./classes/logic-component";
14
+ export { Scene } from "./classes/scene";
15
+ export { Camera } from "./classes/camera";
16
+ export { Sprite } from "./classes/sprites/sprite";
17
+ export { AvatarSprite } from "./classes/sprites/avatar.sprite";
18
+ export { ColorSprite } from "./classes/sprites/color.sprite";
19
+ export { SpriteFrom } from "./decorators/sprite-from.decor";
20
+ export { SoundFrom } from "./decorators/sound-from.decor";
21
+ export { SceneTag } from "./decorators/scene-tag.decor";
22
+ export { SceneUI } from "./decorators/scene-ui.decor";
23
+ export { ScenesProcess } from "./ui-components/ScenesProcess";
24
+ export { default as Matter } from "matter-js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { ComponentType, ReactNode } from "react";
2
+ import { Scene } from "../classes/scene";
3
+ export declare type SceneRunnerPublicProps = {
4
+ width: number;
5
+ height: number;
6
+ assetsLoader?: ReactNode | ComponentType;
7
+ assetsDelay?: number;
8
+ };
9
+ declare type SceneRunnerProps = SceneRunnerPublicProps & {
10
+ current: Scene;
11
+ };
12
+ export declare function SceneRunner({ assetsDelay, current, width, height, assetsLoader: AssetsLoader, }: SceneRunnerProps): JSX.Element;
13
+ export {};
14
+ //# sourceMappingURL=SceneRunner.d.ts.map
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import { SceneClass } from "../classes/scene-management";
3
+ import { SceneRunnerPublicProps } from "./SceneRunner";
4
+ declare type WorldViewProps = SceneRunnerPublicProps & {
5
+ list: SceneClass[];
6
+ };
7
+ export declare function ScenesProcess({ list, ...props }: WorldViewProps): JSX.Element;
8
+ export {};
9
+ //# sourceMappingURL=ScenesProcess.d.ts.map
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { Camera } from "../classes/camera";
3
+ declare type SketchProps = {
4
+ onSetup: (camera: Camera) => void;
5
+ onDraw: () => void;
6
+ onPreload?: () => void;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ export declare function Sketch({ onSetup, onDraw, onPreload, width, height, }: SketchProps): JSX.Element;
11
+ export {};
12
+ //# sourceMappingURL=Sketch.d.ts.map
@@ -1,2 +1,3 @@
1
1
  export * from "./classes/watcher";
2
2
  export * from "./classes/sound-watcher";
3
+ //# sourceMappingURL=utilities.d.ts.map
package/lib/utils.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Sound } from "./classes/sound";
2
+ import { SoundType } from "./export-enums";
3
+ import { Avatar } from "./export-types";
4
+ export declare function createAssetImage(src: string): Promise<Avatar>;
5
+ export declare function createAssetSound(src: string, type?: SoundType): Promise<Sound>;
6
+ export declare function tick(delay?: number): Promise<unknown>;
7
+ export declare function copyProperties(source: Record<string, any>, target: Record<string, any>): void;
8
+ //# sourceMappingURL=utils.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-simple-game-engine",
3
- "version": "0.1.60",
3
+ "version": "0.1.63",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib",
@@ -22,10 +22,9 @@
22
22
  },
23
23
  "files": [
24
24
  "/lib/index.js",
25
- "/lib/utilities.js",
26
- "/lib/export-types.js",
27
- "/lib/export-interfaces.js",
28
- "/lib/export-enums.js"
25
+ "/lib/*/**/***.d.ts",
26
+ "/lib/*/**.d.ts",
27
+ "/lib/*.d.ts"
29
28
  ],
30
29
  "keywords": [
31
30
  "game engine",
@@ -1,5 +0,0 @@
1
- export var SoundType;
2
- (function (SoundType) {
3
- SoundType[SoundType["ONCE"] = 0] = "ONCE";
4
- SoundType[SoundType["BACKGROUND"] = 1] = "BACKGROUND";
5
- })(SoundType || (SoundType = {}));
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};