bard-legends-framework 0.9.5 → 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.js +1 -1
- 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 +6 -12
|
@@ -1,144 +1,153 @@
|
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports,
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || (mod => (mod && mod.__esModule ? mod : { default: mod }));
|
|
20
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
15
21
|
exports.PhysicsWorld = void 0;
|
|
16
|
-
const helpers_lib_1 = require(
|
|
17
|
-
const actions_lib_1 = require(
|
|
18
|
-
const p2_1 = __importDefault(require(
|
|
19
|
-
const physics_materials_1 = require(
|
|
20
|
-
const physics_collision_1 = require(
|
|
21
|
-
const interfaces_1 = require(
|
|
22
|
-
const game_entities_1 = require(
|
|
23
|
-
const physics_availability_grid_1 = require(
|
|
24
|
-
const physics_available_spaces_1 = require(
|
|
25
|
-
const physics_body_groups_1 = require(
|
|
26
|
-
const physics_explosion_1 = require(
|
|
27
|
-
const immovable_physics_entity_1 = require(
|
|
22
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
23
|
+
const actions_lib_1 = require('actions-lib');
|
|
24
|
+
const p2_1 = __importDefault(require('p2'));
|
|
25
|
+
const physics_materials_1 = require('./sub-elements/elements/physics-materials');
|
|
26
|
+
const physics_collision_1 = require('./sub-elements/collisions/physics-collision');
|
|
27
|
+
const interfaces_1 = require('./interfaces');
|
|
28
|
+
const game_entities_1 = require('../game-entities');
|
|
29
|
+
const physics_availability_grid_1 = require('./sub-elements/available-spaces/physics-availability-grid');
|
|
30
|
+
const physics_available_spaces_1 = require('./sub-elements/available-spaces/physics-available-spaces');
|
|
31
|
+
const physics_body_groups_1 = require('./sub-elements/elements/physics-body-groups');
|
|
32
|
+
const physics_explosion_1 = require('./sub-elements/raycasting/physics-explosion');
|
|
33
|
+
const immovable_physics_entity_1 = require('./entitity-types/immovable-physics-entity');
|
|
28
34
|
let PhysicsWorld = class PhysicsWorld extends game_entities_1.Entity {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
35
|
+
constructor(mapSize, borderProperties, materialDefinitions, materialContactDefinitions, modifyUpdateCycle = true) {
|
|
36
|
+
super();
|
|
37
|
+
this.onPhysicsStep = new actions_lib_1.Action();
|
|
38
|
+
this.lastP2Time = 0;
|
|
39
|
+
this.mapSize = mapSize;
|
|
40
|
+
this.mapSizeCenter = this.mapSize.multiply(0.5);
|
|
41
|
+
this.modifyUpdateCycle = modifyUpdateCycle;
|
|
42
|
+
this.p2World = new p2_1.default.World({ gravity: [0, 0] });
|
|
43
|
+
this.physicsMaterials = new physics_materials_1.PhysicsMaterials(
|
|
44
|
+
this.p2World,
|
|
45
|
+
borderProperties,
|
|
46
|
+
materialDefinitions,
|
|
47
|
+
materialContactDefinitions
|
|
48
|
+
);
|
|
49
|
+
this.physicsCollision = new physics_collision_1.PhysicsCollision(this.p2World);
|
|
50
|
+
this.physicsAvailabilityGrid = new physics_availability_grid_1.PhysicsAvailabilityGrid(this.p2World, mapSize);
|
|
51
|
+
this.physicsAvailableSpaces = new physics_available_spaces_1.PhysicsAvailableSpaces(this.physicsAvailabilityGrid);
|
|
52
|
+
this.createBorders(this, mapSize);
|
|
53
|
+
if (modifyUpdateCycle) {
|
|
54
|
+
game_entities_1.UpdateCycle.registerUpdateModifier((time, delta) => this.step(time, delta));
|
|
55
|
+
} else {
|
|
56
|
+
game_entities_1.UpdateCycle.beforeSceneUpdateAction
|
|
57
|
+
.subscribe(({ time, delta }) => {
|
|
58
|
+
this.step(time, delta);
|
|
59
|
+
})
|
|
60
|
+
.attach(this);
|
|
52
61
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
let time = previousTime + delta;
|
|
61
|
-
this.physicsCollision.update(time, delta);
|
|
62
|
-
this.onPhysicsStep.trigger({ time, delta });
|
|
63
|
-
this.lastP2Time = this.p2World.time;
|
|
64
|
-
return delta;
|
|
62
|
+
}
|
|
63
|
+
step(previousTime, delta) {
|
|
64
|
+
this.physicsAvailabilityGrid.clear();
|
|
65
|
+
this.physicsAvailableSpaces.clear();
|
|
66
|
+
this.p2World.step(1, delta, 100);
|
|
67
|
+
if (this.modifyUpdateCycle) {
|
|
68
|
+
delta = this.p2World.time - this.lastP2Time;
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const time = previousTime + delta;
|
|
71
|
+
this.physicsCollision.update(time, delta);
|
|
72
|
+
this.onPhysicsStep.trigger({ time, delta });
|
|
73
|
+
this.lastP2Time = this.p2World.time;
|
|
74
|
+
return delta;
|
|
75
|
+
}
|
|
76
|
+
destroy() {
|
|
77
|
+
this.p2World.clear();
|
|
78
|
+
if (this.modifyUpdateCycle) {
|
|
79
|
+
game_entities_1.UpdateCycle.cleanUpdateModifier();
|
|
71
80
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.p2World.addBody(body);
|
|
90
|
-
return true;
|
|
81
|
+
}
|
|
82
|
+
addBody(body, addInEmptySpace, physicsBodyGroup, includeOnPathfinding) {
|
|
83
|
+
if (addInEmptySpace) {
|
|
84
|
+
const changeVector = this.physicsAvailableSpaces.findClosestAvailableSpace(body, physicsBodyGroup);
|
|
85
|
+
if (changeVector) {
|
|
86
|
+
body.position[0] += changeVector.x;
|
|
87
|
+
body.position[1] += changeVector.y;
|
|
88
|
+
this.p2World.addBody(body);
|
|
89
|
+
if (includeOnPathfinding) {
|
|
90
|
+
this.physicsAvailabilityGrid.onBodyAdded(body, physicsBodyGroup);
|
|
91
91
|
}
|
|
92
|
+
return true;
|
|
93
|
+
} else {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
this.p2World.addBody(body);
|
|
98
|
+
return true;
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
100
|
+
}
|
|
101
|
+
removeBody(body) {
|
|
102
|
+
this.p2World.removeBody(body);
|
|
103
|
+
}
|
|
104
|
+
isCollidingWithAnything(p2Body) {
|
|
105
|
+
return this.physicsCollision.isCollidingWithAnything(p2Body);
|
|
106
|
+
}
|
|
107
|
+
getAvailabilityGrid(physicsBodyGroup) {
|
|
108
|
+
return this.physicsAvailableSpaces.getAvailabilityGrid(physicsBodyGroup);
|
|
109
|
+
}
|
|
110
|
+
findPath(startingPosition, target, options) {
|
|
111
|
+
return this.physicsAvailableSpaces.findPathAStar(startingPosition, target, options);
|
|
112
|
+
}
|
|
113
|
+
findPathDirection(startingPosition, target, collidableWithGroup) {
|
|
114
|
+
return this.physicsAvailableSpaces.findPathDirection(startingPosition, target, collidableWithGroup);
|
|
115
|
+
}
|
|
116
|
+
createExplosion(position, radius, physicsBodyGroup, severity, options) {
|
|
117
|
+
return physics_explosion_1.PhysicsExplosion.createExplosion(position, radius, physicsBodyGroup, severity, this, options);
|
|
118
|
+
}
|
|
119
|
+
createBorders(physicsWorld, mapSize) {
|
|
120
|
+
let BorderEntity = class BorderEntity extends immovable_physics_entity_1.ImmovablePhysicsEntity {
|
|
121
|
+
constructor(physicsEntityDefinition) {
|
|
122
|
+
super(physicsWorld, physicsEntityDefinition);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
BorderEntity = __decorate([(0, game_entities_1.EntityDecorator)(), __metadata('design:paramtypes', [Object])], BorderEntity);
|
|
126
|
+
const createBorder = (position, size) =>
|
|
127
|
+
new BorderEntity({
|
|
128
|
+
shapeDefinition: {
|
|
129
|
+
materialName: interfaces_1.BorderMaterialName,
|
|
130
|
+
group: physics_body_groups_1.PhysicsBodyGroup.border,
|
|
131
|
+
shapeType: interfaces_1.PhysicsShapeType.rectangle,
|
|
132
|
+
shapeData: { size }
|
|
133
|
+
},
|
|
134
|
+
position,
|
|
135
|
+
rotation: 0,
|
|
136
|
+
addInEmptySpace: false,
|
|
137
|
+
includeOnPathfinding: true
|
|
138
|
+
}).attach(physicsWorld);
|
|
139
|
+
createBorder(new helpers_lib_1.Vector(mapSize.x / 2, -50), new helpers_lib_1.Vector(mapSize.x + 200, 100)); // Top border
|
|
140
|
+
createBorder(new helpers_lib_1.Vector(mapSize.x / 2, mapSize.y + 50), new helpers_lib_1.Vector(mapSize.x + 200, 100)); // Bottom border
|
|
141
|
+
createBorder(new helpers_lib_1.Vector(-50, mapSize.y / 2), new helpers_lib_1.Vector(100, mapSize.y + 200)); // Left border
|
|
142
|
+
createBorder(new helpers_lib_1.Vector(mapSize.x + 50, mapSize.y / 2), new helpers_lib_1.Vector(100, mapSize.y + 200)); // Right border
|
|
143
|
+
}
|
|
138
144
|
};
|
|
139
145
|
exports.PhysicsWorld = PhysicsWorld;
|
|
140
|
-
exports.PhysicsWorld = PhysicsWorld = __decorate(
|
|
146
|
+
exports.PhysicsWorld = PhysicsWorld = __decorate(
|
|
147
|
+
[
|
|
141
148
|
(0, game_entities_1.EntityDecorator)(),
|
|
142
|
-
__metadata(
|
|
143
|
-
],
|
|
144
|
-
|
|
149
|
+
__metadata('design:paramtypes', [helpers_lib_1.Vector, Object, Array, Array, Boolean])
|
|
150
|
+
],
|
|
151
|
+
PhysicsWorld
|
|
152
|
+
);
|
|
153
|
+
//# sourceMappingURL=physics-world.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Rectangle, Vector } from 'helpers-lib';
|
|
2
2
|
export declare class AvailabilityGridHelper {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
static areaToGridArea(boundingBox: Rectangle, cellSize: number): Rectangle;
|
|
4
|
+
static positionToGridPosition(point: Vector, cellSize: number): Vector;
|
|
5
|
+
static gridPositionToPosition(gridPosition: Vector, cellSize: number): Vector;
|
|
6
6
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.AvailabilityGridHelper = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
5
4
|
class AvailabilityGridHelper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
static areaToGridArea(boundingBox, cellSize) {
|
|
6
|
+
return new helpers_lib_1.Rectangle(
|
|
7
|
+
AvailabilityGridHelper.positionToGridPosition(boundingBox.topLeft, cellSize),
|
|
8
|
+
AvailabilityGridHelper.positionToGridPosition(boundingBox.bottomRight, cellSize)
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
static positionToGridPosition(point, cellSize) {
|
|
12
|
+
return point.divide(cellSize).floor();
|
|
13
|
+
}
|
|
14
|
+
static gridPositionToPosition(gridPosition, cellSize) {
|
|
15
|
+
return gridPosition.add(new helpers_lib_1.Vector(0.5, 0.5)).multiply(cellSize);
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
exports.AvailabilityGridHelper = AvailabilityGridHelper;
|
|
17
|
-
//# sourceMappingURL=availability-grid.helper.js.map
|
|
19
|
+
//# sourceMappingURL=availability-grid.helper.js.map
|
|
@@ -3,13 +3,13 @@ import { Vector } from 'helpers-lib';
|
|
|
3
3
|
import { Grid } from '../../../utilities/libraries/data-structures/grid/grid';
|
|
4
4
|
import { PhysicsBodyGroup } from '../elements/physics-body-groups';
|
|
5
5
|
export declare class PhysicsAvailabilityGrid {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
private p2World;
|
|
7
|
+
private mapSize;
|
|
8
|
+
private availabilityGrids;
|
|
9
|
+
constructor(p2World: p2.World, mapsize: Vector);
|
|
10
|
+
clear(): void;
|
|
11
|
+
onBodyAdded(body: p2.Body, physicsBodyGroup: PhysicsBodyGroup): void;
|
|
12
|
+
getAvilabilityGrid(cellSize: number, physicsBodyGroup?: PhysicsBodyGroup): Grid<boolean>;
|
|
13
|
+
private createGrid;
|
|
14
|
+
private getGridSpaceBoundingBox;
|
|
15
15
|
}
|
|
@@ -1,87 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
2
|
exports.PhysicsAvailabilityGrid = void 0;
|
|
4
|
-
const helpers_lib_1 = require(
|
|
5
|
-
const grid_1 = require(
|
|
6
|
-
const p2js_helper_1 = require(
|
|
7
|
-
const physics_body_groups_1 = require(
|
|
8
|
-
const physics_entity_1 = require(
|
|
9
|
-
const availability_grid_helper_1 = require(
|
|
3
|
+
const helpers_lib_1 = require('helpers-lib');
|
|
4
|
+
const grid_1 = require('../../../utilities/libraries/data-structures/grid/grid');
|
|
5
|
+
const p2js_helper_1 = require('../../helpers/p2js.helper');
|
|
6
|
+
const physics_body_groups_1 = require('../elements/physics-body-groups');
|
|
7
|
+
const physics_entity_1 = require('../../entitity-types/physics-entity');
|
|
8
|
+
const availability_grid_helper_1 = require('./helpers/availability-grid.helper');
|
|
10
9
|
class AvailabilityGridCache {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
constructor() {
|
|
11
|
+
this.grids = new Map();
|
|
12
|
+
}
|
|
13
|
+
get(cellSize, group) {
|
|
14
|
+
const cellSizeMap = this.grids.get(cellSize);
|
|
15
|
+
if (!cellSizeMap) {
|
|
16
|
+
return undefined;
|
|
13
17
|
}
|
|
14
|
-
get(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
return cellSizeMap.get(group);
|
|
19
|
+
}
|
|
20
|
+
getCollidableGrids(physicsBodyGroup) {
|
|
21
|
+
const results = [];
|
|
22
|
+
this.grids.forEach((cellSizeMap, cellSize) => {
|
|
23
|
+
cellSizeMap.forEach((grid, gridPhysicsBodyGroup) => {
|
|
24
|
+
if (physics_body_groups_1.PhysicsBodyGroups.canCollide(gridPhysicsBodyGroup, physicsBodyGroup)) {
|
|
25
|
+
results.push({ grid, cellSize });
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return results;
|
|
31
|
-
}
|
|
32
|
-
set(cellSize, group, grid) {
|
|
33
|
-
let cellSizeMap = this.grids.get(cellSize);
|
|
34
|
-
if (!cellSizeMap) {
|
|
35
|
-
cellSizeMap = new Map();
|
|
36
|
-
this.grids.set(cellSize, cellSizeMap);
|
|
37
|
-
}
|
|
38
|
-
cellSizeMap.set(group, grid);
|
|
39
|
-
}
|
|
40
|
-
clear() {
|
|
41
|
-
this.grids.clear();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return results;
|
|
30
|
+
}
|
|
31
|
+
set(cellSize, group, grid) {
|
|
32
|
+
let cellSizeMap = this.grids.get(cellSize);
|
|
33
|
+
if (!cellSizeMap) {
|
|
34
|
+
cellSizeMap = new Map();
|
|
35
|
+
this.grids.set(cellSize, cellSizeMap);
|
|
42
36
|
}
|
|
37
|
+
cellSizeMap.set(group, grid);
|
|
38
|
+
}
|
|
39
|
+
clear() {
|
|
40
|
+
this.grids.clear();
|
|
41
|
+
}
|
|
43
42
|
}
|
|
44
43
|
class PhysicsAvailabilityGrid {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return grid;
|
|
69
|
-
}
|
|
70
|
-
createGrid(cellSize, physicsBodyGroup) {
|
|
71
|
-
let grid = grid_1.Grid.createNew(new helpers_lib_1.Vector(Math.floor(this.mapSize.x / cellSize), Math.floor(this.mapSize.y / cellSize)), true);
|
|
72
|
-
this.p2World.bodies.forEach(p2Body => {
|
|
73
|
-
let physicsEntity = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(p2Body.id);
|
|
74
|
-
if (physicsEntity.includeInPathfinding && physics_body_groups_1.PhysicsBodyGroups.canCollide(physicsEntity.physicsBodyGroup, physicsBodyGroup)) {
|
|
75
|
-
let gridSpaceBoundingBox = this.getGridSpaceBoundingBox(p2Body, cellSize);
|
|
76
|
-
grid?.safeSetArea(gridSpaceBoundingBox, false);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return grid;
|
|
80
|
-
}
|
|
81
|
-
getGridSpaceBoundingBox(p2Body, cellSize) {
|
|
82
|
-
let boundingBox = p2js_helper_1.P2JSHelper.aabbToBoundingBox(p2Body.aabb);
|
|
83
|
-
return availability_grid_helper_1.AvailabilityGridHelper.areaToGridArea(boundingBox, cellSize);
|
|
44
|
+
constructor(p2World, mapsize) {
|
|
45
|
+
this.availabilityGrids = new AvailabilityGridCache();
|
|
46
|
+
this.p2World = p2World;
|
|
47
|
+
this.mapSize = mapsize;
|
|
48
|
+
}
|
|
49
|
+
clear() {
|
|
50
|
+
this.availabilityGrids.clear();
|
|
51
|
+
}
|
|
52
|
+
onBodyAdded(body, physicsBodyGroup) {
|
|
53
|
+
body.aabbNeedsUpdate = true;
|
|
54
|
+
body.updateAABB();
|
|
55
|
+
const boundingBox = p2js_helper_1.P2JSHelper.aabbToBoundingBox(body.aabb);
|
|
56
|
+
this.availabilityGrids.getCollidableGrids(physicsBodyGroup).forEach(item => {
|
|
57
|
+
const gridSpaceBoundingBox = availability_grid_helper_1.AvailabilityGridHelper.areaToGridArea(boundingBox, item.cellSize);
|
|
58
|
+
item.grid.safeSetArea(gridSpaceBoundingBox, false);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
getAvilabilityGrid(cellSize, physicsBodyGroup = physics_body_groups_1.PhysicsBodyGroup.none) {
|
|
62
|
+
let grid = this.availabilityGrids.get(cellSize, physicsBodyGroup);
|
|
63
|
+
if (!grid) {
|
|
64
|
+
grid = this.createGrid(cellSize, physicsBodyGroup);
|
|
65
|
+
this.availabilityGrids.set(cellSize, physicsBodyGroup, grid);
|
|
84
66
|
}
|
|
67
|
+
return grid;
|
|
68
|
+
}
|
|
69
|
+
createGrid(cellSize, physicsBodyGroup) {
|
|
70
|
+
const grid = grid_1.Grid.createNew(
|
|
71
|
+
new helpers_lib_1.Vector(Math.floor(this.mapSize.x / cellSize), Math.floor(this.mapSize.y / cellSize)),
|
|
72
|
+
true
|
|
73
|
+
);
|
|
74
|
+
this.p2World.bodies.forEach(p2Body => {
|
|
75
|
+
const physicsEntity = physics_entity_1.PhysicsEntity.getFromP2BodyIdOrFail(p2Body.id);
|
|
76
|
+
if (
|
|
77
|
+
physicsEntity.includeInPathfinding &&
|
|
78
|
+
physics_body_groups_1.PhysicsBodyGroups.canCollide(physicsEntity.physicsBodyGroup, physicsBodyGroup)
|
|
79
|
+
) {
|
|
80
|
+
const gridSpaceBoundingBox = this.getGridSpaceBoundingBox(p2Body, cellSize);
|
|
81
|
+
grid?.safeSetArea(gridSpaceBoundingBox, false);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return grid;
|
|
85
|
+
}
|
|
86
|
+
getGridSpaceBoundingBox(p2Body, cellSize) {
|
|
87
|
+
const boundingBox = p2js_helper_1.P2JSHelper.aabbToBoundingBox(p2Body.aabb);
|
|
88
|
+
return availability_grid_helper_1.AvailabilityGridHelper.areaToGridArea(boundingBox, cellSize);
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
91
|
exports.PhysicsAvailabilityGrid = PhysicsAvailabilityGrid;
|
|
87
|
-
//# sourceMappingURL=physics-availability-grid.js.map
|
|
92
|
+
//# sourceMappingURL=physics-availability-grid.js.map
|
|
@@ -5,18 +5,22 @@ import { PathFinderResult } from '../../../utilities/libraries/grid-algorithms/p
|
|
|
5
5
|
import { PhysicsBodyGroup } from '../elements/physics-body-groups';
|
|
6
6
|
import { Grid } from '../../../utilities/libraries/data-structures/grid/grid';
|
|
7
7
|
export declare class PhysicsAvailableSpaces {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
private physicsAvailabilityGrid;
|
|
9
|
+
private vectorFieldCache;
|
|
10
|
+
constructor(physicsAvailabilityGrid: PhysicsAvailabilityGrid);
|
|
11
|
+
clear(): void;
|
|
12
|
+
getAvailabilityGrid(physicsBodyGroup: PhysicsBodyGroup): Grid<{
|
|
13
|
+
position: Vector;
|
|
14
|
+
availability: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
findClosestAvailableSpace(body: p2.Body, physicsBodyGroup: PhysicsBodyGroup): Vector | undefined;
|
|
17
|
+
findPathAStar(
|
|
18
|
+
startingPosition: Vector,
|
|
19
|
+
target: Vector | string,
|
|
20
|
+
options?: {
|
|
21
|
+
includeDiagonals?: boolean;
|
|
22
|
+
collidableWithGroup?: PhysicsBodyGroup;
|
|
23
|
+
}
|
|
24
|
+
): PathFinderResult;
|
|
25
|
+
findPathDirection(startingPosition: Vector, target: Vector | string, collidableWithGroup: PhysicsBodyGroup): number | undefined;
|
|
22
26
|
}
|