bard-legends-framework 0.10.9 → 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 (109) hide show
  1. package/dist/game-entities/controller/controller.d.ts +0 -1
  2. package/dist/game-entities/controller/controller.js +1 -0
  3. package/dist/game-entities/controller/controller.test.js +2 -2
  4. package/dist/game-entities/entity/entity.d.ts +8 -6
  5. package/dist/game-entities/entity/entity.js +5 -7
  6. package/dist/game-entities/entity/entity.test.js +40 -134
  7. package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
  8. package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
  9. package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
  10. package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
  11. package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +1 -1
  12. package/dist/game-entities/entity/helpers/entity-views.helper.js +5 -3
  13. package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
  14. package/dist/game-entities/entity/singleton-entity.js +1 -1
  15. package/dist/game-entities/entity/singleton-entity.test.js +2 -29
  16. package/dist/game-entities/index.d.ts +1 -3
  17. package/dist/game-entities/index.js +3 -7
  18. package/dist/game-entities/scene/scene.d.ts +3 -3
  19. package/dist/game-entities/scene/scene.js +31 -25
  20. package/dist/game-entities/scene/scene.test.js +4 -32
  21. package/dist/game-entities/service/service.js +5 -3
  22. package/dist/game-entities/service/service.test.js +2 -28
  23. package/dist/game-entities/unit-test.helper.d.ts +5 -0
  24. package/dist/game-entities/unit-test.helper.js +14 -0
  25. package/dist/game-entities/update-cycle.d.ts +15 -4
  26. package/dist/game-entities/update-cycle.js +14 -9
  27. package/dist/game-entities/view/view.d.ts +5 -6
  28. package/dist/game-entities/view/view.js +5 -17
  29. package/dist/game-entities/view/view.test.js +36 -244
  30. package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -3
  31. package/dist/physics/entity-types/immovable-physics-entity.js +1 -3
  32. package/dist/physics/entity-types/movable-entity.js +4 -4
  33. package/dist/physics/entity-types/movable-physics-entity.d.ts +2 -3
  34. package/dist/physics/entity-types/movable-physics-entity.js +5 -6
  35. package/dist/physics/entity-types/physics-entity.d.ts +2 -1
  36. package/dist/physics/entity-types/physics-entity.js +3 -2
  37. package/dist/physics/interfaces.d.ts +1 -1
  38. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +3 -3
  39. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +1 -1
  40. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +3 -3
  41. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +1 -1
  42. package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +2 -2
  43. package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +1 -1
  44. package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +1 -1
  45. package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +3 -3
  46. package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +17 -7
  47. package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
  48. package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -1
  49. package/dist/pixi/components/mouse-wheel-listener.ui.js +4 -3
  50. package/dist/pixi/display-object/container-attributes.d.ts +2 -3
  51. package/dist/pixi/display-object/container-attributes.js +2 -3
  52. package/dist/pixi/display-object/container.d.ts +0 -3
  53. package/dist/pixi/display-object/container.js +0 -10
  54. package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +5 -3
  55. package/dist/pixi/game.d.ts +6 -2
  56. package/dist/pixi/game.js +14 -5
  57. package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
  58. package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +1 -1
  59. package/dist/pixi/services/keyboard/keyboard.d.ts +4 -2
  60. package/dist/pixi/services/keyboard/keyboard.js +6 -4
  61. package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +2 -1
  62. package/dist/pixi/services/mouse/mouse-target-focus.service.js +6 -5
  63. package/dist/pixi/services/mouse/mouse.service.d.ts +15 -5
  64. package/dist/pixi/services/mouse/mouse.service.js +38 -18
  65. package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
  66. package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
  67. package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
  68. package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
  69. package/dist/utilities/animator/animations.d.ts +37 -0
  70. package/dist/utilities/animator/animations.js +88 -0
  71. package/dist/utilities/animator/animator.d.ts +61 -0
  72. package/dist/utilities/animator/animator.js +315 -0
  73. package/dist/utilities/animator/animator.test.d.ts +1 -0
  74. package/dist/utilities/animator/animator.test.js +867 -0
  75. package/dist/utilities/animator/index.d.ts +7 -0
  76. package/dist/utilities/animator/index.js +24 -0
  77. package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
  78. package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
  79. package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
  80. package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
  81. package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
  82. package/dist/utilities/animator/state-animation/state-animation.js +146 -0
  83. package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
  84. package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
  85. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
  86. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
  87. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
  88. package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
  89. package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
  90. package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
  91. package/dist/utilities/delta-time/delta-time.d.ts +3 -0
  92. package/dist/utilities/delta-time/delta-time.js +10 -0
  93. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
  94. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
  95. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
  96. package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
  97. package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
  98. package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
  99. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
  100. package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
  101. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
  102. package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
  103. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
  104. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
  105. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
  106. package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
  107. package/dist/utilities/index.d.ts +6 -6
  108. package/dist/utilities/index.js +6 -6
  109. package/package.json +3 -3
