bard-legends-framework 0.10.8 → 0.11.0

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 (142) hide show
  1. package/dist/game-entities/base/attachable.d.ts +10 -3
  2. package/dist/game-entities/base/attachable.js +50 -18
  3. package/dist/game-entities/base/attachable.test.js +81 -95
  4. package/dist/game-entities/base/helpers/attachable.store.d.ts +2 -8
  5. package/dist/game-entities/base/helpers/attachable.store.js +46 -17
  6. package/dist/game-entities/base/helpers/attachable.store.test.d.ts +1 -0
  7. package/dist/game-entities/base/helpers/attachable.store.test.js +234 -0
  8. package/dist/game-entities/base/helpers/decorate-actions-lib.d.ts +3 -3
  9. package/dist/game-entities/base/helpers/decorate-actions-lib.js +5 -5
  10. package/dist/game-entities/base/helpers/referance-variable.d.ts +2 -2
  11. package/dist/game-entities/base/helpers/referance-variable.js +2 -2
  12. package/dist/game-entities/controller/controller.d.ts +0 -1
  13. package/dist/game-entities/controller/controller.js +1 -0
  14. package/dist/game-entities/controller/controller.test.js +2 -2
  15. package/dist/game-entities/entity/entity.d.ts +10 -9
  16. package/dist/game-entities/entity/entity.js +9 -13
  17. package/dist/game-entities/entity/entity.test.js +47 -139
  18. package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
  19. package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
  20. package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
  21. package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
  22. package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +1 -1
  23. package/dist/game-entities/entity/helpers/entity-views.helper.js +5 -3
  24. package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
  25. package/dist/game-entities/entity/singleton-entity.js +1 -1
  26. package/dist/game-entities/entity/singleton-entity.test.js +2 -29
  27. package/dist/game-entities/index.d.ts +1 -5
  28. package/dist/game-entities/index.js +3 -24
  29. package/dist/game-entities/scene/scene.d.ts +4 -4
  30. package/dist/game-entities/scene/scene.js +31 -25
  31. package/dist/game-entities/scene/scene.test.js +14 -36
  32. package/dist/game-entities/service/service.js +5 -3
  33. package/dist/game-entities/service/service.test.js +2 -28
  34. package/dist/game-entities/unit-test.helper.d.ts +5 -0
  35. package/dist/game-entities/unit-test.helper.js +14 -0
  36. package/dist/game-entities/update-cycle.d.ts +15 -4
  37. package/dist/game-entities/update-cycle.js +14 -9
  38. package/dist/game-entities/view/view.d.ts +7 -8
  39. package/dist/game-entities/view/view.js +12 -21
  40. package/dist/game-entities/view/view.test.js +54 -244
  41. package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -3
  42. package/dist/physics/entity-types/immovable-physics-entity.js +1 -3
  43. package/dist/physics/entity-types/movable-entity.js +4 -4
  44. package/dist/physics/entity-types/movable-physics-entity.d.ts +2 -3
  45. package/dist/physics/entity-types/movable-physics-entity.js +5 -6
  46. package/dist/physics/entity-types/physics-entity.d.ts +3 -2
  47. package/dist/physics/entity-types/physics-entity.js +10 -7
  48. package/dist/physics/interfaces.d.ts +1 -1
  49. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +3 -3
  50. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +1 -1
  51. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +3 -3
  52. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +1 -1
  53. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +2 -2
  54. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +1 -1
  55. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +1 -1
  56. package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +3 -3
  57. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +17 -7
  58. package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
  59. package/dist/pixi/components/helpers/smooth-scroller.d.ts +1 -2
  60. package/dist/pixi/components/helpers/smooth-scroller.js +1 -3
  61. package/dist/pixi/components/helpers/smooth-scroller.test.js +5 -5
  62. package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +3 -2
  63. package/dist/pixi/components/mouse-wheel-listener.ui.js +10 -7
  64. package/dist/pixi/components/scroll-area.ui.d.ts +0 -1
  65. package/dist/pixi/components/scroll-area.ui.js +1 -4
  66. package/dist/pixi/display-object/container-attributes.d.ts +3 -4
  67. package/dist/pixi/display-object/container-attributes.js +2 -3
  68. package/dist/pixi/display-object/container.d.ts +0 -4
  69. package/dist/pixi/display-object/container.js +5 -17
  70. package/dist/pixi/display-object/objects/graphics/graphics.d.ts +1 -1
  71. package/dist/pixi/display-object/objects/graphics/graphics.js +5 -3
  72. package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
  73. package/dist/pixi/display-object/objects/placeholder.js +5 -3
  74. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +5 -3
  75. package/dist/pixi/display-object/objects/sprite/sprite.d.ts +1 -1
  76. package/dist/pixi/display-object/objects/sprite/sprite.js +12 -10
  77. package/dist/pixi/display-object/objects/text/text.d.ts +1 -1
  78. package/dist/pixi/display-object/objects/text/text.js +5 -3
  79. package/dist/pixi/game.d.ts +6 -2
  80. package/dist/pixi/game.js +14 -5
  81. package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
  82. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +1 -1
  83. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +6 -4
  84. package/dist/pixi/services/keyboard/keyboard.d.ts +4 -2
  85. package/dist/pixi/services/keyboard/keyboard.js +6 -4
  86. package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +2 -1
  87. package/dist/pixi/services/mouse/mouse-target-focus.service.js +6 -5
  88. package/dist/pixi/services/mouse/mouse.service.d.ts +15 -5
  89. package/dist/pixi/services/mouse/mouse.service.js +38 -18
  90. package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
  91. package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
  92. package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
  93. package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
  94. package/dist/utilities/animator/animations.d.ts +37 -0
  95. package/dist/utilities/animator/animations.js +88 -0
  96. package/dist/utilities/animator/animator.d.ts +61 -0
  97. package/dist/utilities/animator/animator.js +315 -0
  98. package/dist/utilities/animator/animator.test.d.ts +1 -0
  99. package/dist/utilities/animator/animator.test.js +867 -0
  100. package/dist/utilities/animator/index.d.ts +7 -0
  101. package/dist/utilities/animator/index.js +24 -0
  102. package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
  103. package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
  104. package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
  105. package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
  106. package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
  107. package/dist/utilities/animator/state-animation/state-animation.js +146 -0
  108. package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
  109. package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
  110. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
  111. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
  112. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
  113. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
  114. package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
  115. package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
  116. package/dist/utilities/delta-time/delta-time.d.ts +3 -0
  117. package/dist/utilities/delta-time/delta-time.js +10 -0
  118. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
  119. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
  120. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
  121. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
  122. package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
  123. package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
  124. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
  125. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
  126. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
  127. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
  128. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
  129. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
  130. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
  131. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
  132. package/dist/utilities/index.d.ts +6 -6
  133. package/dist/utilities/index.js +6 -6
  134. package/dist/utilities/libraries/animator/animator.d.ts +3 -5
  135. package/dist/utilities/libraries/animator/animator.js +17 -19
  136. package/dist/utilities/libraries/animator/state-animation/slide-state-animation.d.ts +2 -2
  137. package/dist/utilities/libraries/animator/state-animation/slide-state-animation.js +1 -1
  138. package/dist/utilities/libraries/animator/state-animation/state-animation.d.ts +2 -2
  139. package/dist/utilities/libraries/animator/state-animation/state-animation.js +1 -1
  140. package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts +2 -2
  141. package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.js +1 -1
  142. package/package.json +6 -6
