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
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Animator = exports.CompleteAnimationsHandlingType = exports.ReAnimateHandlingType = void 0;
|
|
4
|
+
const actions_lib_1 = require("actions-lib");
|
|
5
|
+
const helpers_lib_1 = require("helpers-lib");
|
|
6
|
+
const update_cycle_1 = require("../../game-entities/update-cycle");
|
|
7
|
+
const animations_1 = require("./animations");
|
|
8
|
+
var ReAnimateHandlingType;
|
|
9
|
+
(function (ReAnimateHandlingType) {
|
|
10
|
+
ReAnimateHandlingType["throwError"] = "throwError";
|
|
11
|
+
ReAnimateHandlingType["ignoreNewAnimation"] = "ignoreNewAnimation";
|
|
12
|
+
ReAnimateHandlingType["completePrevious"] = "completePrevious";
|
|
13
|
+
})(ReAnimateHandlingType || (exports.ReAnimateHandlingType = ReAnimateHandlingType = {}));
|
|
14
|
+
var CompleteAnimationsHandlingType;
|
|
15
|
+
(function (CompleteAnimationsHandlingType) {
|
|
16
|
+
CompleteAnimationsHandlingType["returnToOriginal"] = "returnToOriginal";
|
|
17
|
+
CompleteAnimationsHandlingType["stayInCurrentState"] = "stayInCurrentState";
|
|
18
|
+
CompleteAnimationsHandlingType["jumpToEnd"] = "jumpToEnd";
|
|
19
|
+
})(CompleteAnimationsHandlingType || (exports.CompleteAnimationsHandlingType = CompleteAnimationsHandlingType = {}));
|
|
20
|
+
const DEFAULT_DURATION = 200;
|
|
21
|
+
const DEFAULT_ANIMATION = new animations_1.AnimationLineer();
|
|
22
|
+
const DEFAULT_LOOP = false;
|
|
23
|
+
const DEFAULT_RE_ANIMATE_HANDLING = ReAnimateHandlingType.throwError;
|
|
24
|
+
const DEFAULT_COMPLETE_ANIMATIONS_HANDLING = CompleteAnimationsHandlingType.stayInCurrentState;
|
|
25
|
+
class Animator extends actions_lib_1.Attachable {
|
|
26
|
+
static { this.animatedObjects = new Map(); }
|
|
27
|
+
get isAnimating() {
|
|
28
|
+
return this.propertyStates.size > 0;
|
|
29
|
+
}
|
|
30
|
+
constructor(target, effectOn, options = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.target = target;
|
|
33
|
+
this.effectOn = new Set();
|
|
34
|
+
this.running = true;
|
|
35
|
+
this.propertyStates = new Map();
|
|
36
|
+
this.allResolvers = new Set();
|
|
37
|
+
if (!helpers_lib_1.Comparator.isObject(target)) {
|
|
38
|
+
this.attachToRoot();
|
|
39
|
+
throw new Error(`Animator: target is not an object! Target: "${target}"`);
|
|
40
|
+
}
|
|
41
|
+
this.effectOn = helpers_lib_1.Comparator.isArray(effectOn) ? new Set(effectOn) : new Set([effectOn]);
|
|
42
|
+
let animatedObjectProperties = Animator.animatedObjects.get(target);
|
|
43
|
+
if (!animatedObjectProperties) {
|
|
44
|
+
animatedObjectProperties = new Set();
|
|
45
|
+
Animator.animatedObjects.set(target, animatedObjectProperties);
|
|
46
|
+
}
|
|
47
|
+
this.effectOn.forEach(key => {
|
|
48
|
+
if (animatedObjectProperties.has(key)) {
|
|
49
|
+
this.attachToRoot();
|
|
50
|
+
throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(target, undefined, 2)}", Property: "${key}"`);
|
|
51
|
+
}
|
|
52
|
+
animatedObjectProperties.add(key);
|
|
53
|
+
});
|
|
54
|
+
this.defaultDuration = options.duration ?? DEFAULT_DURATION;
|
|
55
|
+
this.defaultAnimation = options.animation ?? DEFAULT_ANIMATION;
|
|
56
|
+
this.defaultLoop = options.loop ?? DEFAULT_LOOP;
|
|
57
|
+
this.defaultReAnimateHandling = options.reAnimateHandling ?? DEFAULT_RE_ANIMATE_HANDLING;
|
|
58
|
+
this.defaultCompleteAnimationsHandling = options.completeAnimationsHandling ?? DEFAULT_COMPLETE_ANIMATIONS_HANDLING;
|
|
59
|
+
this.effectOn.forEach(key => {
|
|
60
|
+
if (!helpers_lib_1.Comparator.hasProperty(target, key)) {
|
|
61
|
+
this.attachToRoot();
|
|
62
|
+
throw new Error(`Animator: target does not have property. Target property: "${key}"`);
|
|
63
|
+
}
|
|
64
|
+
else if (!helpers_lib_1.Comparator.isNumber(target[key])) {
|
|
65
|
+
this.attachToRoot();
|
|
66
|
+
throw new Error(`Animator: target property is not a number. Target property: "${key}"`);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
onChange(callback) {
|
|
71
|
+
if (this.onChangeCallback) {
|
|
72
|
+
this.attachToRoot();
|
|
73
|
+
throw new Error('Animator: onChangeCallback is already set!');
|
|
74
|
+
}
|
|
75
|
+
this.onChangeCallback = callback;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
onComplete(callback) {
|
|
79
|
+
if (this.onCompleteCallback) {
|
|
80
|
+
this.attachToRoot();
|
|
81
|
+
throw new Error('Animator: onCompleteCallback is already set!');
|
|
82
|
+
}
|
|
83
|
+
this.onCompleteCallback = callback;
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
destroy() {
|
|
87
|
+
if (!this.destroyed) {
|
|
88
|
+
this.onChangeCallback = undefined;
|
|
89
|
+
this.onCompleteCallback = undefined;
|
|
90
|
+
this.defaultAnimation = DEFAULT_ANIMATION;
|
|
91
|
+
this.propertyStates.clear();
|
|
92
|
+
let animatedObjectProperties = Animator.animatedObjects.get(this.target);
|
|
93
|
+
this.effectOn.forEach(key => animatedObjectProperties.delete(key));
|
|
94
|
+
if (animatedObjectProperties.size <= 0) {
|
|
95
|
+
Animator.animatedObjects.delete(this.target);
|
|
96
|
+
}
|
|
97
|
+
this.target = undefined;
|
|
98
|
+
this.allResolvers.forEach(resolver => resolver());
|
|
99
|
+
this.allResolvers.clear();
|
|
100
|
+
super.destroy();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
getAnimationStateOfKey(key) {
|
|
104
|
+
let propertyState = this.propertyStates.get(key);
|
|
105
|
+
if (propertyState) {
|
|
106
|
+
return {
|
|
107
|
+
duration: propertyState.duration,
|
|
108
|
+
elapsedTime: propertyState.elapsedTime,
|
|
109
|
+
startingValue: propertyState.startingValue,
|
|
110
|
+
targetValue: propertyState.targetValue,
|
|
111
|
+
loop: propertyState.loop,
|
|
112
|
+
completeAnimationsHandling: propertyState.completeAnimationsHandling
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
pauseAnimations() {
|
|
117
|
+
this.running = false;
|
|
118
|
+
}
|
|
119
|
+
resumeAnimations() {
|
|
120
|
+
this.running = true;
|
|
121
|
+
}
|
|
122
|
+
completeAnimations(completeAnimationsHandling) {
|
|
123
|
+
let triggerOnChange = false;
|
|
124
|
+
this.propertyStates.forEach((value, key) => {
|
|
125
|
+
let completeAnimationsHandlingFinal = completeAnimationsHandling ?? value.completeAnimationsHandling;
|
|
126
|
+
if (completeAnimationsHandlingFinal === CompleteAnimationsHandlingType.returnToOriginal) {
|
|
127
|
+
if (this.target[key] !== value.startingValue) {
|
|
128
|
+
triggerOnChange = true;
|
|
129
|
+
this.target[key] = value.startingValue;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (completeAnimationsHandlingFinal === CompleteAnimationsHandlingType.jumpToEnd) {
|
|
133
|
+
if (this.target[key] !== value.targetValue) {
|
|
134
|
+
triggerOnChange = true;
|
|
135
|
+
this.target[key] = value.targetValue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
this.completeAnimationOfProperty(value);
|
|
139
|
+
});
|
|
140
|
+
triggerOnChange && this.triggerOnChange();
|
|
141
|
+
}
|
|
142
|
+
set(values) {
|
|
143
|
+
Object.keys(values).forEach(key => {
|
|
144
|
+
this.checkPropertyValidity(key);
|
|
145
|
+
});
|
|
146
|
+
this.checkOngoingAnimations(values);
|
|
147
|
+
let triggerOnChange = false;
|
|
148
|
+
Object.keys(values).forEach(key => {
|
|
149
|
+
triggerOnChange = triggerOnChange || this.target[key] !== values[key];
|
|
150
|
+
this.target[key] = values[key];
|
|
151
|
+
});
|
|
152
|
+
triggerOnChange && this.triggerOnChange();
|
|
153
|
+
}
|
|
154
|
+
async animate(values, options = {}) {
|
|
155
|
+
if (this.destroyed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let valueKeys = Object.keys(values);
|
|
159
|
+
valueKeys.forEach(key => {
|
|
160
|
+
this.checkPropertyValidity(key);
|
|
161
|
+
});
|
|
162
|
+
this.checkOngoingAnimations(values, options.reAnimateHandling);
|
|
163
|
+
return new Promise(resolveAll => {
|
|
164
|
+
this.allResolvers.add(resolveAll);
|
|
165
|
+
Promise.all(Object.keys(values).map(key => new Promise(resolve => {
|
|
166
|
+
let duration = options.duration ?? this.defaultDuration;
|
|
167
|
+
let animation = options.animation ?? this.defaultAnimation;
|
|
168
|
+
let loop = options.loop ?? this.defaultLoop;
|
|
169
|
+
let completeAnimationsHandling = options.completeAnimationsHandling ?? this.defaultCompleteAnimationsHandling;
|
|
170
|
+
let startingValue = this.target[key];
|
|
171
|
+
let targetValue = values[key];
|
|
172
|
+
if (startingValue === targetValue && !loop) {
|
|
173
|
+
resolve(undefined);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
animation.start();
|
|
177
|
+
try {
|
|
178
|
+
this.propertyStates.set(key, {
|
|
179
|
+
propertyName: key,
|
|
180
|
+
duration,
|
|
181
|
+
animation,
|
|
182
|
+
elapsedTime: 0,
|
|
183
|
+
startingValue,
|
|
184
|
+
targetValue,
|
|
185
|
+
loop,
|
|
186
|
+
completeAnimationsHandling,
|
|
187
|
+
completionCallback: () => {
|
|
188
|
+
resolve(undefined);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
resolveAll();
|
|
194
|
+
this.allResolvers.delete(resolveAll);
|
|
195
|
+
}
|
|
196
|
+
}))).then(() => {
|
|
197
|
+
resolveAll();
|
|
198
|
+
this.allResolvers.delete(resolveAll);
|
|
199
|
+
});
|
|
200
|
+
this.subscribeUpdateCycle();
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
completeAnimationOfProperty(propertyState) {
|
|
204
|
+
let currentState = this.target[propertyState.propertyName];
|
|
205
|
+
this.propertyStates.delete(propertyState.propertyName);
|
|
206
|
+
try {
|
|
207
|
+
propertyState.completionCallback();
|
|
208
|
+
this.onCompleteCallback?.(propertyState.propertyName, currentState);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
console.error('Animator:', e);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
checkOngoingAnimations(values, reAnimateHandling) {
|
|
215
|
+
reAnimateHandling = reAnimateHandling ?? this.defaultReAnimateHandling;
|
|
216
|
+
Object.keys(values).forEach(key => {
|
|
217
|
+
let previousState = this.propertyStates.get(key);
|
|
218
|
+
if (previousState) {
|
|
219
|
+
if (reAnimateHandling === ReAnimateHandlingType.throwError) {
|
|
220
|
+
this.attachToRoot();
|
|
221
|
+
throw new Error(`Animator: property is already being animated. Property: "${key}"`);
|
|
222
|
+
}
|
|
223
|
+
else if (reAnimateHandling === ReAnimateHandlingType.ignoreNewAnimation) {
|
|
224
|
+
delete values[key];
|
|
225
|
+
}
|
|
226
|
+
else if (reAnimateHandling === ReAnimateHandlingType.completePrevious) {
|
|
227
|
+
this.completeAnimationOfProperty(previousState);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
update(delta) {
|
|
233
|
+
if (this.running && !this.destroyed) {
|
|
234
|
+
let triggerOnChange = this.propertyStates.size;
|
|
235
|
+
let propertyStatesToComplete = [];
|
|
236
|
+
this.propertyStates.forEach((value, key) => {
|
|
237
|
+
value.elapsedTime += delta;
|
|
238
|
+
let animationIsCompete = value.elapsedTime >= value.duration;
|
|
239
|
+
if (animationIsCompete) {
|
|
240
|
+
if (value.loop) {
|
|
241
|
+
value.animation.start();
|
|
242
|
+
value.elapsedTime -= value.duration;
|
|
243
|
+
animationIsCompete = false;
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
if (value.completeAnimationsHandling === CompleteAnimationsHandlingType.returnToOriginal) {
|
|
247
|
+
this.target[key] = value.startingValue;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
this.target[key] = value.targetValue;
|
|
251
|
+
}
|
|
252
|
+
// Do not complete inside the forEach loop, completion can start a new animation which will put forEach into infinite loop
|
|
253
|
+
propertyStatesToComplete.push(value);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (!animationIsCompete) {
|
|
257
|
+
let multiplier = value.animation.multiplierFunction(value.elapsedTime / value.duration);
|
|
258
|
+
let relativeTarget = value.targetValue - value.startingValue;
|
|
259
|
+
this.target[key] = relativeTarget * multiplier + value.startingValue;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
propertyStatesToComplete.forEach(value => {
|
|
263
|
+
this.completeAnimationOfProperty(value);
|
|
264
|
+
});
|
|
265
|
+
triggerOnChange && this.triggerOnChange();
|
|
266
|
+
if (this.propertyStates.size <= 0) {
|
|
267
|
+
this.unsubscribeUpdateCycle();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
subscribeUpdateCycle() {
|
|
272
|
+
if (!this.updateCycleSubscription && !this.destroyed) {
|
|
273
|
+
this.updateCycleSubscription = update_cycle_1.UpdateCycle.beforeSceneUpdateAction
|
|
274
|
+
.subscribe(update => {
|
|
275
|
+
try {
|
|
276
|
+
this.update(update.delta);
|
|
277
|
+
}
|
|
278
|
+
catch (e) {
|
|
279
|
+
console.error('Animator:', e);
|
|
280
|
+
this.propertyStates.forEach(value => {
|
|
281
|
+
try {
|
|
282
|
+
value.completionCallback();
|
|
283
|
+
}
|
|
284
|
+
catch (err) {
|
|
285
|
+
console.error('Animator:', err);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
this.propertyStates = new Map();
|
|
289
|
+
this.unsubscribeUpdateCycle();
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
.attachToRoot();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
unsubscribeUpdateCycle() {
|
|
296
|
+
this.updateCycleSubscription?.destroy();
|
|
297
|
+
this.updateCycleSubscription = undefined;
|
|
298
|
+
}
|
|
299
|
+
checkPropertyValidity(key) {
|
|
300
|
+
if (!this.effectOn.has(key)) {
|
|
301
|
+
this.attachToRoot();
|
|
302
|
+
throw new Error(`Animator: not effected property is tried to update. Key: "${key}", EffectOn: "${this.effectOn}"`);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
triggerOnChange() {
|
|
306
|
+
try {
|
|
307
|
+
this.onChangeCallback?.(this.target);
|
|
308
|
+
}
|
|
309
|
+
catch (e) {
|
|
310
|
+
console.error('Animator:', e);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.Animator = Animator;
|
|
315
|
+
//# sourceMappingURL=animator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|