bard-legends-framework 0.9.6 → 0.9.7
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.
- package/dist/_interfaces/index.d.ts +2 -2
- package/dist/_interfaces/index.js +2 -3
- package/dist/game-entities/attachable/attachable.d.ts +6 -6
- package/dist/game-entities/attachable/attachable.js +28 -30
- package/dist/game-entities/attachable/attachable.spec.js +129 -128
- package/dist/game-entities/attachable/attachable.store.d.ts +5 -5
- package/dist/game-entities/attachable/attachable.store.js +34 -32
- package/dist/game-entities/attachable/attachable.test.js +132 -131
- package/dist/game-entities/attachable/destroyable.d.ts +13 -13
- package/dist/game-entities/attachable/destroyable.js +64 -69
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/decorate-actions-lib.js +125 -116
- package/dist/game-entities/attachable/helpers/referance-variable.d.ts +15 -15
- package/dist/game-entities/attachable/helpers/referance-variable.js +47 -48
- package/dist/game-entities/attachable/interfaces.d.ts +6 -6
- package/dist/game-entities/attachable/interfaces.js +2 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +0 -1
- package/dist/game-entities/controller/controller.js +0 -1
- package/dist/game-entities/controller/controller.spec.js +128 -125
- package/dist/game-entities/entity/entity.spec.js +263 -293
- package/dist/game-entities/entity/helpers/view-creation.helper.d.ts +7 -7
- package/dist/game-entities/entity/helpers/view-creation.helper.js +48 -48
- package/dist/game-entities/scene/scene.spec.js +219 -223
- package/dist/game-entities/service/service.js +0 -4
- package/dist/game-entities/service/service.spec.js +265 -237
- package/dist/game-entities/service/service.test.js +4 -2
- package/dist/game-entities/update-loop.d.ts +18 -18
- package/dist/game-entities/update-loop.js +46 -28
- package/dist/game-entities/view/view.spec.js +490 -506
- package/dist/game-entities/view/view.test.js +1 -1
- package/dist/lib/animator/animations.d.ts +13 -13
- package/dist/lib/animator/animations.js +43 -40
- package/dist/lib/animator/animator.d.ts +41 -41
- package/dist/lib/animator/animator.js +194 -197
- package/dist/lib/animator/animator.spec.js +699 -612
- package/dist/lib/animator/index.js +24 -19
- package/dist/lib/libraries/animator/animations.d.ts +13 -13
- package/dist/lib/libraries/animator/animations.js +43 -40
- package/dist/lib/libraries/animator/animator.d.ts +41 -41
- package/dist/lib/libraries/animator/animator.js +194 -197
- package/dist/lib/libraries/animator/animator.spec.js +699 -612
- package/dist/lib/libraries/animator/index.js +24 -19
- package/dist/lib/libraries/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/libraries/path-finder/path-finder.js +19 -20
- package/dist/lib/path-finder/path-finder.d.ts +2 -2
- package/dist/lib/path-finder/path-finder.js +19 -20
- package/dist/lib/services/keyboard/keyboard.d.ts +4 -4
- package/dist/lib/services/keyboard/keyboard.js +39 -31
- package/dist/lib/services/mouse/mouse.service.d.ts +8 -8
- package/dist/lib/services/mouse/mouse.service.js +65 -53
- package/dist/lib/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/lib/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/lib/update-loop.d.ts +10 -10
- package/dist/lib/update-loop.js +35 -27
- package/dist/physics/entitity-types/immovable-physics-entity.d.ts +6 -6
- package/dist/physics/entitity-types/immovable-physics-entity.js +23 -24
- package/dist/physics/entitity-types/movable-entity.d.ts +6 -6
- package/dist/physics/entitity-types/movable-entity.js +21 -22
- package/dist/physics/entitity-types/movable-physics-entity.d.ts +14 -14
- package/dist/physics/entitity-types/movable-physics-entity.js +83 -88
- package/dist/physics/entitity-types/physics-entity.d.ts +23 -23
- package/dist/physics/entitity-types/physics-entity.js +97 -88
- package/dist/physics/helpers/closest-available-space.helper.d.ts +16 -16
- package/dist/physics/helpers/closest-available-space.helper.js +98 -96
- package/dist/physics/helpers/closest-available-space.helper.spec.js +115 -68
- package/dist/physics/helpers/p2js.helper.d.ts +3 -3
- package/dist/physics/helpers/p2js.helper.js +21 -22
- package/dist/physics/helpers/shape-factory.d.ts +9 -4
- package/dist/physics/helpers/shape-factory.js +99 -75
- package/dist/physics/libs/p2js.helper.js +1 -1
- package/dist/physics/libs/position-to-grid-position-converter.d.ts +3 -3
- package/dist/physics/libs/position-to-grid-position-converter.js +15 -13
- package/dist/physics/module//360/237/223/220services/availability-grid.service.d.ts +10 -5
- package/dist/physics/module//360/237/223/220services/availability-grid.service.js +77 -57
- package/dist/physics/module//360/237/223/220services/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/border.service.js +57 -37
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/collisions.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/collisions.service.js +110 -98
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.d.ts +28 -6
- package/dist/physics/module//360/237/223/220services/debug-visuals.service.js +121 -89
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts +15 -7
- package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.js +117 -93
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.d.ts +14 -7
- package/dist/physics/module//360/237/223/220services/explosions/explosion.service.js +102 -77
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/explosions/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/helpers/ray-cast-hit-converter.js +71 -67
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/materials.service.d.ts +16 -11
- package/dist/physics/module//360/237/223/220services/materials.service.js +118 -108
- package/dist/physics/module//360/237/223/220services/path-finder.service.d.ts +19 -8
- package/dist/physics/module//360/237/223/220services/path-finder.service.js +121 -82
- package/dist/physics/module//360/237/223/220services/physics-world.service.d.ts +30 -15
- package/dist/physics/module//360/237/223/220services/physics-world.service.js +122 -100
- package/dist/physics/module//360/237/223/220services/ray-casting.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/ray-casting.service.js +87 -86
- package/dist/physics/module//360/237/223/220services/shape-creation.service.d.ts +9 -4
- package/dist/physics/module//360/237/223/220services/shape-creation.service.js +113 -84
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +2 -1
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.d.ts +8 -8
- package/dist/physics/module//360/237/247/212entities/data-structures/availability-grid-cache.js +32 -33
- package/dist/physics/physics-world.d.ts +50 -34
- package/dist/physics/physics-world.js +142 -133
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.d.ts +3 -3
- package/dist/physics/sub-elements/available-spaces/helpers/availability-grid.helper.js +15 -13
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.d.ts +9 -9
- package/dist/physics/sub-elements/available-spaces/physics-availability-grid.js +82 -77
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.d.ts +18 -14
- package/dist/physics/sub-elements/available-spaces/physics-available-spaces.js +91 -79
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.d.ts +11 -11
- package/dist/physics/sub-elements/collisions/contact-equation-orginiser.js +84 -76
- package/dist/physics/sub-elements/collisions/physics-collision.d.ts +7 -7
- package/dist/physics/sub-elements/collisions/physics-collision.js +43 -44
- package/dist/physics/sub-elements/elements/physics-body-groups.d.ts +11 -11
- package/dist/physics/sub-elements/elements/physics-body-groups.js +54 -54
- package/dist/physics/sub-elements/elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/elements/physics-world-borders.d.ts +3 -3
- package/dist/physics/sub-elements/elements/physics-world-borders.js +69 -45
- package/dist/physics/sub-elements/physics-body-groups.d.ts +8 -8
- package/dist/physics/sub-elements/physics-body-groups.js +41 -42
- package/dist/physics/sub-elements/physics-collision.d.ts +16 -16
- package/dist/physics/sub-elements/physics-collision.js +141 -121
- package/dist/physics/sub-elements/physics-materials.d.ts +15 -10
- package/dist/physics/sub-elements/physics-materials.js +101 -100
- package/dist/physics/sub-elements/physics-world-borders.d.ts +2 -2
- package/dist/physics/sub-elements/physics-world-borders.js +25 -26
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.d.ts +15 -11
- package/dist/physics/sub-elements/raycasting/physics-body-explosion-hit.js +59 -59
- package/dist/physics/sub-elements/raycasting/physics-explosion.d.ts +13 -6
- package/dist/physics/sub-elements/raycasting/physics-explosion.js +108 -73
- package/dist/physics/sub-elements/raycasting/ray-cast.d.ts +19 -19
- package/dist/physics/sub-elements/raycasting/ray-cast.js +93 -98
- package/dist/pixi/display-object/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/components/filters.js +106 -81
- package/dist/pixi/display-object/components/glow-effect.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-effect.js +33 -36
- package/dist/pixi/display-object/components/glow-filter.d.ts +8 -8
- package/dist/pixi/display-object/components/glow-filter.js +33 -36
- package/dist/pixi/display-object/container-attributes.js +1 -1
- package/dist/pixi/display-object/display-object-attributes.d.ts +41 -41
- package/dist/pixi/display-object/display-object-attributes.js +148 -150
- package/dist/pixi/display-object/display-object.d.ts +17 -17
- package/dist/pixi/display-object/display-object.js +79 -75
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/alpha-primer-color.filter.js +89 -77
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +30 -30
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.d.ts +9 -4
- package/dist/pixi/display-object/filters/base-filters/contrast-filter.js +62 -53
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-alpha-color.js +93 -81
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.d.ts +12 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color-gradient.js +120 -109
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.d.ts +10 -5
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +32 -32
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.js +92 -85
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +28 -28
- package/dist/pixi/display-object/filters/templates/plane.template.js +20 -20
- package/dist/pixi/display-object/filters.js +20 -4
- package/dist/pixi/display-object/objects/components/filters.d.ts +18 -18
- package/dist/pixi/display-object/objects/components/filters.js +106 -81
- package/dist/pixi/display-object/objects/container.d.ts +2 -2
- package/dist/pixi/display-object/objects/container.js +39 -30
- package/dist/pixi/display-object/objects/graphics.d.ts +28 -28
- package/dist/pixi/display-object/objects/graphics.js +218 -202
- package/dist/pixi/display-object/objects/helpers/filters.d.ts +25 -25
- package/dist/pixi/display-object/objects/helpers/filters.js +150 -124
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.d.ts +7 -7
- package/dist/pixi/display-object/objects/helpers/glow-sprite-generator.js +114 -95
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.d.ts +5 -5
- package/dist/pixi/display-object/objects/premade-objects/sprite-with-glowing-shapes.js +81 -57
- package/dist/pixi/display-object/objects/sprite.d.ts +43 -43
- package/dist/pixi/display-object/objects/sprite.js +248 -233
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +9 -9
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +1 -1
- package/dist/pixi/display-object/objects/text.d.ts +25 -25
- package/dist/pixi/display-object/objects/text.js +111 -102
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.d.ts +13 -9
- package/dist/pixi/display-object/premade-objects/sprite-with-glowing-shapes.js +96 -67
- package/dist/pixi/game.d.ts +1 -1
- package/dist/pixi/game.js +2 -2
- package/dist/pixi/helpers/glow-sprite-generator.d.ts +6 -6
- package/dist/pixi/helpers/glow-sprite-generator.js +99 -84
- package/dist/pixi/helpers/pixi-container.helper.d.ts +1 -1
- package/dist/pixi/helpers/pixi-container.helper.js +10 -8
- package/dist/pixi/helpers/screen-position-to-stage.helper.d.ts +1 -1
- package/dist/pixi/helpers/screen-position-to-stage.helper.js +12 -12
- package/dist/pixi/helpers/screen-position-to-stage.helper.test.js +174 -79
- package/dist/pixi/modules/CAMERA/index.d.ts +1 -1
- package/dist/pixi/modules/CAMERA/index.js +3 -3
- package/dist/services/keyboard/keyboard.d.ts +4 -4
- package/dist/services/keyboard/keyboard.js +39 -31
- package/dist/services/mouse/mouse.service.d.ts +8 -8
- package/dist/services/mouse/mouse.service.js +65 -53
- package/dist/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/services/mouse/mouser-target-focus.service.js +83 -81
- package/dist/utilities/libraries/animator/animating-content/state-animation.d.ts +29 -26
- package/dist/utilities/libraries/animator/animating-content/state-animation.js +159 -165
- package/dist/utilities/libraries/animator/animating-content/state-animation.test.js +386 -375
- package/dist/utilities/libraries/animator/animator.spec.js +765 -656
- package/dist/utilities/libraries/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.d.ts +11 -11
- package/dist/utilities/libraries/data-structures/binary-heap/binary-heap.js +79 -81
- package/dist/utilities/libraries/data-structures/grid/grid.d.ts +35 -31
- package/dist/utilities/libraries/data-structures/grid/grid.js +128 -117
- package/dist/utilities/libraries/data-structures/grid/grid.spec.js +176 -138
- package/dist/utilities/libraries/data-structures/grid/grid.test.js +218 -141
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.d.ts +3 -3
- package/dist/utilities/libraries/data-structures/grid/position-to-grid-position-converter.js +15 -13
- package/dist/utilities/libraries/data-structures/queue/queue.d.ts +21 -21
- package/dist/utilities/libraries/data-structures/queue/queue.js +63 -66
- package/dist/utilities/libraries/data-structures/queue/queue.test.js +54 -55
- package/dist/utilities/libraries/grid-algorithms/closest-available-space/closest-available-space.helper.spec.js +122 -68
- package/dist/utilities/libraries/grid-algorithms/path-finder/path-finder.spec.js +140 -135
- package/dist/utilities/libraries/grid-algorithms/vector-field-path-finder/vector-field-path-finder.spec.js +293 -229
- package/dist/utilities/libraries/path-finder/path-finder.d.ts +7 -7
- package/dist/utilities/libraries/path-finder/path-finder.js +113 -109
- package/dist/utilities/libraries/path-finder/path-finder.spec.js +131 -106
- package/dist/utilities/services/keyboard/keyboard.d.ts +4 -4
- package/dist/utilities/services/keyboard/keyboard.js +42 -34
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.d.ts +1 -1
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.js +12 -12
- package/dist/utilities/services/mouse/helpers/mouse-position.helper.test.js +168 -73
- package/dist/utilities/services/mouse/mouse-target-focus.service.d.ts +15 -15
- package/dist/utilities/services/mouse/mouse-target-focus.service.js +79 -76
- package/dist/utilities/services/mouse/mouse.service.d.ts +9 -9
- package/dist/utilities/services/mouse/mouse.service.js +86 -72
- package/dist/utilities/services/mouse/mouser-target-focus.service.d.ts +11 -11
- package/dist/utilities/services/mouse/mouser-target-focus.service.js +83 -81
- package/package.json +4 -10
|
@@ -1,73 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.RayCastHitConverter = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
5
|
-
const physics_entity_1 = require(
|
|
6
|
-
const p2js_helper_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
4
|
+
const physics_entity_1 = require('../../../entity-types/physics-entity');
|
|
5
|
+
const p2js_helper_1 = require('../../../libs/p2js.helper');
|
|
7
6
|
class RayCastHitConverter {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
return [...bodyToHitResults.values()].map(rayResultGroupOfABody => this.convertRayResultGroupToExplosionHit(rayResultGroupOfABody, rayCasts.length));
|
|
39
|
-
}
|
|
40
|
-
static convertRayResultGroupToExplosionHit(rayResultGroupOfABody, totalCountOfRays) {
|
|
41
|
-
let ratioOfHits = rayResultGroupOfABody.hitCount / totalCountOfRays;
|
|
42
|
-
let raycastResults = rayResultGroupOfABody.rayCastHits;
|
|
43
|
-
if (rayResultGroupOfABody.isExternal) {
|
|
44
|
-
return {
|
|
45
|
-
body: physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastHit.body.id).convertToDTO(),
|
|
46
|
-
p2Body: rayResultGroupOfABody.closestRaycastHit.body,
|
|
47
|
-
isExternal: true,
|
|
48
|
-
normal: rayResultGroupOfABody.closestRaycastHit.normal,
|
|
49
|
-
fraction: rayResultGroupOfABody.closestRaycastHit.fraction,
|
|
50
|
-
ratioOfHits,
|
|
51
|
-
raycastResults,
|
|
52
|
-
getHitPosition: rayResultGroupOfABody.closestRaycastHit.hitPosition,
|
|
53
|
-
getHitDistance: rayResultGroupOfABody.closestRaycastHit.hitDistance
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
let bodyPosition = p2js_helper_1.P2JSHelper.arrayToVector(rayResultGroupOfABody.closestRaycastHit.body.position);
|
|
58
|
-
return {
|
|
59
|
-
body: physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(rayResultGroupOfABody.closestRaycastHit.body.id).convertToDTO(),
|
|
60
|
-
p2Body: rayResultGroupOfABody.closestRaycastHit.body,
|
|
61
|
-
isExternal: false,
|
|
62
|
-
normal: helpers_lib_1.Vector.fromTo(bodyPosition, rayResultGroupOfABody.explosionCenter).normalize(),
|
|
63
|
-
fraction: 0,
|
|
64
|
-
ratioOfHits,
|
|
65
|
-
raycastResults,
|
|
66
|
-
getHitPosition: () => rayResultGroupOfABody.explosionCenter,
|
|
67
|
-
getHitDistance: () => 0
|
|
68
|
-
};
|
|
7
|
+
static toExplosionHits(rayCasts, allRaysStartingFromSamePosition = true) {
|
|
8
|
+
const bodyToHitResults = new Map();
|
|
9
|
+
rayCasts.forEach(rayCast => {
|
|
10
|
+
rayCast.hits.forEach(rayCastHit => {
|
|
11
|
+
const previousRecord = bodyToHitResults.get(rayCastHit.body);
|
|
12
|
+
if (previousRecord) {
|
|
13
|
+
const closestRaycastResult =
|
|
14
|
+
rayCastHit.fraction < previousRecord.closestRaycastHit.fraction ? rayCastHit : previousRecord.closestRaycastHit;
|
|
15
|
+
previousRecord.rayCastHits.push(rayCastHit);
|
|
16
|
+
bodyToHitResults.set(rayCastHit.body, {
|
|
17
|
+
hitCount: previousRecord.hitCount + 1,
|
|
18
|
+
closestRaycastHit: closestRaycastResult,
|
|
19
|
+
rayCastHits: previousRecord.rayCastHits,
|
|
20
|
+
isExternal: allRaysStartingFromSamePosition
|
|
21
|
+
? previousRecord.isExternal
|
|
22
|
+
: previousRecord.isExternal && rayCastHit.isExternal(),
|
|
23
|
+
explosionCenter: rayCastHit.line.from
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
const isExternal = rayCastHit.isExternal();
|
|
27
|
+
bodyToHitResults.set(rayCastHit.body, {
|
|
28
|
+
hitCount: 1,
|
|
29
|
+
closestRaycastHit: rayCastHit,
|
|
30
|
+
rayCastHits: [rayCastHit],
|
|
31
|
+
isExternal,
|
|
32
|
+
explosionCenter: rayCastHit.line.from
|
|
33
|
+
});
|
|
69
34
|
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return [...bodyToHitResults.values()].map(rayResultGroupOfABody =>
|
|
38
|
+
RayCastHitConverter.convertRayResultGroupToExplosionHit(rayResultGroupOfABody, rayCasts.length)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
static convertRayResultGroupToExplosionHit(rayResultGroupOfABody, totalCountOfRays) {
|
|
42
|
+
const ratioOfHits = rayResultGroupOfABody.hitCount / totalCountOfRays;
|
|
43
|
+
const raycastResults = rayResultGroupOfABody.rayCastHits;
|
|
44
|
+
if (rayResultGroupOfABody.isExternal) {
|
|
45
|
+
return {
|
|
46
|
+
body: physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(
|
|
47
|
+
rayResultGroupOfABody.closestRaycastHit.body.id
|
|
48
|
+
).convertToDTO(),
|
|
49
|
+
p2Body: rayResultGroupOfABody.closestRaycastHit.body,
|
|
50
|
+
isExternal: true,
|
|
51
|
+
normal: rayResultGroupOfABody.closestRaycastHit.normal,
|
|
52
|
+
fraction: rayResultGroupOfABody.closestRaycastHit.fraction,
|
|
53
|
+
ratioOfHits,
|
|
54
|
+
raycastResults,
|
|
55
|
+
getHitPosition: rayResultGroupOfABody.closestRaycastHit.hitPosition,
|
|
56
|
+
getHitDistance: rayResultGroupOfABody.closestRaycastHit.hitDistance
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
const bodyPosition = p2js_helper_1.P2JSHelper.arrayToVector(rayResultGroupOfABody.closestRaycastHit.body.position);
|
|
60
|
+
return {
|
|
61
|
+
body: physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(
|
|
62
|
+
rayResultGroupOfABody.closestRaycastHit.body.id
|
|
63
|
+
).convertToDTO(),
|
|
64
|
+
p2Body: rayResultGroupOfABody.closestRaycastHit.body,
|
|
65
|
+
isExternal: false,
|
|
66
|
+
normal: helpers_lib_1.Vector.fromTo(bodyPosition, rayResultGroupOfABody.explosionCenter).normalize(),
|
|
67
|
+
fraction: 0,
|
|
68
|
+
ratioOfHits,
|
|
69
|
+
raycastResults,
|
|
70
|
+
getHitPosition: () => rayResultGroupOfABody.explosionCenter,
|
|
71
|
+
getHitDistance: () => 0
|
|
72
|
+
};
|
|
70
73
|
}
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
exports.RayCastHitConverter = RayCastHitConverter;
|
|
73
|
-
//# sourceMappingURL=ray-cast-hit-converter.js.map
|
|
77
|
+
//# sourceMappingURL=ray-cast-hit-converter.js.map
|
|
@@ -34,7 +34,7 @@ let ElipticExplosionService = class ElipticExplosionService {
|
|
|
34
34
|
this.testVisualsService.createElipticExplosionDebugVisual(physicsWorld, options.testLayerId, rayCasts, explosionCenter, rotation, size, options.debugRayDuration);
|
|
35
35
|
}
|
|
36
36
|
return explosionHitWithP2Bodies.map(explosionHitWithP2Body => {
|
|
37
|
-
let { p2Body, ...explosionHit } = explosionHitWithP2Body;
|
|
37
|
+
let { p2Body: _p2Body, ...explosionHit } = explosionHitWithP2Body;
|
|
38
38
|
return explosionHit;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import p2 from 'p2';
|
|
2
2
|
import { BorderProperties, MaterialContactDefinition, MaterialDefinition } from '../⚜️gateways';
|
|
3
3
|
export declare class MaterialsService {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
createMaterials(
|
|
5
|
+
p2World: p2.World,
|
|
6
|
+
borderProperties: BorderProperties,
|
|
7
|
+
materialDefinitions: ReadonlyArray<MaterialDefinition>,
|
|
8
|
+
materialContactDefinitions: ReadonlyArray<MaterialContactDefinition>
|
|
9
|
+
): {
|
|
10
|
+
materials: Map<string, p2.Material>;
|
|
11
|
+
materialDefinitions: Map<string, MaterialDefinition>;
|
|
12
|
+
};
|
|
13
|
+
getMaterial(physicsWorldId: string, name: string): p2.Material;
|
|
14
|
+
getMaterialDefinition(physicsWorldId: string, name: string): MaterialDefinition;
|
|
15
|
+
private getMaterialInternal;
|
|
16
|
+
private getMaterialDefinitionInternal;
|
|
17
|
+
private addContactMaterials;
|
|
18
|
+
private getFullListOfMaterialContactDefinitions;
|
|
19
|
+
private addContactMaterialsWithBorder;
|
|
15
20
|
}
|
|
@@ -1,120 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var __decorate =
|
|
2
|
+
(this && this.__decorate) ||
|
|
3
|
+
((decorators, target, key, desc) => {
|
|
4
|
+
var c = arguments.length,
|
|
5
|
+
r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
|
|
6
|
+
d;
|
|
7
|
+
if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function')
|
|
8
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
+
else
|
|
10
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
11
|
+
if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
12
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) ||
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
});
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || (mod => (mod && mod.__esModule ? mod : { default: mod }));
|
|
15
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
16
|
exports.MaterialsService = void 0;
|
|
13
|
-
const p2_1 = __importDefault(require(
|
|
14
|
-
const __gateways_1 = require(
|
|
15
|
-
const game_entities_1 = require(
|
|
16
|
-
const physics_world_entity_1 = require(
|
|
17
|
+
const p2_1 = __importDefault(require('p2'));
|
|
18
|
+
const __gateways_1 = require('../\u269C\uFE0Fgateways');
|
|
19
|
+
const game_entities_1 = require('../../../game-entities');
|
|
20
|
+
const physics_world_entity_1 = require('../\uD83E\uDDCAentities/physics-world.entity');
|
|
17
21
|
const BORDER_MATERIAL = new p2_1.default.Material();
|
|
18
22
|
const BORDER_MATERIAL_DEFINITION = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
name: __gateways_1.BORDER_MATERIAL_NAME,
|
|
24
|
+
density: Number.MAX_SAFE_INTEGER,
|
|
25
|
+
velocityDrag: 1,
|
|
26
|
+
rotationalDrag: 1
|
|
23
27
|
};
|
|
24
28
|
let MaterialsService = class MaterialsService {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
materialDefinitionsMap.set(__gateways_1.BORDER_MATERIAL_NAME, BORDER_MATERIAL_DEFINITION);
|
|
37
|
-
this.addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions, materials);
|
|
38
|
-
return { materials, materialDefinitions: materialDefinitionsMap };
|
|
29
|
+
createMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions) {
|
|
30
|
+
const materials = new Map();
|
|
31
|
+
const materialDefinitionsMap = new Map();
|
|
32
|
+
materialDefinitions.forEach(materialDefinition => {
|
|
33
|
+
materials.set(materialDefinition.name, new p2_1.default.Material());
|
|
34
|
+
materialDefinitionsMap.set(materialDefinition.name, materialDefinition);
|
|
35
|
+
});
|
|
36
|
+
if (materials.has(__gateways_1.BORDER_MATERIAL_NAME)) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Material with name ${__gateways_1.BORDER_MATERIAL_NAME} cannot be defined, pick another name for the material.`
|
|
39
|
+
);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
materials.set(__gateways_1.BORDER_MATERIAL_NAME, BORDER_MATERIAL);
|
|
42
|
+
materialDefinitionsMap.set(__gateways_1.BORDER_MATERIAL_NAME, BORDER_MATERIAL_DEFINITION);
|
|
43
|
+
this.addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions, materials);
|
|
44
|
+
return { materials, materialDefinitions: materialDefinitionsMap };
|
|
45
|
+
}
|
|
46
|
+
getMaterial(physicsWorldId, name) {
|
|
47
|
+
const physicsWorld = physics_world_entity_1.PhysicsWorldEntity.getInstanceByIdOrFail(physicsWorldId);
|
|
48
|
+
return this.getMaterialInternal(name, physicsWorld.materials);
|
|
49
|
+
}
|
|
50
|
+
getMaterialDefinition(physicsWorldId, name) {
|
|
51
|
+
const physicsWorld = physics_world_entity_1.PhysicsWorldEntity.getInstanceByIdOrFail(physicsWorldId);
|
|
52
|
+
return this.getMaterialDefinitionInternal(name, physicsWorld.materialDefinitions);
|
|
53
|
+
}
|
|
54
|
+
getMaterialInternal(name, materials) {
|
|
55
|
+
const material = materials.get(name);
|
|
56
|
+
if (!material) {
|
|
57
|
+
throw new Error(`Could not find material with name ${name}.`);
|
|
43
58
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (!material) {
|
|
51
|
-
throw new Error(`Could not find material with name ${name}.`);
|
|
52
|
-
}
|
|
53
|
-
return material;
|
|
59
|
+
return material;
|
|
60
|
+
}
|
|
61
|
+
getMaterialDefinitionInternal(name, materialDefinitions) {
|
|
62
|
+
const materialDefinition = materialDefinitions.get(name);
|
|
63
|
+
if (!materialDefinition) {
|
|
64
|
+
throw new Error(`Could not find material definition with name ${name}.`);
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
return materialDefinition;
|
|
67
|
+
}
|
|
68
|
+
addContactMaterials(p2World, borderProperties, materialDefinitions, materialContactDefinitions, materials) {
|
|
69
|
+
this.getFullListOfMaterialContactDefinitions(
|
|
70
|
+
materialDefinitions.map(definition => definition.name),
|
|
71
|
+
materialContactDefinitions
|
|
72
|
+
).forEach(contactDefinition => {
|
|
73
|
+
const materialA = this.getMaterialInternal(contactDefinition.materialA, materials);
|
|
74
|
+
const materialB = this.getMaterialInternal(contactDefinition.materialB, materials);
|
|
75
|
+
p2World.addContactMaterial(
|
|
76
|
+
new p2_1.default.ContactMaterial(materialA, materialB, {
|
|
77
|
+
friction: contactDefinition.friction,
|
|
78
|
+
restitution: contactDefinition.bounciness,
|
|
79
|
+
stiffness: contactDefinition.stiffness
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
this.addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions, materials);
|
|
84
|
+
}
|
|
85
|
+
getFullListOfMaterialContactDefinitions(materialNames, materialContactDefinitions) {
|
|
86
|
+
const definedCombinations = new Map();
|
|
87
|
+
materialContactDefinitions.forEach(contactDefinition => {
|
|
88
|
+
let materialAMap = definedCombinations.get(contactDefinition.materialA);
|
|
89
|
+
if (!materialAMap) {
|
|
90
|
+
materialAMap = new Map();
|
|
91
|
+
definedCombinations.set(contactDefinition.materialA, materialAMap);
|
|
92
|
+
}
|
|
93
|
+
materialAMap.set(contactDefinition.materialB, contactDefinition);
|
|
94
|
+
});
|
|
95
|
+
const fullList = [];
|
|
96
|
+
materialNames.forEach((materialA, index) => {
|
|
97
|
+
for (let i = index; i < materialNames.length; i++) {
|
|
98
|
+
const materialB = materialNames[i];
|
|
99
|
+
const contactDefinition = definedCombinations.get(materialA)?.get(materialB);
|
|
100
|
+
if (contactDefinition) {
|
|
101
|
+
fullList.push(contactDefinition);
|
|
102
|
+
} else {
|
|
103
|
+
fullList.push({
|
|
104
|
+
materialA,
|
|
105
|
+
materialB,
|
|
106
|
+
friction: 0,
|
|
107
|
+
bounciness: 0,
|
|
108
|
+
stiffness: 1e6 // default p2js stiffness
|
|
109
|
+
});
|
|
59
110
|
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
materialContactDefinitions.forEach(contactDefinition => {
|
|
77
|
-
let materialAMap = definedCombinations.get(contactDefinition.materialA);
|
|
78
|
-
if (!materialAMap) {
|
|
79
|
-
materialAMap = new Map();
|
|
80
|
-
definedCombinations.set(contactDefinition.materialA, materialAMap);
|
|
81
|
-
}
|
|
82
|
-
materialAMap.set(contactDefinition.materialB, contactDefinition);
|
|
83
|
-
});
|
|
84
|
-
let fullList = [];
|
|
85
|
-
materialNames.forEach((materialA, index) => {
|
|
86
|
-
for (let i = index; i < materialNames.length; i++) {
|
|
87
|
-
let materialB = materialNames[i];
|
|
88
|
-
let contactDefinition = definedCombinations.get(materialA)?.get(materialB);
|
|
89
|
-
if (contactDefinition) {
|
|
90
|
-
fullList.push(contactDefinition);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
fullList.push({
|
|
94
|
-
materialA,
|
|
95
|
-
materialB,
|
|
96
|
-
friction: 0,
|
|
97
|
-
bounciness: 0,
|
|
98
|
-
stiffness: 1e6 // default p2js stiffness
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return fullList;
|
|
104
|
-
}
|
|
105
|
-
addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions, materials) {
|
|
106
|
-
materialDefinitions.forEach(materialDefinition => {
|
|
107
|
-
let materialA = this.getMaterialInternal(materialDefinition.name, materials);
|
|
108
|
-
p2World.addContactMaterial(new p2_1.default.ContactMaterial(materialA, BORDER_MATERIAL, {
|
|
109
|
-
friction: borderProperties.friction,
|
|
110
|
-
restitution: borderProperties.bounciness,
|
|
111
|
-
stiffness: borderProperties.stiffness
|
|
112
|
-
}));
|
|
113
|
-
});
|
|
114
|
-
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return fullList;
|
|
114
|
+
}
|
|
115
|
+
addContactMaterialsWithBorder(p2World, borderProperties, materialDefinitions, materials) {
|
|
116
|
+
materialDefinitions.forEach(materialDefinition => {
|
|
117
|
+
const materialA = this.getMaterialInternal(materialDefinition.name, materials);
|
|
118
|
+
p2World.addContactMaterial(
|
|
119
|
+
new p2_1.default.ContactMaterial(materialA, BORDER_MATERIAL, {
|
|
120
|
+
friction: borderProperties.friction,
|
|
121
|
+
restitution: borderProperties.bounciness,
|
|
122
|
+
stiffness: borderProperties.stiffness
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
115
127
|
};
|
|
116
128
|
exports.MaterialsService = MaterialsService;
|
|
117
|
-
exports.MaterialsService = MaterialsService = __decorate([
|
|
118
|
-
|
|
119
|
-
], MaterialsService);
|
|
120
|
-
//# sourceMappingURL=materials.service.js.map
|
|
129
|
+
exports.MaterialsService = MaterialsService = __decorate([(0, game_entities_1.ServiceDecorator)()], MaterialsService);
|
|
130
|
+
//# sourceMappingURL=materials.service.js.map
|
|
@@ -4,12 +4,23 @@ import { AvailabilityGridService } from './availability-grid.service';
|
|
|
4
4
|
import { PathFinderResult } from '../../../utilities';
|
|
5
5
|
export declare const DEFAULT_GRID_CELL_SIZE = 50;
|
|
6
6
|
export declare class PathFinderService {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
private physicsAvailabilityGrid;
|
|
8
|
+
constructor(physicsAvailabilityGrid: AvailabilityGridService);
|
|
9
|
+
findPathAStar(
|
|
10
|
+
physicsWorldId: string,
|
|
11
|
+
startingPosition: Vector,
|
|
12
|
+
target: Vector | string,
|
|
13
|
+
options?: {
|
|
14
|
+
includeDiagonals?: boolean;
|
|
15
|
+
collidableWithGroup?: PhysicsBodyGroup;
|
|
16
|
+
gridCellSize?: number;
|
|
17
|
+
}
|
|
18
|
+
): PathFinderResult;
|
|
19
|
+
findPathDirection(
|
|
20
|
+
physicsWorldId: string,
|
|
21
|
+
startingPosition: Vector,
|
|
22
|
+
target: Vector | string,
|
|
23
|
+
collidableWithGroup: PhysicsBodyGroup,
|
|
24
|
+
gridCellSize?: number
|
|
25
|
+
): number | undefined;
|
|
15
26
|
}
|