react-simple-game-engine 0.1.57 → 0.1.60

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 (103) hide show
  1. package/lib/index.js +2 -1
  2. package/lib/utilities.js +0 -1
  3. package/package.json +6 -2
  4. package/lib/classes/animations/animation.d.ts +0 -14
  5. package/lib/classes/animations/animation.d.ts.map +0 -1
  6. package/lib/classes/animations/animation.js +0 -35
  7. package/lib/classes/animations/avatar.animation.d.ts +0 -16
  8. package/lib/classes/animations/avatar.animation.d.ts.map +0 -1
  9. package/lib/classes/animations/avatar.animation.js +0 -45
  10. package/lib/classes/animations/color.animation.d.ts +0 -9
  11. package/lib/classes/animations/color.animation.d.ts.map +0 -1
  12. package/lib/classes/animations/color.animation.js +0 -33
  13. package/lib/classes/camera.d.ts +0 -14
  14. package/lib/classes/camera.d.ts.map +0 -1
  15. package/lib/classes/camera.js +0 -34
  16. package/lib/classes/entities/circle.entity.d.ts +0 -15
  17. package/lib/classes/entities/circle.entity.d.ts.map +0 -1
  18. package/lib/classes/entities/circle.entity.js +0 -55
  19. package/lib/classes/entities/entity-sult.d.ts +0 -34
  20. package/lib/classes/entities/entity-sult.d.ts.map +0 -1
  21. package/lib/classes/entities/entity-sult.js +0 -108
  22. package/lib/classes/entities/entity.d.ts +0 -55
  23. package/lib/classes/entities/entity.d.ts.map +0 -1
  24. package/lib/classes/entities/entity.js +0 -180
  25. package/lib/classes/entities/rect.entity.d.ts +0 -17
  26. package/lib/classes/entities/rect.entity.d.ts.map +0 -1
  27. package/lib/classes/entities/rect.entity.js +0 -56
  28. package/lib/classes/logic-component.d.ts +0 -16
  29. package/lib/classes/logic-component.d.ts.map +0 -1
  30. package/lib/classes/logic-component.js +0 -77
  31. package/lib/classes/p5.d.ts +0 -11
  32. package/lib/classes/p5.d.ts.map +0 -1
  33. package/lib/classes/p5.js +0 -58
  34. package/lib/classes/particle-system.d.ts +0 -30
  35. package/lib/classes/particle-system.d.ts.map +0 -1
  36. package/lib/classes/particle-system.js +0 -98
  37. package/lib/classes/particle.d.ts +0 -35
  38. package/lib/classes/particle.d.ts.map +0 -1
  39. package/lib/classes/particle.js +0 -117
  40. package/lib/classes/prefab.d.ts +0 -7
  41. package/lib/classes/prefab.d.ts.map +0 -1
  42. package/lib/classes/prefab.js +0 -24
  43. package/lib/classes/saver.d.ts +0 -11
  44. package/lib/classes/saver.d.ts.map +0 -1
  45. package/lib/classes/saver.js +0 -33
  46. package/lib/classes/scene-management.d.ts +0 -22
  47. package/lib/classes/scene-management.d.ts.map +0 -1
  48. package/lib/classes/scene-management.js +0 -58
  49. package/lib/classes/scene.d.ts +0 -67
  50. package/lib/classes/scene.d.ts.map +0 -1
  51. package/lib/classes/scene.js +0 -338
  52. package/lib/classes/sound-watcher.d.ts +0 -16
  53. package/lib/classes/sound-watcher.d.ts.map +0 -1
  54. package/lib/classes/sound-watcher.js +0 -33
  55. package/lib/classes/sound.d.ts +0 -14
  56. package/lib/classes/sound.d.ts.map +0 -1
  57. package/lib/classes/sound.js +0 -119
  58. package/lib/classes/sprites/avatar.sprite.d.ts +0 -20
  59. package/lib/classes/sprites/avatar.sprite.d.ts.map +0 -1
  60. package/lib/classes/sprites/avatar.sprite.js +0 -89
  61. package/lib/classes/sprites/color.sprite.d.ts +0 -7
  62. package/lib/classes/sprites/color.sprite.d.ts.map +0 -1
  63. package/lib/classes/sprites/color.sprite.js +0 -40
  64. package/lib/classes/sprites/sprite.d.ts +0 -26
  65. package/lib/classes/sprites/sprite.d.ts.map +0 -1
  66. package/lib/classes/sprites/sprite.js +0 -70
  67. package/lib/classes/watcher.d.ts +0 -11
  68. package/lib/classes/watcher.d.ts.map +0 -1
  69. package/lib/classes/watcher.js +0 -44
  70. package/lib/classes/world-management.d.ts +0 -28
  71. package/lib/classes/world-management.d.ts.map +0 -1
  72. package/lib/classes/world-management.js +0 -160
  73. package/lib/decorators/scene-sound.decor.d.ts +0 -6
  74. package/lib/decorators/scene-sound.decor.d.ts.map +0 -1
  75. package/lib/decorators/scene-sound.decor.js +0 -17
  76. package/lib/decorators/scene-tag.decor.d.ts +0 -6
  77. package/lib/decorators/scene-tag.decor.d.ts.map +0 -1
  78. package/lib/decorators/scene-tag.decor.js +0 -5
  79. package/lib/decorators/scene-ui.decor.d.ts +0 -7
  80. package/lib/decorators/scene-ui.decor.d.ts.map +0 -1
  81. package/lib/decorators/scene-ui.decor.js +0 -5
  82. package/lib/export-enums.d.ts +0 -5
  83. package/lib/export-enums.d.ts.map +0 -1
  84. package/lib/export-interfaces.d.ts +0 -4
  85. package/lib/export-interfaces.d.ts.map +0 -1
  86. package/lib/export-types.d.ts +0 -49
  87. package/lib/export-types.d.ts.map +0 -1
  88. package/lib/index.d.ts +0 -24
  89. package/lib/index.d.ts.map +0 -1
  90. package/lib/ui-components/SceneRunner.d.ts +0 -14
  91. package/lib/ui-components/SceneRunner.d.ts.map +0 -1
  92. package/lib/ui-components/SceneRunner.js +0 -43
  93. package/lib/ui-components/ScenesProcess.d.ts +0 -9
  94. package/lib/ui-components/ScenesProcess.d.ts.map +0 -1
  95. package/lib/ui-components/ScenesProcess.js +0 -46
  96. package/lib/ui-components/Sketch.d.ts +0 -12
  97. package/lib/ui-components/Sketch.d.ts.map +0 -1
  98. package/lib/ui-components/Sketch.js +0 -33
  99. package/lib/utilities.d.ts +0 -4
  100. package/lib/utilities.d.ts.map +0 -1
  101. package/lib/utils.d.ts +0 -8
  102. package/lib/utils.d.ts.map +0 -1
  103. package/lib/utils.js +0 -97
