@urso/core 0.4.44 → 0.4.45

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.
Files changed (153) hide show
  1. package/.babelrc +11 -11
  2. package/LICENSE +20 -20
  3. package/README.md +220 -220
  4. package/build/js/index.js +1 -1
  5. package/build/js/index.js.LICENSE.txt +32 -32
  6. package/package.json +51 -51
  7. package/src/js/app.js +78 -78
  8. package/src/js/components/_info.js +10 -10
  9. package/src/js/components/base/_info.js +3 -3
  10. package/src/js/components/base/controller.js +78 -78
  11. package/src/js/components/debug/_info.js +7 -7
  12. package/src/js/components/debug/controller.js +38 -38
  13. package/src/js/components/debug/coords.js +23 -23
  14. package/src/js/components/debug/fps.js +34 -34
  15. package/src/js/components/debug/template.js +55 -55
  16. package/src/js/components/debug/timescale.js +60 -60
  17. package/src/js/components/deviceRotate/_info.js +3 -3
  18. package/src/js/components/deviceRotate/controller.js +86 -86
  19. package/src/js/components/fullscreen/_info.js +6 -6
  20. package/src/js/components/fullscreen/android.js +104 -104
  21. package/src/js/components/fullscreen/controller.js +76 -76
  22. package/src/js/components/fullscreen/desktop.js +49 -49
  23. package/src/js/components/fullscreen/ios.js +115 -115
  24. package/src/js/components/layersSwitcher/_info.js +4 -4
  25. package/src/js/components/layersSwitcher/config.js +26 -26
  26. package/src/js/components/layersSwitcher/controller.js +34 -34
  27. package/src/js/components/loader/_info.js +4 -4
  28. package/src/js/components/loader/controller.js +66 -66
  29. package/src/js/components/loader/template.js +70 -70
  30. package/src/js/components/soundInitialPopup/_info.js +3 -3
  31. package/src/js/components/soundInitialPopup/controller.js +42 -42
  32. package/src/js/components/soundInitialPopup/template.js +109 -109
  33. package/src/js/components/stateDriven/_info.js +3 -3
  34. package/src/js/components/stateDriven/controller.js +118 -118
  35. package/src/js/config/load.js +5 -5
  36. package/src/js/config/main.js +10 -10
  37. package/src/js/extra/_info.js +24 -24
  38. package/src/js/extra/browserEvents.js +38 -38
  39. package/src/js/extra/pixiPatch.js +79 -79
  40. package/src/js/extra/setTimeout.js +7 -7
  41. package/src/js/index.js +8 -8
  42. package/src/js/lib/_info.js +13 -13
  43. package/src/js/lib/cache.js +105 -105
  44. package/src/js/lib/composition.js +85 -85
  45. package/src/js/lib/device.js +1286 -1286
  46. package/src/js/lib/helper.js +539 -539
  47. package/src/js/lib/loader.js +131 -131
  48. package/src/js/lib/localData.js +15 -15
  49. package/src/js/lib/logger.js +22 -22
  50. package/src/js/lib/math.js +35 -35
  51. package/src/js/lib/objectPool.js +54 -54
  52. package/src/js/lib/time.js +18 -18
  53. package/src/js/lib/tween.js +147 -147
  54. package/src/js/modules/_info.js +12 -12
  55. package/src/js/modules/assets/_info.js +7 -7
  56. package/src/js/modules/assets/baseModel.js +18 -18
  57. package/src/js/modules/assets/config.js +37 -37
  58. package/src/js/modules/assets/controller.js +46 -46
  59. package/src/js/modules/assets/models/_info.js +11 -11
  60. package/src/js/modules/assets/models/atlas.js +8 -8
  61. package/src/js/modules/assets/models/audiosprite.js +27 -27
  62. package/src/js/modules/assets/models/bitmapFont.js +8 -8
  63. package/src/js/modules/assets/models/container.js +16 -16
  64. package/src/js/modules/assets/models/font.js +8 -8
  65. package/src/js/modules/assets/models/image.js +13 -13
  66. package/src/js/modules/assets/models/json.js +8 -8
  67. package/src/js/modules/assets/models/sound.js +14 -14
  68. package/src/js/modules/assets/models/spine.js +14 -14
  69. package/src/js/modules/assets/service.js +365 -365
  70. package/src/js/modules/i18n/_info.js +4 -4
  71. package/src/js/modules/i18n/config.js +17 -17
  72. package/src/js/modules/i18n/controller.js +79 -79
  73. package/src/js/modules/instances/_info.js +3 -3
  74. package/src/js/modules/instances/controller.js +261 -261
  75. package/src/js/modules/logic/_info.js +4 -4
  76. package/src/js/modules/logic/config/_info.js +2 -2
  77. package/src/js/modules/logic/config/sounds.js +23 -23
  78. package/src/js/modules/logic/controller.js +48 -48
  79. package/src/js/modules/logic/sounds.js +103 -103
  80. package/src/js/modules/objects/_info.js +11 -11
  81. package/src/js/modules/objects/baseModel.js +197 -197
  82. package/src/js/modules/objects/cache.js +99 -99
  83. package/src/js/modules/objects/controller.js +131 -131
  84. package/src/js/modules/objects/create.js +237 -237
  85. package/src/js/modules/objects/find.js +140 -140
  86. package/src/js/modules/objects/models/_info.js +25 -25
  87. package/src/js/modules/objects/models/atlasImage.js +50 -50
  88. package/src/js/modules/objects/models/bitmapText.js +39 -39
  89. package/src/js/modules/objects/models/button.js +189 -189
  90. package/src/js/modules/objects/models/buttonComposite.js +35 -35
  91. package/src/js/modules/objects/models/checkbox.js +96 -96
  92. package/src/js/modules/objects/models/collection.js +54 -54
  93. package/src/js/modules/objects/models/component.js +44 -44
  94. package/src/js/modules/objects/models/container.js +19 -19
  95. package/src/js/modules/objects/models/emitter.js +54 -54
  96. package/src/js/modules/objects/models/graphics.js +38 -38
  97. package/src/js/modules/objects/models/group.js +19 -19
  98. package/src/js/modules/objects/models/hitArea.js +104 -104
  99. package/src/js/modules/objects/models/image.js +34 -34
  100. package/src/js/modules/objects/models/imagesAnimation.js +113 -113
  101. package/src/js/modules/objects/models/mask.js +38 -38
  102. package/src/js/modules/objects/models/nineSlicePlane.js +30 -30
  103. package/src/js/modules/objects/models/scrollbox.js +61 -61
  104. package/src/js/modules/objects/models/slider.js +253 -253
  105. package/src/js/modules/objects/models/spine.js +271 -275
  106. package/src/js/modules/objects/models/text.js +59 -59
  107. package/src/js/modules/objects/models/textInput.js +66 -66
  108. package/src/js/modules/objects/models/toggle.js +180 -180
  109. package/src/js/modules/objects/models/world.js +19 -19
  110. package/src/js/modules/objects/propertyAdapter.js +422 -422
  111. package/src/js/modules/objects/proxy.js +282 -282
  112. package/src/js/modules/objects/styles.js +120 -120
  113. package/src/js/modules/observer/_info.js +4 -4
  114. package/src/js/modules/observer/controller.js +99 -99
  115. package/src/js/modules/observer/events.js +44 -44
  116. package/src/js/modules/scenes/_info.js +8 -8
  117. package/src/js/modules/scenes/controller.js +103 -103
  118. package/src/js/modules/scenes/model.js +28 -28
  119. package/src/js/modules/scenes/pixiWrapper.js +237 -237
  120. package/src/js/modules/scenes/resolutions.js +173 -173
  121. package/src/js/modules/scenes/resolutionsConfig.js +73 -73
  122. package/src/js/modules/scenes/service.js +139 -139
  123. package/src/js/modules/soundManager/_info.js +3 -3
  124. package/src/js/modules/soundManager/controller.js +100 -100
  125. package/src/js/modules/soundManager/soundSprite.js +243 -243
  126. package/src/js/modules/statesManager/_info.js +12 -12
  127. package/src/js/modules/statesManager/action.js +60 -60
  128. package/src/js/modules/statesManager/actions/_info.js +3 -3
  129. package/src/js/modules/statesManager/all.js +23 -23
  130. package/src/js/modules/statesManager/configStates.js +71 -71
  131. package/src/js/modules/statesManager/controller.js +170 -170
  132. package/src/js/modules/statesManager/functionsStorage.js +82 -82
  133. package/src/js/modules/statesManager/helper.js +27 -27
  134. package/src/js/modules/statesManager/race.js +75 -75
  135. package/src/js/modules/statesManager/sequence.js +47 -47
  136. package/src/js/modules/template/_info.js +6 -6
  137. package/src/js/modules/template/controller.js +28 -28
  138. package/src/js/modules/template/model.js +11 -11
  139. package/src/js/modules/template/service.js +137 -137
  140. package/src/js/modules/template/types.js +45 -45
  141. package/src/js/modules/transport/_info.js +8 -8
  142. package/src/js/modules/transport/baseConnectionType.js +24 -24
  143. package/src/js/modules/transport/config.js +13 -13
  144. package/src/js/modules/transport/connectionTypes/_info.js +3 -3
  145. package/src/js/modules/transport/connectionTypes/websocket.js +74 -74
  146. package/src/js/modules/transport/connectionTypes/xhr.js +44 -44
  147. package/src/js/modules/transport/controller.js +48 -48
  148. package/src/js/modules/transport/decorator.js +17 -17
  149. package/src/js/modules/transport/service.js +153 -153
  150. package/src/js/templates/_info.js +4 -4
  151. package/src/js/templates/groups/_info.js +1 -1
  152. package/src/js/templates/scenes/_info.js +1 -1
  153. package/webpack.config.js +47 -47