@@ -1,50 +1,24 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
8
  var __metadata = (this && this.__metadata) || function (k, v) {
32
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
10
  };
34
11
  Object.defineProperty(exports, "__esModule", { value: true });
35
- const ActionsLib = __importStar(require("actions-lib"));
36
12
  const actions_lib_1 = require("actions-lib");
37
- const helpers_lib_1 = require("helpers-lib");
38
13
  const vitest_1 = require("vitest");
39
- const decorate_actions_lib_1 = require("../base/helpers/decorate-actions-lib");
40
14
  const entity_1 = require("../entity/entity");
41
15
  const scene_1 = require("../scene/scene");
16
+ const unit_test_helper_1 = require("../unit-test.helper");
42
17
  const update_cycle_1 = require("../update-cycle");
43
18
  const view_1 = require("./view");
44
- decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
45
19
  (0, vitest_1.describe)('VIEW', () => {
46
20
  (0, vitest_1.beforeEach)(() => {
47
- update_cycle_1.UpdateCycle.hardResetAction.trigger();
21
+ unit_test_helper_1.UnitTestHelper.hardReset();
48
22
  let SampleScene = class SampleScene extends scene_1.Scene {
49
23
  async init() { }
50
24
  update() { }
@@ -64,57 +38,13 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
64
38
  ], Sample);
65
39
  let SampleView = class SampleView extends view_1.View {
66
40
  static { SampleView_1 = this; }
67
- constructor(entity) {
68
- super();
69
- SampleView_1.viewInstance = this;
70
- }
71
- };
72
- SampleView = SampleView_1 = __decorate([
73
- (0, view_1.ViewDecorator)({ entity: Sample }),
74
- __metadata("design:paramtypes", [Sample])
75
- ], SampleView);
76
- new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
77
- (0, vitest_1.expect)(SampleView.viewInstance).toBeDefined();
78
- });
79
- (0, vitest_1.test)('class names should be unique', () => {
80
- let Sample = class Sample extends entity_1.Entity {
81
- };
82
- Sample = __decorate([
83
- (0, entity_1.EntityDecorator)()
84
- ], Sample);
85
- (0, vitest_1.expect)(() => {
86
- {
87
- let _SampleView = class _SampleView extends view_1.View {
88
- };
89
- _SampleView = __decorate([
90
- (0, view_1.ViewDecorator)({ entity: Sample })
91
- ], _SampleView);
92
- }
93
- {
94
- let _SampleView = class _SampleView extends view_1.View {
95
- };
96
- _SampleView = __decorate([
97
- (0, view_1.ViewDecorator)({ entity: Sample })
98
- ], _SampleView);
99
- }
100
- }).toThrow();
101
- });
102
- (0, vitest_1.test)('entity creation should create related view once', () => {
103
- var SampleView_2;
104
- let Sample = class Sample extends entity_1.Entity {
105
- };
106
- Sample = __decorate([
107
- (0, entity_1.EntityDecorator)()
108
- ], Sample);
109
- let SampleView = class SampleView extends view_1.View {
110
- static { SampleView_2 = this; }
111
41
  static { this.viewCall = 0; }
112
42
  constructor(entity) {
113
43
  super();
114
- SampleView_2.viewCall++;
44
+ SampleView_1.viewCall++;
115
45
  }
116
46
  };
117
- SampleView = SampleView_2 = __decorate([
47
+ SampleView = SampleView_1 = __decorate([
118
48
  (0, view_1.ViewDecorator)({ entity: Sample }),
119
49
  __metadata("design:paramtypes", [Sample])
120
50
  ], SampleView);
@@ -122,7 +52,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
122
52
  (0, vitest_1.expect)(SampleView.viewCall).toEqual(1);
123
53
  });
124
54
  (0, vitest_1.test)('entities should not destroy each others views on destroy', async () => {
125
- var SampleView_3;
55
+ var SampleView_2;
126
56
  let BaseEntity = class BaseEntity extends entity_1.Entity {
127
57
  };
128
58
  BaseEntity = __decorate([
@@ -135,17 +65,20 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
135
65
  (0, entity_1.EntityDecorator)()
136
66
  ], Sample);
137
67
  let SampleView = class SampleView extends view_1.View {
138
- static { SampleView_3 = this; }
68
+ static { SampleView_2 = this; }
139
69
  static { this.viewInstanceCount = 0; }
140
70
  constructor(entity) {
141
71
  super();
142
- SampleView_3.viewInstanceCount++;
72
+ SampleView_2.viewInstanceCount++;
143
73
  }
144
- afterDestroy() {
145
- SampleView_3.viewInstanceCount--;
74
+ destroy() {
75
+ if (!this.destroyed) {
76
+ SampleView_2.viewInstanceCount--;
77
+ super.destroy();
78
+ }
146
79
  }
147
80
  };
148
- SampleView = SampleView_3 = __decorate([
81
+ SampleView = SampleView_2 = __decorate([
149
82
  (0, view_1.ViewDecorator)({ entity: Sample }),
150
83
  __metadata("design:paramtypes", [Sample])
151
84
  ], SampleView);
@@ -153,10 +86,8 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
153
86
  let entity2 = new Sample().attach(baseEntity);
154
87
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(2);
155
88
  entity1.destroy();
156
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
157
89
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(1);
158
90
  entity2.destroy();
159
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
160
91
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(0);
161
92
  });
162
93
  (0, vitest_1.test)('entity destruction should destroy related views', async () => {
@@ -167,8 +98,11 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
167
98
  (0, entity_1.EntityDecorator)()
168
99
  ], Sample);
169
100
  let _SampleView = class _SampleView extends view_1.View {
170
- afterDestroy() {
171
- viewDestroyCount++;
101
+ destroy() {
102
+ if (!this.destroyed) {
103
+ viewDestroyCount++;
104
+ super.destroy();
105
+ }
172
106
  }
173
107
  };
174
108
  _SampleView = __decorate([
@@ -176,58 +110,6 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
176
110
  ], _SampleView);
177
111
  let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
178
112
  entity.destroy();
179
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
180
- (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
181
- });
182
- (0, vitest_1.test)('view destruction should destroy attached items', async () => {
183
- let viewDestroyCount = 0;
184
- let Sample = class Sample extends entity_1.Entity {
185
- };
186
- Sample = __decorate([
187
- (0, entity_1.EntityDecorator)()
188
- ], Sample);
189
- let Sample2 = class Sample2 extends entity_1.Entity {
190
- afterDestroy() {
191
- viewDestroyCount++;
192
- }
193
- };
194
- Sample2 = __decorate([
195
- (0, entity_1.EntityDecorator)()
196
- ], Sample2);
197
- let _SampleView = class _SampleView extends view_1.View {
198
- constructor(entity) {
199
- super();
200
- new Sample2().attach(this);
201
- }
202
- };
203
- _SampleView = __decorate([
204
- (0, view_1.ViewDecorator)({ entity: Sample }),
205
- __metadata("design:paramtypes", [Sample])
206
- ], _SampleView);
207
- let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
208
- entity.destroy();
209
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
210
- (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
211
- });
212
- (0, vitest_1.test)('triggering destroy() multiple times should not take effect multiply', async () => {
213
- let viewDestroyCount = 0;
214
- let Sample = class Sample extends entity_1.Entity {
215
- };
216
- Sample = __decorate([
217
- (0, entity_1.EntityDecorator)()
218
- ], Sample);
219
- let _SampleView = class _SampleView extends view_1.View {
220
- afterDestroy() {
221
- viewDestroyCount++;
222
- }
223
- };
224
- _SampleView = __decorate([
225
- (0, view_1.ViewDecorator)({ entity: Sample })
226
- ], _SampleView);
227
- let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
228
- entity.destroy();
229
- entity.destroy();
230
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
231
113
  (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
232
114
  });
233
115
  (0, vitest_1.test)('update tick should update view', async () => {
@@ -250,42 +132,27 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
250
132
  __metadata("design:paramtypes", [Sample])
251
133
  ], _SampleView);
252
134
  new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
253
- await (0, helpers_lib_1.Wait)(); // wait for async view init to be completed, so views can listen update ticks
254
135
  (0, vitest_1.expect)(viewUpdateCount).toEqual(0);
255
136
  update_cycle_1.UpdateCycle.triggerUpdateTick(1);
256
137
  (0, vitest_1.expect)(viewUpdateCount).toEqual(1);
257
138
  update_cycle_1.UpdateCycle.triggerUpdateTick(1);
258
139
  (0, vitest_1.expect)(viewUpdateCount).toEqual(2);
259
140
  });
260
- (0, vitest_1.test)('decorator should not effect static variables', () => {
261
- let BaseEntity = class BaseEntity extends entity_1.Entity {
262
- };
263
- BaseEntity = __decorate([
264
- (0, entity_1.EntityDecorator)()
265
- ], BaseEntity);
266
- let SampleView = class SampleView extends view_1.View {
267
- static { this.test = 'test'; }
268
- };
269
- SampleView = __decorate([
270
- (0, view_1.ViewDecorator)({ entity: BaseEntity })
271
- ], SampleView);
272
- (0, vitest_1.expect)(SampleView.test).toEqual('test');
273
- });
274
- (0, vitest_1.test)('getInstance should wait until creation and return the view object after', () => {
275
- var SampleView_4;
141
+ (0, vitest_1.test)('getInstance should return the view object', () => {
142
+ var SampleView_3;
276
143
  let BaseEntity = class BaseEntity extends entity_1.Entity {
277
144
  };
278
145
  BaseEntity = __decorate([
279
146
  (0, entity_1.EntityDecorator)()
280
147
  ], BaseEntity);
281
148
  let SampleView = class SampleView extends view_1.View {
282
- static { SampleView_4 = this; }
149
+ static { SampleView_3 = this; }
283
150
  constructor(entity) {
284
151
  super();
285
- SampleView_4.instance = this;
152
+ SampleView_3.instance = this;
286
153
  }
287
154
  };
288
- SampleView = SampleView_4 = __decorate([
155
+ SampleView = SampleView_3 = __decorate([
289
156
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
290
157
  __metadata("design:paramtypes", [BaseEntity])
291
158
  ], SampleView);
@@ -295,93 +162,31 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
295
162
  (0, vitest_1.expect)(SampleView.instance).toEqual(view);
296
163
  });
297
164
  (0, vitest_1.test)('getInstance should return undefined if entity get destroyed', async () => {
298
- var SampleView_5;
165
+ var SampleView_4;
299
166
  let BaseEntity = class BaseEntity extends entity_1.Entity {
300
167
  };
301
168
  BaseEntity = __decorate([
302
169
  (0, entity_1.EntityDecorator)()
303
170
  ], BaseEntity);
304
171
  let SampleView = class SampleView extends view_1.View {
305
- static { SampleView_5 = this; }
172
+ static { SampleView_4 = this; }
306
173
  constructor(entity) {
307
174
  super();
308
- SampleView_5.instance = this;
175
+ SampleView_4.instance = this;
309
176
  }
310
177
  };
311
- SampleView = SampleView_5 = __decorate([
178
+ SampleView = SampleView_4 = __decorate([
312
179
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
313
180
  __metadata("design:paramtypes", [BaseEntity])
314
181
  ], SampleView);
315
182
  let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
316
183
  baseEntity.destroy();
317
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
318
184
  let view = SampleView.getInstance(baseEntity.id);
319
185
  (0, vitest_1.expect)(SampleView.instance).toBeDefined();
320
186
  (0, vitest_1.expect)(view).toBe(undefined);
321
187
  });
322
- (0, vitest_1.test)('getInstanceOrFail should wait until creation and return the view object after', () => {
323
- var SampleView_6;
324
- let BaseEntity = class BaseEntity extends entity_1.Entity {
325
- };
326
- BaseEntity = __decorate([
327
- (0, entity_1.EntityDecorator)()
328
- ], BaseEntity);
329
- let SampleView = class SampleView extends view_1.View {
330
- static { SampleView_6 = this; }
331
- constructor(entity) {
332
- super();
333
- SampleView_6.instance = this;
334
- }
335
- };
336
- SampleView = SampleView_6 = __decorate([
337
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
338
- __metadata("design:paramtypes", [BaseEntity])
339
- ], SampleView);
340
- let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
341
- let view = SampleView.getInstanceOrFail(baseEntity.id);
342
- (0, vitest_1.expect)(SampleView.instance).toBeDefined();
343
- (0, vitest_1.expect)(SampleView.instance).toEqual(view);
344
- });
345
- (0, vitest_1.test)('should wait until creation and return the view object after in other views init', () => {
346
- var SampleView1_1;
347
- let BaseEntity = class BaseEntity extends entity_1.Entity {
348
- };
349
- BaseEntity = __decorate([
350
- (0, entity_1.EntityDecorator)()
351
- ], BaseEntity);
352
- let _SampleView2 = class _SampleView2 extends view_1.View {
353
- constructor(entity) {
354
- super();
355
- this.entity = entity;
356
- }
357
- async init() {
358
- let view = SampleView1.getInstanceOrFail(this.entity.id);
359
- (0, vitest_1.expect)(SampleView1.instance).toBeDefined();
360
- (0, vitest_1.expect)(SampleView1.instance).toEqual(view);
361
- }
362
- };
363
- _SampleView2 = __decorate([
364
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
365
- __metadata("design:paramtypes", [BaseEntity])
366
- ], _SampleView2);
367
- let SampleView1 = class SampleView1 extends view_1.View {
368
- static { SampleView1_1 = this; }
369
- constructor(entity) {
370
- super();
371
- SampleView1_1.instance = this;
372
- }
373
- async init() {
374
- await (0, helpers_lib_1.Wait)();
375
- }
376
- };
377
- SampleView1 = SampleView1_1 = __decorate([
378
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
379
- __metadata("design:paramtypes", [BaseEntity])
380
- ], SampleView1);
381
- new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
382
- });
383
- (0, vitest_1.test)('should wait until creation and return the view object after, case entity get created before the view definition', () => {
384
- var SampleView_7;
188
+ (0, vitest_1.test)('view getInstanceOrFail should return the view object', () => {
189
+ var SampleView_5;
385
190
  let BaseEntity = class BaseEntity extends entity_1.Entity {
386
191
  };
387
192
  BaseEntity = __decorate([
@@ -389,13 +194,13 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
389
194
  ], BaseEntity);
390
195
  let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
391
196
  let SampleView = class SampleView extends view_1.View {
392
- static { SampleView_7 = this; }
197
+ static { SampleView_5 = this; }
393
198
  constructor(entity) {
394
199
  super();
395
- SampleView_7.instance = this;
200
+ SampleView_5.instance = this;
396
201
  }
397
202
  };
398
- SampleView = SampleView_7 = __decorate([
203
+ SampleView = SampleView_5 = __decorate([
399
204
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
400
205
  __metadata("design:paramtypes", [BaseEntity])
401
206
  ], SampleView);
@@ -404,7 +209,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
404
209
  (0, vitest_1.expect)(SampleView.instance).toEqual(view);
405
210
  });
406
211
  (0, vitest_1.test)('should throw error if the entity id is belonging to another entity', () => {
407
- var SampleView_8;
212
+ var SampleView_6;
408
213
  let BaseEntity = class BaseEntity extends entity_1.Entity {
409
214
  };
410
215
  BaseEntity = __decorate([
@@ -418,20 +223,20 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
418
223
  ], SampleEntity);
419
224
  let sampleEntity = new SampleEntity().attach(baseEntity);
420
225
  let SampleView = class SampleView extends view_1.View {
421
- static { SampleView_8 = this; }
226
+ static { SampleView_6 = this; }
422
227
  constructor(entity) {
423
228
  super();
424
- SampleView_8.instance = this;
229
+ SampleView_6.instance = this;
425
230
  }
426
231
  };
427
- SampleView = SampleView_8 = __decorate([
232
+ SampleView = SampleView_6 = __decorate([
428
233
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
429
234
  __metadata("design:paramtypes", [BaseEntity])
430
235
  ], SampleView);
431
- (0, vitest_1.expect)(() => SampleView.getInstanceOrFail(sampleEntity.id)).toThrowError();
236
+ (0, vitest_1.expect)(() => SampleView.getInstanceOrFail(sampleEntity.id)).toThrow('View: getInstance is called with entity id: "3:1", that is not belonging to the class:');
432
237
  });
433
238
  (0, vitest_1.test)('destroying entity should not prevent subscription of the view', async () => {
434
- var Sample_1, SampleView_9;
239
+ var Sample_1, SampleView_7;
435
240
  let sampleAction = new actions_lib_1.Action();
436
241
  let Sample = class Sample extends entity_1.Entity {
437
242
  static { Sample_1 = this; }
@@ -451,18 +256,18 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
451
256
  __metadata("design:paramtypes", [])
452
257
  ], Sample);
453
258
  let SampleView = class SampleView extends view_1.View {
454
- static { SampleView_9 = this; }
259
+ static { SampleView_7 = this; }
455
260
  static { this.triggered = false; }
456
261
  constructor(entity) {
457
262
  super();
458
263
  sampleAction
459
264
  .subscribe(() => {
460
- SampleView_9.triggered = true;
265
+ SampleView_7.triggered = true;
461
266
  })
462
267
  .attach(this);
463
268
  }
464
269
  };
465
- SampleView = SampleView_9 = __decorate([
270
+ SampleView = SampleView_7 = __decorate([
466
271
  (0, view_1.ViewDecorator)({ entity: Sample }),
467
272
  __metadata("design:paramtypes", [Sample])
468
273
  ], SampleView);
@@ -472,34 +277,39 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
472
277
  (0, vitest_1.expect)(SampleView.triggered).toEqual(true);
473
278
  });
474
279
  (0, vitest_1.test)('if view destroys the entity, the view should also be destroyed', async () => {
475
- var Sample_2, SampleView_10;
280
+ var Sample_2, SampleView_8;
476
281
  let Sample = class Sample extends entity_1.Entity {
477
282
  static { Sample_2 = this; }
478
283
  static { this.destroyed = false; }
479
- afterDestroy() {
480
- Sample_2.destroyed = true;
284
+ destroy() {
285
+ if (!this.destroyed) {
286
+ Sample_2.destroyed = true;
287
+ super.destroy();
288
+ }
481
289
  }
482
290
  };
483
291
  Sample = Sample_2 = __decorate([
484
292
  (0, entity_1.EntityDecorator)()
485
293
  ], Sample);
486
294
  let SampleView = class SampleView extends view_1.View {
487
- static { SampleView_10 = this; }
295
+ static { SampleView_8 = this; }
488
296
  static { this.destroyed = false; }
489
297
  constructor(entity) {
490
298
  super();
491
299
  entity.destroy();
492
300
  }
493
- afterDestroy() {
494
- SampleView_10.destroyed = true;
301
+ destroy() {
302
+ if (!this.destroyed) {
303
+ SampleView_8.destroyed = true;
304
+ super.destroy();
305
+ }
495
306
  }
496
307
  };
497
- SampleView = SampleView_10 = __decorate([
308
+ SampleView = SampleView_8 = __decorate([
498
309
  (0, view_1.ViewDecorator)({ entity: Sample }),
499
310
  __metadata("design:paramtypes", [Sample])
500
311
  ], SampleView);
501
312
  new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
502
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
503
313
  (0, vitest_1.expect)(Sample.destroyed).toEqual(true);
504
314
  (0, vitest_1.expect)(SampleView.destroyed).toEqual(true);
505
315
  });
@@ -1,11 +1,9 @@
1
- import { Action } from 'actions-lib';
2
1
  import { Radian, Vector } from 'helpers-lib';
3
- import { CollisionReport, PhysicsBodyDTO, PhysicsEntityDefinition } from '../interfaces';
2
+ import { PhysicsBodyDTO, PhysicsEntityDefinition } from '../interfaces';
4
3
  import { PhysicsEntity } from './physics-entity';
5
4
  export declare abstract class ImmovablePhysicsEntity extends PhysicsEntity {
6
5
  readonly position: Vector;
7
6
  readonly rotation: Radian;
8
- readonly onCollision: Action<CollisionReport[]>;
9
7
  constructor(physicsWorldId: string, physicsEntityDefinition: PhysicsEntityDefinition);
10
8
  convertToDTO(): PhysicsBodyDTO;
11
9
  }
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ImmovablePhysicsEntity = void 0;
4
- const actions_lib_1 = require("actions-lib");
5
4
  const helpers_lib_1 = require("helpers-lib");
6
5
  const p2js_helper_1 = require("../libs/p2js.helper");
7
6
  const physics_entity_1 = require("./physics-entity");
8
7
  class ImmovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
9
8
  constructor(physicsWorldId, physicsEntityDefinition) {
10
9
  super(physicsWorldId, physicsEntityDefinition, 'static');
11
- this.onCollision = new actions_lib_1.Action();
12
10
  this.position = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.position);
13
11
  this.rotation = new helpers_lib_1.Radian(this.p2Body.angle);
14
12
  }
15
13
  convertToDTO() {
16
14
  return {
17
15
  entityId: this.id,
18
- entityClassName: this.constructor.name,
16
+ classId: this.classId,
19
17
  position: this.position,
20
18
  rotation: this.rotation,
21
19
  velocity: helpers_lib_1.Vector.zero,
@@ -7,10 +7,10 @@ const game_entities_1 = require("../../game-entities");
7
7
  class MovableEntity extends game_entities_1.Entity {
8
8
  constructor() {
9
9
  super();
10
- this.position = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
11
- this.rotation = new actions_lib_1.Variable().set(helpers_lib_1.Radian.get0);
12
- this.velocity = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
13
- this.rotationalSpeed = new actions_lib_1.Variable().set(0);
10
+ this.position = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
11
+ this.rotation = new actions_lib_1.Variable(helpers_lib_1.Radian.get0);
12
+ this.velocity = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
13
+ this.rotationalSpeed = new actions_lib_1.Variable(0);
14
14
  game_entities_1.UpdateCycle.beforeSceneUpdateAction
15
15
  .subscribe(({ time, delta }) => {
16
16
  this.step(time, delta);
@@ -1,13 +1,12 @@
1
- import { Action, Variable } from 'actions-lib';
1
+ import { Variable } from 'actions-lib';
2
2
  import { Radian, Vector } from 'helpers-lib';
3
- import { CollisionReport, PhysicsBodyDTO, PhysicsEntityDefinition } from '../interfaces';
3
+ import { PhysicsBodyDTO, PhysicsEntityDefinition } from '../interfaces';
4
4
  import { PhysicsEntity } from './physics-entity';
5
5
  export declare abstract class MovablePhysicsEntity extends PhysicsEntity {
6
6
  readonly position: Variable<Vector>;
7
7
  readonly rotation: Variable<Radian>;
8
8
  readonly velocity: Variable<Vector>;
9
9
  readonly rotationalSpeed: Variable<number>;
10
- readonly onCollision: Action<CollisionReport[]>;
11
10
  private ignorePositionUpdate;
12
11
  private ignoreRotationUpdate;
13
12
  private ignoreVelocityUpdate;
@@ -10,11 +10,10 @@ const physics_entity_1 = require("./physics-entity");
10
10
  class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
11
11
  constructor(physicsWorldId, physicsEntityDefinition) {
12
12
  super(physicsWorldId, physicsEntityDefinition, 'dynamic');
13
- this.position = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
14
- this.rotation = new actions_lib_1.Variable().set(helpers_lib_1.Radian.get0);
15
- this.velocity = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
16
- this.rotationalSpeed = new actions_lib_1.Variable().set(0);
17
- this.onCollision = new actions_lib_1.Action();
13
+ this.position = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
14
+ this.rotation = new actions_lib_1.Variable(helpers_lib_1.Radian.get0);
15
+ this.velocity = new actions_lib_1.Variable(helpers_lib_1.Vector.zero);
16
+ this.rotationalSpeed = new actions_lib_1.Variable(0);
18
17
  this.ignorePositionUpdate = false;
19
18
  this.ignoreRotationUpdate = false;
20
19
  this.ignoreVelocityUpdate = false;
@@ -28,7 +27,7 @@ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
28
27
  convertToDTO() {
29
28
  return {
30
29
  entityId: this.id,
31
- entityClassName: this.constructor.name,
30
+ classId: this.classId,
32
31
  position: this.position.value,
33
32
  rotation: this.rotation.value,
34
33
  velocity: this.velocity.value,
@@ -10,7 +10,8 @@ export declare abstract class PhysicsEntity extends Entity {
10
10
  static getFromP2BodyIdOrFail(p2BodyId: number): PhysicsEntity;
11
11
  static getPhysicsInstanceOrFail(id: string): PhysicsEntity;
12
12
  static getPhysicsEntities(): PhysicsEntity[];
13
- readonly onCollision: Action<readonly CollisionReport[]>;
13
+ readonly _onCollision: Action<readonly CollisionReport[]>;
14
+ readonly onCollision: import("actions-lib").Notifier<readonly CollisionReport[]>;
14
15
  get area(): number;
15
16
  get mass(): number;
16
17
  get collisions(): readonly CollisionReport[];
@@ -27,7 +28,7 @@ export declare abstract class PhysicsEntity extends Entity {
27
28
  private _collisions;
28
29
  constructor(physicsWorldId: string, physicsEntityDefinition: PhysicsEntityDefinition, type: 'dynamic' | 'static');
29
30
  abstract convertToDTO(): PhysicsBodyDTO;
30
- protected destroySelf(): void;
31
+ destroy(): void;
31
32
  canCollideWith(target: PhysicsEntity): boolean;
32
33
  protected setCollisionReports(collisionReports: CollisionReport[]): void;
33
34
  }
@@ -39,7 +39,8 @@ class PhysicsEntity extends game_entities_1.Entity {
39
39
  }
40
40
  constructor(physicsWorldId, physicsEntityDefinition, type) {
41
41
  super();
42
- this.onCollision = new actions_lib_1.Action();
42
+ this._onCollision = new actions_lib_1.Action();
43
+ this.onCollision = this._onCollision.notifier;
43
44
  this.type = 'dynamic';
44
45
  this._area = 0;
45
46
  this._mass = 0;
@@ -65,11 +66,13 @@ class PhysicsEntity extends game_entities_1.Entity {
65
66
  PhysicsEntity.p2BodyIdToPhysicsBody.set(this.p2Body.id, this);
66
67
  PhysicsEntity.physicsEntities.set(this.id, this);
67
68
  }
68
- destroySelf() {
69
- super.destroySelf();
70
- this.physicsInternalGateway.removeBody(this.physicsWorldId, this.p2Body);
71
- PhysicsEntity.p2BodyIdToPhysicsBody.delete(this.p2Body.id);
72
- PhysicsEntity.physicsEntities.delete(this.id);
69
+ destroy() {
70
+ if (!this.destroyed) {
71
+ this.physicsInternalGateway.removeBody(this.physicsWorldId, this.p2Body);
72
+ PhysicsEntity.p2BodyIdToPhysicsBody.delete(this.p2Body.id);
73
+ PhysicsEntity.physicsEntities.delete(this.id);
74
+ super.destroy();
75
+ }
73
76
  }
74
77
  canCollideWith(target) {
75
78
  return p2js_helper_1.P2JSHelper.arePhysicsGroupsCollidable(this.physicsGroup, this.physicsMask, target.physicsGroup, target.physicsMask);
@@ -78,7 +81,7 @@ class PhysicsEntity extends game_entities_1.Entity {
78
81
  setCollisionReports(collisionReports) {
79
82
  this._collisions = collisionReports;
80
83
  if (collisionReports.length > 0) {
81
- this.onCollision.trigger(collisionReports);
84
+ this._onCollision.trigger(collisionReports);
82
85
  }
83
86
  }
84
87
  }
@@ -5,7 +5,7 @@ export declare const SPEED_LIMIT = 10.8;
5
5
  export declare const ROTATIONAL_SPEED_LIMIT = 10.01;
6
6
  export interface PhysicsBodyDTO {
7
7
  readonly entityId: string;
8
- readonly entityClassName: string;
8
+ readonly classId: string;
9
9
  readonly position: Vector;
10
10
  readonly rotation: Radian;
11
11
  readonly velocity: Vector;