bard-legends-framework 0.3.2 → 0.4.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 (126) hide show
  1. package/dist/game-entities/service/service.test.js +24 -8
  2. package/dist/game-entities/service/service.test.js.map +1 -1
  3. package/dist/physics/entity-types/immovable-physics-entity.d.ts +12 -0
  4. package/dist/physics/entity-types/immovable-physics-entity.js +28 -0
  5. package/dist/physics/entity-types/immovable-physics-entity.js.map +1 -0
  6. package/dist/physics/entity-types/movable-entity.d.ts +11 -0
  7. package/dist/physics/entity-types/movable-entity.js +26 -0
  8. package/dist/physics/entity-types/movable-entity.js.map +1 -0
  9. package/dist/physics/entity-types/movable-physics-entity.d.ts +20 -0
  10. package/dist/physics/entity-types/movable-physics-entity.js +96 -0
  11. package/dist/physics/entity-types/movable-physics-entity.js.map +1 -0
  12. package/dist/physics/entity-types/physics-entity.d.ts +31 -0
  13. package/dist/physics/entity-types/physics-entity.js +91 -0
  14. package/dist/physics/entity-types/physics-entity.js.map +1 -0
  15. package/dist/physics/index.d.ts +6 -9
  16. package/dist/physics/index.js +7 -14
  17. package/dist/physics/index.js.map +1 -1
  18. package/dist/physics/interfaces.d.ts +1 -35
  19. package/dist/physics/interfaces.js +1 -2
  20. package/dist/physics/interfaces.js.map +1 -1
  21. package/dist/physics/libs/p2js.helper.d.ts +7 -0
  22. package/dist/physics/libs/p2js.helper.js +26 -0
  23. package/dist/physics/libs/p2js.helper.js.map +1 -0
  24. package/dist/physics/libs/physics-body-groups.d.ts +15 -0
  25. package/dist/physics/libs/physics-body-groups.js +76 -0
  26. package/dist/physics/libs/physics-body-groups.js.map +1 -0
  27. package/dist/physics/libs/position-to-grid-position-converter.d.ts +6 -0
  28. package/dist/physics/libs/position-to-grid-position-converter.js +17 -0
  29. package/dist/physics/libs/position-to-grid-position-converter.js.map +1 -0
  30. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +23 -0
  31. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +50 -0
  32. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js.map +1 -0
  33. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +25 -0
  34. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +53 -0
  35. package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js.map +1 -0
  36. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +15 -0
  37. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.js +3 -0
  38. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.js.map +1 -0
  39. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/responses.dto.d.ts +30 -0
  40. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/responses.dto.js +3 -0
  41. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/responses.dto.js.map +1 -0
  42. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/shared-interfaces.dto.d.ts +21 -0
  43. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/shared-interfaces.dto.js +7 -0
  44. package/dist/physics/module//342/232/234/357/270/217gateways/dtos/shared-interfaces.dto.js.map +1 -0
  45. package/dist/physics/module//342/232/234/357/270/217gateways/index.d.ts +4 -0
  46. package/dist/physics/module//342/232/234/357/270/217gateways/index.js +26 -0
  47. package/dist/physics/module//342/232/234/357/270/217gateways/index.js.map +1 -0
  48. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +18 -0
  49. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +36 -0
  50. package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js.map +1 -0
  51. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +18 -0
  52. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +37 -0
  53. package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js.map +1 -0
  54. package/dist/physics/module//360/237/223/220services/availability-grid.service.d.ts +12 -0
  55. package/dist/physics/module//360/237/223/220services/availability-grid.service.js +63 -0
  56. package/dist/physics/module//360/237/223/220services/availability-grid.service.js.map +1 -0
  57. package/dist/physics/module//360/237/223/220services/border.service.d.ts +5 -0
  58. package/dist/physics/module//360/237/223/220services/border.service.js +42 -0
  59. package/dist/physics/module//360/237/223/220services/border.service.js.map +1 -0
  60. package/dist/physics/module//360/237/223/220services/collisions.service.d.ts +10 -0
  61. package/dist/physics/module//360/237/223/220services/collisions.service.js +106 -0
  62. package/dist/physics/module//360/237/223/220services/collisions.service.js.map +1 -0
  63. package/dist/physics/module//360/237/223/220services/debug-visuals.service.d.ts +13 -0
  64. package/dist/physics/module//360/237/223/220services/debug-visuals.service.js +79 -0
  65. package/dist/physics/module//360/237/223/220services/debug-visuals.service.js.map +1 -0
  66. package/dist/physics/module//360/237/223/220services/explosion.service.d.ts +15 -0
  67. package/dist/physics/module//360/237/223/220services/explosion.service.js +93 -0
  68. package/dist/physics/module//360/237/223/220services/explosion.service.js.map +1 -0
  69. package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.d.ts +5 -0
  70. package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js +69 -0
  71. package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js.map +1 -0
  72. package/dist/physics/module//360/237/223/220services/materials.service.d.ts +15 -0
  73. package/dist/physics/module//360/237/223/220services/materials.service.js +120 -0
  74. package/dist/physics/module//360/237/223/220services/materials.service.js.map +1 -0
  75. package/dist/physics/module//360/237/223/220services/path-finder.service.d.ts +15 -0
  76. package/dist/physics/module//360/237/223/220services/path-finder.service.js +92 -0
  77. package/dist/physics/module//360/237/223/220services/path-finder.service.js.map +1 -0
  78. package/dist/physics/module//360/237/223/220services/physics-world.service.d.ts +26 -0
  79. package/dist/physics/module//360/237/223/220services/physics-world.service.js +112 -0
  80. package/dist/physics/module//360/237/223/220services/physics-world.service.js.map +1 -0
  81. package/dist/physics/module//360/237/223/220services/ray-casting.service.d.ts +9 -0
  82. package/dist/physics/module//360/237/223/220services/ray-casting.service.js +92 -0
  83. package/dist/physics/module//360/237/223/220services/ray-casting.service.js.map +1 -0
  84. package/dist/physics/module//360/237/223/220services/shape-creation.service.d.ts +9 -0
  85. package/dist/physics/module//360/237/223/220services/shape-creation.service.js +95 -0
  86. package/dist/physics/module//360/237/223/220services/shape-creation.service.js.map +1 -0
  87. package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +5 -0
  88. package/dist/physics/module//360/237/247/212entities/border.entity.js +25 -0
  89. package/dist/physics/module//360/237/247/212entities/border.entity.js.map +1 -0
  90. package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.d.ts +12 -0
  91. package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js +40 -0
  92. package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js.map +1 -0
  93. package/dist/physics/module//360/237/247/212entities/physics-world.entity.d.ts +30 -0
  94. package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +45 -0
  95. package/dist/physics/module//360/237/247/212entities/physics-world.entity.js.map +1 -0
  96. package/dist/physics/physics-world.d.ts +1 -0
  97. package/dist/physics/physics-world.js +31 -2
  98. package/dist/physics/physics-world.js.map +1 -1
  99. package/dist/pixi/game.d.ts +4 -0
  100. package/dist/pixi/game.js +12 -0
  101. package/dist/pixi/game.js.map +1 -1
  102. package/dist/pixi/helpers/screen-position-to-stage.helper.d.ts +4 -0
  103. package/dist/pixi/helpers/screen-position-to-stage.helper.js +17 -0
  104. package/dist/pixi/helpers/screen-position-to-stage.helper.js.map +1 -0
  105. package/dist/pixi/helpers/screen-position-to-stage.helper.test.d.ts +1 -0
  106. package/dist/pixi/helpers/screen-position-to-stage.helper.test.js +83 -0
  107. package/dist/pixi/helpers/screen-position-to-stage.helper.test.js.map +1 -0
  108. package/dist/pixi/index.d.ts +3 -0
  109. package/dist/pixi/index.js +7 -1
  110. package/dist/pixi/index.js.map +1 -1
  111. package/dist/pixi/services/keyboard/keyboard.d.ts +7 -0
  112. package/dist/pixi/services/keyboard/keyboard.js +39 -0
  113. package/dist/pixi/services/keyboard/keyboard.js.map +1 -0
  114. package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +20 -0
  115. package/dist/pixi/services/mouse/mouse-target-focus.service.js +85 -0
  116. package/dist/pixi/services/mouse/mouse-target-focus.service.js.map +1 -0
  117. package/dist/pixi/services/mouse/mouse.service.d.ts +10 -0
  118. package/dist/pixi/services/mouse/mouse.service.js +68 -0
  119. package/dist/pixi/services/mouse/mouse.service.js.map +1 -0
  120. package/dist/utilities/index.d.ts +4 -4
  121. package/dist/utilities/index.js +7 -7
  122. package/dist/utilities/index.js.map +1 -1
  123. package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.js +3 -2
  124. package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.js.map +1 -1
  125. package/package.json +2 -2
  126. package/package.json.bak +2 -2
