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,102 +1,126 @@
|
|
|
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 __metadata =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
});
|
|
14
|
+
var __metadata =
|
|
15
|
+
(this && this.__metadata) ||
|
|
16
|
+
((k, v) => {
|
|
17
|
+
if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function') return Reflect.metadata(k, v);
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
20
|
exports.ElipticExplosionService = void 0;
|
|
13
|
-
const helpers_lib_1 = require(
|
|
14
|
-
const game_entities_1 = require(
|
|
15
|
-
const ray_casting_service_1 = require(
|
|
16
|
-
const debug_visuals_service_1 = require(
|
|
17
|
-
const physics_world_entity_1 = require(
|
|
18
|
-
const ray_cast_hit_converter_1 = require(
|
|
19
|
-
const p2js_helper_1 = require(
|
|
21
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
22
|
+
const game_entities_1 = require('../../../game-entities');
|
|
23
|
+
const ray_casting_service_1 = require('./ray-casting.service');
|
|
24
|
+
const debug_visuals_service_1 = require('./debug-visuals.service');
|
|
25
|
+
const physics_world_entity_1 = require('../\uD83E\uDDCAentities/physics-world.entity');
|
|
26
|
+
const ray_cast_hit_converter_1 = require('./helpers/ray-cast-hit-converter');
|
|
27
|
+
const p2js_helper_1 = require('../../libs/p2js.helper');
|
|
20
28
|
const MIN_GAP_BETWEEN_LINES = 15;
|
|
21
29
|
let ElipticExplosionService = class ElipticExplosionService {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
constructor(rayCastingService, debugVisualsService) {
|
|
31
|
+
this.rayCastingService = rayCastingService;
|
|
32
|
+
this.debugVisualsService = debugVisualsService;
|
|
33
|
+
}
|
|
34
|
+
createElipticExplosion(physicsWorldId, explosionCenter, rotation, size, physicsBodyGroup, severity, options) {
|
|
35
|
+
const physicsWorld = physics_world_entity_1.PhysicsWorldEntity.getInstanceByIdOrFail(physicsWorldId);
|
|
36
|
+
const rayCasts = this.createRays(
|
|
37
|
+
explosionCenter,
|
|
38
|
+
rotation,
|
|
39
|
+
size,
|
|
40
|
+
physicsBodyGroup,
|
|
41
|
+
options?.hitOnlyClosest === true,
|
|
42
|
+
physicsWorld
|
|
43
|
+
);
|
|
44
|
+
const explosionHitWithP2Bodies = ray_cast_hit_converter_1.RayCastHitConverter.toExplosionHits(rayCasts, false);
|
|
45
|
+
this.applyForcesToBodies(explosionHitWithP2Bodies, severity);
|
|
46
|
+
if (options?.testLayerId) {
|
|
47
|
+
this.debugVisualsService.createElipticExplosionDebugVisual(
|
|
48
|
+
physicsWorld,
|
|
49
|
+
options.testLayerId,
|
|
50
|
+
rayCasts,
|
|
51
|
+
explosionCenter,
|
|
52
|
+
rotation,
|
|
53
|
+
size,
|
|
54
|
+
options.debugRayDuration
|
|
55
|
+
);
|
|
25
56
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
57
|
+
return explosionHitWithP2Bodies.map(explosionHitWithP2Body => {
|
|
58
|
+
const { p2Body, ...explosionHit } = explosionHitWithP2Body;
|
|
59
|
+
return explosionHit;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
createRays(explosionCenter, rotation, size, physicsBodyGroup, hitOnlyClosest, physicsWorld) {
|
|
63
|
+
const lines = [];
|
|
64
|
+
const centerDirection = helpers_lib_1.Radian.toVector(rotation);
|
|
65
|
+
const lineDirection = helpers_lib_1.Radian.toVector(rotation + helpers_lib_1.Radian.get90);
|
|
66
|
+
const horizontalVector = lineDirection.normalize(size.x);
|
|
67
|
+
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(horizontalVector)));
|
|
68
|
+
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(horizontalVector.multiply(-1))));
|
|
69
|
+
const verticalVector = centerDirection.normalize(size.y);
|
|
70
|
+
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(verticalVector)));
|
|
71
|
+
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(verticalVector.multiply(-1))));
|
|
72
|
+
const lineCount = Math.round(size.y / MIN_GAP_BETWEEN_LINES);
|
|
73
|
+
const gap = (size.y / (lineCount * 2 + 1)) * 2;
|
|
74
|
+
const gapVector = centerDirection.normalize(gap);
|
|
75
|
+
const width = size.x;
|
|
76
|
+
const heightSquared = size.y ** 2;
|
|
77
|
+
helpers_lib_1.ArrayHelper.createIntegerArray(lineCount).forEach(index => {
|
|
78
|
+
const distanceFromCenter = gap * (index + 1);
|
|
79
|
+
const distanceFromCenterVector = gapVector.multiply(index + 1);
|
|
80
|
+
const vector = lineDirection.normalize(this.getWidthOfLine(width, heightSquared, distanceFromCenter));
|
|
81
|
+
const center1 = explosionCenter.add(distanceFromCenterVector);
|
|
82
|
+
lines.push(new helpers_lib_1.Line(center1, center1.add(vector)));
|
|
83
|
+
lines.push(new helpers_lib_1.Line(center1, center1.add(vector.multiply(-1))));
|
|
84
|
+
const center2 = explosionCenter.add(distanceFromCenterVector.multiply(-1));
|
|
85
|
+
lines.push(new helpers_lib_1.Line(center2, center2.add(vector)));
|
|
86
|
+
lines.push(new helpers_lib_1.Line(center2, center2.add(vector.multiply(-1))));
|
|
87
|
+
});
|
|
88
|
+
return lines.map(line => {
|
|
89
|
+
if (hitOnlyClosest) {
|
|
90
|
+
const hit = this.rayCastingService.castClosest(physicsWorld, line, physicsBodyGroup);
|
|
91
|
+
return { line, hits: hit ? [hit] : [] };
|
|
92
|
+
} else {
|
|
93
|
+
const hits = this.rayCastingService.castAllFirstContacts(physicsWorld, line, physicsBodyGroup);
|
|
94
|
+
return { line, hits };
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
getWidthOfLine(width, heightSquared, distanceFromCenter) {
|
|
99
|
+
return Math.sqrt(1 - distanceFromCenter ** 2 / heightSquared) * width;
|
|
100
|
+
}
|
|
101
|
+
applyForcesToBodies(explosionHits, severity) {
|
|
102
|
+
explosionHits.forEach(explosionHit => {
|
|
103
|
+
explosionHit.raycastResults.forEach(rayCastResult => {
|
|
104
|
+
let hitDirection;
|
|
105
|
+
let force;
|
|
106
|
+
if (rayCastResult.isExternal()) {
|
|
107
|
+
hitDirection = rayCastResult.line.fromTo;
|
|
108
|
+
force = severity * 2;
|
|
109
|
+
} else {
|
|
110
|
+
hitDirection = rayCastResult.line.fromTo.multiply(-1);
|
|
111
|
+
force = severity * (1 - rayCastResult.fraction) * 8;
|
|
33
112
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
createRays(explosionCenter, rotation, size, physicsBodyGroup, hitOnlyClosest, physicsWorld) {
|
|
40
|
-
let lines = [];
|
|
41
|
-
let centerDirection = helpers_lib_1.Radian.toVector(rotation);
|
|
42
|
-
let lineDirection = helpers_lib_1.Radian.toVector(rotation + helpers_lib_1.Radian.get90);
|
|
43
|
-
let horizontalVector = lineDirection.normalize(size.x);
|
|
44
|
-
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(horizontalVector)));
|
|
45
|
-
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(horizontalVector.multiply(-1))));
|
|
46
|
-
let verticalVector = centerDirection.normalize(size.y);
|
|
47
|
-
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(verticalVector)));
|
|
48
|
-
lines.push(new helpers_lib_1.Line(explosionCenter, explosionCenter.add(verticalVector.multiply(-1))));
|
|
49
|
-
let lineCount = Math.round(size.y / MIN_GAP_BETWEEN_LINES);
|
|
50
|
-
let gap = (size.y / (lineCount * 2 + 1)) * 2;
|
|
51
|
-
let gapVector = centerDirection.normalize(gap);
|
|
52
|
-
let width = size.x;
|
|
53
|
-
let heightSquared = Math.pow(size.y, 2);
|
|
54
|
-
helpers_lib_1.ArrayHelper.createIntegerArray(lineCount).forEach(index => {
|
|
55
|
-
let distanceFromCenter = gap * (index + 1);
|
|
56
|
-
let distanceFromCenterVector = gapVector.multiply(index + 1);
|
|
57
|
-
let vector = lineDirection.normalize(this.getWidthOfLine(width, heightSquared, distanceFromCenter));
|
|
58
|
-
let center1 = explosionCenter.add(distanceFromCenterVector);
|
|
59
|
-
lines.push(new helpers_lib_1.Line(center1, center1.add(vector)));
|
|
60
|
-
lines.push(new helpers_lib_1.Line(center1, center1.add(vector.multiply(-1))));
|
|
61
|
-
let center2 = explosionCenter.add(distanceFromCenterVector.multiply(-1));
|
|
62
|
-
lines.push(new helpers_lib_1.Line(center2, center2.add(vector)));
|
|
63
|
-
lines.push(new helpers_lib_1.Line(center2, center2.add(vector.multiply(-1))));
|
|
64
|
-
});
|
|
65
|
-
return lines.map(line => {
|
|
66
|
-
if (hitOnlyClosest) {
|
|
67
|
-
let hit = this.rayCastingService.castClosest(physicsWorld, line, physicsBodyGroup);
|
|
68
|
-
return { line, hits: hit ? [hit] : [] };
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
let hits = this.rayCastingService.castAllFirstContacts(physicsWorld, line, physicsBodyGroup);
|
|
72
|
-
return { line, hits };
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
getWidthOfLine(width, heightSquared, distanceFromCenter) {
|
|
77
|
-
return Math.sqrt(1 - Math.pow(distanceFromCenter, 2) / heightSquared) * width;
|
|
78
|
-
}
|
|
79
|
-
applyForcesToBodies(explosionHits, severity) {
|
|
80
|
-
explosionHits.forEach(explosionHit => {
|
|
81
|
-
explosionHit.raycastResults.forEach(rayCastResult => {
|
|
82
|
-
let hitDirection;
|
|
83
|
-
let force;
|
|
84
|
-
if (rayCastResult.isExternal()) {
|
|
85
|
-
hitDirection = rayCastResult.line.fromTo;
|
|
86
|
-
force = severity * 2;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
hitDirection = rayCastResult.line.fromTo.multiply(-1);
|
|
90
|
-
force = severity * (1 - rayCastResult.fraction) * 8;
|
|
91
|
-
}
|
|
92
|
-
p2js_helper_1.P2JSHelper.pushBody(rayCastResult.body, rayCastResult.hitPosition(), hitDirection, force);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
113
|
+
p2js_helper_1.P2JSHelper.pushBody(rayCastResult.body, rayCastResult.hitPosition(), hitDirection, force);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
96
117
|
};
|
|
97
118
|
exports.ElipticExplosionService = ElipticExplosionService;
|
|
98
|
-
exports.ElipticExplosionService = ElipticExplosionService = __decorate(
|
|
119
|
+
exports.ElipticExplosionService = ElipticExplosionService = __decorate(
|
|
120
|
+
[
|
|
99
121
|
(0, game_entities_1.ServiceDecorator)(),
|
|
100
|
-
__metadata(
|
|
101
|
-
],
|
|
102
|
-
|
|
122
|
+
__metadata('design:paramtypes', [ray_casting_service_1.RayCastingService, debug_visuals_service_1.DebugVisualsService])
|
|
123
|
+
],
|
|
124
|
+
ElipticExplosionService
|
|
125
|
+
);
|
|
126
|
+
//# sourceMappingURL=eliptic-explosion.service.js.map
|
|
@@ -4,11 +4,18 @@ import { PhysicsBodyGroup } from '../../libs/physics-body-groups';
|
|
|
4
4
|
import { DebugVisualsService } from './debug-visuals.service';
|
|
5
5
|
import { RayCastingService } from './ray-casting.service';
|
|
6
6
|
export declare class ExplosionService {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
private rayCastingService;
|
|
8
|
+
private debugVisualsService;
|
|
9
|
+
constructor(rayCastingService: RayCastingService, debugVisualsService: DebugVisualsService);
|
|
10
|
+
createExplosion(
|
|
11
|
+
physicsWorldId: string,
|
|
12
|
+
explosionCenter: Vector,
|
|
13
|
+
radius: number,
|
|
14
|
+
physicsBodyGroup: PhysicsBodyGroup,
|
|
15
|
+
severity: number,
|
|
16
|
+
options?: PhysicsExplosionOptions
|
|
17
|
+
): ExplosionHit[];
|
|
18
|
+
private createRays;
|
|
19
|
+
private applyForcesToBodies;
|
|
20
|
+
private getTotalCountOfRays;
|
|
14
21
|
}
|
|
@@ -1,87 +1,112 @@
|
|
|
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 __metadata =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
});
|
|
14
|
+
var __metadata =
|
|
15
|
+
(this && this.__metadata) ||
|
|
16
|
+
((k, v) => {
|
|
17
|
+
if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function') return Reflect.metadata(k, v);
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
20
|
exports.ExplosionService = void 0;
|
|
13
|
-
const helpers_lib_1 = require(
|
|
14
|
-
const game_entities_1 = require(
|
|
15
|
-
const physics_world_entity_1 = require(
|
|
16
|
-
const p2js_helper_1 = require(
|
|
17
|
-
const ray_cast_hit_converter_1 = require(
|
|
18
|
-
const debug_visuals_service_1 = require(
|
|
19
|
-
const ray_casting_service_1 = require(
|
|
21
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
22
|
+
const game_entities_1 = require('../../../game-entities');
|
|
23
|
+
const physics_world_entity_1 = require('../\uD83E\uDDCAentities/physics-world.entity');
|
|
24
|
+
const p2js_helper_1 = require('../../libs/p2js.helper');
|
|
25
|
+
const ray_cast_hit_converter_1 = require('./helpers/ray-cast-hit-converter');
|
|
26
|
+
const debug_visuals_service_1 = require('./debug-visuals.service');
|
|
27
|
+
const ray_casting_service_1 = require('./ray-casting.service');
|
|
20
28
|
let ExplosionService = class ExplosionService {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
constructor(rayCastingService, debugVisualsService) {
|
|
30
|
+
this.rayCastingService = rayCastingService;
|
|
31
|
+
this.debugVisualsService = debugVisualsService;
|
|
32
|
+
}
|
|
33
|
+
createExplosion(physicsWorldId, explosionCenter, radius, physicsBodyGroup, severity, options) {
|
|
34
|
+
const physicsWorld = physics_world_entity_1.PhysicsWorldEntity.getInstanceByIdOrFail(physicsWorldId);
|
|
35
|
+
const totalCountOfRays = this.getTotalCountOfRays(radius);
|
|
36
|
+
const rayCasts = this.createRays(
|
|
37
|
+
explosionCenter,
|
|
38
|
+
radius,
|
|
39
|
+
physicsBodyGroup,
|
|
40
|
+
totalCountOfRays,
|
|
41
|
+
options?.hitOnlyClosest === true,
|
|
42
|
+
physicsWorld
|
|
43
|
+
);
|
|
44
|
+
const explosionHits = ray_cast_hit_converter_1.RayCastHitConverter.toExplosionHits(rayCasts);
|
|
45
|
+
this.applyForcesToBodies(explosionCenter, radius, severity, totalCountOfRays, explosionHits);
|
|
46
|
+
if (options?.testLayerId) {
|
|
47
|
+
this.debugVisualsService.createExplosionDebugVisual(
|
|
48
|
+
physicsWorld,
|
|
49
|
+
options.testLayerId,
|
|
50
|
+
rayCasts,
|
|
51
|
+
explosionCenter,
|
|
52
|
+
radius,
|
|
53
|
+
options.debugRayDuration
|
|
54
|
+
);
|
|
24
55
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
return explosionHits;
|
|
57
|
+
}
|
|
58
|
+
createRays(explosionCenter, radius, physicsBodyGroup, totalCountOfRays, hitOnlyClosest, physicsWorld) {
|
|
59
|
+
const radianPerLine = helpers_lib_1.Radian.get360 / totalCountOfRays;
|
|
60
|
+
let directionVector = new helpers_lib_1.Vector(0, -radius);
|
|
61
|
+
const rotationVector = helpers_lib_1.Radian.toVector(radianPerLine);
|
|
62
|
+
return helpers_lib_1.ArrayHelper.createEmptyArray(totalCountOfRays)
|
|
63
|
+
.map(() => {
|
|
64
|
+
const to = explosionCenter.add(directionVector);
|
|
65
|
+
directionVector = directionVector.rotate(rotationVector);
|
|
66
|
+
return new helpers_lib_1.Line(explosionCenter, to);
|
|
67
|
+
})
|
|
68
|
+
.map(line => {
|
|
69
|
+
if (hitOnlyClosest) {
|
|
70
|
+
const hit = this.rayCastingService.castClosest(physicsWorld, line, physicsBodyGroup);
|
|
71
|
+
return { line, hits: hit ? [hit] : [] };
|
|
72
|
+
} else {
|
|
73
|
+
const hits = this.rayCastingService.castAllFirstContacts(physicsWorld, line, physicsBodyGroup);
|
|
74
|
+
return { line, hits };
|
|
33
75
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let to = explosionCenter.add(directionVector);
|
|
43
|
-
directionVector = directionVector.rotate(rotationVector);
|
|
44
|
-
return new helpers_lib_1.Line(explosionCenter, to);
|
|
45
|
-
})
|
|
46
|
-
.map(line => {
|
|
47
|
-
if (hitOnlyClosest) {
|
|
48
|
-
let hit = this.rayCastingService.castClosest(physicsWorld, line, physicsBodyGroup);
|
|
49
|
-
return { line, hits: hit ? [hit] : [] };
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
let hits = this.rayCastingService.castAllFirstContacts(physicsWorld, line, physicsBodyGroup);
|
|
53
|
-
return { line, hits };
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
applyForcesToBodies(explosionCenter, radius, severity, totalCountOfRays, explosionHits) {
|
|
58
|
-
explosionHits.forEach(explosionHit => {
|
|
59
|
-
if (explosionHit.isExternal) {
|
|
60
|
-
explosionHit.raycastResults.forEach(rayCastResult => {
|
|
61
|
-
let force = severity * (1 - rayCastResult.fraction);
|
|
62
|
-
p2js_helper_1.P2JSHelper.pushBody(rayCastResult.body, rayCastResult.hitPosition(), rayCastResult.line.fromTo, force);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
let vectorToCenter = helpers_lib_1.Vector.fromTo(explosionCenter, p2js_helper_1.P2JSHelper.arrayToVector(explosionHit.p2Body.position));
|
|
67
|
-
let fractionToCenter = vectorToCenter.length / radius;
|
|
68
|
-
let force = (severity * totalCountOfRays * fractionToCenter) / 2;
|
|
69
|
-
p2js_helper_1.P2JSHelper.pushBody(explosionHit.p2Body, explosionHit.getHitPosition(), vectorToCenter, force);
|
|
70
|
-
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
applyForcesToBodies(explosionCenter, radius, severity, totalCountOfRays, explosionHits) {
|
|
79
|
+
explosionHits.forEach(explosionHit => {
|
|
80
|
+
if (explosionHit.isExternal) {
|
|
81
|
+
explosionHit.raycastResults.forEach(rayCastResult => {
|
|
82
|
+
const force = severity * (1 - rayCastResult.fraction);
|
|
83
|
+
p2js_helper_1.P2JSHelper.pushBody(rayCastResult.body, rayCastResult.hitPosition(), rayCastResult.line.fromTo, force);
|
|
71
84
|
});
|
|
85
|
+
} else {
|
|
86
|
+
const vectorToCenter = helpers_lib_1.Vector.fromTo(
|
|
87
|
+
explosionCenter,
|
|
88
|
+
p2js_helper_1.P2JSHelper.arrayToVector(explosionHit.p2Body.position)
|
|
89
|
+
);
|
|
90
|
+
const fractionToCenter = vectorToCenter.length / radius;
|
|
91
|
+
const force = (severity * totalCountOfRays * fractionToCenter) / 2;
|
|
92
|
+
p2js_helper_1.P2JSHelper.pushBody(explosionHit.p2Body, explosionHit.getHitPosition(), vectorToCenter, force);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getTotalCountOfRays(radius) {
|
|
97
|
+
if (radius > 100) {
|
|
98
|
+
return Math.floor(radius * 0.3);
|
|
99
|
+
} else {
|
|
100
|
+
return Math.floor(radius * 0.26 + 4);
|
|
72
101
|
}
|
|
73
|
-
|
|
74
|
-
if (radius > 100) {
|
|
75
|
-
return Math.floor(radius * 0.3);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
return Math.floor(radius * 0.26 + 4);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
102
|
+
}
|
|
81
103
|
};
|
|
82
104
|
exports.ExplosionService = ExplosionService;
|
|
83
|
-
exports.ExplosionService = ExplosionService = __decorate(
|
|
105
|
+
exports.ExplosionService = ExplosionService = __decorate(
|
|
106
|
+
[
|
|
84
107
|
(0, game_entities_1.ServiceDecorator)(),
|
|
85
|
-
__metadata(
|
|
86
|
-
],
|
|
87
|
-
|
|
108
|
+
__metadata('design:paramtypes', [ray_casting_service_1.RayCastingService, debug_visuals_service_1.DebugVisualsService])
|
|
109
|
+
],
|
|
110
|
+
ExplosionService
|
|
111
|
+
);
|
|
112
|
+
//# sourceMappingURL=explosion.service.js.map
|
package/dist/physics/module//360/237/223/220services/explosions/eliptic-explosion.service.d.ts
CHANGED
|
@@ -4,11 +4,19 @@ import { ExplosionHit, PhysicsExplosionOptions } from '../../⚜️gateways';
|
|
|
4
4
|
import { RayCastingService } from '../ray-casting/ray-casting.service';
|
|
5
5
|
import { TestVisualsService } from '../test-visuals/test-visuals.service';
|
|
6
6
|
export declare class ElipticExplosionService {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
private rayCastingService;
|
|
8
|
+
private testVisualsService;
|
|
9
|
+
constructor(rayCastingService: RayCastingService, testVisualsService: TestVisualsService);
|
|
10
|
+
createElipticExplosion(
|
|
11
|
+
physicsWorldId: string,
|
|
12
|
+
explosionCenter: Vector,
|
|
13
|
+
rotation: Radian,
|
|
14
|
+
size: Vector,
|
|
15
|
+
physicsBodyGroup: PhysicsBodyGroup,
|
|
16
|
+
severity: number,
|
|
17
|
+
options?: PhysicsExplosionOptions
|
|
18
|
+
): ExplosionHit[];
|
|
19
|
+
private createRays;
|
|
20
|
+
private getWidthOfLine;
|
|
21
|
+
private applyForcesToBodies;
|
|
14
22
|
}
|