@@ -1,244 +1,244 @@
1
- class SoundSprite {
2
- constructor({ name, sprite, audiosprite }) {
3
- this._player = null;
4
- this._totalVolume = 0;
5
- this._makePlayer(sprite, audiosprite);
6
-
7
- this._name = name;
8
- this._sprite = sprite;
9
-
10
- this._soundsState = this._initSoundsState();
11
-
12
- this._eventsCfg = {};
13
- this._fadeTweens = {};
14
- this._eventsQueue = [];
15
- this._isAudioUnlocked = false;
16
-
17
- this._reactToEvent = this._reactToEvent.bind(this);
18
- };
19
-
20
-
21
- _initSoundsState() {
22
- const soundsNames = Object.keys(this._sprite);
23
- const soundsStateObj = {};
24
-
25
- soundsNames.forEach(soundName => {
26
- soundsStateObj[soundName] = {
27
- id: null,
28
- loop: false,
29
- volume: 1,
30
- relaunch: false
31
- }
32
- });
33
-
34
- return soundsStateObj;
35
- }
36
-
37
- _makePlayer(sprite, audiosprite) {
38
- var reader = new FileReader();
39
- reader.readAsDataURL(audiosprite);
40
- reader.onloadend = () => {
41
- var base64data = reader.result;
42
- this._player = new Howl({
43
- src: base64data,
44
- sprite
45
- });
46
- this._subscribePlayerEvents();
47
- }
48
- };
49
-
50
- _subscribePlayerEvents() {
51
- this._player.on('unlock', () => setTimeout(() => {
52
- this._isAudioUnlocked = true;
53
- this._onUnlock();
54
- }, 1000));
55
-
56
- this._player.on('end', id => {
57
- const soundState = this._getSoundStateById(id);
58
-
59
- if (!soundState)
60
- return Urso.logger.error(`SoundSprite error: soundState for id '${id}' not found!`);
61
-
62
- if (!soundState.loop)
63
- soundState.id = null;
64
- });
65
- };
66
-
67
- _getSoundStateById(id) {
68
- for (const [name, state] of Object.entries(this._soundsState)) {
69
- if (state.id === id) {
70
- return {
71
- id: { ...state, name }
72
- }
73
- }
74
- }
75
- }
76
-
77
- canPlayCheck() {
78
- return this._isAudioUnlocked;
79
- };
80
-
81
- play({ loop = false, volume = this._volume, relaunch = false, soundKey }) {
82
- if (!this.canPlayCheck() || (this._soundsState[soundKey].id !== null && !relaunch))
83
- return false;
84
-
85
- this.stop({ soundKey });
86
-
87
- this._soundsState[soundKey].id = this._player.play(soundKey);
88
-
89
- this.setRelaunch(soundKey, relaunch);
90
- this.setLoop(soundKey, loop);
91
- this.setVolume(soundKey, volume);
92
-
93
- return true;
94
- };
95
-
96
- setLoop(soundKey, loop = false) {
97
- this._soundsState[soundKey].loop = loop;
98
- this._player.loop(loop, this._soundsState[soundKey].id);
99
- };
100
-
101
- setVolume(soundKey, volume = 1, saveVolumeState = true) {
102
- this._player.volume(volume, this._soundsState[soundKey].id);
103
-
104
- if(saveVolumeState) {
105
- this._soundsState[soundKey].volume = volume;
106
- }
107
- };
108
-
109
- setAllVolume(volume) {
110
- this._totalVolume = volume;
111
- this._player._volume = volume;
112
-
113
- if (this.canPlayCheck()) {
114
- this._updateVolume();
115
- }
116
- }
117
-
118
- _updateVolume() {
119
- const soundKeys = Object.keys(this._soundsState);
120
- this._player._volume = this._totalVolume;
121
- soundKeys.forEach(soundKey => {
122
- const soundVolume = this._soundsState[soundKey].volume * this._totalVolume;
123
- this.setVolume(soundKey, soundVolume, false);
124
- });
125
- }
126
-
127
- setRelaunch(soundKey, needRelaunch = false) {
128
- this._soundsState[soundKey].relaunch = needRelaunch;
129
- };
130
-
131
- stop({ soundKey }) {
132
- if (!this._soundsState[soundKey].id)
133
- return;
134
-
135
- this._player.stop(this._soundsState[soundKey].id);
136
- this._soundsState[soundKey].id = null;
137
- };
138
-
139
- pause({ soundKey }) {
140
- if (this.canPlayCheck() || this._player.playing(this._soundsState[soundKey].id))
141
- this._player.pause(this._soundsState[soundKey].id);
142
- };
143
-
144
- resume({ soundKey }) {
145
- if (this.canPlayCheck() && !this._player.playing(this._soundsState[soundKey].id))
146
- this._player.play(this._soundsState[soundKey].id);
147
- };
148
-
149
- updateEvents(eventsCfg) {
150
- this._customUnsubscribe();
151
- this._saveEvents(eventsCfg);
152
- this._customSubscribe();
153
- };
154
-
155
- _stopPrevFade(soundKey) {
156
- if(this._fadeTweens[soundKey]) {
157
- this._fadeTweens[soundKey].kill();
158
- }
159
-
160
- delete this._fadeTweens[soundKey];
161
- }
162
-
163
- _startFade({ fadeTo, fadeDuration, soundKey }) {
164
- const fadeFrom = this._soundsState[soundKey].volume;
165
- const delta = fadeTo - fadeFrom;
166
-
167
- const onUpdate = () => {
168
- const volume = fadeFrom + (delta * this._fadeTweens[soundKey].ratio);
169
- this.setVolume(soundKey, volume);
170
- };
171
-
172
- this._fadeTweens[soundKey] = gsap.to({}, fadeDuration / 1000, { onUpdate });
173
- }
174
-
175
- fade({ fadeTo = 1, fadeDuration = 200, startSound = false, soundKey, ...others }) {
176
- if(startSound) {
177
- this.play({ ...others, soundKey });
178
- }
179
- if(this._soundsState[soundKey].id === null) {
180
- return;
181
- }
182
-
183
- this._stopPrevFade(soundKey);
184
- this._startFade({ fadeTo, fadeDuration, soundKey });
185
- }
186
-
187
- _saveEvents(eventsCfg) {
188
- this._eventsCfg = eventsCfg;
189
- }
190
-
191
- _setEventCallback(soundKey, event) {
192
- return function () {
193
- const params = this._eventsCfg[soundKey].events[event];
194
-
195
- this._reactToEvent(soundKey, params);
196
- };
197
- };
198
-
199
- _onUnlock() {
200
- this._runEventsFromQueue();
201
- this._updateVolume();
202
- };
203
-
204
- _runEventsFromQueue() {
205
- this._eventsQueue.forEach(event => this._reactToEvent(event.soundKey, event));
206
- this._eventsQueue = [];
207
- };
208
-
209
- _addEventToQueue(data) {
210
- this._eventsQueue.push(data);
211
- };
212
-
213
- _reactToEvent(soundKey, { action, volume, ...otherParams }) {
214
- volume *= this._totalVolume;
215
- const self = this;
216
- const params = { ...otherParams, action, soundKey, volume };
217
-
218
- if (!self[action])
219
- return Urso.logger.error(`SoundSprite error: Sound action '${action}' not found!`);
220
-
221
- if (!this._isAudioUnlocked)
222
- this._addEventToQueue({ ...params, action });
223
-
224
- self[action](params);
225
- };
226
-
227
- _customSubscribe() {
228
- for (const soundKey in this._eventsCfg) {
229
- const { events = {} } = this._eventsCfg[soundKey];
230
-
231
- for (const event in events) {
232
- this.addListener(event, this._setEventCallback(soundKey, event).bind(this), true);
233
- }
234
- }
235
- };
236
-
237
- _customUnsubscribe() {
238
- for (const event in this._eventsCfg) {
239
- this.removeListener(event, this._setEventCallback(event).bind(this), true);
240
- }
241
- };
242
- };
243
-
1
+ class SoundSprite {
2
+ constructor({ name, sprite, audiosprite }) {
3
+ this._player = null;
4
+ this._totalVolume = 0;
5
+ this._makePlayer(sprite, audiosprite);
6
+
7
+ this._name = name;
8
+ this._sprite = sprite;
9
+
10
+ this._soundsState = this._initSoundsState();
11
+
12
+ this._eventsCfg = {};
13
+ this._fadeTweens = {};
14
+ this._eventsQueue = [];
15
+ this._isAudioUnlocked = false;
16
+
17
+ this._reactToEvent = this._reactToEvent.bind(this);
18
+ };
19
+
20
+
21
+ _initSoundsState() {
22
+ const soundsNames = Object.keys(this._sprite);
23
+ const soundsStateObj = {};
24
+
25
+ soundsNames.forEach(soundName => {
26
+ soundsStateObj[soundName] = {
27
+ id: null,
28
+ loop: false,
29
+ volume: 1,
30
+ relaunch: false
31
+ }
32
+ });
33
+
34
+ return soundsStateObj;
35
+ }
36
+
37
+ _makePlayer(sprite, audiosprite) {
38
+ var reader = new FileReader();
39
+ reader.readAsDataURL(audiosprite);
40
+ reader.onloadend = () => {
41
+ var base64data = reader.result;
42
+ this._player = new Howl({
43
+ src: base64data,
44
+ sprite
45
+ });
46
+ this._subscribePlayerEvents();
47
+ }
48
+ };
49
+
50
+ _subscribePlayerEvents() {
51
+ this._player.on('unlock', () => setTimeout(() => {
52
+ this._isAudioUnlocked = true;
53
+ this._onUnlock();
54
+ }, 1000));
55
+
56
+ this._player.on('end', id => {
57
+ const soundState = this._getSoundStateById(id);
58
+
59
+ if (!soundState)
60
+ return Urso.logger.error(`SoundSprite error: soundState for id '${id}' not found!`);
61
+
62
+ if (!soundState.loop)
63
+ soundState.id = null;
64
+ });
65
+ };
66
+
67
+ _getSoundStateById(id) {
68
+ for (const [name, state] of Object.entries(this._soundsState)) {
69
+ if (state.id === id) {
70
+ return {
71
+ id: { ...state, name }
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ canPlayCheck() {
78
+ return this._isAudioUnlocked;
79
+ };
80
+
81
+ play({ loop = false, volume = this._volume, relaunch = false, soundKey }) {
82
+ if (!this.canPlayCheck() || (this._soundsState[soundKey].id !== null && !relaunch))
83
+ return false;
84
+
85
+ this.stop({ soundKey });
86
+
87
+ this._soundsState[soundKey].id = this._player.play(soundKey);
88
+
89
+ this.setRelaunch(soundKey, relaunch);
90
+ this.setLoop(soundKey, loop);
91
+ this.setVolume(soundKey, volume);
92
+
93
+ return true;
94
+ };
95
+
96
+ setLoop(soundKey, loop = false) {
97
+ this._soundsState[soundKey].loop = loop;
98
+ this._player.loop(loop, this._soundsState[soundKey].id);
99
+ };
100
+
101
+ setVolume(soundKey, volume = 1, saveVolumeState = true) {
102
+ this._player.volume(volume, this._soundsState[soundKey].id);
103
+
104
+ if(saveVolumeState) {
105
+ this._soundsState[soundKey].volume = volume;
106
+ }
107
+ };
108
+
109
+ setAllVolume(volume) {
110
+ this._totalVolume = volume;
111
+ this._player._volume = volume;
112
+
113
+ if (this.canPlayCheck()) {
114
+ this._updateVolume();
115
+ }
116
+ }
117
+
118
+ _updateVolume() {
119
+ const soundKeys = Object.keys(this._soundsState);
120
+ this._player._volume = this._totalVolume;
121
+ soundKeys.forEach(soundKey => {
122
+ const soundVolume = this._soundsState[soundKey].volume * this._totalVolume;
123
+ this.setVolume(soundKey, soundVolume, false);
124
+ });
125
+ }
126
+
127
+ setRelaunch(soundKey, needRelaunch = false) {
128
+ this._soundsState[soundKey].relaunch = needRelaunch;
129
+ };
130
+
131
+ stop({ soundKey }) {
132
+ if (!this._soundsState[soundKey].id)
133
+ return;
134
+
135
+ this._player.stop(this._soundsState[soundKey].id);
136
+ this._soundsState[soundKey].id = null;
137
+ };
138
+
139
+ pause({ soundKey }) {
140
+ if (this.canPlayCheck() || this._player.playing(this._soundsState[soundKey].id))
141
+ this._player.pause(this._soundsState[soundKey].id);
142
+ };
143
+
144
+ resume({ soundKey }) {
145
+ if (this.canPlayCheck() && !this._player.playing(this._soundsState[soundKey].id))
146
+ this._player.play(this._soundsState[soundKey].id);
147
+ };
148
+
149
+ updateEvents(eventsCfg) {
150
+ this._customUnsubscribe();
151
+ this._saveEvents(eventsCfg);
152
+ this._customSubscribe();
153
+ };
154
+
155
+ _stopPrevFade(soundKey) {
156
+ if(this._fadeTweens[soundKey]) {
157
+ this._fadeTweens[soundKey].kill();
158
+ }
159
+
160
+ delete this._fadeTweens[soundKey];
161
+ }
162
+
163
+ _startFade({ fadeTo, fadeDuration, soundKey }) {
164
+ const fadeFrom = this._soundsState[soundKey].volume;
165
+ const delta = fadeTo - fadeFrom;
166
+
167
+ const onUpdate = () => {
168
+ const volume = fadeFrom + (delta * this._fadeTweens[soundKey].ratio);
169
+ this.setVolume(soundKey, volume);
170
+ };
171
+
172
+ this._fadeTweens[soundKey] = gsap.to({}, fadeDuration / 1000, { onUpdate });
173
+ }
174
+
175
+ fade({ fadeTo = 1, fadeDuration = 200, startSound = false, soundKey, ...others }) {
176
+ if(startSound) {
177
+ this.play({ ...others, soundKey });
178
+ }
179
+ if(this._soundsState[soundKey].id === null) {
180
+ return;
181
+ }
182
+
183
+ this._stopPrevFade(soundKey);
184
+ this._startFade({ fadeTo, fadeDuration, soundKey });
185
+ }
186
+
187
+ _saveEvents(eventsCfg) {
188
+ this._eventsCfg = eventsCfg;
189
+ }
190
+
191
+ _setEventCallback(soundKey, event) {
192
+ return function () {
193
+ const params = this._eventsCfg[soundKey].events[event];
194
+
195
+ this._reactToEvent(soundKey, params);
196
+ };
197
+ };
198
+
199
+ _onUnlock() {
200
+ this._runEventsFromQueue();
201
+ this._updateVolume();
202
+ };
203
+
204
+ _runEventsFromQueue() {
205
+ this._eventsQueue.forEach(event => this._reactToEvent(event.soundKey, event));
206
+ this._eventsQueue = [];
207
+ };
208
+
209
+ _addEventToQueue(data) {
210
+ this._eventsQueue.push(data);
211
+ };
212
+
213
+ _reactToEvent(soundKey, { action, volume, ...otherParams }) {
214
+ volume *= this._totalVolume;
215
+ const self = this;
216
+ const params = { ...otherParams, action, soundKey, volume };
217
+
218
+ if (!self[action])
219
+ return Urso.logger.error(`SoundSprite error: Sound action '${action}' not found!`);
220
+
221
+ if (!this._isAudioUnlocked)
222
+ this._addEventToQueue({ ...params, action });
223
+
224
+ self[action](params);
225
+ };
226
+
227
+ _customSubscribe() {
228
+ for (const soundKey in this._eventsCfg) {
229
+ const { events = {} } = this._eventsCfg[soundKey];
230
+
231
+ for (const event in events) {
232
+ this.addListener(event, this._setEventCallback(soundKey, event).bind(this), true);
233
+ }
234
+ }
235
+ };
236
+
237
+ _customUnsubscribe() {
238
+ for (const event in this._eventsCfg) {
239
+ this.removeListener(event, this._setEventCallback(event).bind(this), true);
240
+ }
241
+ };
242
+ };
243
+
244
244
  module.exports = SoundSprite;
@@ -1,12 +1,12 @@
1
- Urso.Core.Modules.StatesManager = {
2
- Action: require('./action.js'),
3
- All: require('./all.js'),
4
- ConfigStates: require('./configStates.js'),
5
- Controller: require('./controller.js'),
6
- FunctionsStorage: require('./functionsStorage.js'),
7
- Helper: require('./helper.js'),
8
- Race: require('./race.js'),
9
- Sequence: require('./sequence.js')
10
- };
11
-
12
- require('./actions/_info.js');
1
+ Urso.Core.Modules.StatesManager = {
2
+ Action: require('./action.js'),
3
+ All: require('./all.js'),
4
+ ConfigStates: require('./configStates.js'),
5
+ Controller: require('./controller.js'),
6
+ FunctionsStorage: require('./functionsStorage.js'),
7
+ Helper: require('./helper.js'),
8
+ Race: require('./race.js'),
9
+ Sequence: require('./sequence.js')
10
+ };
11
+
12
+ require('./actions/_info.js');
@@ -1,60 +1,60 @@
1
- class ModulesStatesManagerAction {
2
-
3
- constructor(name) {
4
- this.name = name;
5
-
6
- this._terminating = false;
7
- this.finished = false;
8
- this._onFinishCallback = false;
9
-
10
- this._onFinish = this._onFinish.bind(this);
11
- }
12
-
13
- //can we start this action?
14
- guard() {
15
- return this.getInstance('Controller').checkActionGuard(this.name);
16
- }
17
-
18
- run(onFinishCallback) {
19
- log(`%c action run ---> ${this.name}`, 'color: blue');
20
-
21
- this.emit(Urso.events.MODULES_STATES_MANAGER_ACTION_START, this.name);
22
-
23
- this.finished = false;
24
- this._onFinishCallback = onFinishCallback;
25
-
26
- Urso.statesManager.runAction(this.name, this._onFinish);
27
-
28
- //TODO remove temp for debug
29
- //let timeout = Math.floor(Math.random() * 2000);
30
- //Urso.statesManager.runAction(this.name, () => setTimeout(() => { this._onFinish(); }, timeout));
31
- }
32
-
33
- terminate() {
34
- if (this._terminating) {
35
- Urso.logger.error('ModulesStatesManagerAction: action alredy terminating', this.name);
36
- return;
37
- }
38
-
39
- log(`%c action terminate X ${this.name}`, 'color: blue');
40
- this._terminating = true;
41
- Urso.statesManager.terminateAction(this.name);
42
- }
43
-
44
- _onFinish() {
45
- if (this.finished) {
46
- Urso.logger.error('ModulesStatesManagerAction: action alredy finished', this.name);
47
- return;
48
- }
49
-
50
- this._terminating = false;
51
- this.finished = true;
52
-
53
- this.emit(Urso.events.MODULES_STATES_MANAGER_ACTION_FINISH, this.name);
54
-
55
- log(`%c action finish <--- ${this.name}`, 'color: blue');
56
- this._onFinishCallback();
57
- }
58
- }
59
-
60
- module.exports = ModulesStatesManagerAction;
1
+ class ModulesStatesManagerAction {
2
+
3
+ constructor(name) {
4
+ this.name = name;
5
+
6
+ this._terminating = false;
7
+ this.finished = false;
8
+ this._onFinishCallback = false;
9
+
10
+ this._onFinish = this._onFinish.bind(this);
11
+ }
12
+
13
+ //can we start this action?
14
+ guard() {
15
+ return this.getInstance('Controller').checkActionGuard(this.name);
16
+ }
17
+
18
+ run(onFinishCallback) {
19
+ log(`%c action run ---> ${this.name}`, 'color: blue');
20
+
21
+ this.emit(Urso.events.MODULES_STATES_MANAGER_ACTION_START, this.name);
22
+
23
+ this.finished = false;
24
+ this._onFinishCallback = onFinishCallback;
25
+
26
+ Urso.statesManager.runAction(this.name, this._onFinish);
27
+
28
+ //TODO remove temp for debug
29
+ //let timeout = Math.floor(Math.random() * 2000);
30
+ //Urso.statesManager.runAction(this.name, () => setTimeout(() => { this._onFinish(); }, timeout));
31
+ }
32
+
33
+ terminate() {
34
+ if (this._terminating) {
35
+ Urso.logger.error('ModulesStatesManagerAction: action alredy terminating', this.name);
36
+ return;
37
+ }
38
+
39
+ log(`%c action terminate X ${this.name}`, 'color: blue');
40
+ this._terminating = true;
41
+ Urso.statesManager.terminateAction(this.name);
42
+ }
43
+
44
+ _onFinish() {
45
+ if (this.finished) {
46
+ Urso.logger.error('ModulesStatesManagerAction: action alredy finished', this.name);
47
+ return;
48
+ }
49
+
50
+ this._terminating = false;
51
+ this.finished = true;
52
+
53
+ this.emit(Urso.events.MODULES_STATES_MANAGER_ACTION_FINISH, this.name);
54
+
55
+ log(`%c action finish <--- ${this.name}`, 'color: blue');
56
+ this._onFinishCallback();
57
+ }
58
+ }
59
+
60
+ module.exports = ModulesStatesManagerAction;
@@ -1,3 +1,3 @@
1
- Urso.Core.Modules.StatesManager.Actions = {
2
- //todo
3
- };
1
+ Urso.Core.Modules.StatesManager.Actions = {
2
+ //todo
3
+ };