@@ -45,8 +45,24 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
45
45
  (0, vitest_1.beforeEach)(() => {
46
46
  update_cycle_1.UpdateCycle.hardResetAction.trigger();
47
47
  });
48
+ (0, vitest_1.test)('get services', () => {
49
+ var SampleService_1;
50
+ let SampleService = class SampleService {
51
+ static { SampleService_1 = this; }
52
+ constructor() {
53
+ SampleService_1.instance = this;
54
+ }
55
+ };
56
+ SampleService = SampleService_1 = __decorate([
57
+ (0, service_1.ServiceDecorator)(),
58
+ __metadata("design:paramtypes", [])
59
+ ], SampleService);
60
+ (0, vitest_1.expect)(SampleService.instance).not.toBeDefined();
61
+ service_1.Service.get(SampleService);
62
+ (0, vitest_1.expect)(SampleService.instance).toBeDefined();
63
+ });
48
64
  (0, vitest_1.test)('inject services to views', () => {
49
- var SampleService_1, SampleView_1;
65
+ var SampleService_2, SampleView_1;
50
66
  let SampleScene = class SampleScene extends scene_1.Scene {
51
67
  };
52
68
  SampleScene = __decorate([
@@ -54,12 +70,12 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
54
70
  ], SampleScene);
55
71
  SampleScene.open(undefined);
56
72
  let SampleService = class SampleService {
57
- static { SampleService_1 = this; }
73
+ static { SampleService_2 = this; }
58
74
  constructor() {
59
- SampleService_1.instance = this;
75
+ SampleService_2.instance = this;
60
76
  }
61
77
  };
62
- SampleService = SampleService_1 = __decorate([
78
+ SampleService = SampleService_2 = __decorate([
63
79
  (0, service_1.ServiceDecorator)(),
64
80
  __metadata("design:paramtypes", [])
65
81
  ], SampleService);
@@ -180,14 +196,14 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
180
196
  (0, vitest_1.expect)(SampleScene.getInstanceOrFail().service2?.service1).toEqual(SampleScene.getInstanceOrFail().service3?.service1);
181
197
  });
182
198
  (0, vitest_1.test)('services should be lazy initiated', () => {
183
- var SampleService_2;
199
+ var SampleService_3;
184
200
  let SampleService = class SampleService {
185
- static { SampleService_2 = this; }
201
+ static { SampleService_3 = this; }
186
202
  constructor() {
187
- SampleService_2.instance = this;
203
+ SampleService_3.instance = this;
188
204
  }
189
205
  };
190
- SampleService = SampleService_2 = __decorate([
206
+ SampleService = SampleService_3 = __decorate([
191
207
  (0, service_1.ServiceDecorator)(),
192
208
  __metadata("design:paramtypes", [])
193
209
  ], SampleService);
@@ -1 +1 @@
1
- {"version":3,"file":"service.test.js","sourceRoot":"","sources":["../../../src/game-entities/service/service.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA4D;AAC5D,wDAA0C;AAE1C,6CAA2D;AAC3D,uCAA6C;AAC7C,uCAAmD;AACnD,kDAA8C;AAC9C,0CAAuD;AAEvD,qFAAiF;AACjF,0CAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAEzC,IAAA,iBAAQ,EA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9D,IAAA,eAAM,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAChD,IAAA,eAAM,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QACxD,IAAA,eAAM,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACpD,IAAA,eAAM,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,8CAA8C,EAAE,GAAG,EAAE;QAExD,IAAM,aAAa,GAAnB,MAAM,aAAa;qBACV,SAAI,GAAG,MAAM,AAAT,CAAU;;QADjB,aAAa;YADlB,IAAA,0BAAgB,GAAE;WACb,aAAa,CAElB;QAED,IAAA,eAAM,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Action } from 'actions-lib';
2
+ import { Vector } from 'helpers-lib';
3
+ import { PhysicsEntityDefinition, CollisionReport, PhysicsBodyDTO } from '../interfaces';
4
+ import { PhysicsEntity } from './physics-entity';
5
+ export declare abstract class ImmovablePhysicsEntity extends PhysicsEntity {
6
+ readonly position: Vector;
7
+ readonly rotation: number;
8
+ readonly onCollision: Action<CollisionReport[]>;
9
+ constructor(physicsWorldId: string, physicsEntityDefinition: PhysicsEntityDefinition);
10
+ destroy(): void;
11
+ convertToDTO(): PhysicsBodyDTO;
12
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImmovablePhysicsEntity = void 0;
4
+ const actions_lib_1 = require("actions-lib");
5
+ const helpers_lib_1 = require("helpers-lib");
6
+ const physics_entity_1 = require("./physics-entity");
7
+ const p2js_helper_1 = require("../libs/p2js.helper");
8
+ class ImmovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
9
+ constructor(physicsWorldId, physicsEntityDefinition) {
10
+ super(physicsWorldId, physicsEntityDefinition, 'static');
11
+ this.onCollision = new actions_lib_1.Action();
12
+ this.position = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.position);
13
+ this.rotation = this.p2Body.angle;
14
+ }
15
+ destroy() { }
16
+ convertToDTO() {
17
+ return {
18
+ entityId: this.id,
19
+ entityClassName: this.constructor.name,
20
+ position: this.position,
21
+ rotation: this.rotation,
22
+ velocity: helpers_lib_1.Vector.zero,
23
+ rotationalSpeed: 0
24
+ };
25
+ }
26
+ }
27
+ exports.ImmovablePhysicsEntity = ImmovablePhysicsEntity;
28
+ //# sourceMappingURL=immovable-physics-entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"immovable-physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entity-types/immovable-physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AACrC,6CAAqC;AAGrC,qDAAiD;AACjD,qDAAiD;AAEjD,MAAsB,sBAAuB,SAAQ,8BAAa;IAMhE,YAAY,cAAsB,EAAE,uBAAgD;QAClF,KAAK,CAAC,cAAc,EAAE,uBAAuB,EAAE,QAAQ,CAAC,CAAC;QAHlD,gBAAW,GAAG,IAAI,oBAAM,EAAqB,CAAC;QAKrD,IAAI,CAAC,QAAQ,GAAG,wBAAU,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,OAAO,KAAU,CAAC;IAElB,YAAY;QACV,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,EAAE;YACjB,eAAe,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI;YACtC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,oBAAM,CAAC,IAAI;YACrB,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;CACF;AAzBD,wDAyBC"}
@@ -0,0 +1,11 @@
1
+ import { Variable } from 'actions-lib';
2
+ import { Vector } from 'helpers-lib';
3
+ import { Entity } from '../../game-entities';
4
+ export declare abstract class MovableEntity extends Entity {
5
+ readonly position: Variable<Vector>;
6
+ readonly rotation: Variable<number>;
7
+ readonly velocity: Variable<Vector>;
8
+ readonly rotationalSpeed: Variable<number>;
9
+ constructor();
10
+ private step;
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MovableEntity = void 0;
4
+ const actions_lib_1 = require("actions-lib");
5
+ const helpers_lib_1 = require("helpers-lib");
6
+ const game_entities_1 = require("../../game-entities");
7
+ class MovableEntity extends game_entities_1.Entity {
8
+ constructor() {
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(0);
12
+ this.velocity = new actions_lib_1.Variable().set(helpers_lib_1.Vector.zero);
13
+ this.rotationalSpeed = new actions_lib_1.Variable().set(0);
14
+ game_entities_1.UpdateCycle.beforeSceneUpdateAction
15
+ .subscribe(({ time, delta }) => {
16
+ this.step(time, delta);
17
+ })
18
+ .attach(this);
19
+ }
20
+ step(time, delta) {
21
+ this.position.value = this.position.value.add(this.velocity.value.multiply(delta));
22
+ this.rotation.value = this.rotation.value + this.rotationalSpeed.value * delta;
23
+ }
24
+ }
25
+ exports.MovableEntity = MovableEntity;
26
+ //# sourceMappingURL=movable-entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"movable-entity.js","sourceRoot":"","sources":["../../../src/physics/entity-types/movable-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,6CAAqC;AAErC,uDAA0D;AAE1D,MAAsB,aAAc,SAAQ,sBAAM;IAMhD;QACE,KAAK,EAAE,CAAC;QAND,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,oBAAe,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAIvD,2BAAW,CAAC,uBAAuB;aAChC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAEO,IAAI,CAAC,IAAY,EAAE,KAAa;QACtC,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,KAAK,CAAC;IACjF,CAAC;CACF;AAnBD,sCAmBC"}
@@ -0,0 +1,20 @@
1
+ import { Action, Variable } from 'actions-lib';
2
+ import { Vector } from 'helpers-lib';
3
+ import { PhysicsEntityDefinition, CollisionReport, PhysicsBodyDTO } from '../interfaces';
4
+ import { PhysicsEntity } from './physics-entity';
5
+ export declare abstract class MovablePhysicsEntity extends PhysicsEntity {
6
+ readonly position: Variable<Vector>;
7
+ readonly rotation: Variable<number>;
8
+ readonly velocity: Variable<Vector>;
9
+ readonly rotationalSpeed: Variable<number>;
10
+ readonly onCollision: Action<CollisionReport[]>;
11
+ private ignorePositionUpdate;
12
+ private ignoreRotationUpdate;
13
+ private ignoreVelocityUpdate;
14
+ private ignoreRotationalSpeedUpdate;
15
+ constructor(physicsWorldId: string, physicsEntityDefinition: PhysicsEntityDefinition);
16
+ convertToDTO(): PhysicsBodyDTO;
17
+ private step;
18
+ private phsicsToLocalSync;
19
+ private localToPhsicsSync;
20
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MovablePhysicsEntity = void 0;
4
+ const actions_lib_1 = require("actions-lib");
5
+ const helpers_lib_1 = require("helpers-lib");
6
+ const physics_internal_gateway_1 = require("../module/\u269C\uFE0Fgateways/physics-internal.gateway");
7
+ const p2js_helper_1 = require("../libs/p2js.helper");
8
+ const physics_entity_1 = require("./physics-entity");
9
+ const game_entities_1 = require("../../game-entities");
10
+ class MovablePhysicsEntity extends physics_entity_1.PhysicsEntity {
11
+ constructor(physicsWorldId, physicsEntityDefinition) {
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(0);
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();
18
+ this.ignorePositionUpdate = false;
19
+ this.ignoreRotationUpdate = false;
20
+ this.ignoreVelocityUpdate = false;
21
+ this.ignoreRotationalSpeedUpdate = false;
22
+ this.phsicsToLocalSync();
23
+ this.localToPhsicsSync();
24
+ game_entities_1.Service.get(physics_internal_gateway_1.PhysicsInternalGateway)
25
+ .subscribeToPhysicsStep(physicsWorldId, ({ time, delta }) => this.step(time, delta))
26
+ .attach(this);
27
+ }
28
+ convertToDTO() {
29
+ return {
30
+ entityId: this.id,
31
+ entityClassName: this.constructor.name,
32
+ position: this.position.value,
33
+ rotation: this.rotation.value,
34
+ velocity: this.velocity.value,
35
+ rotationalSpeed: this.rotationalSpeed.value
36
+ };
37
+ }
38
+ step(time, delta) {
39
+ this.ignorePositionUpdate = true;
40
+ this.ignoreRotationUpdate = true;
41
+ this.ignoreVelocityUpdate = true;
42
+ this.ignoreRotationalSpeedUpdate = true;
43
+ this.phsicsToLocalSync();
44
+ }
45
+ phsicsToLocalSync() {
46
+ this.position.value = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.position);
47
+ this.rotation.value = this.p2Body.angle;
48
+ this.velocity.value = p2js_helper_1.P2JSHelper.arrayToVector(this.p2Body.velocity);
49
+ this.rotationalSpeed.value = this.p2Body.angularVelocity;
50
+ }
51
+ localToPhsicsSync() {
52
+ this.position
53
+ .subscribe(position => {
54
+ if (this.ignorePositionUpdate) {
55
+ this.ignorePositionUpdate = false;
56
+ }
57
+ else {
58
+ this.p2Body.position = [position.x, position.y];
59
+ }
60
+ })
61
+ .attach(this);
62
+ this.rotation
63
+ .subscribe(rotation => {
64
+ if (this.ignoreRotationUpdate) {
65
+ this.ignoreRotationUpdate = false;
66
+ }
67
+ else {
68
+ this.p2Body.angle = rotation;
69
+ }
70
+ })
71
+ .attach(this);
72
+ this.velocity
73
+ .subscribe(velocity => {
74
+ if (this.ignoreVelocityUpdate) {
75
+ this.ignoreVelocityUpdate = false;
76
+ }
77
+ else {
78
+ this.p2Body.velocity = [velocity.x, velocity.y];
79
+ }
80
+ })
81
+ .attach(this);
82
+ this.rotationalSpeed
83
+ .subscribe(rotationalSpeed => {
84
+ if (this.ignoreRotationalSpeedUpdate) {
85
+ this.ignoreRotationalSpeedUpdate = false;
86
+ }
87
+ else {
88
+ let torque = (rotationalSpeed - this.p2Body.angularVelocity) / this.p2Body.invInertia;
89
+ this.p2Body.angularForce = torque;
90
+ }
91
+ })
92
+ .attach(this);
93
+ }
94
+ }
95
+ exports.MovablePhysicsEntity = MovablePhysicsEntity;
96
+ //# sourceMappingURL=movable-physics-entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"movable-physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entity-types/movable-physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAC/C,6CAAqC;AAErC,sGAAuF;AAEvF,qDAAiD;AAEjD,qDAAiD;AACjD,uDAA8C;AAE9C,MAAsB,oBAAqB,SAAQ,8BAAa;IAa9D,YAAY,cAAsB,EAAE,uBAAgD;QAClF,KAAK,CAAC,cAAc,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;QAbnD,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzC,aAAQ,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,oBAAM,CAAC,IAAI,CAAC,CAAC;QACnD,oBAAe,GAAG,IAAI,sBAAQ,EAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEhD,gBAAW,GAAG,IAAI,oBAAM,EAAqB,CAAC;QAE/C,yBAAoB,GAAG,KAAK,CAAC;QAC7B,yBAAoB,GAAG,KAAK,CAAC;QAC7B,yBAAoB,GAAG,KAAK,CAAC;QAC7B,gCAA2B,GAAG,KAAK,CAAC;QAK1C,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,uBAAO,CAAC,GAAG,CAAC,iDAAsB,CAAC;aAChC,sBAAsB,CAAC,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACnF,MAAM,CAAC,IAAI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IAClB,CAAC;CACF;AA7FD,oDA6FC"}
@@ -0,0 +1,31 @@
1
+ import { Action } from 'actions-lib';
2
+ import p2 from 'p2';
3
+ import { CollisionReport, PhysicsBodyDTO, PhysicsEntityDefinition } from '../interfaces';
4
+ import { Entity } from '../../game-entities';
5
+ import { PhysicsBodyGroup } from '../libs/physics-body-groups';
6
+ export declare abstract class PhysicsEntity extends Entity {
7
+ private static p2BodyIdToPhysicsBody;
8
+ private static physicsEntities;
9
+ static getFromP2BodyId(p2BodyId: number): PhysicsEntity | undefined;
10
+ static getFromP2BodyIdOrFail(p2BodyId: number): PhysicsEntity;
11
+ static getPhysicsInstanceOrFail(id: string): PhysicsEntity;
12
+ static getPhysicsEntities(): PhysicsEntity[];
13
+ readonly onCollision: Action<CollisionReport[]>;
14
+ get area(): number;
15
+ get mass(): number;
16
+ get collisions(): ReadonlyArray<CollisionReport>;
17
+ readonly physicsBodyGroup: PhysicsBodyGroup;
18
+ readonly includeInPathfinding: boolean;
19
+ protected readonly p2Body: p2.Body;
20
+ protected readonly type: 'dynamic' | 'static';
21
+ protected physicsDestroy: () => void;
22
+ private readonly physicsWorldId;
23
+ private readonly physicsInternalGateway;
24
+ private _area;
25
+ private _mass;
26
+ private _collisions;
27
+ constructor(physicsWorldId: string, physicsEntityDefinition: PhysicsEntityDefinition, type: 'dynamic' | 'static');
28
+ abstract convertToDTO(): PhysicsBodyDTO;
29
+ destroy(): void;
30
+ protected setCollisionReports(collisionReports: CollisionReport[]): void;
31
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PhysicsEntity = void 0;
4
+ const actions_lib_1 = require("actions-lib");
5
+ const physics_internal_gateway_1 = require("../module/\u269C\uFE0Fgateways/physics-internal.gateway");
6
+ const p2js_helper_1 = require("../libs/p2js.helper");
7
+ const game_entities_1 = require("../../game-entities");
8
+ const update_cycle_1 = require("../../game-entities/update-cycle");
9
+ class PhysicsEntity extends game_entities_1.Entity {
10
+ static { this.p2BodyIdToPhysicsBody = new Map(); }
11
+ static { this.physicsEntities = new Map(); }
12
+ static getFromP2BodyId(p2BodyId) {
13
+ return PhysicsEntity.p2BodyIdToPhysicsBody.get(p2BodyId);
14
+ }
15
+ static getFromP2BodyIdOrFail(p2BodyId) {
16
+ let physicsBody = PhysicsEntity.p2BodyIdToPhysicsBody.get(p2BodyId);
17
+ if (!physicsBody) {
18
+ throw new Error(`PhysicsEntity with p2BodyId ${p2BodyId} not found`);
19
+ }
20
+ return physicsBody;
21
+ }
22
+ static getPhysicsInstanceOrFail(id) {
23
+ let physicsEntity = PhysicsEntity.physicsEntities.get(id);
24
+ if (!physicsEntity) {
25
+ throw new Error(`PhysicsEntity with id ${id} not found`);
26
+ }
27
+ return physicsEntity;
28
+ }
29
+ static getPhysicsEntities() {
30
+ return Array.from(PhysicsEntity.physicsEntities.values());
31
+ }
32
+ get area() {
33
+ return this._area;
34
+ }
35
+ get mass() {
36
+ return this._mass;
37
+ }
38
+ get collisions() {
39
+ return this._collisions;
40
+ }
41
+ constructor(physicsWorldId, physicsEntityDefinition, type) {
42
+ super();
43
+ this.onCollision = new actions_lib_1.Action();
44
+ this.type = 'dynamic';
45
+ this.physicsDestroy = () => {
46
+ this.physicsInternalGateway.removeBody(this.physicsWorldId, this.p2Body);
47
+ PhysicsEntity.p2BodyIdToPhysicsBody.delete(this.p2Body.id);
48
+ PhysicsEntity.physicsEntities.delete(this.id);
49
+ };
50
+ this._area = 0;
51
+ this._mass = 0;
52
+ this._collisions = [];
53
+ this.physicsWorldId = physicsWorldId;
54
+ this.physicsInternalGateway = game_entities_1.Service.get(physics_internal_gateway_1.PhysicsInternalGateway);
55
+ let material = this.physicsInternalGateway.getMaterial(this.physicsWorldId, physicsEntityDefinition.shapeDefinition.materialName);
56
+ let materialDefinition = this.physicsInternalGateway.getMaterialDefinition(this.physicsWorldId, physicsEntityDefinition.shapeDefinition.materialName);
57
+ this.type = type;
58
+ this.physicsBodyGroup = physicsEntityDefinition.shapeDefinition.group;
59
+ this.includeInPathfinding = physicsEntityDefinition.includeOnPathfinding;
60
+ this.p2Body = this.physicsInternalGateway.createBody(physicsEntityDefinition, material, materialDefinition, this.type);
61
+ this._area = this.p2Body.getArea();
62
+ this._mass = this.p2Body.mass;
63
+ this.p2Body.position = p2js_helper_1.P2JSHelper.vectorToArray(physicsEntityDefinition.position);
64
+ this.p2Body.angle = physicsEntityDefinition.rotation;
65
+ let addedToTheWorld = this.physicsInternalGateway.addBody(this.physicsWorldId, this.p2Body, physicsEntityDefinition.addInEmptySpace, physicsEntityDefinition.shapeDefinition.group, physicsEntityDefinition.includeOnPathfinding);
66
+ if (!addedToTheWorld) {
67
+ throw new Error('PhysicsEntity was not able to be added to the world!');
68
+ }
69
+ PhysicsEntity.p2BodyIdToPhysicsBody.set(this.p2Body.id, this);
70
+ PhysicsEntity.physicsEntities.set(this.id, this);
71
+ this.destroy = function () {
72
+ update_cycle_1.UpdateCycle.waitUntilDestroyPhase(() => {
73
+ this.destroyed = true;
74
+ this.attachableDestroy();
75
+ this.entityDestroy();
76
+ this.physicsDestroy();
77
+ this.childDestroy();
78
+ });
79
+ };
80
+ }
81
+ destroy() { }
82
+ // Managed by CollisionsService
83
+ setCollisionReports(collisionReports) {
84
+ this._collisions = collisionReports;
85
+ if (collisionReports.length > 0) {
86
+ this.onCollision.trigger(collisionReports);
87
+ }
88
+ }
89
+ }
90
+ exports.PhysicsEntity = PhysicsEntity;
91
+ //# sourceMappingURL=physics-entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physics-entity.js","sourceRoot":"","sources":["../../../src/physics/entity-types/physics-entity.ts"],"names":[],"mappings":";;;AAAA,6CAAqC;AAGrC,sGAAuF;AAEvF,qDAAiD;AAEjD,uDAAsD;AACtD,mEAA+D;AAG/D,MAAsB,aAAc,SAAQ,sBAAM;aACjC,0BAAqB,GAAG,IAAI,GAAG,EAAyB,AAAnC,CAAoC;aACzD,oBAAe,GAAG,IAAI,G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physics-world';
2
- export { MovableEntity } from './entitity-types/movable-entity';
3
- export { MovablePhysicsEntity } from './entitity-types/movable-physics-entity';
4
- export { ImmovablePhysicsEntity } from './entitity-types/immovable-physics-entity';
5
- export { PhysicsEntity } from './entitity-types/physics-entity';
6
- export { PhysicsBodyGroup } from './sub-elements/elements/physics-body-groups';
7
- export { PhysicsCollision } from './sub-elements/collisions/physics-collision';
8
- export { PhysicsMaterials } from './sub-elements/elements/physics-materials';
9
- export { PhysicsBodyExplosionHit } from './sub-elements/raycasting/physics-body-explosion-hit';
1
+ export { MovableEntity } from './entity-types/movable-entity';
2
+ export { MovablePhysicsEntity } from './entity-types/movable-physics-entity';
3
+ export { ImmovablePhysicsEntity } from './entity-types/immovable-physics-entity';
4
+ export { PhysicsEntity } from './entity-types/physics-entity';
5
+ export { PhysicsBodyGroup } from './libs/physics-body-groups';
6
+ export * from './module/⚜️gateways/index';
10
7
  export * from './interfaces';
@@ -14,24 +14,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PhysicsBodyExplosionHit = exports.PhysicsMaterials = exports.PhysicsCollision = exports.PhysicsBodyGroup = exports.PhysicsEntity = exports.ImmovablePhysicsEntity = exports.MovablePhysicsEntity = exports.MovableEntity = exports.PhysicsWorld = void 0;
18
- var physics_world_1 = require("./physics-world");
19
- Object.defineProperty(exports, "PhysicsWorld", { enumerable: true, get: function () { return physics_world_1.PhysicsWorld; } });
20
- var movable_entity_1 = require("./entitity-types/movable-entity");
17
+ exports.PhysicsBodyGroup = exports.PhysicsEntity = exports.ImmovablePhysicsEntity = exports.MovablePhysicsEntity = exports.MovableEntity = void 0;
18
+ var movable_entity_1 = require("./entity-types/movable-entity");
21
19
  Object.defineProperty(exports, "MovableEntity", { enumerable: true, get: function () { return movable_entity_1.MovableEntity; } });
22
- var movable_physics_entity_1 = require("./entitity-types/movable-physics-entity");
20
+ var movable_physics_entity_1 = require("./entity-types/movable-physics-entity");
23
21
  Object.defineProperty(exports, "MovablePhysicsEntity", { enumerable: true, get: function () { return movable_physics_entity_1.MovablePhysicsEntity; } });
24
- var immovable_physics_entity_1 = require("./entitity-types/immovable-physics-entity");
22
+ var immovable_physics_entity_1 = require("./entity-types/immovable-physics-entity");
25
23
  Object.defineProperty(exports, "ImmovablePhysicsEntity", { enumerable: true, get: function () { return immovable_physics_entity_1.ImmovablePhysicsEntity; } });
26
- var physics_entity_1 = require("./entitity-types/physics-entity");
24
+ var physics_entity_1 = require("./entity-types/physics-entity");
27
25
  Object.defineProperty(exports, "PhysicsEntity", { enumerable: true, get: function () { return physics_entity_1.PhysicsEntity; } });
28
- var physics_body_groups_1 = require("./sub-elements/elements/physics-body-groups");
26
+ var physics_body_groups_1 = require("./libs/physics-body-groups");
29
27
  Object.defineProperty(exports, "PhysicsBodyGroup", { enumerable: true, get: function () { return physics_body_groups_1.PhysicsBodyGroup; } });
30
- var physics_collision_1 = require("./sub-elements/collisions/physics-collision");
31
- Object.defineProperty(exports, "PhysicsCollision", { enumerable: true, get: function () { return physics_collision_1.PhysicsCollision; } });
32
- var physics_materials_1 = require("./sub-elements/elements/physics-materials");
33
- Object.defineProperty(exports, "PhysicsMaterials", { enumerable: true, get: function () { return physics_materials_1.PhysicsMaterials; } });
34
- var physics_body_explosion_hit_1 = require("./sub-elements/raycasting/physics-body-explosion-hit");
35
- Object.defineProperty(exports, "PhysicsBodyExplosionHit", { enumerable: true, get: function () { return physics_body_explosion_hit_1.PhysicsBodyExplosionHit; } });
28
+ __exportStar(require("./module/\u269C\uFE0Fgateways/index"), exports);
36
29
  __exportStar(require("./interfaces"), exports);
37
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/physics/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,kEAAgE;AAAvD,+GAAA,aAAa,OAAA;AACtB,kFAA+E;AAAtE,8HAAA,oBAAoB,OAAA;AAC7B,sFAAmF;AAA1E,kIAAA,sBAAsB,OAAA;AAC/B,kEAAgE;AAAvD,+GAAA,aAAa,OAAA;AACtB,mFAA+E;AAAtE,uHAAA,gBAAgB,OAAA;AACzB,iFAA+E;AAAtE,qHAAA,gBAAgB,OAAA;AACzB,+EAA6E;AAApE,qHAAA,gBAAgB,OAAA;AACzB,mGAA+F;AAAtF,qIAAA,uBAAuB,OAAA;AAChC,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/physics/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gEAA8D;AAArD,+GAAA,aAAa,OAAA;AACtB,gFAA6E;AAApE,8HAAA,oBAAoB,OAAA;AAC7B,oFAAiF;AAAxE,kIAAA,sBAAsB,OAAA;AAC/B,gEAA8D;AAArD,+GAAA,aAAa,OAAA;AAEtB,kEAA8D;AAArD,uHAAA,gBAAgB,OAAA;AAEzB,sEAA0C;AAC1C,+CAA6B"}
@@ -1,34 +1,5 @@
1
1
  import { Vec2, Vector } from 'helpers-lib';
2
- import p2 from 'p2';
3
- import { PhysicsBodyGroup } from './sub-elements/elements/physics-body-groups';
4
- export declare const BorderMaterialName = "border";
5
- export interface MaterialContactDefinition {
6
- readonly materialA: string;
7
- readonly materialB: string;
8
- readonly friction: number;
9
- readonly bounciness: number;
10
- readonly stiffness: number;
11
- }
12
- export interface MaterialDefinition {
13
- readonly name: string;
14
- readonly density: number;
15
- readonly velocityDrag: number;
16
- readonly rotationalDrag: number;
17
- }
18
- export interface PhysicsShape {
19
- readonly area: number;
20
- readonly setBody: (body: p2.Body) => void;
21
- }
22
- export interface ImageProperties {
23
- readonly size: Vector;
24
- readonly anchor: Vector;
25
- readonly scale: number;
26
- }
27
- export interface BorderProperties {
28
- readonly friction: number;
29
- readonly bounciness: number;
30
- readonly stiffness: number;
31
- }
2
+ import { PhysicsBodyGroup } from './libs/physics-body-groups';
32
3
  export interface PhysicsBodyDTO {
33
4
  readonly entityId: string;
34
5
  readonly entityClassName: string;
@@ -80,8 +51,3 @@ export interface PhysicsEntityDefinition {
80
51
  readonly addInEmptySpace: boolean;
81
52
  readonly includeOnPathfinding: boolean;
82
53
  }
83
- export interface PhysicsExplosionOptions {
84
- readonly printRaysOn?: string;
85
- readonly debugRayDuration?: number;
86
- readonly hitOnlyClosest?: boolean;
87
- }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PhysicsShapeType = exports.BorderMaterialName = void 0;
4
- exports.BorderMaterialName = 'border';
3
+ exports.PhysicsShapeType = void 0;
5
4
  var PhysicsShapeType;
6
5
  (function (PhysicsShapeType) {
7
6
  PhysicsShapeType["point"] = "point";
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/physics/interfaces.ts"],"names":[],"mappings":";;;AAKa,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAyD3C,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;AACzB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/physics/interfaces.ts"],"names":[],"mappings":";;;AA2BA,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,2CAAuB,CAAA;AACzB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="p2" />
2
+ import { Rectangle, Vector } from 'helpers-lib';
3
+ export declare class P2JSHelper {
4
+ static aabbToBoundingBox(aabb: p2.AABB): Rectangle;
5
+ static arrayToVector(array: [number, number]): Vector;
6
+ static vectorToArray(vector: Vector): [number, number];
7
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.P2JSHelper = void 0;
4
+ const helpers_lib_1 = require("helpers-lib");
5
+ class P2JSHelper {
6
+ static aabbToBoundingBox(aabb) {
7
+ return helpers_lib_1.Rectangle.fromRect({
8
+ topLeft: {
9
+ x: aabb.lowerBound[0],
10
+ y: aabb.lowerBound[1]
11
+ },
12
+ bottomRight: {
13
+ x: aabb.upperBound[0],
14
+ y: aabb.upperBound[1]
15
+ }
16
+ });
17
+ }
18
+ static arrayToVector(array) {
19
+ return new helpers_lib_1.Vector(array[0], array[1]);
20
+ }
21
+ static vectorToArray(vector) {
22
+ return [vector.x, vector.y];
23
+ }
24
+ }
25
+ exports.P2JSHelper = P2JSHelper;
26
+ //# sourceMappingURL=p2js.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p2js.helper.js","sourceRoot":"","sources":["../../../src/physics/libs/p2js.helper.ts"],"names":[],"mappings":";;;AAAA,6CAAgD;AAEhD,MAAa,UAAU;IACrB,MAAM,CAAC,iBAAiB,CAAC,IAAa;QACpC,OAAO,uBAAS,CAAC,QAAQ,CAAC;YACxB,OAAO,EAAE;gBACP,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;gBACrB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;aACtB;YACD,WAAW,EAAE;gBACX,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;gBACrB,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;aACtB;SACF,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAuB;QAC1C,OAAO,IAAI,oBAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,MAAc;QACjC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;CACF;AArBD,gCAqBC"}
@@ -0,0 +1,15 @@
1
+ export declare enum PhysicsBodyGroup {
2
+ none = 0,
3
+ border = 1,
4
+ friend = 2,
5
+ friendProjectile = 3,
6
+ enemy = 4,
7
+ enemyProjectile = 5,
8
+ neutral = 6,
9
+ explosion = 7
10
+ }
11
+ export declare class PhysicsBodyGroups {
12
+ static getGroupConstant(group: PhysicsBodyGroup): number;
13
+ static getMaskConstant(group: PhysicsBodyGroup): number;
14
+ static canCollide(group1: PhysicsBodyGroup, group2: PhysicsBodyGroup): boolean;
15
+ }