bard-legends-framework 0.11.0 → 0.12.1
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/actions-performance.test.d.ts +1 -0
- package/dist/actions-performance.test.js +83 -0
- package/dist/game-entities/controller/controller.d.ts +2 -2
- package/dist/game-entities/controller/controller.js +8 -8
- package/dist/game-entities/controller/controller.test.js +2 -2
- package/dist/game-entities/entity/entity.d.ts +7 -7
- package/dist/game-entities/entity/entity.js +18 -12
- package/dist/game-entities/entity/entity.test.js +93 -30
- package/dist/game-entities/entity/helpers/entity-store.helper.d.ts +3 -3
- package/dist/game-entities/entity/helpers/entity-store.helper.js +12 -12
- package/dist/game-entities/entity/helpers/entity-store.helper.test.js +11 -11
- package/dist/game-entities/entity/helpers/entity-views.helper.d.ts +6 -6
- package/dist/game-entities/entity/helpers/entity-views.helper.js +25 -22
- package/dist/game-entities/entity/singleton-entity.test.js +9 -4
- package/dist/game-entities/hard-reset.d.ts +5 -0
- package/dist/game-entities/hard-reset.js +14 -0
- package/dist/game-entities/index.d.ts +1 -1
- package/dist/game-entities/index.js +3 -3
- package/dist/game-entities/scene/scene.d.ts +13 -13
- package/dist/game-entities/scene/scene.js +41 -46
- package/dist/game-entities/scene/scene.test.js +95 -37
- package/dist/game-entities/service/service.d.ts +1 -4
- package/dist/game-entities/service/service.js +12 -13
- package/dist/game-entities/service/service.test.js +33 -12
- package/dist/game-entities/unit-test.helper.js +1 -1
- package/dist/game-entities/update-cycle.d.ts +7 -17
- package/dist/game-entities/update-cycle.js +25 -19
- package/dist/game-entities/view/view.d.ts +6 -6
- package/dist/game-entities/view/view.js +15 -21
- package/dist/game-entities/view/view.test.js +40 -9
- package/dist/physics/entity-types/immovable-physics-entity.d.ts +1 -1
- package/dist/physics/entity-types/immovable-physics-entity.js +4 -4
- package/dist/physics/entity-types/movable-entity.d.ts +1 -1
- package/dist/physics/entity-types/movable-entity.js +2 -2
- package/dist/physics/entity-types/movable-physics-entity.d.ts +8 -8
- package/dist/physics/entity-types/movable-physics-entity.js +27 -27
- package/dist/physics/entity-types/physics-entity.d.ts +10 -14
- package/dist/physics/entity-types/physics-entity.js +27 -26
- package/dist/physics/interfaces.d.ts +6 -6
- package/dist/physics/interfaces.js +4 -4
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.d.ts +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics-internal.controller.js +22 -22
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.d.ts +19 -19
- package/dist/physics/module//342/232/234/357/270/217gateways/controllers/physics.controller.js +30 -30
- package/dist/physics/module//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +3 -3
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics-internal.gateway.js +16 -16
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.d.ts +10 -10
- package/dist/physics/module//342/232/234/357/270/217gateways/physics.gateway.js +18 -18
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/collision/collisions.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/collision/hit-test.service.js +11 -11
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/collision/physics-body-group.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/creation/border.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/creation/border.service.js +9 -9
- package/dist/physics/module//360/237/223/220services/creation/materials.service.d.ts +7 -7
- package/dist/physics/module//360/237/223/220services/creation/materials.service.js +17 -17
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.d.ts +11 -11
- package/dist/physics/module//360/237/223/220services/creation/physics-world.service.js +27 -26
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/creation/shape-creation.service.js +13 -13
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/eliptic-explosion.service.js +19 -19
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/impact/explosion.service.js +20 -20
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.d.ts +1 -1
- package/dist/physics/module//360/237/223/220services/impact/ray-cast-hit-converter.js +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.d.ts +2 -2
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid-cache.service.js +3 -3
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.d.ts +5 -5
- package/dist/physics/module//360/237/223/220services/path-finding/availability-grid.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/path-finding/path-finder.service.js +12 -12
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.d.ts +4 -4
- package/dist/physics/module//360/237/223/220services/query/physics-query.service.js +4 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.d.ts +1 -4
- package/dist/physics/module//360/237/223/220services/ray-casting/ray-casting.service.js +7 -15
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.d.ts +9 -9
- package/dist/physics/module//360/237/223/220services/test-visuals/test-visuals.service.js +43 -42
- package/dist/physics/module//360/237/247/212entities/border.entity.d.ts +1 -1
- package/dist/physics/module//360/237/247/212entities/border.entity.js +3 -3
- package/dist/pixi/components/display-object-array.d.ts +5 -5
- package/dist/pixi/components/display-object-array.js +14 -14
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +7 -7
- package/dist/pixi/components/helpers/smooth-scroller.js +23 -23
- package/dist/pixi/components/helpers/smooth-scroller.test.js +14 -14
- package/dist/pixi/components/menu/menu-entity.d.ts +14 -0
- package/dist/pixi/components/menu/menu-entity.js +48 -0
- package/dist/pixi/components/menu/menu.ui.d.ts +23 -0
- package/dist/pixi/components/menu/menu.ui.js +97 -0
- package/dist/pixi/components/mouse-wheel-listener.ui.d.ts +2 -2
- package/dist/pixi/components/mouse-wheel-listener.ui.js +11 -11
- package/dist/pixi/components/scroll-area.ui.d.ts +1 -1
- package/dist/pixi/components/scroll-area.ui.js +9 -9
- package/dist/pixi/components/scroll-mask.ui.d.ts +9 -8
- package/dist/pixi/components/scroll-mask.ui.js +25 -24
- package/dist/pixi/display-object/container-attributes.d.ts +24 -25
- package/dist/pixi/display-object/container-attributes.js +26 -26
- package/dist/pixi/display-object/container.d.ts +3 -3
- package/dist/pixi/display-object/container.js +2 -2
- package/dist/pixi/display-object/filters/base-filters/blur.filter.d.ts +9 -9
- package/dist/pixi/display-object/filters/base-filters/blur.filter.js +25 -25
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.d.ts +7 -7
- package/dist/pixi/display-object/filters/base-filters/expand-with-color.filter.js +17 -17
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.d.ts +6 -6
- package/dist/pixi/display-object/filters/composite-filters/glow-filter.js +10 -11
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.d.ts +2 -2
- package/dist/pixi/display-object/filters/helpers/gaussian-values.helper.js +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/checking-neighbors.template.js +8 -8
- package/dist/pixi/display-object/filters/templates/plane.template.d.ts +5 -5
- package/dist/pixi/display-object/filters/templates/plane.template.js +7 -7
- package/dist/pixi/display-object/filters.d.ts +7 -7
- package/dist/pixi/display-object/filters.js +34 -34
- package/dist/pixi/display-object/index.d.ts +1 -1
- package/dist/pixi/display-object/objects/graphics/graphics.d.ts +9 -9
- package/dist/pixi/display-object/objects/graphics/graphics.js +25 -25
- package/dist/pixi/display-object/objects/placeholder.d.ts +1 -1
- package/dist/pixi/display-object/objects/placeholder.js +7 -7
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.d.ts +9 -9
- package/dist/pixi/display-object/objects/sprite/glow-sprite-generator.js +26 -25
- package/dist/pixi/display-object/objects/sprite/sprite.d.ts +10 -9
- package/dist/pixi/display-object/objects/sprite/sprite.js +62 -53
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/pixi-text-style-converter.d.ts +4 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.d.ts +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.js +16 -16
- package/dist/pixi/display-object/objects/text/helpers/process-steps/1-data-in-converter/rich-text-data-in-converter.test.js +28 -28
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.d.ts +1 -1
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/consistent-space-text-wrapper.js +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.d.ts +17 -17
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.js +62 -62
- package/dist/pixi/display-object/objects/text/helpers/process-steps/2-wrapping-text/rich-text-typewriter.test.js +2 -2
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.d.ts +3 -3
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.js +6 -6
- package/dist/pixi/display-object/objects/text/helpers/process-steps/3-data-out-converter/rich-text-data-out-converter.test.js +12 -12
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.d.ts +2 -2
- package/dist/pixi/display-object/objects/text/helpers/rich-text-to-plane-text.test.js +5 -5
- package/dist/pixi/display-object/objects/text/rich-text.d.ts +0 -1
- package/dist/pixi/display-object/objects/text/rich-text.js +0 -1
- package/dist/pixi/display-object/objects/text/text.d.ts +9 -10
- package/dist/pixi/display-object/objects/text/text.js +34 -35
- package/dist/pixi/game.d.ts +20 -15
- package/dist/pixi/game.js +40 -35
- package/dist/pixi/helpers/game-assets.d.ts +5 -5
- package/dist/pixi/helpers/game-assets.js +14 -11
- package/dist/pixi/helpers/position-conversion.helper.d.ts +4 -4
- package/dist/pixi/helpers/position-conversion.helper.js +3 -3
- package/dist/pixi/index.d.ts +3 -37
- package/dist/pixi/index.js +6 -22
- package/dist/pixi/modules/CAMERA/camera.d.ts +5 -4
- package/dist/pixi/modules/CAMERA/camera.js +9 -9
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/camera-view.gateway.js +1 -1
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.d.ts +3 -2
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera-view.controller.js +5 -5
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.d.ts +3 -3
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/controllers/camera.controller.js +7 -7
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.d.ts +8 -8
- package/dist/pixi/modules/CAMERA//342/232/234/357/270/217gateways/dtos/requests.dto.js +8 -8
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.d.ts +2 -2
- package/dist/pixi/modules/CAMERA//360/237/223/220services/camera.service.js +12 -12
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.d.ts +17 -16
- package/dist/pixi/modules/CAMERA//360/237/247/251views/camera.view.js +49 -48
- package/dist/pixi/pixi-definitions.d.ts +38 -0
- package/dist/pixi/pixi-definitions.js +37 -0
- package/dist/pixi/services/keyboard/keyboard.d.ts +2 -2
- package/dist/pixi/services/keyboard/keyboard.js +9 -9
- package/dist/pixi/services/mouse/mouse-target-focus.service.d.ts +10 -10
- package/dist/pixi/services/mouse/mouse-target-focus.service.js +28 -28
- package/dist/pixi/services/mouse/mouse.service.d.ts +1 -1
- package/dist/pixi/services/mouse/mouse.service.js +5 -5
- package/dist/utilities/animator/animating-content/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/animating-content/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/animations.d.ts +14 -6
- package/dist/utilities/animator/animations.js +15 -11
- package/dist/utilities/animator/animator/animator.d.ts +44 -0
- package/dist/utilities/animator/animator/animator.js +234 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.performance.test.js +116 -0
- package/dist/utilities/animator/animator/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator/animator.test.js +1046 -0
- package/dist/utilities/animator/animator.d.ts +2 -3
- package/dist/utilities/animator/animator.js +66 -59
- package/dist/utilities/animator/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator.performance.test.js +46 -0
- package/dist/utilities/animator/animator.test.js +89 -28
- package/dist/utilities/animator/animator2/animator.d.ts +42 -0
- package/dist/utilities/animator/animator2/animator.js +222 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.memory-leak.test.js +73 -0
- package/dist/utilities/animator/animator2/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.performance.test.js +65 -0
- package/dist/utilities/animator/animator2/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator2/animator.test.js +1007 -0
- package/dist/utilities/animator/animator_old/animator.d.ts +60 -0
- package/dist/utilities/animator/animator_old/animator.js +337 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.performance.test.js +121 -0
- package/dist/utilities/animator/animator_old/animator.test.d.ts +1 -0
- package/dist/utilities/animator/animator_old/animator.test.js +996 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.d.ts +38 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.js +208 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/fade-in/fade-in-state-animation.test.js +439 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.d.ts +41 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.js +107 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.js +138 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/slide-state-animation.test.js +307 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.d.ts +37 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.js +170 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/content-animations/slide/state-animation.test.js +340 -0
- package/dist/utilities/animator/index.d.ts +6 -6
- package/dist/utilities/animator/index.js +6 -6
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.d.ts +18 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.js +37 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.d.ts +32 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.js +168 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/fade-in/fade-in-state-animation.test.js +431 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.d.ts +37 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.js +100 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-in-content.test.js +10 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.d.ts +24 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.js +130 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.d.ts +1 -0
- package/dist/utilities/animator/state-animation/slide/slide-state-animation.test.js +301 -0
- package/dist/utilities/animator/state-animation/slide-state-animation.test.js +30 -30
- package/dist/utilities/animator/state-animation/state-animation.js +7 -7
- package/dist/utilities/animator/state-animation/state-animation.test.js +24 -24
- package/dist/utilities/animator/state-animation/visit-disappear-state-animation.test.js +30 -30
- package/dist/utilities/data-structures/vector-set/vector-set.d.ts +1 -1
- package/dist/utilities/data-structures/vector-set/vector-set.js +5 -5
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.d.ts +1 -1
- package/dist/utilities/grid-algorithms/closest-available-space/closest-available-space.helper.js +5 -5
- package/dist/utilities/grid-algorithms/path-finder/path-finder.js +21 -21
- package/dist/utilities/grid-algorithms/path-finder/path-finder.test.js +9 -9
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.d.ts +14 -14
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.js +43 -43
- package/dist/utilities/grid-algorithms/vector-field-path-finder/vector-field-path-finder.test.js +21 -21
- package/package.json +7 -5
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SlideStateAnimation = exports.SlideStateAnimationState = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
+
const animations_1 = require("../../animations");
|
|
7
|
+
const state_animation_1 = require("./state-animation");
|
|
8
|
+
var SlideStateAnimationState;
|
|
9
|
+
(function (SlideStateAnimationState) {
|
|
10
|
+
SlideStateAnimationState[SlideStateAnimationState["Appear"] = 1] = "Appear";
|
|
11
|
+
SlideStateAnimationState[SlideStateAnimationState["Disappear"] = 2] = "Disappear";
|
|
12
|
+
})(SlideStateAnimationState || (exports.SlideStateAnimationState = SlideStateAnimationState = {}));
|
|
13
|
+
var AnimationState;
|
|
14
|
+
(function (AnimationState) {
|
|
15
|
+
AnimationState[AnimationState["Idle"] = 1] = "Idle";
|
|
16
|
+
AnimationState[AnimationState["TransitionForward"] = 2] = "TransitionForward";
|
|
17
|
+
AnimationState[AnimationState["TransitionBackward"] = 3] = "TransitionBackward";
|
|
18
|
+
AnimationState[AnimationState["Reverting"] = 4] = "Reverting";
|
|
19
|
+
})(AnimationState || (AnimationState = {}));
|
|
20
|
+
class SlideStateAnimation extends actions_lib_1.Attachable {
|
|
21
|
+
constructor(partialOptions) {
|
|
22
|
+
super();
|
|
23
|
+
this._animationState = AnimationState.Idle;
|
|
24
|
+
this._onStateChangeAction = new actions_lib_1.Action();
|
|
25
|
+
this._onValueChangeAction = new actions_lib_1.Action();
|
|
26
|
+
this._options = { duration: 500, animation: animations_1.Animations.easeInOutCubic, ...partialOptions };
|
|
27
|
+
this._stateAnimation = new state_animation_1.StateAnimation({
|
|
28
|
+
duration: this._options.duration,
|
|
29
|
+
animation: this._options.animation
|
|
30
|
+
})
|
|
31
|
+
.onStateChange((state, nextState) => this._handleStateChange(state, nextState))
|
|
32
|
+
.onValueChange(value => this._handleValueChange(value))
|
|
33
|
+
.attach(this);
|
|
34
|
+
}
|
|
35
|
+
setIndex(index, options) {
|
|
36
|
+
if (!helpers_lib_1.Comparator.isInteger(index)) {
|
|
37
|
+
throw new Error('SlideStateAnimation: index must be an integer!');
|
|
38
|
+
}
|
|
39
|
+
if (this._index === undefined) {
|
|
40
|
+
this._index = index;
|
|
41
|
+
this._onStateChangeAction.trigger({ state: SlideStateAnimationState.Appear, index });
|
|
42
|
+
this._stateAnimation.setState(index, options);
|
|
43
|
+
}
|
|
44
|
+
else if (this._index !== index) {
|
|
45
|
+
if (this._nextIndex !== index) {
|
|
46
|
+
if (this._animationState === AnimationState.Idle) {
|
|
47
|
+
this._animationState = index > this._index ? AnimationState.TransitionForward : AnimationState.TransitionBackward;
|
|
48
|
+
this._nextIndex = index;
|
|
49
|
+
this._onStateChangeAction.trigger({ state: SlideStateAnimationState.Appear, index: this._nextIndex });
|
|
50
|
+
this._stateAnimation.setState(index, options);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this._stateAnimation.setState(index, options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (this._animationState === AnimationState.Reverting && this._nextIndex === index) {
|
|
57
|
+
this._animationState = index > this._index ? AnimationState.TransitionForward : AnimationState.TransitionBackward;
|
|
58
|
+
this._stateAnimation.setState(index, options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (this._animationState === AnimationState.TransitionForward ||
|
|
62
|
+
this._animationState === AnimationState.TransitionBackward) {
|
|
63
|
+
this._animationState = AnimationState.Reverting;
|
|
64
|
+
this._stateAnimation.setState(index, options);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_handleStateChange(state, nextState) {
|
|
68
|
+
if (this._index !== undefined && this._index !== state && this._index !== nextState) {
|
|
69
|
+
this._onStateChangeAction.trigger({ state: SlideStateAnimationState.Disappear, index: this._index });
|
|
70
|
+
}
|
|
71
|
+
if (this._nextIndex !== undefined && this._nextIndex !== state && this._nextIndex !== nextState) {
|
|
72
|
+
this._onStateChangeAction.trigger({ state: SlideStateAnimationState.Disappear, index: this._nextIndex });
|
|
73
|
+
}
|
|
74
|
+
if (nextState !== undefined && nextState !== this._index && nextState !== this._nextIndex) {
|
|
75
|
+
this._onStateChangeAction.trigger({ state: SlideStateAnimationState.Appear, index: nextState });
|
|
76
|
+
}
|
|
77
|
+
switch (this._animationState) {
|
|
78
|
+
case AnimationState.TransitionForward:
|
|
79
|
+
case AnimationState.TransitionBackward:
|
|
80
|
+
if (nextState === undefined) {
|
|
81
|
+
this._animationState = AnimationState.Idle;
|
|
82
|
+
this._index = this._nextIndex;
|
|
83
|
+
this._nextIndex = undefined;
|
|
84
|
+
}
|
|
85
|
+
else if (this._index !== state) {
|
|
86
|
+
this._handleNewTarget(state, nextState);
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case AnimationState.Reverting:
|
|
90
|
+
if (nextState === undefined) {
|
|
91
|
+
this._animationState = AnimationState.Idle;
|
|
92
|
+
this._nextIndex = undefined;
|
|
93
|
+
}
|
|
94
|
+
else if (this._index !== nextState) {
|
|
95
|
+
this._handleNewTarget(state, nextState);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_handleValueChange(value) {
|
|
101
|
+
let directionMultiplier = 1;
|
|
102
|
+
if (this._animationState === AnimationState.TransitionBackward ||
|
|
103
|
+
(this._animationState === AnimationState.Reverting &&
|
|
104
|
+
this._index !== undefined &&
|
|
105
|
+
this._nextIndex !== undefined &&
|
|
106
|
+
this._index > this._nextIndex)) {
|
|
107
|
+
directionMultiplier = -1;
|
|
108
|
+
}
|
|
109
|
+
if (this._animationState === AnimationState.Idle || value !== 0) {
|
|
110
|
+
this._onValueChangeAction.trigger({
|
|
111
|
+
value: helpers_lib_1.NumberHelper.ensurePositiveZero(-directionMultiplier * value),
|
|
112
|
+
index: this._index
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (this._nextIndex !== undefined) {
|
|
116
|
+
this._onValueChangeAction.trigger({
|
|
117
|
+
value: helpers_lib_1.NumberHelper.ensurePositiveZero(directionMultiplier * (1 - value)),
|
|
118
|
+
index: this._nextIndex
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
_handleNewTarget(state, nextState) {
|
|
123
|
+
this._index = state;
|
|
124
|
+
this._nextIndex = nextState;
|
|
125
|
+
this._onValueChangeAction.trigger({ value: 0, index: this._index });
|
|
126
|
+
this._animationState = this._index < this._nextIndex ? AnimationState.TransitionForward : AnimationState.TransitionBackward;
|
|
127
|
+
}
|
|
128
|
+
onStateChange(callback) {
|
|
129
|
+
this._onStateChangeAction.subscribe(value => callback(value.state, value.index)).attach(this);
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
onValueChange(callback) {
|
|
133
|
+
this._onValueChangeAction.subscribe(value => callback(value.value, value.index)).attach(this);
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.SlideStateAnimation = SlideStateAnimation;
|
|
138
|
+
//# sourceMappingURL=slide-state-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const game_entities_1 = require("../../../../game-entities");
|
|
5
|
+
const animations_1 = require("../../animations");
|
|
6
|
+
const slide_state_animation_1 = require("./slide-state-animation");
|
|
7
|
+
var AnimationState;
|
|
8
|
+
(function (AnimationState) {
|
|
9
|
+
AnimationState[AnimationState["Idle"] = 1] = "Idle";
|
|
10
|
+
AnimationState[AnimationState["Transitioning"] = 2] = "Transitioning";
|
|
11
|
+
AnimationState[AnimationState["Rreverting"] = 3] = "Rreverting";
|
|
12
|
+
})(AnimationState || (AnimationState = {}));
|
|
13
|
+
(0, vitest_1.describe)('SlideStateAnimation', () => {
|
|
14
|
+
let stateAnimation;
|
|
15
|
+
let heap = [];
|
|
16
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
17
|
+
if (stateAnimation) {
|
|
18
|
+
stateAnimation.destroy();
|
|
19
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
20
|
+
}
|
|
21
|
+
heap = [];
|
|
22
|
+
stateAnimation = new slide_state_animation_1.SlideStateAnimation({ duration: 4, animation: animations_1.Animations.lineer })
|
|
23
|
+
.onStateChange((state, index) => heap.push({ state, index }))
|
|
24
|
+
.onValueChange((value, index) => heap.push({ value, index }))
|
|
25
|
+
.attachToRoot();
|
|
26
|
+
});
|
|
27
|
+
(0, vitest_1.describe)('Creation', () => {
|
|
28
|
+
(0, vitest_1.test)('initial values', () => {
|
|
29
|
+
(0, vitest_1.expect)(stateAnimation).toBeDefined();
|
|
30
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
31
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
32
|
+
});
|
|
33
|
+
(0, vitest_1.test)('initial state default', () => {
|
|
34
|
+
stateAnimation.setIndex(0);
|
|
35
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
36
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 0 },
|
|
37
|
+
{ value: 0, index: 0 }
|
|
38
|
+
]);
|
|
39
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
40
|
+
});
|
|
41
|
+
(0, vitest_1.test)('initial state instant', () => {
|
|
42
|
+
stateAnimation.setIndex(0, { instant: true });
|
|
43
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
44
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 0 },
|
|
45
|
+
{ value: 0, index: 0 }
|
|
46
|
+
]);
|
|
47
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.test)('setting same index', () => {
|
|
50
|
+
stateAnimation.setIndex(0);
|
|
51
|
+
heap = [];
|
|
52
|
+
stateAnimation.setIndex(0);
|
|
53
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
54
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
(0, vitest_1.describe)('Slide Next', () => {
|
|
58
|
+
(0, vitest_1.beforeEach)(() => {
|
|
59
|
+
stateAnimation.setIndex(0);
|
|
60
|
+
heap = [];
|
|
61
|
+
stateAnimation.setIndex(1);
|
|
62
|
+
});
|
|
63
|
+
(0, vitest_1.test)('initial state', () => {
|
|
64
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
65
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 1 },
|
|
66
|
+
{ value: 1, index: 1 }
|
|
67
|
+
]);
|
|
68
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
69
|
+
});
|
|
70
|
+
(0, vitest_1.test)('during the animation', async () => {
|
|
71
|
+
heap = [];
|
|
72
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
73
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
74
|
+
{ value: -0.25, index: 0 },
|
|
75
|
+
{ value: 0.75, index: 1 }
|
|
76
|
+
]);
|
|
77
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.test)('end of the animation', async () => {
|
|
80
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
81
|
+
heap = [];
|
|
82
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
83
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
84
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 0 },
|
|
85
|
+
{ value: 0, index: 1 }
|
|
86
|
+
]);
|
|
87
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
88
|
+
});
|
|
89
|
+
(0, vitest_1.test)('animating again', async () => {
|
|
90
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(4);
|
|
91
|
+
heap = [];
|
|
92
|
+
stateAnimation.setIndex(2);
|
|
93
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
94
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 2 },
|
|
95
|
+
{ value: 1, index: 2 }
|
|
96
|
+
]);
|
|
97
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
98
|
+
});
|
|
99
|
+
(0, vitest_1.test)('setting same index', async () => {
|
|
100
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
101
|
+
heap = [];
|
|
102
|
+
stateAnimation.setIndex(1);
|
|
103
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
104
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.describe)('Slide Previous', () => {
|
|
108
|
+
(0, vitest_1.beforeEach)(() => {
|
|
109
|
+
stateAnimation.setIndex(1);
|
|
110
|
+
heap = [];
|
|
111
|
+
stateAnimation.setIndex(0);
|
|
112
|
+
});
|
|
113
|
+
(0, vitest_1.test)('initial state', () => {
|
|
114
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
115
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 0 },
|
|
116
|
+
{ value: -1, index: 0 }
|
|
117
|
+
]);
|
|
118
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
119
|
+
});
|
|
120
|
+
(0, vitest_1.test)('during the animation', async () => {
|
|
121
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
122
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
123
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 0 },
|
|
124
|
+
{ value: -1, index: 0 },
|
|
125
|
+
{ value: 0.25, index: 1 },
|
|
126
|
+
{ value: -0.75, index: 0 }
|
|
127
|
+
]);
|
|
128
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
129
|
+
});
|
|
130
|
+
(0, vitest_1.test)('end of the animation', async () => {
|
|
131
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
132
|
+
heap = [];
|
|
133
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
134
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
135
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 1 },
|
|
136
|
+
{ value: 0, index: 0 }
|
|
137
|
+
]);
|
|
138
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
(0, vitest_1.describe)('Reverting', () => {
|
|
142
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
143
|
+
stateAnimation.setIndex(0);
|
|
144
|
+
});
|
|
145
|
+
(0, vitest_1.test)('forward reverting', async () => {
|
|
146
|
+
stateAnimation.setIndex(1);
|
|
147
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
148
|
+
heap = [];
|
|
149
|
+
stateAnimation.setIndex(0);
|
|
150
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
151
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
152
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
153
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
154
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
155
|
+
{ value: -0.25, index: 0 },
|
|
156
|
+
{ value: 0.75, index: 1 }
|
|
157
|
+
]);
|
|
158
|
+
heap = [];
|
|
159
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
160
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
161
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
162
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 1 },
|
|
163
|
+
{ value: 0, index: 0 }
|
|
164
|
+
]);
|
|
165
|
+
});
|
|
166
|
+
(0, vitest_1.test)('backward reverting', async () => {
|
|
167
|
+
stateAnimation.setIndex(-1);
|
|
168
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
169
|
+
heap = [];
|
|
170
|
+
stateAnimation.setIndex(0);
|
|
171
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
172
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
173
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
174
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
175
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
176
|
+
{ value: 0.25, index: 0 },
|
|
177
|
+
{ value: -0.75, index: -1 }
|
|
178
|
+
]);
|
|
179
|
+
heap = [];
|
|
180
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
181
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
182
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
183
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: -1 },
|
|
184
|
+
{ value: 0, index: 0 }
|
|
185
|
+
]);
|
|
186
|
+
});
|
|
187
|
+
(0, vitest_1.test)('re-reverting', async () => {
|
|
188
|
+
stateAnimation.setIndex(1);
|
|
189
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
190
|
+
heap = [];
|
|
191
|
+
stateAnimation.setIndex(0);
|
|
192
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
193
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
194
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
195
|
+
{ value: -0.25, index: 0 },
|
|
196
|
+
{ value: 0.75, index: 1 }
|
|
197
|
+
]);
|
|
198
|
+
heap = [];
|
|
199
|
+
stateAnimation.setIndex(1);
|
|
200
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
201
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
202
|
+
heap = [];
|
|
203
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
204
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
205
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
206
|
+
{ value: -0.75, index: 0 },
|
|
207
|
+
{ value: 0.25, index: 1 }
|
|
208
|
+
]);
|
|
209
|
+
heap = [];
|
|
210
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
211
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
212
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
213
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 0 },
|
|
214
|
+
{ value: 0, index: 1 }
|
|
215
|
+
]);
|
|
216
|
+
});
|
|
217
|
+
(0, vitest_1.test)('setting same index', async () => {
|
|
218
|
+
stateAnimation.setIndex(1);
|
|
219
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
220
|
+
heap = [];
|
|
221
|
+
stateAnimation.setIndex(0);
|
|
222
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
223
|
+
heap = [];
|
|
224
|
+
stateAnimation.setIndex(0);
|
|
225
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
226
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
(0, vitest_1.describe)('Re-targeting', () => {
|
|
230
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
231
|
+
stateAnimation.setIndex(0);
|
|
232
|
+
stateAnimation.setIndex(2);
|
|
233
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(2);
|
|
234
|
+
heap = [];
|
|
235
|
+
});
|
|
236
|
+
(0, vitest_1.test)('changing target in transitioning', async () => {
|
|
237
|
+
stateAnimation.setIndex(1);
|
|
238
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
239
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
240
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
241
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
242
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
243
|
+
{ value: -0.75, index: 0 },
|
|
244
|
+
{ value: 0.25, index: 2 }
|
|
245
|
+
]);
|
|
246
|
+
heap = [];
|
|
247
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
248
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
249
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
250
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 0 },
|
|
251
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 1 },
|
|
252
|
+
{ value: 0, index: 2 },
|
|
253
|
+
{ value: -1, index: 1 }
|
|
254
|
+
]);
|
|
255
|
+
heap = [];
|
|
256
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
257
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
258
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
259
|
+
{ value: 0.25, index: 2 },
|
|
260
|
+
{ value: -0.75, index: 1 }
|
|
261
|
+
]);
|
|
262
|
+
heap = [];
|
|
263
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
264
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
265
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
266
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 2 },
|
|
267
|
+
{ value: 0, index: 1 }
|
|
268
|
+
]);
|
|
269
|
+
});
|
|
270
|
+
(0, vitest_1.test)('changing target in reverting', async () => {
|
|
271
|
+
stateAnimation.setIndex(0);
|
|
272
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
273
|
+
heap = [];
|
|
274
|
+
stateAnimation.setIndex(1);
|
|
275
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Rreverting);
|
|
276
|
+
(0, vitest_1.expect)(heap).toEqual([]);
|
|
277
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
278
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
279
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
280
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 2 },
|
|
281
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Appear, index: 1 },
|
|
282
|
+
{ value: 0, index: 0 },
|
|
283
|
+
{ value: 1, index: 1 }
|
|
284
|
+
]);
|
|
285
|
+
heap = [];
|
|
286
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
287
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Transitioning);
|
|
288
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
289
|
+
{ value: -0.25, index: 0 },
|
|
290
|
+
{ value: 0.75, index: 1 }
|
|
291
|
+
]);
|
|
292
|
+
heap = [];
|
|
293
|
+
game_entities_1.UpdateCycle.triggerUpdateTick(3);
|
|
294
|
+
(0, vitest_1.expect)(stateAnimation['_stateAnimation']['_animationState']).toBe(AnimationState.Idle);
|
|
295
|
+
(0, vitest_1.expect)(heap).toEqual([
|
|
296
|
+
{ state: slide_state_animation_1.SlideStateAnimationState.Disappear, index: 0 },
|
|
297
|
+
{ value: 0, index: 1 }
|
|
298
|
+
]);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
(0, vitest_1.describe)('Error Cases:', () => {
|
|
302
|
+
(0, vitest_1.test)('index must be an integer', async () => {
|
|
303
|
+
(0, vitest_1.expect)(() => stateAnimation.setIndex(0.25)).toThrowError('SlideStateAnimation: index must be an integer!');
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
//# sourceMappingURL=slide-state-animation.test.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Attachable } from 'actions-lib';
|
|
2
|
+
import { AnimatorAnimation } from '../../animations';
|
|
3
|
+
export interface StateAnimationOptions {
|
|
4
|
+
readonly duration: number;
|
|
5
|
+
readonly animation: AnimatorAnimation;
|
|
6
|
+
}
|
|
7
|
+
declare enum AnimationState {
|
|
8
|
+
Idle = 1,
|
|
9
|
+
Transitioning = 2,
|
|
10
|
+
Reverting = 3
|
|
11
|
+
}
|
|
12
|
+
export declare class StateAnimation<T> extends Attachable {
|
|
13
|
+
private _animator;
|
|
14
|
+
private _options;
|
|
15
|
+
private _animatedObject;
|
|
16
|
+
private _state;
|
|
17
|
+
private _nextState;
|
|
18
|
+
private _queuedState;
|
|
19
|
+
private _animationState;
|
|
20
|
+
get currentState(): {
|
|
21
|
+
value: number;
|
|
22
|
+
state: T | undefined;
|
|
23
|
+
nextState: T | undefined;
|
|
24
|
+
queuedState: T | undefined;
|
|
25
|
+
animationState: AnimationState;
|
|
26
|
+
};
|
|
27
|
+
constructor(partialOptions?: Partial<StateAnimationOptions>);
|
|
28
|
+
setState(state: T, options?: {
|
|
29
|
+
instant?: boolean;
|
|
30
|
+
}): void;
|
|
31
|
+
private _onComplete;
|
|
32
|
+
private _onStateChangeAction;
|
|
33
|
+
private _onValueChangeAction;
|
|
34
|
+
onStateChange(callback: (state: T, nextState?: T) => void): this;
|
|
35
|
+
onValueChange(callback: (value: number) => void): this;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StateAnimation = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const animations_1 = require("../../animations");
|
|
6
|
+
const animator_1 = require("../../animator/animator");
|
|
7
|
+
var AnimationState;
|
|
8
|
+
(function (AnimationState) {
|
|
9
|
+
AnimationState[AnimationState["Idle"] = 1] = "Idle";
|
|
10
|
+
AnimationState[AnimationState["Transitioning"] = 2] = "Transitioning";
|
|
11
|
+
AnimationState[AnimationState["Reverting"] = 3] = "Reverting";
|
|
12
|
+
})(AnimationState || (AnimationState = {}));
|
|
13
|
+
class StateAnimation extends actions_lib_1.Attachable {
|
|
14
|
+
get currentState() {
|
|
15
|
+
return {
|
|
16
|
+
value: this._animatedObject.value,
|
|
17
|
+
state: this._state,
|
|
18
|
+
nextState: this._nextState,
|
|
19
|
+
queuedState: this._queuedState,
|
|
20
|
+
animationState: this._animationState
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
constructor(partialOptions) {
|
|
24
|
+
super();
|
|
25
|
+
this._animatedObject = { value: 0 };
|
|
26
|
+
this._animationState = AnimationState.Idle;
|
|
27
|
+
this._onStateChangeAction = new actions_lib_1.Action();
|
|
28
|
+
this._onValueChangeAction = new actions_lib_1.Action();
|
|
29
|
+
this._options = { duration: 500, animation: animations_1.Animations.lineer, ...partialOptions };
|
|
30
|
+
this._animator = new animator_1.Animator(this._animatedObject, 'value', {
|
|
31
|
+
duration: this._options.duration,
|
|
32
|
+
animation: this._options.animation,
|
|
33
|
+
reAnimateHandling: animator_1.ReAnimateHandlingType.CompletePrevious,
|
|
34
|
+
completionHandling: animator_1.AnimationsCompletionHandlingType.StayInCurrentState
|
|
35
|
+
});
|
|
36
|
+
this._animator.value
|
|
37
|
+
.subscribe(() => {
|
|
38
|
+
if (this._animatedObject.value !== 1 && this._animatedObject.value !== 0) {
|
|
39
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
.attach(this);
|
|
43
|
+
}
|
|
44
|
+
setState(state, options) {
|
|
45
|
+
if (this._state === undefined) {
|
|
46
|
+
this._state = state;
|
|
47
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
48
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
49
|
+
}
|
|
50
|
+
else if (options?.instant) {
|
|
51
|
+
this._animator.completeAnimation();
|
|
52
|
+
this._animationState = AnimationState.Idle;
|
|
53
|
+
this._state = state;
|
|
54
|
+
this._nextState = undefined;
|
|
55
|
+
this._animatedObject.value = 0;
|
|
56
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
57
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
switch (this._animationState) {
|
|
61
|
+
case AnimationState.Idle:
|
|
62
|
+
if (state !== this._state) {
|
|
63
|
+
this._animationState = AnimationState.Transitioning;
|
|
64
|
+
this._nextState = state;
|
|
65
|
+
this._animatedObject.value = 0;
|
|
66
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
67
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
68
|
+
this._animator
|
|
69
|
+
.animate({ value: 1 })
|
|
70
|
+
.tap(() => this._onComplete())
|
|
71
|
+
.attach(this);
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case AnimationState.Transitioning:
|
|
75
|
+
if (state !== this._nextState) {
|
|
76
|
+
if (state === this._state) {
|
|
77
|
+
this._animationState = AnimationState.Reverting;
|
|
78
|
+
this._animator
|
|
79
|
+
.animate({ value: 0 }, { duration: this._animatedObject.value * this._options.duration })
|
|
80
|
+
.tap(() => this._onComplete())
|
|
81
|
+
.attach(this);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this._queuedState = state;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
case AnimationState.Reverting:
|
|
89
|
+
if (state !== this._state) {
|
|
90
|
+
if (state === this._nextState) {
|
|
91
|
+
this._animationState = AnimationState.Transitioning;
|
|
92
|
+
this._animator
|
|
93
|
+
.animate({ value: 1 }, { duration: (1 - this._animatedObject.value) * this._options.duration })
|
|
94
|
+
.tap(() => this._onComplete())
|
|
95
|
+
.attach(this);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this._queuedState = state;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_onComplete() {
|
|
106
|
+
switch (this._animationState) {
|
|
107
|
+
case AnimationState.Transitioning:
|
|
108
|
+
if (this._animatedObject.value === 1) {
|
|
109
|
+
this._animatedObject.value = 0;
|
|
110
|
+
if (this._queuedState !== undefined) {
|
|
111
|
+
this._animationState = AnimationState.Transitioning;
|
|
112
|
+
this._state = this._nextState;
|
|
113
|
+
this._nextState = this._queuedState;
|
|
114
|
+
this._queuedState = undefined;
|
|
115
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
116
|
+
this._animator
|
|
117
|
+
.animate({ value: 1 })
|
|
118
|
+
.tap(() => this._onComplete())
|
|
119
|
+
.attach(this);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this._animationState = AnimationState.Idle;
|
|
123
|
+
this._state = this._nextState;
|
|
124
|
+
this._nextState = undefined;
|
|
125
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
126
|
+
}
|
|
127
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case AnimationState.Reverting:
|
|
131
|
+
if (this._state === undefined) {
|
|
132
|
+
throw new Error('StateAnimation: state must be defined when reverting!');
|
|
133
|
+
}
|
|
134
|
+
if (this._animatedObject.value === 0) {
|
|
135
|
+
if (this._queuedState !== undefined) {
|
|
136
|
+
this._animationState = AnimationState.Transitioning;
|
|
137
|
+
this._nextState = this._queuedState;
|
|
138
|
+
this._queuedState = undefined;
|
|
139
|
+
this._animatedObject.value = 0;
|
|
140
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
141
|
+
this._animator
|
|
142
|
+
.animate({ value: 1 })
|
|
143
|
+
.tap(() => this._onComplete())
|
|
144
|
+
.attach(this);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
this._animationState = AnimationState.Idle;
|
|
148
|
+
this._nextState = undefined;
|
|
149
|
+
this._animatedObject.value = 0;
|
|
150
|
+
this._onStateChangeAction.trigger({ state: this._state, nextState: this._nextState });
|
|
151
|
+
}
|
|
152
|
+
this._onValueChangeAction.trigger(this._animatedObject.value);
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
case AnimationState.Idle:
|
|
156
|
+
// Do nothing
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
onStateChange(callback) {
|
|
161
|
+
this._onStateChangeAction.subscribe(value => callback(value.state, value.nextState)).attach(this);
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
onValueChange(callback) {
|
|
165
|
+
this._onValueChangeAction.subscribe(value => callback(value)).attach(this);
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.StateAnimation = StateAnimation;
|
|
170
|
+
//# sourceMappingURL=state-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|