react-simple-game-engine 0.1.61 → 0.1.64

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/classes/animations/animation.d.ts +14 -0
  2. package/lib/classes/animations/animation.d.ts.map +1 -0
  3. package/lib/classes/animations/animation.js +35 -0
  4. package/lib/classes/animations/avatar.animation.d.ts +16 -0
  5. package/lib/classes/animations/avatar.animation.d.ts.map +1 -0
  6. package/lib/classes/animations/avatar.animation.js +45 -0
  7. package/lib/classes/animations/color.animation.d.ts +9 -0
  8. package/lib/classes/animations/color.animation.d.ts.map +1 -0
  9. package/lib/classes/animations/color.animation.js +33 -0
  10. package/lib/classes/camera.d.ts +14 -0
  11. package/lib/classes/camera.d.ts.map +1 -0
  12. package/lib/classes/camera.js +34 -0
  13. package/lib/classes/entities/circle.entity.d.ts +15 -0
  14. package/lib/classes/entities/circle.entity.d.ts.map +1 -0
  15. package/lib/classes/entities/circle.entity.js +55 -0
  16. package/lib/classes/entities/entity-sult.d.ts +34 -0
  17. package/lib/classes/entities/entity-sult.d.ts.map +1 -0
  18. package/lib/classes/entities/entity-sult.js +108 -0
  19. package/lib/classes/entities/entity.d.ts +55 -0
  20. package/lib/classes/entities/entity.d.ts.map +1 -0
  21. package/lib/classes/entities/entity.js +180 -0
  22. package/lib/classes/entities/rect.entity.d.ts +17 -0
  23. package/lib/classes/entities/rect.entity.d.ts.map +1 -0
  24. package/lib/classes/entities/rect.entity.js +56 -0
  25. package/lib/classes/logic-component.d.ts +16 -0
  26. package/lib/classes/logic-component.d.ts.map +1 -0
  27. package/lib/classes/logic-component.js +77 -0
  28. package/lib/classes/p5.d.ts +11 -0
  29. package/lib/classes/p5.d.ts.map +1 -0
  30. package/lib/classes/p5.js +58 -0
  31. package/lib/classes/particle-system.d.ts +30 -0
  32. package/lib/classes/particle-system.d.ts.map +1 -0
  33. package/lib/classes/particle-system.js +98 -0
  34. package/lib/classes/particle.d.ts +35 -0
  35. package/lib/classes/particle.d.ts.map +1 -0
  36. package/lib/classes/particle.js +117 -0
  37. package/lib/classes/prefab.d.ts +7 -0
  38. package/lib/classes/prefab.d.ts.map +1 -0
  39. package/lib/classes/prefab.js +24 -0
  40. package/lib/classes/saver.d.ts +11 -0
  41. package/lib/classes/saver.d.ts.map +1 -0
  42. package/lib/classes/saver.js +33 -0
  43. package/lib/classes/scene-management.d.ts +22 -0
  44. package/lib/classes/scene-management.d.ts.map +1 -0
  45. package/lib/classes/scene-management.js +58 -0
  46. package/lib/classes/scene.d.ts +75 -0
  47. package/lib/classes/scene.d.ts.map +1 -0
  48. package/lib/classes/scene.js +433 -0
  49. package/lib/classes/sound-watcher.d.ts +16 -0
  50. package/lib/classes/sound-watcher.d.ts.map +1 -0
  51. package/lib/classes/sound-watcher.js +33 -0
  52. package/lib/classes/sound.d.ts +14 -0
  53. package/lib/classes/sound.d.ts.map +1 -0
  54. package/lib/classes/sound.js +119 -0
  55. package/lib/classes/sprites/avatar.sprite.d.ts +20 -0
  56. package/lib/classes/sprites/avatar.sprite.d.ts.map +1 -0
  57. package/lib/classes/sprites/avatar.sprite.js +89 -0
  58. package/lib/classes/sprites/color.sprite.d.ts +7 -0
  59. package/lib/classes/sprites/color.sprite.d.ts.map +1 -0
  60. package/lib/classes/sprites/color.sprite.js +40 -0
  61. package/lib/classes/sprites/sprite.d.ts +26 -0
  62. package/lib/classes/sprites/sprite.d.ts.map +1 -0
  63. package/lib/classes/sprites/sprite.js +70 -0
  64. package/lib/classes/watcher.d.ts +11 -0
  65. package/lib/classes/watcher.d.ts.map +1 -0
  66. package/lib/classes/watcher.js +44 -0
  67. package/lib/classes/world-management.d.ts +28 -0
  68. package/lib/classes/world-management.d.ts.map +1 -0
  69. package/lib/classes/world-management.js +160 -0
  70. package/lib/decorators/scene-tag.decor.d.ts +6 -0
  71. package/lib/decorators/scene-tag.decor.d.ts.map +1 -0
  72. package/lib/decorators/scene-tag.decor.js +5 -0
  73. package/lib/decorators/scene-ui.decor.d.ts +7 -0
  74. package/lib/decorators/scene-ui.decor.d.ts.map +1 -0
  75. package/lib/decorators/scene-ui.decor.js +5 -0
  76. package/lib/decorators/sound-from.decor.d.ts +6 -0
  77. package/lib/decorators/sound-from.decor.d.ts.map +1 -0
  78. package/lib/decorators/sound-from.decor.js +17 -0
  79. package/lib/decorators/sprite-from.decor.d.ts +4 -0
  80. package/lib/decorators/sprite-from.decor.d.ts.map +1 -0
  81. package/lib/decorators/sprite-from.decor.js +13 -0
  82. package/lib/export-enums.d.ts.map +1 -0
  83. package/lib/export-enums.js +5 -0
  84. package/lib/export-interfaces.d.ts.map +1 -0
  85. package/lib/export-interfaces.js +1 -0
  86. package/lib/export-types.d.ts.map +1 -0
  87. package/lib/export-types.js +1 -0
  88. package/lib/index.d.ts.map +1 -0
  89. package/lib/ui-components/SceneRunner.d.ts +14 -0
  90. package/lib/ui-components/SceneRunner.d.ts.map +1 -0
  91. package/lib/ui-components/SceneRunner.js +43 -0
  92. package/lib/ui-components/ScenesProcess.d.ts +9 -0
  93. package/lib/ui-components/ScenesProcess.d.ts.map +1 -0
  94. package/lib/ui-components/ScenesProcess.js +46 -0
  95. package/lib/ui-components/Sketch.d.ts +12 -0
  96. package/lib/ui-components/Sketch.d.ts.map +1 -0
  97. package/lib/ui-components/Sketch.js +33 -0
  98. package/lib/utilities.d.ts.map +1 -0
  99. package/lib/utilities.js +2 -0
  100. package/lib/utils.d.ts +8 -0
  101. package/lib/utils.d.ts.map +1 -0
  102. package/lib/utils.js +97 -0
  103. package/package.json +2 -6
