react-simple-game-engine 0.1.63 → 0.1.66

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 (73) hide show
  1. package/lib/classes/animations/animation.d.ts.map +1 -0
  2. package/lib/classes/animations/animation.js +35 -0
  3. package/lib/classes/animations/avatar.animation.d.ts.map +1 -0
  4. package/lib/classes/animations/avatar.animation.js +45 -0
  5. package/lib/classes/animations/color.animation.d.ts.map +1 -0
  6. package/lib/classes/animations/color.animation.js +33 -0
  7. package/lib/classes/camera.d.ts.map +1 -0
  8. package/lib/classes/camera.js +34 -0
  9. package/lib/classes/entities/circle.entity.d.ts.map +1 -0
  10. package/lib/classes/entities/circle.entity.js +55 -0
  11. package/lib/classes/entities/entity-sult.d.ts.map +1 -0
  12. package/lib/classes/entities/entity-sult.js +108 -0
  13. package/lib/classes/entities/entity.d.ts.map +1 -0
  14. package/lib/classes/entities/entity.js +180 -0
  15. package/lib/classes/entities/rect.entity.d.ts.map +1 -0
  16. package/lib/classes/entities/rect.entity.js +56 -0
  17. package/lib/classes/logic-component.d.ts.map +1 -0
  18. package/lib/classes/logic-component.js +77 -0
  19. package/lib/classes/p5.d.ts.map +1 -0
  20. package/lib/classes/p5.js +58 -0
  21. package/lib/classes/particle-system.d.ts.map +1 -0
  22. package/lib/classes/particle-system.js +98 -0
  23. package/lib/classes/particle.d.ts.map +1 -0
  24. package/lib/classes/particle.js +117 -0
  25. package/lib/classes/prefab.d.ts.map +1 -0
  26. package/lib/classes/prefab.js +24 -0
  27. package/lib/classes/saver.d.ts.map +1 -0
  28. package/lib/classes/saver.js +33 -0
  29. package/lib/classes/scene-management.d.ts.map +1 -0
  30. package/lib/classes/scene-management.js +58 -0
  31. package/lib/classes/scene.d.ts +2 -2
  32. package/lib/classes/scene.d.ts.map +1 -0
  33. package/lib/classes/scene.js +433 -0
  34. package/lib/classes/sound-watcher.d.ts.map +1 -0
  35. package/lib/classes/sound-watcher.js +33 -0
  36. package/lib/classes/sound.d.ts.map +1 -0
  37. package/lib/classes/sound.js +119 -0
  38. package/lib/classes/sprites/avatar.sprite.d.ts.map +1 -0
  39. package/lib/classes/sprites/avatar.sprite.js +89 -0
  40. package/lib/classes/sprites/color.sprite.d.ts.map +1 -0
  41. package/lib/classes/sprites/color.sprite.js +40 -0
  42. package/lib/classes/sprites/sprite.d.ts.map +1 -0
  43. package/lib/classes/sprites/sprite.js +70 -0
  44. package/lib/classes/watcher.d.ts.map +1 -0
  45. package/lib/classes/watcher.js +44 -0
  46. package/lib/classes/world-management.d.ts.map +1 -0
  47. package/lib/classes/world-management.js +160 -0
  48. package/lib/decorators/scene-tag.decor.d.ts.map +1 -0
  49. package/lib/decorators/scene-tag.decor.js +5 -0
  50. package/lib/decorators/scene-ui.decor.d.ts.map +1 -0
  51. package/lib/decorators/scene-ui.decor.js +5 -0
  52. package/lib/decorators/sound-from.decor.d.ts.map +1 -0
  53. package/lib/decorators/sound-from.decor.js +20 -0
  54. package/lib/decorators/sprite-from.decor.d.ts.map +1 -0
  55. package/lib/decorators/sprite-from.decor.js +13 -0
  56. package/lib/export-enums.d.ts.map +1 -0
  57. package/lib/export-enums.js +5 -0
  58. package/lib/export-interfaces.d.ts.map +1 -0
  59. package/lib/export-interfaces.js +1 -0
  60. package/lib/export-types.d.ts.map +1 -0
  61. package/lib/export-types.js +1 -0
  62. package/lib/index.d.ts.map +1 -0
  63. package/lib/ui-components/SceneRunner.d.ts.map +1 -0
  64. package/lib/ui-components/SceneRunner.js +43 -0
  65. package/lib/ui-components/ScenesProcess.d.ts.map +1 -0
  66. package/lib/ui-components/ScenesProcess.js +46 -0
  67. package/lib/ui-components/Sketch.d.ts.map +1 -0
  68. package/lib/ui-components/Sketch.js +33 -0
  69. package/lib/utilities.d.ts.map +1 -0
  70. package/lib/utilities.js +2 -0
  71. package/lib/utils.d.ts.map +1 -0
  72. package/lib/utils.js +97 -0
  73. package/package.json +5 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,8BAAsB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC;IACzD,SAAS,CAAC,YAAY,EAAE,MAAM,CAAK;IACnC,SAAS,CAAC,UAAU,UAAQ;IAC5B,SAAS,CAAC,WAAW,SAAK;IAE1B,QAAQ,SAAU;IAClB,MAAM,EAAG,CAAC,CAAC;IAEX,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,EAOhC;IAED,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;IAEnC,IAAI;IAgBJ,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,OAAO;IAC3C,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI;CAClC"}