@@ -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,20 +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
74
  destroy() {
145
75
  if (!this.destroyed) {
146
- SampleView_3.viewInstanceCount--;
76
+ SampleView_2.viewInstanceCount--;
147
77
  super.destroy();
148
78
  }
149
79
  }
150
80
  };
151
- SampleView = SampleView_3 = __decorate([
81
+ SampleView = SampleView_2 = __decorate([
152
82
  (0, view_1.ViewDecorator)({ entity: Sample }),
153
83
  __metadata("design:paramtypes", [Sample])
154
84
  ], SampleView);
@@ -156,10 +86,8 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
156
86
  let entity2 = new Sample().attach(baseEntity);
157
87
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(2);
158
88
  entity1.destroy();
159
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
160
89
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(1);
161
90
  entity2.destroy();
162
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
163
91
  (0, vitest_1.expect)(SampleView.viewInstanceCount).toEqual(0);
164
92
  });
165
93
  (0, vitest_1.test)('entity destruction should destroy related views', async () => {
@@ -182,64 +110,6 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
182
110
  ], _SampleView);
183
111
  let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
184
112
  entity.destroy();
185
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
186
- (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
187
- });
188
- (0, vitest_1.test)('view destruction should destroy attached items', async () => {
189
- let viewDestroyCount = 0;
190
- let Sample = class Sample extends entity_1.Entity {
191
- };
192
- Sample = __decorate([
193
- (0, entity_1.EntityDecorator)()
194
- ], Sample);
195
- let Sample2 = class Sample2 extends entity_1.Entity {
196
- destroy() {
197
- if (!this.destroyed) {
198
- viewDestroyCount++;
199
- super.destroy();
200
- }
201
- }
202
- };
203
- Sample2 = __decorate([
204
- (0, entity_1.EntityDecorator)()
205
- ], Sample2);
206
- let _SampleView = class _SampleView extends view_1.View {
207
- constructor(entity) {
208
- super();
209
- new Sample2().attach(this);
210
- }
211
- };
212
- _SampleView = __decorate([
213
- (0, view_1.ViewDecorator)({ entity: Sample }),
214
- __metadata("design:paramtypes", [Sample])
215
- ], _SampleView);
216
- let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
217
- entity.destroy();
218
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
219
- (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
220
- });
221
- (0, vitest_1.test)('triggering destroy() multiple times should not take effect multiply', async () => {
222
- let viewDestroyCount = 0;
223
- let Sample = class Sample extends entity_1.Entity {
224
- };
225
- Sample = __decorate([
226
- (0, entity_1.EntityDecorator)()
227
- ], Sample);
228
- let _SampleView = class _SampleView extends view_1.View {
229
- destroy() {
230
- if (!this.destroyed) {
231
- viewDestroyCount++;
232
- super.destroy();
233
- }
234
- }
235
- };
236
- _SampleView = __decorate([
237
- (0, view_1.ViewDecorator)({ entity: Sample })
238
- ], _SampleView);
239
- let entity = new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
240
- entity.destroy();
241
- entity.destroy();
242
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
243
113
  (0, vitest_1.expect)(viewDestroyCount).toEqual(1);
244
114
  });
245
115
  (0, vitest_1.test)('update tick should update view', async () => {
@@ -262,42 +132,27 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
262
132
  __metadata("design:paramtypes", [Sample])
263
133
  ], _SampleView);
264
134
  new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
265
- await (0, helpers_lib_1.Wait)(); // wait for async view init to be completed, so views can listen update ticks
266
135
  (0, vitest_1.expect)(viewUpdateCount).toEqual(0);
267
136
  update_cycle_1.UpdateCycle.triggerUpdateTick(1);
268
137
  (0, vitest_1.expect)(viewUpdateCount).toEqual(1);
269
138
  update_cycle_1.UpdateCycle.triggerUpdateTick(1);
270
139
  (0, vitest_1.expect)(viewUpdateCount).toEqual(2);
271
140
  });
