react-simple-game-engine 0.1.59 → 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 (105) hide show
  1. package/lib/utilities.js +0 -1
  2. package/package.json +6 -2
  3. package/lib/classes/animations/animation.d.ts +0 -14
  4. package/lib/classes/animations/animation.d.ts.map +0 -1
  5. package/lib/classes/animations/animation.js +0 -35
  6. package/lib/classes/animations/avatar.animation.d.ts +0 -16
  7. package/lib/classes/animations/avatar.animation.d.ts.map +0 -1
  8. package/lib/classes/animations/avatar.animation.js +0 -45
  9. package/lib/classes/animations/color.animation.d.ts +0 -9
  10. package/lib/classes/animations/color.animation.d.ts.map +0 -1
  11. package/lib/classes/animations/color.animation.js +0 -33
  12. package/lib/classes/camera.d.ts +0 -14
  13. package/lib/classes/camera.d.ts.map +0 -1
  14. package/lib/classes/camera.js +0 -34
  15. package/lib/classes/entities/circle.entity.d.ts +0 -15
  16. package/lib/classes/entities/circle.entity.d.ts.map +0 -1
  17. package/lib/classes/entities/circle.entity.js +0 -55
  18. package/lib/classes/entities/entity-sult.d.ts +0 -34
  19. package/lib/classes/entities/entity-sult.d.ts.map +0 -1
  20. package/lib/classes/entities/entity-sult.js +0 -108
  21. package/lib/classes/entities/entity.d.ts +0 -55
  22. package/lib/classes/entities/entity.d.ts.map +0 -1
  23. package/lib/classes/entities/entity.js +0 -180
  24. package/lib/classes/entities/rect.entity.d.ts +0 -17
  25. package/lib/classes/entities/rect.entity.d.ts.map +0 -1
  26. package/lib/classes/entities/rect.entity.js +0 -56
  27. package/lib/classes/logic-component.d.ts +0 -16
  28. package/lib/classes/logic-component.d.ts.map +0 -1
  29. package/lib/classes/logic-component.js +0 -77
  30. package/lib/classes/p5.d.ts +0 -11
  31. package/lib/classes/p5.d.ts.map +0 -1
  32. package/lib/classes/p5.js +0 -58
  33. package/lib/classes/particle-system.d.ts +0 -30
  34. package/lib/classes/particle-system.d.ts.map +0 -1
  35. package/lib/classes/particle-system.js +0 -98
  36. package/lib/classes/particle.d.ts +0 -35
  37. package/lib/classes/particle.d.ts.map +0 -1
  38. package/lib/classes/particle.js +0 -117
  39. package/lib/classes/prefab.d.ts +0 -7
  40. package/lib/classes/prefab.d.ts.map +0 -1
  41. package/lib/classes/prefab.js +0 -24
  42. package/lib/classes/saver.d.ts +0 -11
  43. package/lib/classes/saver.d.ts.map +0 -1
  44. package/lib/classes/saver.js +0 -33
  45. package/lib/classes/scene-management.d.ts +0 -22
  46. package/lib/classes/scene-management.d.ts.map +0 -1
  47. package/lib/classes/scene-management.js +0 -58
  48. package/lib/classes/scene.d.ts +0 -75
  49. package/lib/classes/scene.d.ts.map +0 -1
  50. package/lib/classes/scene.js +0 -433
  51. package/lib/classes/sound-watcher.d.ts +0 -16
  52. package/lib/classes/sound-watcher.d.ts.map +0 -1
  53. package/lib/classes/sound-watcher.js +0 -33
  54. package/lib/classes/sound.d.ts +0 -14
  55. package/lib/classes/sound.d.ts.map +0 -1
  56. package/lib/classes/sound.js +0 -119
  57. package/lib/classes/sprites/avatar.sprite.d.ts +0 -20
  58. package/lib/classes/sprites/avatar.sprite.d.ts.map +0 -1
  59. package/lib/classes/sprites/avatar.sprite.js +0 -89
  60. package/lib/classes/sprites/color.sprite.d.ts +0 -7
  61. package/lib/classes/sprites/color.sprite.d.ts.map +0 -1
  62. package/lib/classes/sprites/color.sprite.js +0 -40
  63. package/lib/classes/sprites/sprite.d.ts +0 -26
  64. package/lib/classes/sprites/sprite.d.ts.map +0 -1
  65. package/lib/classes/sprites/sprite.js +0 -70
  66. package/lib/classes/watcher.d.ts +0 -11
  67. package/lib/classes/watcher.d.ts.map +0 -1
  68. package/lib/classes/watcher.js +0 -44
  69. package/lib/classes/world-management.d.ts +0 -28
  70. package/lib/classes/world-management.d.ts.map +0 -1
  71. package/lib/classes/world-management.js +0 -160
  72. package/lib/decorators/scene-tag.decor.d.ts +0 -6
  73. package/lib/decorators/scene-tag.decor.d.ts.map +0 -1
  74. package/lib/decorators/scene-tag.decor.js +0 -5
  75. package/lib/decorators/scene-ui.decor.d.ts +0 -7
  76. package/lib/decorators/scene-ui.decor.d.ts.map +0 -1
  77. package/lib/decorators/scene-ui.decor.js +0 -5
  78. package/lib/decorators/sound-from.decor.d.ts +0 -6
  79. package/lib/decorators/sound-from.decor.d.ts.map +0 -1
  80. package/lib/decorators/sound-from.decor.js +0 -17
  81. package/lib/decorators/sprite-from.decor.d.ts +0 -4
  82. package/lib/decorators/sprite-from.decor.d.ts.map +0 -1
  83. package/lib/decorators/sprite-from.decor.js +0 -13
  84. package/lib/export-enums.d.ts +0 -5
  85. package/lib/export-enums.d.ts.map +0 -1
  86. package/lib/export-interfaces.d.ts +0 -4
  87. package/lib/export-interfaces.d.ts.map +0 -1
  88. package/lib/export-types.d.ts +0 -53
  89. package/lib/export-types.d.ts.map +0 -1
  90. package/lib/index.d.ts +0 -25
  91. package/lib/index.d.ts.map +0 -1
  92. package/lib/ui-components/SceneRunner.d.ts +0 -14
  93. package/lib/ui-components/SceneRunner.d.ts.map +0 -1
  94. package/lib/ui-components/SceneRunner.js +0 -43
  95. package/lib/ui-components/ScenesProcess.d.ts +0 -9
  96. package/lib/ui-components/ScenesProcess.d.ts.map +0 -1
  97. package/lib/ui-components/ScenesProcess.js +0 -46
  98. package/lib/ui-components/Sketch.d.ts +0 -12
  99. package/lib/ui-components/Sketch.d.ts.map +0 -1
  100. package/lib/ui-components/Sketch.js +0 -33
  101. package/lib/utilities.d.ts +0 -4
  102. package/lib/utilities.d.ts.map +0 -1
  103. package/lib/utils.d.ts +0 -8
  104. package/lib/utils.d.ts.map +0 -1
  105. package/lib/utils.js +0 -97
@@ -1,89 +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
- 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 };
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -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 { 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,6 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,17 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- export declare function SpriteFrom(srcable?: string | {
2
- src?: string;
3
- }): (target: any, propertyKey: string) => void;
4
- //# sourceMappingURL=sprite-from.decor.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,13 +0,0 @@
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
- }
@@ -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"}