bard-legends-framework 0.10.8 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/game-entities/base/attachable.d.ts +10 -3
- package/dist/game-entities/base/attachable.js +50 -18
- package/dist/game-entities/base/attachable.test.js +81 -95
- package/dist/game-entities/base/helpers/attachable.store.d.ts +2 -8
- package/dist/game-entities/base/helpers/attachable.store.js +46 -17
- package/dist/game-entities/base/helpers/attachable.store.test.d.ts +1 -0
- package/dist/game-entities/base/helpers/attachable.store.test.js +234 -0
- package/dist/game-entities/base/helpers/decorate-actions-lib.d.ts +3 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +5 -5
- package/dist/game-entities/base/helpers/referance-variable.d.ts +2 -2
- package/dist/game-entities/base/helpers/referance-variable.js +2 -2
- package/dist/game-entities/controller/controller.d.ts +0 -1
- package/dist/game-entities/controller/controller.js +1 -0
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +10 -9
- package/dist/game-entities/entity/entity.js +9 -13
- package/dist/game-entities/entity/entity.test.js +47 -139
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +6 -9
- package/dist/game-entities/entity/helpers/entity-store.helper.js +22 -57
- package/dist/game-entities/entity/helpers/entity-store.helper.test.d.ts +1 -0
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +136 -0
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +1 -1
- package/dist/game-entities/entity/helpers/entity-views.helper.js +5 -3
- package/dist/game-entities/entity/singleton-entity.d.ts +3 -3
- package/dist/game-entities/entity/singleton-entity.js +1 -1
- package/dist/game-entities/entity/singleton-entity.test.js +2 -29
- package/dist/game-entities/index.d.ts +1 -5
- package/dist/game-entities/index.js +3 -24
- package/dist/game-entities/scene/scene.d.ts +4 -4
- package/dist/game-entities/scene/scene.js +31 -25
- package/dist/game-entities/scene/scene.test.js +14 -36
- package/dist/game-entities/service/service.js +5 -3
- package/dist/game-entities/service/service.test.js +2 -28
- package/dist/game-entities/unit-test.helper.d.ts +5 -0
- package/dist/game-entities/unit-test.helper.js +14 -0
- package/dist/game-entities/update-cycle.d.ts +15 -4
- package/dist/game-entities/update-cycle.js +14 -9
- package/dist/game-entities/view/view.d.ts +7 -8
- package/dist/game-entities/view/view.js +12 -21
- package/dist/game-entities/view/view.test.js +54 -244
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -3
- package/dist/physics/entity-types/immovable-physics-entity.js +1 -3
- package/dist/physics/entity-types/movable-entity.js +4 -4
- package/dist/physics/entity-types/movable-physics-entity.d.ts +2 -3
- package/dist/physics/entity-types/movable-physics-entity.js +5 -6
- package/dist/physics/entity-types/physics-entity.d.ts +3 -2
- package/dist/physics/entity-types/physics-entity.js +10 -7
- package/dist/physics/interfaces.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +1 -1
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +1 -1
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +3 -3
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +17 -7
- package/dist/physics/module//360/237/247/212entities/physics-world.entity.js +2 -2
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +1 -2
- package/dist/pixi/components/helpers/smooth-scroller.js +1 -3
- package/dist/pixi/components/helpers/smooth-scroller.test.js +5 -5
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +3 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +10 -7
- package/dist/pixi/components/scroll-area.ui.d.ts +0 -1
- package/dist/pixi/components/scroll-area.ui.js +1 -4
- package/dist/pixi/display-object/container-attributes.d.ts +3 -4
- package/dist/pixi/display-object/container-attributes.js +2 -3
- package/dist/pixi/display-object/container.d.ts +0 -4
- package/dist/pixi/display-object/container.js +5 -17
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.js +5 -3
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +5 -3
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +5 -3
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +1 -1
- package/dist/pixi/display-object/objects/sprite/sprite.js +12 -10
- package/dist/pixi/display-object/objects/text/text.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/text.js +5 -3
- package/dist/pixi/game.d.ts +6 -2
- package/dist/pixi/game.js +14 -5
- package/dist/pixi/modules/CAMERA//360/237/247/212entities/camera.entity.js +4 -4
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +1 -1
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +6 -4
- package/dist/pixi/services/keyboard/keyboard.d.ts +4 -2
- package/dist/pixi/services/keyboard/keyboard.js +6 -4
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +2 -1
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +6 -5
- package/dist/pixi/services/mouse/mouse.service.d.ts +15 -5
- package/dist/pixi/services/mouse/mouse.service.js +38 -18
- package/dist/utilities/animator/animating-content/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/animating-content/fade-in-content.js +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/animating-content/slide-in-content.js +99 -0
- package/dist/utilities/animator/animations.d.ts +37 -0
- package/dist/utilities/animator/animations.js +88 -0
- package/dist/utilities/animator/animator.d.ts +61 -0
- package/dist/utilities/animator/animator.js +315 -0
- package/dist/utilities/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator.test.js +867 -0
- package/dist/utilities/animator/index.d.ts +7 -0
- package/dist/utilities/animator/index.js +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/state-animation.d.ts +33 -0
- package/dist/utilities/animator/state-animation/state-animation.js +146 -0
- package/dist/utilities/animator/state-animation/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/state-animation.test.js +335 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +431 -0
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +7 -0
- package/dist/utilities/data-structures/vector-set/vector-set.js +26 -0
- package/dist/utilities/delta-time/delta-time.d.ts +3 -0
- package/dist/utilities/delta-time/delta-time.js +10 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +6 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +55 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.test.js +100 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.d.ts +8 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +98 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +155 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.d.ts +6 -0
- package/dist/utilities/grid-algorithms/position-to-grid-position-converter.js +17 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +18 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +129 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.d.ts +1 -0
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +254 -0
- package/dist/utilities/index.d.ts +6 -6
- package/dist/utilities/index.js +6 -6
- package/dist/utilities/libraries/animator/animator.d.ts +3 -5
- package/dist/utilities/libraries/animator/animator.js +17 -19
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.js +1 -1
- package/package.json +6 -6
package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
4
|
+
const vitest_1 = require("vitest");
|
|
5
|
+
const vector_field_path_finder_1 = require("./vector-field-path-finder");
|
|
6
|
+
(0, vitest_1.describe)('VectorFieldPathFinder', () => {
|
|
7
|
+
(0, vitest_1.describe)('weight grid', () => {
|
|
8
|
+
(0, vitest_1.test)('basic 1', () => {
|
|
9
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
10
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(1, 1), defaultValue: true });
|
|
11
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
12
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 0))).toBe(0);
|
|
13
|
+
});
|
|
14
|
+
(0, vitest_1.test)('basic 2', () => {
|
|
15
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } });
|
|
16
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
17
|
+
[true, true],
|
|
18
|
+
[true, true]
|
|
19
|
+
]);
|
|
20
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
21
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 0))).toBe(0);
|
|
22
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(1, 0))).toBe(0);
|
|
23
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 1))).toBe(0);
|
|
24
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(1, 1))).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
(0, vitest_1.test)('sample 1', () => {
|
|
27
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
28
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
29
|
+
[true, true],
|
|
30
|
+
[true, true]
|
|
31
|
+
]);
|
|
32
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
33
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 0))).toBe(0);
|
|
34
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(1, 0))).toBe(10);
|
|
35
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 1))).toBe(10);
|
|
36
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(1, 1))).toBe(14);
|
|
37
|
+
});
|
|
38
|
+
(0, vitest_1.test)('sample 2', () => {
|
|
39
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } });
|
|
40
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(3, 3), defaultValue: true });
|
|
41
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
42
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
43
|
+
[0, 0, 10],
|
|
44
|
+
[0, 0, 10],
|
|
45
|
+
[10, 10, 14]
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
(0, vitest_1.test)('sample 3', () => {
|
|
49
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 1, y: 1 }, bottomRight: { x: 2, y: 2 } });
|
|
50
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(3, 3), defaultValue: true });
|
|
51
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
52
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
53
|
+
[14, 10, 10],
|
|
54
|
+
[10, 0, 0],
|
|
55
|
+
[10, 0, 0]
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.test)('complex 1', () => {
|
|
59
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
60
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
61
|
+
[true, false, true],
|
|
62
|
+
[true, true, true],
|
|
63
|
+
[false, false, true],
|
|
64
|
+
[false, false, true]
|
|
65
|
+
]);
|
|
66
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
67
|
+
let h = pathFinder['getHighestWeight'](availabilityGrid.size);
|
|
68
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
69
|
+
[0, h, 28],
|
|
70
|
+
[10, 14, 24],
|
|
71
|
+
[h, h, 28],
|
|
72
|
+
[h, h, 38]
|
|
73
|
+
]);
|
|
74
|
+
});
|
|
75
|
+
(0, vitest_1.test)('complex 2', () => {
|
|
76
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } });
|
|
77
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
78
|
+
[true, true, false, true],
|
|
79
|
+
[true, true, false, true],
|
|
80
|
+
[false, false, true, true]
|
|
81
|
+
]);
|
|
82
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
83
|
+
let h = pathFinder['getHighestWeight'](availabilityGrid.size);
|
|
84
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
85
|
+
[0, 0, h, 38],
|
|
86
|
+
[0, 0, h, 28],
|
|
87
|
+
[h, h, 14, 24]
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
(0, vitest_1.test)('complex 3', () => {
|
|
91
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 2, y: 2 }, bottomRight: { x: 3, y: 3 } });
|
|
92
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
93
|
+
[true, true, false, true],
|
|
94
|
+
[true, true, false, true],
|
|
95
|
+
[false, false, true, true],
|
|
96
|
+
[false, false, true, true]
|
|
97
|
+
]);
|
|
98
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
99
|
+
let h = pathFinder['getHighestWeight'](availabilityGrid.size);
|
|
100
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
101
|
+
[28, 24, h, 20],
|
|
102
|
+
[24, 14, h, 10],
|
|
103
|
+
[h, h, 0, 0],
|
|
104
|
+
[h, h, 0, 0]
|
|
105
|
+
]);
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.test)('unreachable area 1', () => {
|
|
108
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
109
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
110
|
+
[true, false, true, false, true],
|
|
111
|
+
[true, false, true, false, true],
|
|
112
|
+
[true, false, false, false, true],
|
|
113
|
+
[true, false, false, false, true],
|
|
114
|
+
[true, true, true, true, true]
|
|
115
|
+
]);
|
|
116
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
117
|
+
let h = pathFinder['getHighestWeight'](availabilityGrid.size);
|
|
118
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
119
|
+
[0, h, h, h, 108],
|
|
120
|
+
[10, h, h, h, 98],
|
|
121
|
+
[20, h, h, h, 88],
|
|
122
|
+
[30, h, h, h, 78],
|
|
123
|
+
[40, 44, 54, 64, 74]
|
|
124
|
+
]);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
(0, vitest_1.describe)('getDirectionToTarget', () => {
|
|
128
|
+
(0, vitest_1.test)('sample 1', () => {
|
|
129
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
130
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
131
|
+
[true, true],
|
|
132
|
+
[true, true]
|
|
133
|
+
]);
|
|
134
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
135
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(1, 1))?.value).toEqual(helpers_lib_1.Radian.get315.value);
|
|
136
|
+
});
|
|
137
|
+
(0, vitest_1.test)('sample 2', () => {
|
|
138
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
139
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
140
|
+
[true, true, true],
|
|
141
|
+
[false, true, true]
|
|
142
|
+
]);
|
|
143
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
144
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 1))?.value).toEqual(new helpers_lib_1.Vector(-2, -1).radian.value);
|
|
145
|
+
});
|
|
146
|
+
(0, vitest_1.test)('sample 3', () => {
|
|
147
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
148
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
149
|
+
[true, false, true],
|
|
150
|
+
[true, false, true],
|
|
151
|
+
[true, true, true]
|
|
152
|
+
]);
|
|
153
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
154
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 0))?.value).toEqual(helpers_lib_1.Radian.get180.value);
|
|
155
|
+
});
|
|
156
|
+
(0, vitest_1.test)('sample 4', () => {
|
|
157
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
158
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
159
|
+
[true, false, false],
|
|
160
|
+
[true, false, false]
|
|
161
|
+
]);
|
|
162
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
163
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 0))).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
(0, vitest_1.describe)('edge cases', () => {
|
|
167
|
+
(0, vitest_1.test)('should create an instance', () => {
|
|
168
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
169
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(1, 1), defaultValue: true });
|
|
170
|
+
(0, vitest_1.expect)(new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid)).toBeTruthy();
|
|
171
|
+
});
|
|
172
|
+
(0, vitest_1.test)('should activate unavailable target cells of the target area', () => {
|
|
173
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
174
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(1, 1), defaultValue: false });
|
|
175
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
176
|
+
(0, vitest_1.expect)(pathFinder['weightGrid'].get(new helpers_lib_1.Vector(0, 0))).toBe(0);
|
|
177
|
+
});
|
|
178
|
+
(0, vitest_1.test)('should select closest grid cells if the target is outside of the grid', () => {
|
|
179
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 3, y: -1 }, bottomRight: { x: 3, y: 1 } });
|
|
180
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(3, 3), defaultValue: true });
|
|
181
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
182
|
+
(0, vitest_1.expect)(pathFinder['weightGrid']['_grid']).toEqual([
|
|
183
|
+
[20, 10, 0],
|
|
184
|
+
[20, 10, 0],
|
|
185
|
+
[24, 14, 10]
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
(0, vitest_1.test)('should return undefined if starting position and its neighbors are unreachable', () => {
|
|
189
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
190
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
191
|
+
[true, false, false],
|
|
192
|
+
[true, false, false]
|
|
193
|
+
]);
|
|
194
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
195
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 1))).toBeUndefined();
|
|
196
|
+
});
|
|
197
|
+
(0, vitest_1.test)('should find the direction if starting position is unreachable but there is a reachable neighbor', () => {
|
|
198
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
199
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
200
|
+
[true, true, false],
|
|
201
|
+
[true, false, false]
|
|
202
|
+
]);
|
|
203
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
204
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 1))?.value).toEqual(helpers_lib_1.Radian.get315.value);
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.test)('should return undefined if starting point is inside target area', () => {
|
|
207
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 1, y: 1 } });
|
|
208
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(2, 2), defaultValue: true });
|
|
209
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
210
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(0, 0))).toBeUndefined();
|
|
211
|
+
});
|
|
212
|
+
(0, vitest_1.test)('should return closest cell result if starting point is outside of the grid', () => {
|
|
213
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
214
|
+
let availabilityGrid = new helpers_lib_1.Grid({ size: new helpers_lib_1.Vector(2, 1), defaultValue: true });
|
|
215
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
216
|
+
(0, vitest_1.expect)(pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 0))?.value).toEqual(helpers_lib_1.Radian.get270.value);
|
|
217
|
+
});
|
|
218
|
+
(0, vitest_1.test)('if average direction is pointing blocked path, it should pick random available direction', () => {
|
|
219
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
220
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
221
|
+
[true, true, true],
|
|
222
|
+
[true, false, true],
|
|
223
|
+
[true, true, true]
|
|
224
|
+
]);
|
|
225
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
226
|
+
let result = pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 2));
|
|
227
|
+
(0, vitest_1.expect)(result?.value === helpers_lib_1.Radian.get270.value || result?.value === 0).toBeTruthy();
|
|
228
|
+
});
|
|
229
|
+
(0, vitest_1.test)('finding path from unavailable space should point the direction away from the obstacle', () => {
|
|
230
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
231
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
232
|
+
[true, true, true, true],
|
|
233
|
+
[true, false, false, true],
|
|
234
|
+
[true, false, false, true],
|
|
235
|
+
[true, true, true, true]
|
|
236
|
+
]);
|
|
237
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
238
|
+
let result = pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(2, 2));
|
|
239
|
+
(0, vitest_1.expect)(result?.value).toEqual(helpers_lib_1.Radian.get135.value);
|
|
240
|
+
});
|
|
241
|
+
(0, vitest_1.test)('finding path from unavailable space should point the direction to the best neighbor if all neighbors are available', () => {
|
|
242
|
+
let targetArea = helpers_lib_1.Rectangle.fromRect({ topLeft: { x: 0, y: 0 }, bottomRight: { x: 0, y: 0 } });
|
|
243
|
+
let availabilityGrid = new helpers_lib_1.Grid([
|
|
244
|
+
[true, false, true, false],
|
|
245
|
+
[true, false, true, true],
|
|
246
|
+
[true, true, true, true]
|
|
247
|
+
]);
|
|
248
|
+
let pathFinder = new vector_field_path_finder_1.VectorFieldPathFinder(targetArea, availabilityGrid);
|
|
249
|
+
let result = pathFinder.getDirectionToTarget(new helpers_lib_1.Vector(3, 0));
|
|
250
|
+
(0, vitest_1.expect)(result?.value).toEqual(-helpers_lib_1.Radian.get135.value);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
//# sourceMappingURL=vector-field-path-finder.test.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { VectorSet } from './
|
|
3
|
-
export { DeltaTime } from './
|
|
4
|
-
export { ClosestAvailableSpaceHelper } from './
|
|
5
|
-
export { PathFinder, PathFinderResult } from './
|
|
6
|
-
export { VectorFieldPathFinder } from './
|
|
1
|
+
export * from './animator';
|
|
2
|
+
export { VectorSet } from './data-structures/vector-set/vector-set';
|
|
3
|
+
export { DeltaTime } from './delta-time/delta-time';
|
|
4
|
+
export { ClosestAvailableSpaceHelper } from './grid-algorithms/closest-available-space/closest-available-space.helper';
|
|
5
|
+
export { PathFinder, PathFinderResult } from './grid-algorithms/path-finder/path-finder';
|
|
6
|
+
export { VectorFieldPathFinder } from './grid-algorithms/vector-field-path-finder/vector-field-path-finder';
|
package/dist/utilities/index.js
CHANGED
|
@@ -15,15 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.VectorFieldPathFinder = exports.PathFinder = exports.ClosestAvailableSpaceHelper = exports.DeltaTime = exports.VectorSet = void 0;
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
var vector_set_1 = require("./
|
|
18
|
+
__exportStar(require("./animator"), exports);
|
|
19
|
+
var vector_set_1 = require("./data-structures/vector-set/vector-set");
|
|
20
20
|
Object.defineProperty(exports, "VectorSet", { enumerable: true, get: function () { return vector_set_1.VectorSet; } });
|
|
21
|
-
var delta_time_1 = require("./
|
|
21
|
+
var delta_time_1 = require("./delta-time/delta-time");
|
|
22
22
|
Object.defineProperty(exports, "DeltaTime", { enumerable: true, get: function () { return delta_time_1.DeltaTime; } });
|
|
23
|
-
var closest_available_space_helper_1 = require("./
|
|
23
|
+
var closest_available_space_helper_1 = require("./grid-algorithms/closest-available-space/closest-available-space.helper");
|
|
24
24
|
Object.defineProperty(exports, "ClosestAvailableSpaceHelper", { enumerable: true, get: function () { return closest_available_space_helper_1.ClosestAvailableSpaceHelper; } });
|
|
25
|
-
var path_finder_1 = require("./
|
|
25
|
+
var path_finder_1 = require("./grid-algorithms/path-finder/path-finder");
|
|
26
26
|
Object.defineProperty(exports, "PathFinder", { enumerable: true, get: function () { return path_finder_1.PathFinder; } });
|
|
27
|
-
var vector_field_path_finder_1 = require("./
|
|
27
|
+
var vector_field_path_finder_1 = require("./grid-algorithms/vector-field-path-finder/vector-field-path-finder");
|
|
28
28
|
Object.defineProperty(exports, "VectorFieldPathFinder", { enumerable: true, get: function () { return vector_field_path_finder_1.VectorFieldPathFinder; } });
|
|
29
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Attachable } from '../../../game-entities/base/attachable';
|
|
1
|
+
import { Attachable } from '../../../game-entities';
|
|
3
2
|
import { AnimatorAnimation } from './animations';
|
|
4
3
|
export interface AnimationState {
|
|
5
4
|
duration: number;
|
|
@@ -43,12 +42,11 @@ export declare class Animator<T> extends Attachable {
|
|
|
43
42
|
private allResolvers;
|
|
44
43
|
get isAnimating(): boolean;
|
|
45
44
|
constructor(target: T, effectOn: string | string[], options?: AnimationOptions);
|
|
46
|
-
|
|
47
|
-
attach(parent: AttachmentTarget | string): this;
|
|
45
|
+
attach(parent: Attachable | string): this;
|
|
48
46
|
attachToRoot(): this;
|
|
49
47
|
onChange(callback: (target: T) => void): Animator<T>;
|
|
50
48
|
onComplete(callback: (key: string, value: number) => void): Animator<T>;
|
|
51
|
-
|
|
49
|
+
destroy(): void;
|
|
52
50
|
getAnimationStateOfKey(key: string): AnimationState | undefined;
|
|
53
51
|
pauseAnimations(): void;
|
|
54
52
|
resumeAnimations(): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Animator = exports.CompleteAnimationsHandlingType = exports.ReAnimateHandlingType = void 0;
|
|
4
4
|
const helpers_lib_1 = require("helpers-lib");
|
|
5
|
-
const
|
|
5
|
+
const game_entities_1 = require("../../../game-entities");
|
|
6
6
|
const update_cycle_1 = require("../../../game-entities/update-cycle");
|
|
7
7
|
const animations_1 = require("./animations");
|
|
8
8
|
var ReAnimateHandlingType;
|
|
@@ -22,7 +22,7 @@ const DEFAULT_ANIMATION = new animations_1.AnimationLineer();
|
|
|
22
22
|
const DEFAULT_LOOP = false;
|
|
23
23
|
const DEFAULT_RE_ANIMATE_HANDLING = ReAnimateHandlingType.throwError;
|
|
24
24
|
const DEFAULT_COMPLETE_ANIMATIONS_HANDLING = CompleteAnimationsHandlingType.stayInCurrentState;
|
|
25
|
-
class Animator extends
|
|
25
|
+
class Animator extends game_entities_1.Attachable {
|
|
26
26
|
static { this.animatedObjects = new Map(); }
|
|
27
27
|
get isAnimating() {
|
|
28
28
|
return this.propertyStates.size > 0;
|
|
@@ -67,10 +67,6 @@ class Animator extends attachable_1.Attachable {
|
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
|
-
// make the destroy function non-internal
|
|
71
|
-
destroy() {
|
|
72
|
-
super.destroy();
|
|
73
|
-
}
|
|
74
70
|
// make the attach function non-internal
|
|
75
71
|
attach(parent) {
|
|
76
72
|
super.attach(parent);
|
|
@@ -97,20 +93,22 @@ class Animator extends attachable_1.Attachable {
|
|
|
97
93
|
this.onCompleteCallback = callback;
|
|
98
94
|
return this;
|
|
99
95
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
destroy() {
|
|
97
|
+
if (!this.destroyed) {
|
|
98
|
+
this.onChangeCallback = undefined;
|
|
99
|
+
this.onCompleteCallback = undefined;
|
|
100
|
+
this.defaultAnimation = DEFAULT_ANIMATION;
|
|
101
|
+
this.propertyStates.clear();
|
|
102
|
+
let animatedObjectProperties = Animator.animatedObjects.get(this.target);
|
|
103
|
+
this.effectOn.forEach(key => animatedObjectProperties.delete(key));
|
|
104
|
+
if (animatedObjectProperties.size <= 0) {
|
|
105
|
+
Animator.animatedObjects.delete(this.target);
|
|
106
|
+
}
|
|
107
|
+
this.target = undefined;
|
|
108
|
+
this.allResolvers.forEach(resolver => resolver());
|
|
109
|
+
this.allResolvers.clear();
|
|
110
|
+
super.destroy();
|
|
110
111
|
}
|
|
111
|
-
this.target = undefined;
|
|
112
|
-
this.allResolvers.forEach(resolver => resolver());
|
|
113
|
-
this.allResolvers.clear();
|
|
114
112
|
}
|
|
115
113
|
getAnimationStateOfKey(key) {
|
|
116
114
|
let propertyState = this.propertyStates.get(key);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Attachable } from '../../../../game-entities';
|
|
2
2
|
import { StateAnimationOptions } from './state-animation';
|
|
3
3
|
export declare enum SlideStateAnimationState {
|
|
4
4
|
appear = "appear",
|
|
5
5
|
disappear = "disappear"
|
|
6
6
|
}
|
|
7
|
-
export declare class SlideStateAnimation extends
|
|
7
|
+
export declare class SlideStateAnimation extends Attachable {
|
|
8
8
|
private stateAnimation;
|
|
9
9
|
private options;
|
|
10
10
|
private index;
|
|
@@ -11,7 +11,7 @@ var SlideStateAnimationState;
|
|
|
11
11
|
SlideStateAnimationState["appear"] = "appear";
|
|
12
12
|
SlideStateAnimationState["disappear"] = "disappear";
|
|
13
13
|
})(SlideStateAnimationState || (exports.SlideStateAnimationState = SlideStateAnimationState = {}));
|
|
14
|
-
class SlideStateAnimation extends game_entities_1.
|
|
14
|
+
class SlideStateAnimation extends game_entities_1.Attachable {
|
|
15
15
|
constructor(partialOptions) {
|
|
16
16
|
super();
|
|
17
17
|
this.animationState = 'idle';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Attachable } from '../../../../game-entities';
|
|
2
2
|
import { AnimatorAnimation } from '../animations';
|
|
3
3
|
export interface StateAnimationOptions {
|
|
4
4
|
readonly duration: number;
|
|
5
5
|
readonly animation: AnimatorAnimation;
|
|
6
6
|
}
|
|
7
7
|
type AnimationState = 'idle' | 'transitioning' | 'reverting';
|
|
8
|
-
export declare class StateAnimation<T> extends
|
|
8
|
+
export declare class StateAnimation<T> extends Attachable {
|
|
9
9
|
private animator;
|
|
10
10
|
private options;
|
|
11
11
|
private value;
|
|
@@ -5,7 +5,7 @@ const actions_lib_1 = require("actions-lib");
|
|
|
5
5
|
const game_entities_1 = require("../../../../game-entities");
|
|
6
6
|
const animations_1 = require("../animations");
|
|
7
7
|
const animator_1 = require("../animator");
|
|
8
|
-
class StateAnimation extends game_entities_1.
|
|
8
|
+
class StateAnimation extends game_entities_1.Attachable {
|
|
9
9
|
get currentState() {
|
|
10
10
|
return {
|
|
11
11
|
value: this.value,
|
package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Attachable } from '../../../../game-entities';
|
|
2
2
|
import { StateAnimationOptions } from './state-animation';
|
|
3
3
|
type AnimationState = 'hidden' | 'visible' | 'appearing' | 'disappearing' | 'disappearToChange';
|
|
4
|
-
export declare class VisitDisappearStateAnimation<T> extends
|
|
4
|
+
export declare class VisitDisappearStateAnimation<T> extends Attachable {
|
|
5
5
|
private animator;
|
|
6
6
|
private options;
|
|
7
7
|
private value;
|
package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.js
CHANGED
|
@@ -5,7 +5,7 @@ const actions_lib_1 = require("actions-lib");
|
|
|
5
5
|
const game_entities_1 = require("../../../../game-entities");
|
|
6
6
|
const animations_1 = require("../animations");
|
|
7
7
|
const animator_1 = require("../animator");
|
|
8
|
-
class VisitDisappearStateAnimation extends game_entities_1.
|
|
8
|
+
class VisitDisappearStateAnimation extends game_entities_1.Attachable {
|
|
9
9
|
get currentState() {
|
|
10
10
|
return {
|
|
11
11
|
value: this.value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bard-legends-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Bard Legends Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"test": "vitest run",
|
|
29
29
|
"build": "tsc",
|
|
30
30
|
"lint": "biome check . --write --max-diagnostics=1",
|
|
31
|
-
"deploy": "vitest run && npm run build && npm publish",
|
|
31
|
+
"deploy": "npm i && vitest run && npm run build && npm publish",
|
|
32
32
|
"prepack": "cp package.json package.json.bak && ts-node scripts/prepare-package-json.ts",
|
|
33
33
|
"postpack": "mv package.json.bak package.json"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"p2": "0.7.1",
|
|
37
37
|
"pixi.js": "7.4.2",
|
|
38
|
-
"reflect-metadata": "0.2.
|
|
38
|
+
"reflect-metadata": "0.2.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"actions-lib": "
|
|
42
|
-
"helpers-lib": "1.13.10",
|
|
43
|
-
"script-engine-lib": "0.4.3"
|
|
41
|
+
"actions-lib": "^2.0.0",
|
|
42
|
+
"helpers-lib": "^1.13.10",
|
|
43
|
+
"script-engine-lib": "^0.4.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@biomejs/biome": "2.2.4",
|