@@ -0,0 +1,89 @@
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
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __rest = (this && this.__rest) || function (s, e) {
28
+ var t = {};
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
+ t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
+ t[p[i]] = s[p[i]];
35
+ }
36
+ return t;
37
+ };
38
+ import { copyProperties } from "../../utils";
39
+ import { Sprite } from "./sprite";
40
+ var AvatarSprite = /** @class */ (function (_super) {
41
+ __extends(AvatarSprite, _super);
42
+ function AvatarSprite() {
43
+ var _this = _super !== null && _super.apply(this, arguments) || this;
44
+ _this._offset = {
45
+ x: 0,
46
+ y: 0,
47
+ index: 0,
48
+ width: 0,
49
+ height: 0,
50
+ };
51
+ return _this;
52
+ }
53
+ Object.defineProperty(AvatarSprite.prototype, "offset", {
54
+ get: function () {
55
+ return this._offset;
56
+ },
57
+ enumerable: false,
58
+ configurable: true
59
+ });
60
+ AvatarSprite.prototype.onDraw = function () {
61
+ if (this.source) {
62
+ if (this.animation) {
63
+ this.animation.draw();
64
+ }
65
+ else {
66
+ var _a = this._offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height, index = _a.index;
67
+ Renderer.image(this.source,
68
+ // position on canvas
69
+ 0, 0, this.width, this.height,
70
+ //crop on source image
71
+ index * width + x, y, width, height);
72
+ }
73
+ }
74
+ };
75
+ AvatarSprite.prototype.initial = function (params) {
76
+ var _a = (params ||
77
+ {}), offset = _a.offset, source = _a.source, _params = __rest(_a, ["offset", "source"]);
78
+ if (source) {
79
+ this._offset.width = source.width;
80
+ this._offset.height = source.height;
81
+ }
82
+ if (offset) {
83
+ copyProperties(this._offset, offset);
84
+ }
85
+ _super.prototype.initial.call(this, __assign(__assign({}, _params), { source: source }));
86
+ };
87
+ return AvatarSprite;
88
+ }(Sprite));
89
+ export { AvatarSprite };
@@ -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 @@
1
+ {"version":3,"file":"color.sprite.d.ts","sourceRoot":"","sources":["../../../src/classes/sprites/color.sprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAC;;IAK5C,MAAM;CAYP"}
@@ -0,0 +1,40 @@
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 };
@@ -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 @@
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"}
@@ -0,0 +1,70 @@
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 };
@@ -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 @@
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"}
@@ -0,0 +1,44 @@
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
+ }
@@ -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 @@
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"}
@@ -0,0 +1,160 @@
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 };
@@ -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 @@
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"}
@@ -0,0 +1,5 @@
1
+ export function SceneTag(tag) {
2
+ return function (target) {
3
+ target.tag = tag;
4
+ };
5
+ }
@@ -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 @@
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"}
@@ -0,0 +1,5 @@
1
+ export function SceneUI(ui) {
2
+ return function (target) {
3
+ target.ui = ui;
4
+ };
5
+ }
@@ -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 @@
1
+ {"version":3,"file":"sound-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sound-from.decor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,wBAAgB,SAAS,CACvB,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"}
@@ -0,0 +1,17 @@
1
+ import { SoundType } from "../export-enums";
2
+ export function SoundFrom(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
+ }
@@ -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 @@
1
+ {"version":3,"file":"sprite-from.decor.d.ts","sourceRoot":"","sources":["../../src/decorators/sprite-from.decor.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,YACnC,GAAG,eAAe,MAAM,UAYlD"}
@@ -0,0 +1,13 @@
1
+ export function SpriteFrom(srcable) {
2
+ return function (target, propertyKey) {
3
+ var src = (srcable
4
+ ? typeof srcable === "string"
5
+ ? { src: srcable }
6
+ : srcable
7
+ : { src: undefined }).src;
8
+ target.constructor.spritesDecor.push({
9
+ propertyKey: propertyKey,
10
+ src: src,
11
+ });
12
+ };
13
+ }
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,5 @@
1
+ export var SoundType;
2
+ (function (SoundType) {
3
+ SoundType[SoundType["ONCE"] = 0] = "ONCE";
4
+ SoundType[SoundType["BACKGROUND"] = 1] = "BACKGROUND";
5
+ })(SoundType || (SoundType = {}));
@@ -0,0 +1 @@
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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../src/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,E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AAC;AAE9D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC"}
@@ -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 @@
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"}