@@ -1,40 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- import { Sprite } from "./sprite";
17
- var ColorSprite = /** @class */ (function (_super) {
18
- __extends(ColorSprite, _super);
19
- function ColorSprite() {
20
- var _this = _super.call(this) || this;
21
- _this.source = [255, 255, 255];
22
- return _this;
23
- }
24
- ColorSprite.prototype.onDraw = function () {
25
- if (this.animation) {
26
- this.animation.draw();
27
- }
28
- else {
29
- Renderer.fill.apply(Renderer, this.source);
30
- }
31
- if (this.entity.width != null) {
32
- Renderer.rect(0, 0, this.width, this.height);
33
- }
34
- else {
35
- Renderer.circle(0, 0, this.width);
36
- }
37
- };
38
- return ColorSprite;
39
- }(Sprite));
40
- export { ColorSprite };
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,oBAAY,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC;AAE3D,oBAAY,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI;IAC1D,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACrB,SAAS,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,8BAAsB,MAAM,CAAC,UAAU,SAAS,UAAU;IACjD,MAAM,EAAG,UAAU,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,OAAO,CAAU;IAEzB,OAAO,CAAC,UAAU,CAAoC;IAEtD,IAAI,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,EAGvC;IAED,IAAI,SAAS,IAAI,eAAe,CAAC,IAAI,CAAC,CAErC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAKxB;IAED,IAAI,MAAM,IAPS,MAAM,CASxB;IAED,IAAI,KAAK,WAER;IAED,IAAI,MAAM,WAET;IAED,IAAI;IAUJ,QAAQ,CAAC,MAAM,IAAI,IAAI;IAEvB,OAAO,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,IAAI,CAAC;CAexC"}
@@ -1,70 +0,0 @@
1
- import { LogicComponent } from "../logic-component";
2
- var Sprite = /** @class */ (function () {
3
- function Sprite() {
4
- }
5
- Object.defineProperty(Sprite.prototype, "animation", {
6
- get: function () {
7
- return this._animation;
8
- },
9
- set: function (ani) {
10
- this._animation = ani;
11
- this._animation.sprite = this;
12
- },
13
- enumerable: false,
14
- configurable: true
15
- });
16
- Object.defineProperty(Sprite.prototype, "entity", {
17
- get: function () {
18
- return this._entity;
19
- },
20
- set: function (entity) {
21
- this._entity = entity;
22
- var _a = this._entity.onSpriteWidthHeightBinding(), width = _a.width, height = _a.height;
23
- this._width = width;
24
- this._height = height;
25
- },
26
- enumerable: false,
27
- configurable: true
28
- });
29
- Object.defineProperty(Sprite.prototype, "width", {
30
- get: function () {
31
- return this._width;
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
- Object.defineProperty(Sprite.prototype, "height", {
37
- get: function () {
38
- return this._height;
39
- },
40
- enumerable: false,
41
- configurable: true
42
- });
43
- Sprite.prototype.draw = function () {
44
- var _a = this.entity, body = _a.body, position = _a.position, camera = _a.camera;
45
- Renderer.push();
46
- Renderer.noStroke();
47
- Renderer.translate(position.x - camera.x, position.y - camera.y);
48
- Renderer.rotate(body.angle);
49
- this.onDraw();
50
- Renderer.pop();
51
- };
52
- Sprite.prototype.initial = function (params) {
53
- if (params) {
54
- for (var key in params) {
55
- // @ts-ignore
56
- var P = params[key];
57
- if (P instanceof LogicComponent) {
58
- // @ts-ignore
59
- this[key] = P.output();
60
- }
61
- else {
62
- // @ts-ignore
63
- this[key] = P;
64
- }
65
- }
66
- }
67
- };
68
- return Sprite;
69
- }());
70
- export { Sprite };
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/classes/watcher.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,aAAK,YAAY,CAAC,EAAE,IAAI;IACtB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,EAAE,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,SAAS,CAAC;CACpC,CAAC;AACF,wBAAgB,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC5E,KAAK,EACL,KAAK,EAAE,MAAM,EACb,QAAQ,EACR,aAAa,GACd,EAAE,YAAY,CAAC,EAAE,CAAC,eAqBlB"}
@@ -1,44 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
- if (ar || !(i in from)) {
15
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
- ar[i] = from[i];
17
- }
18
- }
19
- return to.concat(ar || Array.prototype.slice.call(from));
20
- };
21
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
22
- import { useEffect, useState } from "react";
23
- export function Watcher(_a) {
24
- var scene = _a.scene, _names = _a.names, children = _a.children, initialValues = _a.initialValues;
25
- var names = Array.isArray(_names) ? _names : [_names];
26
- var _b = useState(initialValues), values = _b[0], setValues = _b[1];
27
- useEffect(function () {
28
- var unsubs = names.map(function (name) {
29
- return scene.onEntityPropsChange(name, function (value) {
30
- setValues(function (prev) {
31
- var _a;
32
- return (__assign(__assign({}, prev), (_a = {}, _a[name] = value, _a)));
33
- });
34
- });
35
- });
36
- return function () {
37
- for (var _i = 0, unsubs_1 = unsubs; _i < unsubs_1.length; _i++) {
38
- var unsub = unsubs_1[_i];
39
- unsub();
40
- }
41
- };
42
- }, __spreadArray(__spreadArray([], names, true), [scene], false));
43
- return _jsx(_Fragment, { children: children(values) });
44
- }
@@ -1,28 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"world-management.d.ts","sourceRoot":"","sources":["../../src/classes/world-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,qBAAa,eAAe;IAWd,OAAO,CAAC,OAAO;IAAU,OAAO,CAAC,MAAM;IAVnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAkC;IAC/D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAGtB;IACP,OAAO,CAAC,QAAQ,CAAC,YAAY,CACxB;IAEL,OAAO,CAAC,OAAO,CAAU;gBAEL,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,KAAK;IAgD1D,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,IAAI,KAAK,eAER;IAED,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,OAAO;IAWf,UAAU;IAKV,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM;IAK3D,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM;IAKpD,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAK7D,SAAS,CAAC,MAAM,EAAE,UAAU;IAW5B,YAAY,CAAC,MAAM,EAAE,UAAU;IAe/B,MAAM;IAON,IAAI;CAKL"}
@@ -1,160 +0,0 @@
1
- import { Engine, World, Events, Body } from "matter-js";
2
- import { Entity } from "./entities/entity";
3
- var WorldManagement = /** @class */ (function () {
4
- function WorldManagement(_camera, _scene) {
5
- var _this = this;
6
- this._camera = _camera;
7
- this._scene = _scene;
8
- this.entitiesHash = {};
9
- this.entitiesPool = {};
10
- this.entitiesName = {};
11
- this._engine = Engine.create();
12
- Events.on(this.engine, "beforeUpdate", function () {
13
- var gravity = _this.engine.gravity;
14
- _this.iterateEntities(function (entity) {
15
- if (entity instanceof Entity && !entity.enabledGravity) {
16
- Body.applyForce(entity.body, entity.position, {
17
- x: -gravity.x * gravity.scale * entity.body.mass,
18
- y: -gravity.y * gravity.scale * entity.body.mass,
19
- });
20
- }
21
- });
22
- });
23
- Events.on(this.engine, "collisionStart", function (event) {
24
- var pairs = event.pairs;
25
- for (var _i = 0, pairs_1 = pairs; _i < pairs_1.length; _i++) {
26
- var pair = pairs_1[_i];
27
- var _a = pair, bodyA = _a.bodyA, bodyB = _a.bodyB;
28
- bodyA.entity.onCollision(bodyB.entity);
29
- bodyB.entity.onCollision(bodyA.entity);
30
- }
31
- });
32
- Events.on(this.engine, "collisionEnd", function (event) {
33
- var pairs = event.pairs;
34
- for (var _i = 0, pairs_2 = pairs; _i < pairs_2.length; _i++) {
35
- var pair = pairs_2[_i];
36
- var _a = pair, bodyA = _a.bodyA, bodyB = _a.bodyB;
37
- bodyA.entity.onCollisionEnd(bodyB.entity);
38
- bodyB.entity.onCollisionEnd(bodyA.entity);
39
- }
40
- });
41
- Events.on(this.engine, "collisionActive", function (event) {
42
- var pairs = event.pairs;
43
- for (var _i = 0, pairs_3 = pairs; _i < pairs_3.length; _i++) {
44
- var pair = pairs_3[_i];
45
- var _a = pair, bodyA = _a.bodyA, bodyB = _a.bodyB;
46
- bodyA.entity.onCollisionActive(bodyB.entity);
47
- bodyB.entity.onCollisionActive(bodyA.entity);
48
- }
49
- });
50
- }
51
- Object.defineProperty(WorldManagement.prototype, "engine", {
52
- get: function () {
53
- return this._engine;
54
- },
55
- enumerable: false,
56
- configurable: true
57
- });
58
- Object.defineProperty(WorldManagement.prototype, "camera", {
59
- get: function () {
60
- return this._camera;
61
- },
62
- enumerable: false,
63
- configurable: true
64
- });
65
- Object.defineProperty(WorldManagement.prototype, "scene", {
66
- get: function () {
67
- return this._scene;
68
- },
69
- enumerable: false,
70
- configurable: true
71
- });
72
- WorldManagement.prototype.iterateEntities = function (action) {
73
- var _a = this, entitiesPool = _a.entitiesPool, entitiesHash = _a.entitiesHash;
74
- var indexes = Object.keys(this.entitiesPool).map(function (idx) { return +idx; });
75
- indexes.sort();
76
- for (var _i = 0, indexes_1 = indexes; _i < indexes_1.length; _i++) {
77
- var index = indexes_1[_i];
78
- var entitiesId = entitiesPool[index];
79
- var isBreak = false;
80
- for (var _b = 0, entitiesId_1 = entitiesId; _b < entitiesId_1.length; _b++) {
81
- var id = entitiesId_1[_b];
82
- var entity = entitiesHash[id];
83
- isBreak = action(entity);
84
- if (isBreak) {
85
- break;
86
- }
87
- }
88
- if (isBreak) {
89
- break;
90
- }
91
- }
92
- };
93
- WorldManagement.prototype.joinPool = function (index, entity) {
94
- this.entitiesPool[index] = this.entitiesPool[index] || [];
95
- this.entitiesPool[index].push(entity.id);
96
- };
97
- WorldManagement.prototype.outPool = function (entity) {
98
- var pool = this.entitiesPool[entity.layerIndex];
99
- if (!pool) {
100
- return;
101
- }
102
- var delIndex = pool.indexOf(entity.id);
103
- if (delIndex > -1) {
104
- pool.splice(delIndex, 1);
105
- }
106
- };
107
- WorldManagement.prototype.destructor = function () {
108
- World.clear(this.engine.world, false);
109
- Engine.clear(this.engine);
110
- };
111
- WorldManagement.prototype.changeEntityLayerIndex = function (entity, newIndex) {
112
- this.outPool(entity);
113
- this.joinPool(newIndex, entity);
114
- };
115
- WorldManagement.prototype.changeEntityName = function (entity, newName) {
116
- delete this.entitiesName[entity.name];
117
- this.entitiesName[newName] = entity.id;
118
- };
119
- WorldManagement.prototype.getEntity = function (name) {
120
- var id = this.entitiesName[name];
121
- return this.entitiesHash[id];
122
- };
123
- WorldManagement.prototype.addEntity = function (entity) {
124
- this.joinPool(entity.layerIndex, entity);
125
- this.entitiesHash[entity.id] = entity;
126
- this.entitiesName[entity.name] = entity.id;
127
- if (entity instanceof Entity) {
128
- World.add(this.engine.world, entity.body);
129
- }
130
- entity.active(this);
131
- };
132
- WorldManagement.prototype.removeEntity = function (entity) {
133
- if (entity instanceof Entity) {
134
- World.remove(this.engine.world, entity.body);
135
- }
136
- for (var _i = 0, _a = entity.children; _i < _a.length; _i++) {
137
- var child = _a[_i];
138
- this.removeEntity(child);
139
- }
140
- if (entity.parent) {
141
- entity.parent.unChild(entity);
142
- }
143
- delete this.entitiesName[entity.name];
144
- delete this.entitiesHash[entity.id];
145
- this.outPool(entity);
146
- };
147
- WorldManagement.prototype.update = function () {
148
- Engine.update(this.engine);
149
- this.iterateEntities(function (entity) {
150
- entity.update();
151
- });
152
- };
153
- WorldManagement.prototype.draw = function () {
154
- this.iterateEntities(function (entity) {
155
- entity.draw();
156
- });
157
- };
158
- return WorldManagement;
159
- }());
160
- export { WorldManagement };
@@ -1,6 +0,0 @@
1
- import { SoundType } from "../export-enums";
2
- export declare function SceneSound(srcable?: string | {
3
- src?: string;
4
- volumn?: number;
5
- }, type?: SoundType): (target: any, propertyKey: string) => void;
6
- //# sourceMappingURL=scene-sound.decor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-sound.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/scene-sound.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,wBAAgB,UAAU,CACxB,OAAO,CAAC,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACpD,IAAI,GAAE,SAA0B,YAEP,GAAG,eAAe,MAAM,UAclD"}
@@ -1,17 +0,0 @@
1
- import { SoundType } from "../export-enums";
2
- export function SceneSound(srcable, type) {
3
- if (type === void 0) { type = SoundType.ONCE; }
4
- return function (target, propertyKey) {
5
- var _a = srcable
6
- ? typeof srcable === "string"
7
- ? { src: srcable, volumn: undefined }
8
- : srcable
9
- : { volumn: undefined, src: undefined }, volumn = _a.volumn, src = _a.src;
10
- target.constructor.soundsDecor.push({
11
- volumn: volumn,
12
- propertyKey: propertyKey,
13
- src: src,
14
- type: type,
15
- });
16
- };
17
- }
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-tag.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/scene-tag.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,YACT;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,KAAK,CAAA;CAAE,UAGzD"}
@@ -1,5 +0,0 @@
1
- export function SceneTag(tag) {
2
- return function (target) {
3
- target.tag = tag;
4
- };
5
- }
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-ui.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/scene-ui.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,wBAAgB,OAAO,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,CAAC,YACnB;IAAE,EAAE,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC;IAAC,QAAQ,KAAK,CAAA;CAAE,UAGpE"}
@@ -1,5 +0,0 @@
1
- export function SceneUI(ui) {
2
- return function (target) {
3
- target.ui = ui;
4
- };
5
- }
@@ -1,5 +0,0 @@
1
- export declare enum SoundType {
2
- ONCE = 0,
3
- BACKGROUND = 1
4
- }
5
- //# sourceMappingURL=export-enums.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export-enums.d.ts","sourceRoot":"","sources":["../src/export-enums.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,IAAI,IAAA;IACJ,UAAU,IAAA;CACX"}
@@ -1,4 +0,0 @@
1
- export interface Initialler<P = any> {
2
- initial: (params: P) => void;
3
- }
4
- //# sourceMappingURL=export-interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"export-interfaces.d.ts","sourceRoot":"","sources":["../src/export-interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,GAAG;IACjC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;CAC9B"}
@@ -1,49 +0,0 @@
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 GetSoundOptions = DeepPartial<SoundManagement>;
49
- //#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-1,24 +0,0 @@
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 { SceneSound } from "./decorators/scene-sound.decor";
20
- export { SceneTag } from "./decorators/scene-tag.decor";
21
- export { SceneUI } from "./decorators/scene-ui.decor";
22
- export { ScenesProcess } from "./ui-components/ScenesProcess";
23
- export { default as Matter } from "matter-js";
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC"}
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"SceneRunner.d.ts","sourceRoot":"","sources":["../../src/ui-components/SceneRunner.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,SAAS,EAIV,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,aAAK,gBAAgB,GAAG,sBAAsB,GAAG;IAC/C,OAAO,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,OAAO,EACP,KAAK,EACL,MAAM,EACN,YAAY,EAAE,YAAY,GAC3B,EAAE,gBAAgB,eA+ClB"}
@@ -1,43 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { useEffect, useMemo, useState, } from "react";
14
- import { Sketch } from "./Sketch";
15
- export function SceneRunner(_a) {
16
- var assetsDelay = _a.assetsDelay, current = _a.current, width = _a.width, height = _a.height, AssetsLoader = _a.assetsLoader;
17
- var _b = useState(false), isBootDone = _b[0], setBootDone = _b[1];
18
- useEffect(function () {
19
- current.loadAssets(assetsDelay);
20
- }, [current, assetsDelay]);
21
- var setup = function (camera) {
22
- current.bootstrap(camera);
23
- setBootDone(true);
24
- };
25
- var draw = function () {
26
- current.action();
27
- };
28
- var assetsLoader = useMemo(function () {
29
- if (typeof AssetsLoader === "function") {
30
- return _jsx(AssetsLoader, {});
31
- }
32
- return (AssetsLoader !== null && AssetsLoader !== void 0 ? AssetsLoader : _jsx("div", { children: "Assets loading..." }));
33
- }, [AssetsLoader]);
34
- return current.loadedAssets ? (_jsxs("div", __assign({ style: { width: width, height: height, position: "relative" } }, { children: [_jsx(Sketch, { width: width, height: height, onSetup: setup, onDraw: draw }), _jsx("div", __assign({ style: {
35
- position: "absolute",
36
- top: 0,
37
- bottom: 0,
38
- left: 0,
39
- right: 0,
40
- userSelect: "none",
41
- zIndex: 2,
42
- } }, { children: isBootDone ? (_jsx(current.UI, __assign({ scene: current }, current.UIProps))) : (_jsx("div", {})) }))] }))) : (assetsLoader);
43
- }
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"ScenesProcess.d.ts","sourceRoot":"","sources":["../../src/ui-components/ScenesProcess.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAmB,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAe,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEpE,aAAK,cAAc,GAAG,sBAAsB,GAAG;IAC7C,IAAI,EAAE,UAAU,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,cAAc,eA8B/D"}