@@ -0,0 +1,35 @@
1
+ var AnimationSprite = /** @class */ (function () {
2
+ function AnimationSprite() {
3
+ this.currentFrame = 0;
4
+ this._isRunning = true;
5
+ this.timeCounter = 0;
6
+ this.delatime = 1 / 30;
7
+ }
8
+ Object.defineProperty(AnimationSprite.prototype, "isRunning", {
9
+ set: function (_isRunning) {
10
+ this._isRunning = _isRunning;
11
+ if (!_isRunning) {
12
+ // stop
13
+ this.timeCounter = 0;
14
+ this.currentFrame = 0;
15
+ }
16
+ },
17
+ enumerable: false,
18
+ configurable: true
19
+ });
20
+ AnimationSprite.prototype.draw = function () {
21
+ if (this.checkFrameMax()) {
22
+ this.currentFrame = 0;
23
+ }
24
+ this.onDraw();
25
+ if (this.timeCounter / 1000 >= this.delatime) {
26
+ this.timeCounter = 0;
27
+ if (this._isRunning) {
28
+ this.currentFrame++;
29
+ }
30
+ }
31
+ this.timeCounter += Renderer.deltaTime;
32
+ };
33
+ return AnimationSprite;
34
+ }());
35
+ export { AnimationSprite };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"avatar.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/avatar.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,aAAK,MAAM,GAAG;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,YAAY,CAAC;IACtE,OAAO,CAAC,MAAM,CAAU;IAExB,OAAO,CAAC,EAAE,CAAK,EAAE,CAAK,EAAE,KAAS,EAAE,MAAU,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC;IAShE,SAAS,CAAC,aAAa,IAAI,OAAO;IAKlC,MAAM;CAgBP"}
@@ -0,0 +1,45 @@
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 { AnimationSprite } from "./animation";
17
+ var AvatarAnimationSprite = /** @class */ (function (_super) {
18
+ __extends(AvatarAnimationSprite, _super);
19
+ function AvatarAnimationSprite() {
20
+ return _super !== null && _super.apply(this, arguments) || this;
21
+ }
22
+ AvatarAnimationSprite.prototype.initial = function (_a) {
23
+ var _b = _a.x, x = _b === void 0 ? 0 : _b, _c = _a.y, y = _c === void 0 ? 0 : _c, _d = _a.width, width = _d === void 0 ? 0 : _d, _e = _a.height, height = _e === void 0 ? 0 : _e;
24
+ this.offset = {
25
+ x: x,
26
+ y: y,
27
+ width: width,
28
+ height: height,
29
+ };
30
+ };
31
+ AvatarAnimationSprite.prototype.checkFrameMax = function () {
32
+ var _a = this.offset, width = _a.width, x = _a.x;
33
+ return this.currentFrame * width + x >= this.sprite.source.width;
34
+ };
35
+ AvatarAnimationSprite.prototype.onDraw = function () {
36
+ var _a = this.offset, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
37
+ Renderer.image(this.sprite.source,
38
+ // position on canvas
39
+ 0, 0, this.sprite.width, this.sprite.height,
40
+ //crop on source image
41
+ this.currentFrame * width + x, y, width, height);
42
+ };
43
+ return AvatarAnimationSprite;
44
+ }(AnimationSprite));
45
+ export { AvatarAnimationSprite };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.animation.d.ts","sourceRoot":"","sources":["../../../src/classes/animations/color.animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,qBAAa,oBAAqB,SAAQ,eAAe,CAAC,WAAW,CAAC;IACpE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE;IAIvC,SAAS,CAAC,aAAa,IAAI,OAAO;IAIlC,SAAS,CAAC,MAAM,IAAI,IAAI;CAGzB"}
@@ -0,0 +1,33 @@
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 { AnimationSprite } from "./animation";
17
+ var ColorAnimationSprite = /** @class */ (function (_super) {
18
+ __extends(ColorAnimationSprite, _super);
19
+ function ColorAnimationSprite() {
20
+ return _super !== null && _super.apply(this, arguments) || this;
21
+ }
22
+ ColorAnimationSprite.prototype.initial = function (colors) {
23
+ this.colors = colors;
24
+ };
25
+ ColorAnimationSprite.prototype.checkFrameMax = function () {
26
+ return this.currentFrame >= this.colors.length;
27
+ };
28
+ ColorAnimationSprite.prototype.onDraw = function () {
29
+ Renderer.fill.apply(Renderer, this.colors[this.currentFrame]);
30
+ };
31
+ return ColorAnimationSprite;
32
+ }(AnimationSprite));
33
+ export { ColorAnimationSprite };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../src/classes/camera.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM;IAML,OAAO,CAAC,MAAM;IAAU,OAAO,CAAC,OAAO;IALnD,CAAC,EAAE,MAAM,CAAK;IACd,CAAC,EAAE,MAAM,CAAK;IACd,MAAM,EAAE,MAAM,CAAK;IACnB,MAAM,EAAE,MAAM,CAAK;gBAEC,MAAM,EAAE,MAAM,EAAU,OAAO,EAAE,MAAM;IAE3D,IAAI,KAAK,IAQQ,MAAM,CANtB;IAED,IAAI,MAAM,IASS,MAAM,CAPxB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAGxB;CACF"}
@@ -0,0 +1,34 @@
1
+ var Camera = /** @class */ (function () {
2
+ function Camera(_width, _height) {
3
+ this._width = _width;
4
+ this._height = _height;
5
+ this.x = 0;
6
+ this.y = 0;
7
+ this.scaleX = 1;
8
+ this.scaleY = 1;
9
+ }
10
+ Object.defineProperty(Camera.prototype, "width", {
11
+ get: function () {
12
+ return this._width;
13
+ },
14
+ set: function (width) {
15
+ this._width = width;
16
+ Renderer.resizeCanvas(this._width, this._height);
17
+ },
18
+ enumerable: false,
19
+ configurable: true
20
+ });
21
+ Object.defineProperty(Camera.prototype, "height", {
22
+ get: function () {
23
+ return this._height;
24
+ },
25
+ set: function (height) {
26
+ this._height = height;
27
+ Renderer.resizeCanvas(this._width, this._height);
28
+ },
29
+ enumerable: false,
30
+ configurable: true
31
+ });
32
+ return Camera;
33
+ }());
34
+ export { Camera };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circle.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/circle.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAU,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,YAAY,CACvB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,MAAM,CAAC,CAAC,CAAC;IACV,MAAM,EAAG,MAAM,CAAC;IAEvB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAQ1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CAAC,gBAAgB,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
@@ -0,0 +1,55 @@
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 __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ import { Bodies } from "matter-js";
28
+ import { copyProperties } from "../../utils";
29
+ import { Entity } from "./entity";
30
+ var CircleEntity = /** @class */ (function (_super) {
31
+ __extends(CircleEntity, _super);
32
+ function CircleEntity() {
33
+ return _super !== null && _super.apply(this, arguments) || this;
34
+ }
35
+ CircleEntity.prototype.onSpriteWidthHeightBinding = function () {
36
+ return {
37
+ width: this.radius * 2,
38
+ height: this.radius * 2,
39
+ };
40
+ };
41
+ CircleEntity.prototype.onInitial = function () {
42
+ return {
43
+ transform: {
44
+ radius: 1,
45
+ },
46
+ };
47
+ };
48
+ CircleEntity.prototype.onCreateBody = function (_a, options) {
49
+ var x = _a.x, y = _a.y, transform = __rest(_a, ["x", "y"]);
50
+ copyProperties(this, transform);
51
+ return Bodies.circle(x, y, this.radius, options);
52
+ };
53
+ return CircleEntity;
54
+ }(Entity));
55
+ export { CircleEntity };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-sult.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity-sult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,EAAG,MAAM,CAAC;IACvB,SAAgB,EAAE,EAAE,MAAM,CAA8C;IAExE,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,QAAQ,CAAC,MAAM,IAAI,IAAI;IACvB,QAAQ,CAAC,IAAI,IAAI,IAAI;IAErB,IAAI,QAAQ,sBAEX;IAED,IAAI,UAAU,IAQc,MAAM,CANjC;IAED,IAAI,IAAI,IAWQ,MAAM,CATrB;IAED,IAAI,UAAU,CAAC,WAAW,EAAE,MAAM,EAKjC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,EAUrB;IAED,IAAI,MAAM,gCAET;IAED,IAAI,KAAK,eAER;IAED,IAAI,eAAe,oBAElB;IAED,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC;IAWxD,WAAW,CAAC,MAAM,EAAE,UAAU;IAK9B,OAAO,CAAC,MAAM,EAAE,UAAU;IAO1B,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAI/B,UAAU,CAAC,eAAe,EAAE,eAAe;IAM3C,MAAM,CAAC,eAAe,EAAE,eAAe;IAUvC,QAAQ;IACR,OAAO,CAAC,MAAM,EAAE,CAAC;CAClB"}
@@ -0,0 +1,108 @@
1
+ var EntitySult = /** @class */ (function () {
2
+ function EntitySult() {
3
+ this.id = "".concat(Math.random(), "-").concat(new Date().getTime());
4
+ this._layerIndex = 0;
5
+ this._name = this.id;
6
+ this._children = [];
7
+ }
8
+ Object.defineProperty(EntitySult.prototype, "children", {
9
+ get: function () {
10
+ return this._children;
11
+ },
12
+ enumerable: false,
13
+ configurable: true
14
+ });
15
+ Object.defineProperty(EntitySult.prototype, "layerIndex", {
16
+ get: function () {
17
+ return this._layerIndex;
18
+ },
19
+ set: function (_layerIndex) {
20
+ if (this._layerIndex !== _layerIndex) {
21
+ this.worldManagement.changeEntityLayerIndex(this, _layerIndex);
22
+ }
23
+ this._layerIndex = _layerIndex;
24
+ },
25
+ enumerable: false,
26
+ configurable: true
27
+ });
28
+ Object.defineProperty(EntitySult.prototype, "name", {
29
+ get: function () {
30
+ return this._name;
31
+ },
32
+ set: function (_name) {
33
+ var _a;
34
+ var isDuplicated = (_a = this.worldManagement) === null || _a === void 0 ? void 0 : _a.getEntity(_name);
35
+ if (isDuplicated) {
36
+ console.warn("Name ".concat(_name, " is already in use"));
37
+ }
38
+ else {
39
+ if (this._name !== _name) {
40
+ this.worldManagement.changeEntityName(this, _name);
41
+ }
42
+ this._name = _name;
43
+ }
44
+ },
45
+ enumerable: false,
46
+ configurable: true
47
+ });
48
+ Object.defineProperty(EntitySult.prototype, "parent", {
49
+ get: function () {
50
+ return this._parent;
51
+ },
52
+ enumerable: false,
53
+ configurable: true
54
+ });
55
+ Object.defineProperty(EntitySult.prototype, "scene", {
56
+ get: function () {
57
+ return this._scene;
58
+ },
59
+ enumerable: false,
60
+ configurable: true
61
+ });
62
+ Object.defineProperty(EntitySult.prototype, "worldManagement", {
63
+ get: function () {
64
+ return this._worldManagement;
65
+ },
66
+ enumerable: false,
67
+ configurable: true
68
+ });
69
+ EntitySult.prototype.addChild = function (target) {
70
+ var entity = target instanceof EntitySult
71
+ ? target
72
+ : target.output({ worldManagement: this.worldManagement });
73
+ entity._parent = this;
74
+ this.children.push(entity);
75
+ this.worldManagement.addEntity(entity);
76
+ };
77
+ EntitySult.prototype.removeChild = function (entity) {
78
+ this.unChild(entity);
79
+ this.worldManagement.removeEntity(entity);
80
+ };
81
+ EntitySult.prototype.unChild = function (entity) {
82
+ var delIndex = this.children.indexOf(entity);
83
+ if (delIndex > -1) {
84
+ this.children.splice(delIndex, 1);
85
+ }
86
+ };
87
+ EntitySult.prototype.getProperty = function (name) {
88
+ return this[name];
89
+ };
90
+ EntitySult.prototype.preInitial = function (worldManagement) {
91
+ this._worldManagement = worldManagement;
92
+ this._scene = worldManagement.scene;
93
+ this.camera = worldManagement.camera;
94
+ };
95
+ EntitySult.prototype.active = function (worldManagement) {
96
+ if (!this._worldManagement) {
97
+ this._worldManagement = worldManagement;
98
+ this._scene = worldManagement.scene;
99
+ this.camera = worldManagement.camera;
100
+ }
101
+ console.log("Active entity (name : ".concat(this._name, ")"));
102
+ this.onActive();
103
+ };
104
+ EntitySult.prototype.onActive = function () { };
105
+ EntitySult.prototype.initial = function (params) { };
106
+ return EntitySult;
107
+ }());
108
+ export { EntitySult };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/entity.ts"],"names":[],"mappings":"AAAA,OAAO,MAAwB,MAAM,WAAW,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAK,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAEnC,aAAK,gBAAgB,GAAG;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;CACjD,CAAC;AAEF,8BAAsB,MAAM,CAC1B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACnD,SAAQ,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,iBAAiB,CAKhB;IACT,OAAO,CAAC,WAAW,CAAS;IAErB,cAAc,EAAE,OAAO,CAAQ;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;IAErB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,EAG7B;IAED,IAAI,MAAM,IALS,MAAM,CAAC,GAAG,CAAC,CAO7B;IAED,IAAI,QAAQ,kBAEX;IAED,IAAI,IAAI,eAEP;IAED,IAAI,KAAK,MAER;IAED;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAkBpC;;;;OAIG;IACH,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,gBAAgB,EACrB,UAAU,UAAQ,GACjB,MAAM,IAAI;IAiBb,UAAU,CACR,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC;IAO3C,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,MAAM,CAAC,IAAI;IAEd,OAAO,CAAC,EACN,SAAS,EACT,MAAM,EAAE,eAAe,EACvB,WAAW,EACX,KAAU,EACV,GAAG,MAAM,EACV,EAAE,aAAa,CAAC,IAAI,CAAC;IAiDtB,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IACnD,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAI1C,MAAM;IAeN,QAAQ;IAER,IAAI;IAMJ,QAAQ,CAAC,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAExE,WAAW,CAAC,MAAM,EAAE,MAAM;IAC1B,cAAc,CAAC,MAAM,EAAE,MAAM;IAC7B,iBAAiB,CAAC,MAAM,EAAE,MAAM;CACjC"}
@@ -0,0 +1,180 @@
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 { Body } from "matter-js";
39
+ import { ColorSprite } from "../sprites/color.sprite";
40
+ import { EntitySult } from "./entity-sult";
41
+ import { copyProperties } from "../../utils";
42
+ var Entity = /** @class */ (function (_super) {
43
+ __extends(Entity, _super);
44
+ function Entity() {
45
+ var _this = _super !== null && _super.apply(this, arguments) || this;
46
+ _this._props = {};
47
+ _this.timerJobListeners = [];
48
+ _this.isTerminate = false;
49
+ _this.enabledGravity = true;
50
+ return _this;
51
+ }
52
+ Object.defineProperty(Entity.prototype, "sprite", {
53
+ get: function () {
54
+ return this._sprite;
55
+ },
56
+ set: function (sprite) {
57
+ this._sprite = sprite;
58
+ this._sprite.entity = this;
59
+ },
60
+ enumerable: false,
61
+ configurable: true
62
+ });
63
+ Object.defineProperty(Entity.prototype, "position", {
64
+ get: function () {
65
+ return this._body.position;
66
+ },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ Object.defineProperty(Entity.prototype, "body", {
71
+ get: function () {
72
+ return this._body;
73
+ },
74
+ enumerable: false,
75
+ configurable: true
76
+ });
77
+ Object.defineProperty(Entity.prototype, "props", {
78
+ get: function () {
79
+ return this._props;
80
+ },
81
+ enumerable: false,
82
+ configurable: true
83
+ });
84
+ /**
85
+ * @param {TerminateOptions} options
86
+ * #duration: time to disappear from the world in seconds, default: 0.2 seconds
87
+ * #effect: effect to showing on duration time
88
+ * @void
89
+ */
90
+ Entity.prototype.terminate = function (options) {
91
+ var _this = this;
92
+ if (options) {
93
+ var _a = options.duration, duration = _a === void 0 ? 0.2 : _a, effect = options.effect;
94
+ this.isTerminate = true;
95
+ Body.setVelocity(this.body, {
96
+ y: 0,
97
+ x: 0,
98
+ });
99
+ this.addChild(effect);
100
+ setTimeout(function () {
101
+ _this.worldManagement.removeEntity(_this);
102
+ }, duration * 1000);
103
+ }
104
+ else {
105
+ this.worldManagement.removeEntity(this);
106
+ }
107
+ };
108
+ /**
109
+ * @param {number} interval in seconds
110
+ * @param {TimerJobListener} job function that run per #interval
111
+ * @void
112
+ */
113
+ Entity.prototype.onTimer = function (interval, job, defaultRun) {
114
+ var _this = this;
115
+ if (defaultRun === void 0) { defaultRun = false; }
116
+ var listener = {
117
+ timeCounter: 0,
118
+ interval: interval,
119
+ job: job,
120
+ defaultRun: defaultRun,
121
+ };
122
+ this.timerJobListeners.push(listener);
123
+ return function () {
124
+ var index = _this.timerJobListeners.indexOf(listener);
125
+ if (index > -1) {
126
+ _this.timerJobListeners.splice(index, 1);
127
+ }
128
+ };
129
+ };
130
+ Entity.prototype.createBody = function (transform, options) {
131
+ this._body = this.onCreateBody(transform, options);
132
+ this._body.entity = this;
133
+ return this._body;
134
+ };
135
+ Entity.prototype.initial = function (_a) {
136
+ var transform = _a.transform, spriteComponent = _a.sprite, bodyOptions = _a.bodyOptions, _b = _a.props, props = _b === void 0 ? {} : _b, params = __rest(_a, ["transform", "sprite", "bodyOptions", "props"]);
137
+ var _c = this.onInitial(), _d = _c.transform, _e = _d === void 0 ? {} : _d, _f = _e.x, x = _f === void 0 ? 0 : _f, _g = _e.y, y = _g === void 0 ? 0 : _g, dfTransform = __rest(_e, ["x", "y"]), dfBodyOptions = _c.bodyOptions, dfSpriteComponent = _c.sprite, _h = _c.props, dfProps = _h === void 0 ? {} : _h, dfParams = __rest(_c, ["transform", "bodyOptions", "sprite", "props"]);
138
+ copyProperties(this._props, __assign(__assign({}, dfProps), props));
139
+ var _j = this.onPrepare(), transformAlt = _j.transform, bodyOptionsAlt = _j.bodyOptions, spriteComponentAlt = _j.sprite, _k = _j.props, propsAlt = _k === void 0 ? {} : _k, paramsAlt = __rest(_j, ["transform", "bodyOptions", "sprite", "props"]);
140
+ this.createBody(__assign(__assign(__assign({ x: x, y: y }, dfTransform), transform), transformAlt), __assign(__assign(__assign({}, dfBodyOptions), bodyOptions), bodyOptionsAlt));
141
+ copyProperties(this._props, __assign({}, propsAlt));
142
+ copyProperties(this, __assign(__assign(__assign({}, dfParams), params), paramsAlt));
143
+ //@ts-ignore
144
+ this.sprite =
145
+ (dfSpriteComponent === null || dfSpriteComponent === void 0 ? void 0 : dfSpriteComponent.output()) ||
146
+ (spriteComponent === null || spriteComponent === void 0 ? void 0 : spriteComponent.output()) ||
147
+ (spriteComponentAlt === null || spriteComponentAlt === void 0 ? void 0 : spriteComponentAlt.output()) ||
148
+ new ColorSprite();
149
+ };
150
+ Entity.prototype.onPrepare = function () {
151
+ return {};
152
+ };
153
+ Entity.prototype.update = function () {
154
+ if (!this.isTerminate) {
155
+ this.onUpdate();
156
+ }
157
+ for (var _i = 0, _a = this.timerJobListeners; _i < _a.length; _i++) {
158
+ var jobListener = _a[_i];
159
+ var timeCounter = jobListener.timeCounter, interval = jobListener.interval, job = jobListener.job, defaultRun = jobListener.defaultRun;
160
+ if (defaultRun || timeCounter / 1000 >= interval) {
161
+ timeCounter = 0;
162
+ job();
163
+ jobListener.defaultRun = false;
164
+ }
165
+ timeCounter += Renderer.deltaTime;
166
+ jobListener.timeCounter = timeCounter;
167
+ }
168
+ };
169
+ Entity.prototype.onUpdate = function () { };
170
+ Entity.prototype.draw = function () {
171
+ if (!this.isTerminate) {
172
+ this.sprite.draw();
173
+ }
174
+ };
175
+ Entity.prototype.onCollision = function (target) { };
176
+ Entity.prototype.onCollisionEnd = function (target) { };
177
+ Entity.prototype.onCollisionActive = function (target) { };
178
+ return Entity;
179
+ }(EntitySult));
180
+ export { Entity };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rect.entity.d.ts","sourceRoot":"","sources":["../../../src/classes/entities/rect.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IACrE,KAAK,EAAG,MAAM,CAAC;IACf,MAAM,EAAG,MAAM,CAAC;IAEvB,0BAA0B,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAO/D,SAAS,CAAC,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAS1C,SAAS,CAAC,YAAY,CACpB,EACE,CAAC,EACD,CAAC,EACD,GAAG,SAAS,EACb,EAAE,WAAW,CACZ,gBAAgB,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC,WAAW,CAAC,CAChB,EACD,OAAO,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,GACxC,IAAI;CAIR"}
@@ -0,0 +1,56 @@
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 __rest = (this && this.__rest) || function (s, e) {
17
+ var t = {};
18
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
19
+ t[p] = s[p];
20
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
21
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
23
+ t[p[i]] = s[p[i]];
24
+ }
25
+ return t;
26
+ };
27
+ import { Bodies } from "matter-js";
28
+ import { copyProperties } from "../../utils";
29
+ import { Entity } from "./entity";
30
+ var RectEntity = /** @class */ (function (_super) {
31
+ __extends(RectEntity, _super);
32
+ function RectEntity() {
33
+ return _super !== null && _super.apply(this, arguments) || this;
34
+ }
35
+ RectEntity.prototype.onSpriteWidthHeightBinding = function () {
36
+ return {
37
+ width: this.width,
38
+ height: this.height,
39
+ };
40
+ };
41
+ RectEntity.prototype.onInitial = function () {
42
+ return {
43
+ transform: {
44
+ width: 1,
45
+ height: 1,
46
+ },
47
+ };
48
+ };
49
+ RectEntity.prototype.onCreateBody = function (_a, options) {
50
+ var x = _a.x, y = _a.y, transform = __rest(_a, ["x", "y"]);
51
+ copyProperties(this, transform);
52
+ return Bodies.rectangle(x, y, this.width, this.height, options);
53
+ };
54
+ return RectEntity;
55
+ }(Entity));
56
+ export { RectEntity };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logic-component.d.ts","sourceRoot":"","sources":["../../src/classes/logic-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,cAAc,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAIzD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;IAJ7B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,UAAU,EAAE,MAAM,CAAK;gBAEJ,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EACxB,SAAS,CAAC,qBAAS;IAGtC,IAAI,QAAQ,wBAEX;IAED,IAAI,eAAe,CAAC,gBAAgB,EAAE,eAAe,EAMpD;IAED,MAAM,CAAC,EACL,eAAe,EACf,GAAG,YAAY,EAChB,GAAE;QACD,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,WAAW,CAAC,CAAC,CAAM;CA6CxB"}
@@ -0,0 +1,77 @@
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 __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { Entity } from "./entities/entity";
24
+ import { EntitySult } from "./entities/entity-sult";
25
+ var LogicComponent = /** @class */ (function () {
26
+ function LogicComponent(configale, _isPrefab) {
27
+ this.configale = configale;
28
+ this._isPrefab = _isPrefab;
29
+ this.layerIndex = 0;
30
+ }
31
+ Object.defineProperty(LogicComponent.prototype, "isPrefab", {
32
+ get: function () {
33
+ return this._isPrefab;
34
+ },
35
+ enumerable: false,
36
+ configurable: true
37
+ });
38
+ Object.defineProperty(LogicComponent.prototype, "worldManagement", {
39
+ set: function (_worldManagement) {
40
+ if (this._worldManagement) {
41
+ console.warn("Cant change worldManagement");
42
+ }
43
+ else {
44
+ this._worldManagement = _worldManagement;
45
+ }
46
+ },
47
+ enumerable: false,
48
+ configurable: true
49
+ });
50
+ LogicComponent.prototype.output = function (_a) {
51
+ if (_a === void 0) { _a = {}; }
52
+ var worldManagement = _a.worldManagement, targetParams = __rest(_a, ["worldManagement"]);
53
+ var configale = this.configale;
54
+ var _b = Array.isArray(configale)
55
+ ? configale
56
+ : [configale], Class = _b[0], _c = _b[1], params = _c === void 0 ? {} : _c;
57
+ var c = new Class();
58
+ if (worldManagement) {
59
+ this.worldManagement = worldManagement;
60
+ }
61
+ if (c instanceof EntitySult) {
62
+ c["_layerIndex"] = this.layerIndex; // use _layerIndex to not trigger change index process at this step
63
+ c.preInitial(this._worldManagement);
64
+ }
65
+ if (c instanceof Entity) {
66
+ var _d = params, transform = _d.transform, bodyOptions = _d.bodyOptions, props = _d.props, restParams = __rest(_d, ["transform", "bodyOptions", "props"]);
67
+ var extraTransform = targetParams.transform, extraBodyOptions = targetParams.bodyOptions, extraProps = targetParams.props, extraRestParams = __rest(targetParams, ["transform", "bodyOptions", "props"]);
68
+ c.initial(__assign(__assign({ transform: __assign(__assign({}, transform), extraTransform), bodyOptions: __assign(__assign({}, bodyOptions), extraBodyOptions), props: __assign(__assign({}, props), extraProps) }, restParams), extraRestParams));
69
+ }
70
+ else {
71
+ c.initial(__assign(__assign({}, params), targetParams));
72
+ }
73
+ return c;
74
+ };
75
+ return LogicComponent;
76
+ }());
77
+ export { LogicComponent };