272
- (0, vitest_1.test)('decorator should not effect static variables', () => {
273
- let BaseEntity = class BaseEntity extends entity_1.Entity {
274
- };
275
- BaseEntity = __decorate([
276
- (0, entity_1.EntityDecorator)()
277
- ], BaseEntity);
278
- let SampleView = class SampleView extends view_1.View {
279
- static { this.test = 'test'; }
280
- };
281
- SampleView = __decorate([
282
- (0, view_1.ViewDecorator)({ entity: BaseEntity })
283
- ], SampleView);
284
- (0, vitest_1.expect)(SampleView.test).toEqual('test');
285
- });
286
- (0, vitest_1.test)('getInstance should wait until creation and return the view object after', () => {
287
- var SampleView_4;
141
+ (0, vitest_1.test)('getInstance should return the view object', () => {
142
+ var SampleView_3;
288
143
  let BaseEntity = class BaseEntity extends entity_1.Entity {
289
144
  };
290
145
  BaseEntity = __decorate([
291
146
  (0, entity_1.EntityDecorator)()
292
147
  ], BaseEntity);
293
148
  let SampleView = class SampleView extends view_1.View {
294
- static { SampleView_4 = this; }
149
+ static { SampleView_3 = this; }
295
150
  constructor(entity) {
296
151
  super();
297
- SampleView_4.instance = this;
152
+ SampleView_3.instance = this;
298
153
  }
299
154
  };
300
- SampleView = SampleView_4 = __decorate([
155
+ SampleView = SampleView_3 = __decorate([
301
156
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
302
157
  __metadata("design:paramtypes", [BaseEntity])
303
158
  ], SampleView);
@@ -307,93 +162,31 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
307
162
  (0, vitest_1.expect)(SampleView.instance).toEqual(view);
308
163
  });
309
164
  (0, vitest_1.test)('getInstance should return undefined if entity get destroyed', async () => {
310
- var SampleView_5;
165
+ var SampleView_4;
311
166
  let BaseEntity = class BaseEntity extends entity_1.Entity {
312
167
  };
313
168
  BaseEntity = __decorate([
314
169
  (0, entity_1.EntityDecorator)()
315
170
  ], BaseEntity);
316
171
  let SampleView = class SampleView extends view_1.View {
317
- static { SampleView_5 = this; }
172
+ static { SampleView_4 = this; }
318
173
  constructor(entity) {
319
174
  super();
320
- SampleView_5.instance = this;
175
+ SampleView_4.instance = this;
321
176
  }
322
177
  };
323
- SampleView = SampleView_5 = __decorate([
178
+ SampleView = SampleView_4 = __decorate([
324
179
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
325
180
  __metadata("design:paramtypes", [BaseEntity])
326
181
  ], SampleView);
327
182
  let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
328
183
  baseEntity.destroy();
329
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
330
184
  let view = SampleView.getInstance(baseEntity.id);
331
185
  (0, vitest_1.expect)(SampleView.instance).toBeDefined();
332
186
  (0, vitest_1.expect)(view).toBe(undefined);
333
187
  });
334
- (0, vitest_1.test)('getInstanceOrFail should wait until creation and return the view object after', () => {
335
- var SampleView_6;
336
- let BaseEntity = class BaseEntity extends entity_1.Entity {
337
- };
338
- BaseEntity = __decorate([
339
- (0, entity_1.EntityDecorator)()
340
- ], BaseEntity);
341
- let SampleView = class SampleView extends view_1.View {
342
- static { SampleView_6 = this; }
343
- constructor(entity) {
344
- super();
345
- SampleView_6.instance = this;
346
- }
347
- };
348
- SampleView = SampleView_6 = __decorate([
349
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
350
- __metadata("design:paramtypes", [BaseEntity])
351
- ], SampleView);
352
- let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
353
- let view = SampleView.getInstanceOrFail(baseEntity.id);
354
- (0, vitest_1.expect)(SampleView.instance).toBeDefined();
355
- (0, vitest_1.expect)(SampleView.instance).toEqual(view);
356
- });
357
- (0, vitest_1.test)('should wait until creation and return the view object after in other views init', () => {
358
- var SampleView1_1;
359
- let BaseEntity = class BaseEntity extends entity_1.Entity {
360
- };
361
- BaseEntity = __decorate([
362
- (0, entity_1.EntityDecorator)()
363
- ], BaseEntity);
364
- let _SampleView2 = class _SampleView2 extends view_1.View {
365
- constructor(entity) {
366
- super();
367
- this.entity = entity;
368
- }
369
- async init() {
370
- let view = SampleView1.getInstanceOrFail(this.entity.id);
371
- (0, vitest_1.expect)(SampleView1.instance).toBeDefined();
372
- (0, vitest_1.expect)(SampleView1.instance).toEqual(view);
373
- }
374
- };
375
- _SampleView2 = __decorate([
376
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
377
- __metadata("design:paramtypes", [BaseEntity])
378
- ], _SampleView2);
379
- let SampleView1 = class SampleView1 extends view_1.View {
380
- static { SampleView1_1 = this; }
381
- constructor(entity) {
382
- super();
383
- SampleView1_1.instance = this;
384
- }
385
- async init() {
386
- await (0, helpers_lib_1.Wait)();
387
- }
388
- };
389
- SampleView1 = SampleView1_1 = __decorate([
390
- (0, view_1.ViewDecorator)({ entity: BaseEntity }),
391
- __metadata("design:paramtypes", [BaseEntity])
392
- ], SampleView1);
393
- new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
394
- });
395
- (0, vitest_1.test)('should wait until creation and return the view object after, case entity get created before the view definition', () => {
396
- var SampleView_7;
188
+ (0, vitest_1.test)('view getInstanceOrFail should return the view object', () => {
189
+ var SampleView_5;
397
190
  let BaseEntity = class BaseEntity extends entity_1.Entity {
398
191
  };
399
192
  BaseEntity = __decorate([
@@ -401,13 +194,13 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
401
194
  ], BaseEntity);
402
195
  let baseEntity = new BaseEntity().attach(scene_1.Scene.getActiveSceneOrFail());
403
196
  let SampleView = class SampleView extends view_1.View {
404
- static { SampleView_7 = this; }
197
+ static { SampleView_5 = this; }
405
198
  constructor(entity) {
406
199
  super();
407
- SampleView_7.instance = this;
200
+ SampleView_5.instance = this;
408
201
  }
409
202
  };
410
- SampleView = SampleView_7 = __decorate([
203
+ SampleView = SampleView_5 = __decorate([
411
204
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
412
205
  __metadata("design:paramtypes", [BaseEntity])
413
206
  ], SampleView);
@@ -416,7 +209,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
416
209
  (0, vitest_1.expect)(SampleView.instance).toEqual(view);
417
210
  });
418
211
  (0, vitest_1.test)('should throw error if the entity id is belonging to another entity', () => {
419
- var SampleView_8;
212
+ var SampleView_6;
420
213
  let BaseEntity = class BaseEntity extends entity_1.Entity {
421
214
  };
422
215
  BaseEntity = __decorate([
@@ -430,20 +223,20 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
430
223
  ], SampleEntity);
431
224
  let sampleEntity = new SampleEntity().attach(baseEntity);
432
225
  let SampleView = class SampleView extends view_1.View {
433
- static { SampleView_8 = this; }
226
+ static { SampleView_6 = this; }
434
227
  constructor(entity) {
435
228
  super();
436
- SampleView_8.instance = this;
229
+ SampleView_6.instance = this;
437
230
  }
438
231
  };
439
- SampleView = SampleView_8 = __decorate([
232
+ SampleView = SampleView_6 = __decorate([
440
233
  (0, view_1.ViewDecorator)({ entity: BaseEntity }),
441
234
  __metadata("design:paramtypes", [BaseEntity])
442
235
  ], SampleView);
443
- (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:');
444
237
  });
445
238
  (0, vitest_1.test)('destroying entity should not prevent subscription of the view', async () => {
446
- var Sample_1, SampleView_9;
239
+ var Sample_1, SampleView_7;
447
240
  let sampleAction = new actions_lib_1.Action();
448
241
  let Sample = class Sample extends entity_1.Entity {
449
242
  static { Sample_1 = this; }
@@ -463,18 +256,18 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
463
256
  __metadata("design:paramtypes", [])
464
257
  ], Sample);
465
258
  let SampleView = class SampleView extends view_1.View {
466
- static { SampleView_9 = this; }
259
+ static { SampleView_7 = this; }
467
260
  static { this.triggered = false; }
468
261
  constructor(entity) {
469
262
  super();
470
263
  sampleAction
471
264
  .subscribe(() => {
472
- SampleView_9.triggered = true;
265
+ SampleView_7.triggered = true;
473
266
  })
474
267
  .attach(this);
475
268
  }
476
269
  };
477
- SampleView = SampleView_9 = __decorate([
270
+ SampleView = SampleView_7 = __decorate([
478
271
  (0, view_1.ViewDecorator)({ entity: Sample }),
479
272
  __metadata("design:paramtypes", [Sample])
480
273
  ], SampleView);
@@ -484,7 +277,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
484
277
  (0, vitest_1.expect)(SampleView.triggered).toEqual(true);
485
278
  });
486
279
  (0, vitest_1.test)('if view destroys the entity, the view should also be destroyed', async () => {
487
- var Sample_2, SampleView_10;
280
+ var Sample_2, SampleView_8;
488
281
  let Sample = class Sample extends entity_1.Entity {
489
282
  static { Sample_2 = this; }
490
283
  static { this.destroyed = false; }
@@ -499,7 +292,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
499
292
  (0, entity_1.EntityDecorator)()
500
293
  ], Sample);
501
294
  let SampleView = class SampleView extends view_1.View {
502
- static { SampleView_10 = this; }
295
+ static { SampleView_8 = this; }
503
296
  static { this.destroyed = false; }
504
297
  constructor(entity) {
505
298
  super();
@@ -507,17 +300,16 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
507
300
  }
508
301
  destroy() {
509
302
  if (!this.destroyed) {
510
- SampleView_10.destroyed = true;
303
+ SampleView_8.destroyed = true;
511
304
  super.destroy();
512
305
  }
513
306
  }
514
307
  };
515
- SampleView = SampleView_10 = __decorate([
308
+ SampleView = SampleView_8 = __decorate([
516
309
  (0, view_1.ViewDecorator)({ entity: Sample }),
517
310
  __metadata("design:paramtypes", [Sample])
518
311
  ], SampleView);
519
312
  new Sample().attach(scene_1.Scene.getActiveSceneOrFail());
520
- await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
521
313
  (0, vitest_1.expect)(Sample.destroyed).toEqual(true);
522
314
  (0, vitest_1.expect)(SampleView.destroyed).toEqual(true);
523
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[];
@@ -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;
@@ -80,7 +81,7 @@ class PhysicsEntity extends game_entities_1.Entity {
80
81
  setCollisionReports(collisionReports) {
81
82
  this._collisions = collisionReports;
82
83
  if (collisionReports.length > 0) {
83
- this.onCollision.trigger(collisionReports);
84
+ this._onCollision.trigger(collisionReports);
84
85
  }
85
86
  }
86
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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="p2" />
2
- import { ActionListenerCallbackFunction, ActionSubscription } from 'actions-lib';
2
+ import { IAttachable, NotifierCallbackFunction } from 'actions-lib';
3
3
  import { PhysicsEntityDefinition } from '../../../interfaces';
4
4
  import { PhysicsBodyGroup } from '../../../libs/physics-body-groups';
5
5
  import { PhysicsBodyGroupService } from '../../📐services/collision/physics-body-group.service';
@@ -22,8 +22,8 @@ export declare class PhysicsInternalController {
22
22
  getMaskConstant(physicsWorldId: string, group: PhysicsBodyGroup): number;
23
23
  addBody(physicsWorldId: string, body: p2.Body, addInEmptySpace: boolean, physicsBodyGroup: PhysicsBodyGroup, includeOnPathfinding: boolean): boolean;
24
24
  removeBody(physicsWorldId: string, p2Body: p2.Body): void;
25
- subscribeToPhysicsStep(physicsWorldId: string, callback: ActionListenerCallbackFunction<{
25
+ subscribeToPhysicsStep(physicsWorldId: string, callback: NotifierCallbackFunction<{
26
26
  time: number;
27
27
  delta: number;
28
- }>): ActionSubscription;
28
+ }>): IAttachable;
29
29
  }
@@ -1,5 +1,5 @@
1
1
  import { GridNeighborType, Radian, Rectangle, Vector } from 'helpers-lib';
2
- import { PathFinderResult } from '../../../../utilities/libraries/grid-algorithms/path-finder/path-finder';
2
+ import { PathFinderResult } from '../../../../utilities/grid-algorithms/path-finder/path-finder';
3
3
  import { PhysicsBodyGroup } from '../../../libs/physics-body-groups';
4
4
  import { HitTestService } from '../../📐services/collision/hit-test.service';
5
5
  import { PhysicsWorldService } from '../../📐services/creation/physics-world.service';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="p2" />
2
- import { ActionListenerCallbackFunction, ActionSubscription } from 'actions-lib';
2
+ import { IAttachable, NotifierCallbackFunction } from 'actions-lib';
3
3
  import { ControllerLink } from '../../../game-entities';
4
4
  import { PhysicsEntityDefinition } from '../../interfaces';
5
5
  import { PhysicsBodyGroup } from '../../libs/physics-body-groups';
@@ -13,8 +13,8 @@ export declare class PhysicsInternalGateway {
13
13
  getMaskConstant(physicsWorldId: string, group: PhysicsBodyGroup): number;
14
14
  addBody(physicsWorldId: string, body: p2.Body, addInEmptySpace: boolean, physicsBodyGroup: PhysicsBodyGroup, includeOnPathfinding: boolean): boolean;
15
15
  removeBody(physicsWorldId: string, p2Body: p2.Body): void;
16
- subscribeToPhysicsStep(physicsWorldId: string, callback: ActionListenerCallbackFunction<{
16
+ subscribeToPhysicsStep(physicsWorldId: string, callback: NotifierCallbackFunction<{
17
17
  time: number;
18
18
  delta: number;
19
- }>): ActionSubscription;
19
+ }>): IAttachable;
20
20
  }