gdcore-tools 2.0.0-gd-v5.5.242-autobuild → 2.0.0-gd-v5.5.243-autobuild

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 (126) hide show
  1. package/dist/Runtime/AsyncTasksManager.js +2 -2
  2. package/dist/Runtime/AsyncTasksManager.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  6. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +5 -0
  12. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  16. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  17. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  18. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  19. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  20. package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
  21. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  22. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  23. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
  24. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  25. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  26. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  27. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  28. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  29. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  30. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  31. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  32. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
  34. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  35. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  38. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  39. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  40. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  41. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  42. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  43. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  44. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  45. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
  46. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  47. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  48. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  49. package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
  50. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
  51. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
  52. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
  53. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
  54. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  55. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  56. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  57. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  58. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  59. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  60. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
  61. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  62. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  63. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  64. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  65. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  66. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  67. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  68. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  69. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  70. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  71. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  72. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  73. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
  74. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +2 -2
  75. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  76. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  77. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js +1 -1
  78. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
  79. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  80. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  81. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  82. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  83. package/dist/Runtime/RuntimeLayer.js +1 -1
  84. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  85. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  86. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  87. package/dist/Runtime/events-tools/objecttools.js +1 -1
  88. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  89. package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
  90. package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
  91. package/dist/Runtime/gd.js +1 -1
  92. package/dist/Runtime/gd.js.map +2 -2
  93. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  94. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  95. package/dist/Runtime/indexeddb.js +2 -0
  96. package/dist/Runtime/indexeddb.js.map +7 -0
  97. package/dist/Runtime/oncetriggers.js +1 -1
  98. package/dist/Runtime/oncetriggers.js.map +2 -2
  99. package/dist/Runtime/runtimebehavior.js +1 -1
  100. package/dist/Runtime/runtimebehavior.js.map +2 -2
  101. package/dist/Runtime/runtimegame.js +1 -1
  102. package/dist/Runtime/runtimegame.js.map +2 -2
  103. package/dist/Runtime/runtimeobject.js +1 -1
  104. package/dist/Runtime/runtimeobject.js.map +2 -2
  105. package/dist/Runtime/runtimescene.js +1 -1
  106. package/dist/Runtime/runtimescene.js.map +2 -2
  107. package/dist/Runtime/scenestack.js +1 -1
  108. package/dist/Runtime/scenestack.js.map +2 -2
  109. package/dist/Runtime/spriteruntimeobject.js +1 -1
  110. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  111. package/dist/Runtime/timemanager.js +1 -1
  112. package/dist/Runtime/timemanager.js.map +2 -2
  113. package/dist/Runtime/timer.js +1 -1
  114. package/dist/Runtime/timer.js.map +2 -2
  115. package/dist/Runtime/types/global-types.d.ts +29 -0
  116. package/dist/Runtime/types/project-data.d.ts +144 -3
  117. package/dist/Runtime/types/save-state.d.ts +9 -0
  118. package/dist/Runtime/variable.js +1 -1
  119. package/dist/Runtime/variable.js.map +2 -2
  120. package/dist/Runtime/variablescontainer.js +1 -1
  121. package/dist/Runtime/variablescontainer.js.map +2 -2
  122. package/dist/lib/libGD.cjs +1 -1
  123. package/dist/lib/libGD.wasm +0 -0
  124. package/dist/loaders.cjs +1 -1
  125. package/gd.d.ts +1 -0
  126. package/package.json +1 -1
@@ -0,0 +1,488 @@
1
+ //@ts-check
2
+ /// <reference path="../JsExtensionTypes.d.ts" />
3
+ /**
4
+ * This is a declaration of an extension for GDevelop 5.
5
+ *
6
+ * ℹ️ Changes in this file are watched and automatically imported if the editor
7
+ * is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
8
+ *
9
+ * The file must be named "JsExtension.js", otherwise GDevelop won't load it.
10
+ * ⚠️ If you make a change and the extension is not loaded, open the developer console
11
+ * and search for any errors.
12
+ *
13
+ * More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
14
+ */
15
+
16
+ /** @type {ExtensionModule} */
17
+ module.exports = {
18
+ createExtension: function (_, gd) {
19
+ const extension = new gd.PlatformExtension();
20
+ extension
21
+ .setExtensionInformation(
22
+ 'SaveState',
23
+ _('Save State (experimental)'),
24
+ _(
25
+ 'Allows to save and load the full state of a game, usually on the device storage. A Save State, by default, contains the full state of the game (objects, variables, sounds, music, effects etc.). Using the "Save Configuration" behavior, you can customize which objects should not be saved in a Save State. You can also use the "Change the save configuration of a variable" action to change the save configuration of a variable. Finally, both objects, variables and scene/game data can be given a profile name: in this case, when saving or loading with one or more profile names specified, only the object/variables/data belonging to one of the specified profiles will be saved or loaded.'
26
+ ),
27
+ 'Neyl Mahfouf',
28
+ 'Open source (MIT License)'
29
+ )
30
+ .setExtensionHelpPath('/all-features/save-state')
31
+ .setCategory('Game mechanic')
32
+ .addInstructionOrExpressionGroupMetadata(_('Save State (experimental)'))
33
+ .setIcon('res/actions/saveDown.svg');
34
+
35
+ extension
36
+ .addAction(
37
+ 'CreateGameSaveStateInVariable',
38
+ _('Save game to a variable'),
39
+ _(
40
+ 'Create a Save State and save it to a variable. This is for advanced usage, prefer to use "Save game to device storage" in most cases.'
41
+ ),
42
+ _('Save game in variable _PARAM1_ (profile(s): _PARAM2_)'),
43
+ _('Save'),
44
+ 'res/actions/saveDown.svg',
45
+ 'res/actions/saveDown.svg'
46
+ )
47
+ .addCodeOnlyParameter('currentScene', '')
48
+ .addParameter('variable', _('Variable to store the save to'), '', false)
49
+ .addParameter('string', _('Profile(s) to save'), '', true)
50
+ .setDefaultValue('"default"')
51
+ .setParameterLongDescription(
52
+ _(
53
+ 'Comma-separated list of profile names that must be saved. Only objects tagged with at least one of these profiles will be saved. If no profile names are specified, all objects will be saved (unless they have a "Save Configuration" behavior set to "Do not save").'
54
+ )
55
+ )
56
+ .getCodeExtraInformation()
57
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
58
+ .addIncludeFile(
59
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
60
+ )
61
+ .setFunctionName('gdjs.saveState.createGameSaveStateInVariable');
62
+
63
+ extension
64
+ .addAction(
65
+ 'CreateGameSaveStateInStorage',
66
+ _('Save game to device storage'),
67
+ _('Create a Save State and save it to device storage.'),
68
+ _('Save game to device storage named _PARAM1_ (profile(s): _PARAM2_)'),
69
+ _('Save'),
70
+ 'res/actions/saveDown.svg',
71
+ 'res/actions/saveDown.svg'
72
+ )
73
+ .addCodeOnlyParameter('currentScene', '')
74
+ .addParameter('string', _('Storage key to save to'), '', false)
75
+ .addParameter('string', _('Profile(s) to save'), '', true)
76
+ .setDefaultValue('"default"')
77
+ .setParameterLongDescription(
78
+ _(
79
+ 'Comma-separated list of profile names that must be saved. Only objects tagged with at least one of these profiles will be saved. If no profile names are specified, all objects will be saved (unless they have a "Save Configuration" behavior set to "Do not save").'
80
+ )
81
+ )
82
+ .setDefaultValue('no')
83
+ .getCodeExtraInformation()
84
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
85
+ .addIncludeFile(
86
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
87
+ )
88
+ .setFunctionName('gdjs.saveState.createGameSaveStateInStorage');
89
+
90
+ extension
91
+ .addAction(
92
+ 'RestoreGameSaveStateFromVariable',
93
+ _('Load game from variable'),
94
+ _(
95
+ 'Restore the game from a Save State stored in the specified variable. This is for advanced usage, prefer to use "Load game from device storage" in most cases.'
96
+ ),
97
+ _(
98
+ 'Load game from variable _PARAM1_ (profile(s): _PARAM2_, stop and restart all the scenes currently played: _PARAM3_)'
99
+ ),
100
+ _('Load'),
101
+ 'res/actions/saveUp.svg',
102
+ 'res/actions/saveUp.svg'
103
+ )
104
+ .addCodeOnlyParameter('currentScene', '')
105
+ .addParameter('variable', _('Variable to load the game from'), '', false)
106
+ .addParameter('string', _('Profile(s) to load'), '', true)
107
+ .setDefaultValue('"default"')
108
+ .setParameterLongDescription(
109
+ _(
110
+ 'Comma-separated list of profile names that must be loaded. Only objects tagged with at least one of these profiles will be loaded - others will be left alone. If no profile names are specified, all objects will be loaded (unless they have a "Save Configuration" behavior set to "Do not save").'
111
+ )
112
+ )
113
+ .addParameter(
114
+ 'yesorno',
115
+ _('Stop and restart all the scenes currently played?'),
116
+ '',
117
+ true
118
+ )
119
+ .setDefaultValue('no')
120
+ .getCodeExtraInformation()
121
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
122
+ .addIncludeFile(
123
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
124
+ )
125
+ .setFunctionName('gdjs.saveState.restoreGameSaveStateFromVariable');
126
+
127
+ extension
128
+ .addAction(
129
+ 'RestoreGameSaveStateFromStorage',
130
+ _('Load game from device storage'),
131
+ _('Restore the game from a Save State stored on the device.'),
132
+ _(
133
+ 'Load game from device storage named _PARAM1_ (profile(s): _PARAM2_, stop and restart all the scenes currently played: _PARAM3_)'
134
+ ),
135
+ _('Load'),
136
+ 'res/actions/saveUp.svg',
137
+ 'res/actions/saveUp.svg'
138
+ )
139
+ .addCodeOnlyParameter('currentScene', '')
140
+ .addParameter(
141
+ 'string',
142
+ _('Storage name to load the game from'),
143
+ '',
144
+ false
145
+ )
146
+ .addParameter('string', _('Profile(s) to load'), '', true)
147
+ .setDefaultValue('"default"')
148
+ .setParameterLongDescription(
149
+ _(
150
+ 'Comma-separated list of profile names that must be loaded. Only objects tagged with at least one of these profiles will be loaded - others will be left alone. If no profile names are specified, all objects will be loaded.'
151
+ )
152
+ )
153
+ .addParameter(
154
+ 'yesorno',
155
+ _('Stop and restart all the scenes currently played?'),
156
+ '',
157
+ true
158
+ )
159
+ .setDefaultValue('no')
160
+ .getCodeExtraInformation()
161
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
162
+ .addIncludeFile(
163
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
164
+ )
165
+ .setFunctionName('gdjs.saveState.restoreGameSaveStateFromStorage');
166
+
167
+ extension
168
+ .addExpressionAndCondition(
169
+ 'number',
170
+ 'TimeSinceLastSave',
171
+ _('Time since last save'),
172
+ _(
173
+ 'Time since the last save, in seconds. Returns -1 if no save happened, and a positive number otherwise.'
174
+ ),
175
+ _('Time since the last save'),
176
+ '',
177
+ 'res/actions/saveDown.svg'
178
+ )
179
+ .addCodeOnlyParameter('currentScene', '')
180
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
181
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
182
+ .addIncludeFile(
183
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
184
+ )
185
+ .setFunctionName('gdjs.saveState.getSecondsSinceLastSave')
186
+ .setGetter('gdjs.saveState.getSecondsSinceLastSave');
187
+
188
+ extension
189
+ .addExpressionAndCondition(
190
+ 'number',
191
+ 'TimeSinceLastLoad',
192
+ _('Time since last load'),
193
+ _(
194
+ 'Time since the last load, in seconds. Returns -1 if no load happened, and a positive number otherwise.'
195
+ ),
196
+ _('Time since the last load'),
197
+ '',
198
+ 'res/actions/saveDown.svg'
199
+ )
200
+ .addCodeOnlyParameter('currentScene', '')
201
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
202
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
203
+ .addIncludeFile(
204
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
205
+ )
206
+ .setFunctionName('gdjs.saveState.getSecondsSinceLastLoad')
207
+ .setGetter('gdjs.saveState.getSecondsSinceLastLoad');
208
+
209
+ extension
210
+ .addCondition(
211
+ 'SaveJustSucceeded',
212
+ _('Save just succeeded'),
213
+ _('The last save attempt just succeeded.'),
214
+ _('Save just succeeded'),
215
+ _('Save'),
216
+ 'res/actions/saveDown.svg',
217
+ 'res/actions/saveDown.svg'
218
+ )
219
+ .addCodeOnlyParameter('currentScene', '')
220
+ .getCodeExtraInformation()
221
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
222
+ .addIncludeFile(
223
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
224
+ )
225
+ .setFunctionName('gdjs.saveState.hasSaveJustSucceeded');
226
+
227
+ extension
228
+ .addCondition(
229
+ 'SaveJustFailed',
230
+ _('Save just failed'),
231
+ _('The last save attempt just failed.'),
232
+ _('Save just failed'),
233
+ _('Save'),
234
+ 'res/actions/saveDown.svg',
235
+ 'res/actions/saveDown.svg'
236
+ )
237
+ .addCodeOnlyParameter('currentScene', '')
238
+ .getCodeExtraInformation()
239
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
240
+ .addIncludeFile(
241
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
242
+ )
243
+ .setFunctionName('gdjs.saveState.hasSaveJustFailed');
244
+
245
+ extension
246
+ .addCondition(
247
+ 'LoadJustSucceeded',
248
+ _('Load just succeeded'),
249
+ _('The last load attempt just succeeded.'),
250
+ _('Load just succeeded'),
251
+ _('Load'),
252
+ 'res/actions/saveUp.svg',
253
+ 'res/actions/saveUp.svg'
254
+ )
255
+ .addCodeOnlyParameter('currentScene', '')
256
+ .getCodeExtraInformation()
257
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
258
+ .addIncludeFile(
259
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
260
+ )
261
+ .setFunctionName('gdjs.saveState.hasLoadJustSucceeded');
262
+
263
+ extension
264
+ .addCondition(
265
+ 'LoadJustFailed',
266
+ _('Load just failed'),
267
+ _('The last load attempt just failed.'),
268
+ _('Load just failed'),
269
+ _('Load'),
270
+ 'res/actions/saveUp.svg',
271
+ 'res/actions/saveUp.svg'
272
+ )
273
+ .addCodeOnlyParameter('currentScene', '')
274
+ .getCodeExtraInformation()
275
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
276
+ .addIncludeFile(
277
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
278
+ )
279
+ .setFunctionName('gdjs.saveState.hasLoadJustFailed');
280
+
281
+ extension
282
+ .addAction(
283
+ 'SetVariableSaveConfiguration',
284
+ _('Change the save configuration of a variable'),
285
+ _(
286
+ 'Set if a scene or global variable should be saved in the default save state. Also allow to specify one or more profiles in which the variable should be saved.'
287
+ ),
288
+ _(
289
+ 'Change save configuration of _PARAM1_: save it in the default save states: _PARAM2_ and in profiles: _PARAM3_'
290
+ ),
291
+ _('Advanced configuration'),
292
+ 'res/actions/saveDown.svg',
293
+ 'res/actions/saveDown.svg'
294
+ )
295
+ .addCodeOnlyParameter('currentScene', '')
296
+ .addParameter(
297
+ 'variable',
298
+ _('Variable for which configuration should be changed'),
299
+ '',
300
+ false
301
+ )
302
+ .addParameter('yesorno', _('Persist in default save states'), '', false)
303
+ .setDefaultValue('yes')
304
+ .addParameter(
305
+ 'string',
306
+ _('Profiles in which the variable should be saved'),
307
+ '',
308
+ true
309
+ )
310
+ .setDefaultValue('')
311
+ .setParameterLongDescription(
312
+ _(
313
+ 'Comma-separated list of profile names in which the variable will be saved. When a save state is created with one or more profile names specified, the variable will be saved only if it matches one of these profiles.'
314
+ )
315
+ )
316
+ .getCodeExtraInformation()
317
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
318
+ .addIncludeFile(
319
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
320
+ )
321
+ .setFunctionName('gdjs.saveState.setVariableSaveConfiguration');
322
+
323
+ extension
324
+ .addAction(
325
+ 'SetGameDataSaveConfiguration',
326
+ _('Change the save configuration of the global game data'),
327
+ _(
328
+ 'Set if the global game data (audio & global variables) should be saved in the default save state. Also allow to specify one or more profiles in which the global game data should be saved.'
329
+ ),
330
+ _(
331
+ 'Change save configuration of global game data: save them in the default save states: _PARAM1_ and in profiles: _PARAM2_'
332
+ ),
333
+ _('Advanced configuration'),
334
+ 'res/actions/saveDown.svg',
335
+ 'res/actions/saveDown.svg'
336
+ )
337
+ .addCodeOnlyParameter('currentScene', '')
338
+ .addParameter('yesorno', _('Persist in default save states'), '', false)
339
+ .setDefaultValue('yes')
340
+ .addParameter(
341
+ 'string',
342
+ _('Profiles in which the global game data should be saved'),
343
+ '',
344
+ true
345
+ )
346
+ .setDefaultValue('')
347
+ .setParameterLongDescription(
348
+ _(
349
+ 'Comma-separated list of profile names in which the global game data will be saved. When a save state is created with one or more profile names specified, the global game data will be saved only if it matches one of these profiles.'
350
+ )
351
+ )
352
+ .getCodeExtraInformation()
353
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
354
+ .addIncludeFile(
355
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
356
+ )
357
+ .setFunctionName('gdjs.saveState.setGameDataSaveConfiguration');
358
+
359
+ extension
360
+ .addAction(
361
+ 'SetSceneDataSaveConfiguration',
362
+ _('Change the save configuration of a scene data'),
363
+ _(
364
+ 'Set if the data of the specified scene (scene variables, timers, trigger once, wait actions, layers, etc.) should be saved in the default save state. Also allow to specify one or more profiles in which the scene data should be saved. Note: objects are always saved separately from the scene data (use the "Save Configuration" behavior to customize the configuration of objects).'
365
+ ),
366
+ _(
367
+ 'Change save configuration of scene _PARAM1_: save it in the default save states: _PARAM2_ and in profiles: _PARAM3_'
368
+ ),
369
+ _('Advanced configuration'),
370
+ 'res/actions/saveDown.svg',
371
+ 'res/actions/saveDown.svg'
372
+ )
373
+ .addCodeOnlyParameter('currentScene', '')
374
+ .addParameter(
375
+ 'sceneName',
376
+ _('Scene name for which configuration should be changed'),
377
+ '',
378
+ false
379
+ )
380
+ .addParameter('yesorno', _('Persist in default save states'), '', false)
381
+ .setDefaultValue('yes')
382
+ .addParameter(
383
+ 'string',
384
+ _('Profiles in which the scene data should be saved'),
385
+ '',
386
+ true
387
+ )
388
+ .setDefaultValue('')
389
+ .setParameterLongDescription(
390
+ _(
391
+ 'Comma-separated list of profile names in which the scene data will be saved. When a save state is created with one or more profile names specified, the scene data will be saved only if it matches one of these profiles.'
392
+ )
393
+ )
394
+ .getCodeExtraInformation()
395
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
396
+ .addIncludeFile(
397
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
398
+ )
399
+ .setFunctionName('gdjs.saveState.setSceneDataSaveConfiguration');
400
+
401
+ // Save Configuration behavior
402
+ const saveConfigurationBehavior = new gd.BehaviorJsImplementation();
403
+
404
+ saveConfigurationBehavior.updateProperty = function (
405
+ behaviorContent,
406
+ propertyName,
407
+ newValue
408
+ ) {
409
+ if (propertyName === 'defaultProfilePersistence') {
410
+ behaviorContent
411
+ .getChild('defaultProfilePersistence')
412
+ .setStringValue(newValue);
413
+ return true;
414
+ }
415
+ if (propertyName === 'persistedInProfiles') {
416
+ behaviorContent
417
+ .getChild('persistedInProfiles')
418
+ .setStringValue(newValue);
419
+ return true;
420
+ }
421
+
422
+ return false;
423
+ };
424
+
425
+ saveConfigurationBehavior.getProperties = function (behaviorContent) {
426
+ const behaviorProperties = new gd.MapStringPropertyDescriptor();
427
+
428
+ behaviorProperties
429
+ .getOrCreate('defaultProfilePersistence')
430
+ .setValue(
431
+ behaviorContent.getChild('defaultProfilePersistence').getStringValue()
432
+ )
433
+ .setType('Choice')
434
+ .setLabel(_('Persistence mode'))
435
+ .addChoice('Persisted', _('Include in save states (default)'))
436
+ .addChoice('DoNotSave', _('Do not save'));
437
+
438
+ behaviorProperties
439
+ .getOrCreate('persistedInProfiles')
440
+ .setValue(
441
+ behaviorContent.getChild('persistedInProfiles').getStringValue()
442
+ )
443
+ .setType('String')
444
+ .setLabel(_('Save profile names'))
445
+ .setDescription(
446
+ _(
447
+ 'Comma-separated list of profile names in which the object is saved. When a save state is created with one or more profile names specified, the object will be saved only if it matches one of these profiles.'
448
+ )
449
+ )
450
+ .setAdvanced(true);
451
+
452
+ return behaviorProperties;
453
+ };
454
+
455
+ saveConfigurationBehavior.initializeContent = function (behaviorContent) {
456
+ behaviorContent
457
+ .addChild('defaultProfilePersistence')
458
+ .setStringValue('Persisted');
459
+ behaviorContent.addChild('persistedInProfiles').setStringValue('');
460
+ };
461
+
462
+ const sharedData = new gd.BehaviorsSharedData();
463
+
464
+ extension
465
+ .addBehavior(
466
+ 'SaveConfiguration',
467
+ _('Save state configuration'),
468
+ 'SaveConfiguration',
469
+ _('Allow the customize how the object is persisted in a save state.'),
470
+ '',
471
+ 'res/actions/saveUp.svg',
472
+ 'SaveConfiguration',
473
+ // @ts-ignore - TODO: Fix type being a BehaviorJsImplementation instead of an Behavior
474
+ saveConfigurationBehavior,
475
+ sharedData
476
+ )
477
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
478
+ .setIncludeFile('Extensions/SaveState/SaveStateTools.js')
479
+ .addIncludeFile(
480
+ 'Extensions/SaveState/SaveConfigurationRuntimeBehavior.js'
481
+ );
482
+
483
+ return extension;
484
+ },
485
+ runExtensionSanityTests: function (gd, extension) {
486
+ return [];
487
+ },
488
+ };
@@ -0,0 +1,2 @@
1
+ var gdjs;(function(e){class s extends e.RuntimeBehavior{constructor(i,t,r){super(i,t,r);this._defaultProfilePersistence="Persisted";this._persistedInProfiles="";this._defaultProfilePersistence=t.defaultProfilePersistence||"Persisted",this._persistedInProfiles=t.persistedInProfiles||""}getDefaultProfilePersistence(){return this._defaultProfilePersistence}getPersistedInProfiles(){return this._persistedInProfiles}}e.SaveConfigurationRuntimeBehavior=s,e.registerBehavior("SaveState::SaveConfiguration",e.SaveConfigurationRuntimeBehavior)})(gdjs||(gdjs={}));
2
+ //# sourceMappingURL=SaveConfigurationRuntimeBehavior.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../GDevelop/Extensions/SaveState/SaveConfigurationRuntimeBehavior.ts"],
4
+ "sourcesContent": ["namespace gdjs {\n // const logger = new gdjs.Logger('Save State');\n\n export class SaveConfigurationRuntimeBehavior extends gdjs.RuntimeBehavior {\n private readonly _defaultProfilePersistence: 'Persisted' | 'DoNotSave' =\n 'Persisted';\n private readonly _persistedInProfiles = '';\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData: any,\n owner: RuntimeObject\n ) {\n super(instanceContainer, behaviorData, owner);\n this._defaultProfilePersistence =\n behaviorData.defaultProfilePersistence || 'Persisted';\n this._persistedInProfiles = behaviorData.persistedInProfiles || '';\n }\n\n getDefaultProfilePersistence() {\n return this._defaultProfilePersistence;\n }\n\n getPersistedInProfiles() {\n return this._persistedInProfiles;\n }\n }\n gdjs.registerBehavior(\n 'SaveState::SaveConfiguration',\n gdjs.SaveConfigurationRuntimeBehavior\n );\n}\n"],
5
+ "mappings": "AAAA,GAAU,MAAV,UAAU,EAAV,CAGS,eAA+C,GAAK,eAAgB,CAKzE,YACE,EACA,EACA,EACA,CACA,MAAM,EAAmB,EAAc,GATxB,gCACf,YACe,0BAAuB,GAQtC,KAAK,2BACH,EAAa,2BAA6B,YAC5C,KAAK,qBAAuB,EAAa,qBAAuB,GAGlE,8BAA+B,CAC7B,MAAO,MAAK,2BAGd,wBAAyB,CACvB,MAAO,MAAK,sBArBT,EAAM,mCAwBb,EAAK,iBACH,+BACA,EAAK,oCA7BC",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ var gdjs;(function(l){const p=new l.Logger("Save State"),F=new l.Logger("Save State - Debug");l.Logger.getDefaultConsoleLoggerOutput().discardGroup("Save State - Debug");let U;(function(n){n.getIndexedDbDatabaseName=()=>`gdevelop-game-${l.projectData.properties.projectUuid}`,n.getIndexedDbObjectStore=()=>"game-saves",n.getIndexedDbStorageKey=e=>`save-${e}`;const L=new WeakMap,N=new WeakMap,I=new WeakMap;n.setVariableSaveConfiguration=(e,t,r,a)=>{L.set(t,{defaultProfilePersistence:r?"Persisted":"DoNotSave",persistedInProfiles:new Set(k(a))})},n.setSceneDataSaveConfiguration=(e,t,r,a)=>{const o=N.get(e.getGame())||{};N.set(e.getGame(),{...o,[t]:{defaultProfilePersistence:r?"Persisted":"DoNotSave",persistedInProfiles:new Set(k(a))}})},n.setGameDataSaveConfiguration=(e,t,r)=>{I.set(e.getGame(),{defaultProfilePersistence:t?"Persisted":"DoNotSave",persistedInProfiles:new Set(k(r))})};const b=(e,t)=>{if(e.includes("default")&&(!t||t.defaultProfilePersistence==="Persisted"))return!0;if(t){for(const r of e)if(t.persistedInProfiles.has(r))return!0}return!1},_=e=>t=>{const r=L.get(t);return!b(e,r||null)};let j=null,R=null,x=!1,h=!1,O=!1,v=!1,D=null;n.getSecondsSinceLastSave=e=>j?Math.floor((Date.now()-j)/1e3):-1,n.getSecondsSinceLastLoad=e=>R?Math.floor((Date.now()-R)/1e3):-1,n.hasSaveJustSucceeded=e=>x,n.hasLoadJustSucceeded=e=>O,n.hasSaveJustFailed=e=>h,n.hasLoadJustFailed=e=>v,n.markSaveJustSucceeded=e=>{x=!0,j=Date.now()},n.markLoadJustSucceeded=e=>{O=!0,R=Date.now()},n.markSaveJustFailed=e=>{h=!0},n.markLoadJustFailed=e=>{v=!0},l.registerRuntimeScenePostEventsCallback(()=>{x=!1,h=!1,O=!1,v=!1}),l.registerRuntimeScenePostEventsCallback(e=>{q(e)}),n.createGameSaveState=(e,t)=>{const{profileNames:r}=t,a={syncObjectIdentifiers:!0,shouldExcludeVariableFromData:_(r),syncAllBehaviors:!0,syncGameVariables:!0,syncSceneTimers:!0,syncOnceTriggers:!0,syncSounds:!0,syncTweens:!0,syncLayers:!0,syncAsyncTasks:!0,syncSceneVisualProps:!0,syncFullTileMaps:!0},o=b(t.profileNames,I.get(e)),s={gameNetworkSyncData:e.getNetworkSyncData({...a,syncGameVariables:o,syncSounds:o}),layoutNetworkSyncDatas:[]};return e.getSceneStack().getAllScenes().forEach((c,i)=>{s.layoutNetworkSyncDatas[i]={sceneData:{},objectDatas:{}};for(const d of c.getAdhocListOfAllInstances()){let S=r.includes("default");for(const f of d._behaviors)f instanceof l.SaveConfigurationRuntimeBehavior&&(r.includes("default")&&f.getDefaultProfilePersistence()==="Persisted"||r.some(y=>f.getPersistedInProfiles().split(",").map(g=>g.trim()).includes(y))?S=!0:S=!1);if(S){const f=d.getNetworkSyncData(a);s.layoutNetworkSyncDatas[i].objectDatas[d.id]=f}}if(b(t.profileNames,(N.get(e)||{})[c.getName()])){const d=c.getNetworkSyncData(a);d&&(s.layoutNetworkSyncDatas[i].sceneData=d)}}),s},n.createGameSaveStateInVariable=async function(e,t,r){try{const a=n.createGameSaveState(e.getGame(),{profileNames:w(r)});t.fromJSObject(a),n.markSaveJustSucceeded(e)}catch(a){p.error("Error saving to variable:",a),n.markSaveJustFailed(e)}},n.createGameSaveStateInStorage=async function(e,t,r){try{const a=n.createGameSaveState(e.getGame(),{profileNames:w(r)});await l.indexedDb.saveToIndexedDB(n.getIndexedDbDatabaseName(),n.getIndexedDbObjectStore(),n.getIndexedDbStorageKey(t),a),n.markSaveJustSucceeded(e)}catch(a){p.error("Error saving to IndexedDB:",a),n.markSaveJustFailed(e)}};const q=function(e){const t=e.getGame();if(!D)return;const{fromVariable:r,fromStorageName:a,profileNames:o,clearSceneStack:s}=D;if(D=null,r){const u=r.toJSObject();try{n.restoreGameSaveState(t,u,{profileNames:o,clearSceneStack:s}),n.markLoadJustSucceeded(e)}catch(c){p.error("Error loading from variable:",c),n.markLoadJustFailed(e)}}else a&&l.indexedDb.loadFromIndexedDB(n.getIndexedDbDatabaseName(),n.getIndexedDbObjectStore(),n.getIndexedDbStorageKey(a)).then(u=>{const c=u;n.restoreGameSaveState(t,c,{profileNames:o,clearSceneStack:s}),n.markLoadJustSucceeded(e)}).catch(u=>{p.error("Error loading from IndexedDB:",u),n.markLoadJustFailed(e)})},K=({runtimeScene:e,objectName:t,networkId:r})=>{const a=e.getInstancesOf(t);if(!a)return null;let o=a.find(u=>u.networkId===r)||null;if(o)return F.info(`Found instance ${r}, will use it for restoring.`),o;F.info(`Instance ${r} not found, creating instance ${t}.`);const s=e.createObject(t);return s?(s.networkId=r,s):null};n.restoreGameSaveState=(e,t,r)=>{const a=c=>{const i=[];return c._objects.values(i),z(i,r.profileNames)},o={clearSceneStack:r.clearSceneStack===void 0?!0:r.clearSceneStack,getExcludedObjectNames:a,preventSoundsStoppingOnStartup:!0,clearInputs:!0,keepControl:!0,ignoreVariableOwnership:!0,shouldExcludeVariableFromUpdate:_(r.profileNames)};if(t.gameNetworkSyncData){const c=b(r.profileNames,I.get(e));e.updateFromNetworkSyncData(c?t.gameNetworkSyncData:{ss:t.gameNetworkSyncData.ss},o)}const s=e.getSceneStack();s.applyUpdateFromNetworkSyncDataIfAny(o),s.getAllScenes().forEach((c,i)=>{const P=t.layoutNetworkSyncDatas[i];if(!P)return;const d=a(c),S=new Set,f=P.objectDatas;for(const y in f){const g=f[y],m=g.n;if(!m){p.warn("Tried to recreate an object without a name.");continue}if(!d.has(m))continue;const W=g.networkId||"";S.add(W);const $=K({runtimeScene:c,objectName:m,networkId:W});$&&$.updateFromNetworkSyncData(g,o)}for(const y of d){const g=[...c.getInstancesOf(y)];for(const m of g)(!m.networkId||!S.has(m.networkId))&&m.deleteFromScene()}b(r.profileNames,(N.get(e)||{})[c.getName()])&&c.updateFromNetworkSyncData(P.sceneData,o)})};const k=e=>e?e.split(",").map(t=>t.trim()):null,w=e=>k(e)||["default"];n.restoreGameSaveStateFromVariable=async function(e,t,r,a){D={fromVariable:t,profileNames:w(r),clearSceneStack:a}},n.restoreGameSaveStateFromStorage=async function(e,t,r,a){D={fromStorageName:t,profileNames:w(r),clearSceneStack:a}};const z=(e,t)=>{const r=new Set;for(const a of e){let o=t.includes("default");for(const s of a.behaviors){if(s.type!=="SaveState::SaveConfiguration")continue;const u=s.defaultProfilePersistence==="Persisted"?"Persisted":"DoNotSave",c=typeof s.persistedInProfiles=="string"?s.persistedInProfiles.split(",").map(i=>i.trim()):[];o=!1,(t.includes("default")&&u==="Persisted"||t.some(i=>c.includes(i)))&&(o=!0)}o&&r.add(a.name)}return r}})(U=l.saveState||(l.saveState={}))})(gdjs||(gdjs={}));
2
+ //# sourceMappingURL=SaveStateTools.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../GDevelop/Extensions/SaveState/SaveStateTools.ts"],
4
+ "sourcesContent": ["namespace gdjs {\n const logger = new gdjs.Logger('Save State');\n const debugLogger = new gdjs.Logger('Save State - Debug');\n // Comment this to see message logs and ease debugging:\n gdjs.Logger.getDefaultConsoleLoggerOutput().discardGroup(\n 'Save State - Debug'\n );\n\n type ArbitrarySaveConfiguration = {\n defaultProfilePersistence: 'Persisted' | 'DoNotSave';\n persistedInProfiles: Set<string>;\n };\n\n export type RestoreRequestOptions = {\n profileNames: string[];\n clearSceneStack: boolean;\n\n fromStorageName?: string;\n fromVariable?: gdjs.Variable;\n };\n\n export namespace saveState {\n export const getIndexedDbDatabaseName = () => {\n const gameId = gdjs.projectData.properties.projectUuid;\n return `gdevelop-game-${gameId}`;\n };\n export const getIndexedDbObjectStore = () => {\n return `game-saves`;\n };\n export const getIndexedDbStorageKey = (key: string) => {\n return `save-${key}`;\n };\n\n const variablesSaveConfiguration: WeakMap<\n Variable,\n ArbitrarySaveConfiguration\n > = new WeakMap();\n const runtimeSceneDataSaveConfiguration: WeakMap<\n RuntimeGame,\n Record<string, ArbitrarySaveConfiguration>\n > = new WeakMap();\n const runtimeGameDataSaveConfiguration: WeakMap<\n RuntimeGame,\n ArbitrarySaveConfiguration\n > = new WeakMap();\n\n export const setVariableSaveConfiguration = (\n _: gdjs.RuntimeScene,\n variable: gdjs.Variable,\n persistInDefaultProfile: boolean,\n persistedInProfilesAsString: string\n ) => {\n variablesSaveConfiguration.set(variable, {\n defaultProfilePersistence: persistInDefaultProfile\n ? 'Persisted'\n : 'DoNotSave',\n persistedInProfiles: new Set(\n parseCommaSeparatedProfileNames(persistedInProfilesAsString)\n ),\n });\n };\n\n export const setSceneDataSaveConfiguration = (\n runtimeScene: gdjs.RuntimeScene,\n sceneName: string,\n persistInDefaultProfile: boolean,\n persistedInProfilesAsString: string\n ) => {\n const runtimeSceneDataSaveConfigurations =\n runtimeSceneDataSaveConfiguration.get(runtimeScene.getGame()) || {};\n\n runtimeSceneDataSaveConfiguration.set(runtimeScene.getGame(), {\n ...runtimeSceneDataSaveConfigurations,\n [sceneName]: {\n defaultProfilePersistence: persistInDefaultProfile\n ? 'Persisted'\n : 'DoNotSave',\n persistedInProfiles: new Set(\n parseCommaSeparatedProfileNames(persistedInProfilesAsString)\n ),\n },\n });\n };\n\n export const setGameDataSaveConfiguration = (\n runtimeScene: gdjs.RuntimeScene,\n persistInDefaultProfile: boolean,\n persistedInProfilesAsString: string\n ) => {\n runtimeGameDataSaveConfiguration.set(runtimeScene.getGame(), {\n defaultProfilePersistence: persistInDefaultProfile\n ? 'Persisted'\n : 'DoNotSave',\n persistedInProfiles: new Set(\n parseCommaSeparatedProfileNames(persistedInProfilesAsString)\n ),\n });\n };\n\n const checkIfIsPersistedInProfiles = (\n profileNames: string[],\n configuration: ArbitrarySaveConfiguration | null | undefined\n ) => {\n if (profileNames.includes('default')) {\n if (\n !configuration ||\n configuration.defaultProfilePersistence === 'Persisted'\n ) {\n return true;\n }\n }\n\n if (configuration) {\n for (const profileName of profileNames) {\n if (configuration.persistedInProfiles.has(profileName)) {\n return true;\n }\n }\n }\n\n return false;\n };\n\n const makeIsVariableExcludedFromSaveState =\n (profileNames: string[]) => (variable: gdjs.Variable) => {\n const saveConfiguration = variablesSaveConfiguration.get(variable);\n return !checkIfIsPersistedInProfiles(\n profileNames,\n saveConfiguration || null\n );\n };\n\n let lastSaveTime: number | null = null;\n let lastLoadTime: number | null = null;\n let saveJustSucceeded: boolean = false;\n let saveJustFailed: boolean = false;\n let loadJustSucceeded: boolean = false;\n let loadJustFailed: boolean = false;\n\n let restoreRequestOptions: RestoreRequestOptions | null = null;\n\n export const getSecondsSinceLastSave = (_: RuntimeScene): number => {\n if (!lastSaveTime) return -1;\n return Math.floor((Date.now() - lastSaveTime) / 1000);\n };\n export const getSecondsSinceLastLoad = (_: RuntimeScene): number => {\n if (!lastLoadTime) return -1;\n return Math.floor((Date.now() - lastLoadTime) / 1000);\n };\n export const hasSaveJustSucceeded = (_: RuntimeScene) => {\n return saveJustSucceeded;\n };\n export const hasLoadJustSucceeded = (_: RuntimeScene) => {\n return loadJustSucceeded;\n };\n export const hasSaveJustFailed = (_: RuntimeScene) => {\n return saveJustFailed;\n };\n export const hasLoadJustFailed = (_: RuntimeScene) => {\n return loadJustFailed;\n };\n export const markSaveJustSucceeded = (_: RuntimeScene) => {\n saveJustSucceeded = true;\n lastSaveTime = Date.now();\n };\n export const markLoadJustSucceeded = (_: RuntimeScene) => {\n loadJustSucceeded = true;\n lastLoadTime = Date.now();\n };\n export const markSaveJustFailed = (_: RuntimeScene) => {\n saveJustFailed = true;\n };\n export const markLoadJustFailed = (_: RuntimeScene) => {\n loadJustFailed = true;\n };\n\n // Ensure that the condition \"save/load just succeeded/failed\" are valid only for one frame.\n gdjs.registerRuntimeScenePostEventsCallback(() => {\n saveJustSucceeded = false;\n saveJustFailed = false;\n loadJustSucceeded = false;\n loadJustFailed = false;\n });\n\n gdjs.registerRuntimeScenePostEventsCallback(\n (runtimeScene: gdjs.RuntimeScene) => {\n checkAndRestoreGameSaveStateAtEndOfFrame(runtimeScene);\n }\n );\n\n /**\n * Create a Save State from the given game.\n *\n * Only objects, variables etc... tagged with at least one of the profiles\n * given in `options.profileNames` will be saved.\n */\n export const createGameSaveState = (\n runtimeGame: RuntimeGame,\n options: {\n profileNames: string[];\n }\n ) => {\n const { profileNames } = options;\n\n const getNetworkSyncOptions: GetNetworkSyncDataOptions = {\n syncObjectIdentifiers: true,\n shouldExcludeVariableFromData:\n makeIsVariableExcludedFromSaveState(profileNames),\n syncAllBehaviors: true,\n syncGameVariables: true,\n syncSceneTimers: true,\n syncOnceTriggers: true,\n syncSounds: true,\n syncTweens: true,\n syncLayers: true,\n syncAsyncTasks: true,\n syncSceneVisualProps: true,\n syncFullTileMaps: true,\n };\n\n const shouldPersistGameData = checkIfIsPersistedInProfiles(\n options.profileNames,\n runtimeGameDataSaveConfiguration.get(runtimeGame)\n );\n\n const gameSaveState: GameSaveState = {\n // Always persist some game data, but limit it to just the scene stack\n // if asked to not persist the game data.\n gameNetworkSyncData: runtimeGame.getNetworkSyncData({\n ...getNetworkSyncOptions,\n syncGameVariables: shouldPersistGameData,\n syncSounds: shouldPersistGameData,\n }),\n layoutNetworkSyncDatas: [],\n };\n\n const scenes = runtimeGame.getSceneStack().getAllScenes();\n scenes.forEach((runtimeScene, index) => {\n gameSaveState.layoutNetworkSyncDatas[index] = {\n sceneData: {} as LayoutNetworkSyncData,\n objectDatas: {},\n };\n\n // First collect all object sync data, as they may generate unique\n // identifiers like their networkId.\n for (const object of runtimeScene.getAdhocListOfAllInstances()) {\n // By default, an object which has no SaveConfiguration behavior is like\n // it has the default profile persistence set to \"Persisted\".\n let shouldPersist = profileNames.includes('default');\n\n // @ts-ignore - access to `_behaviors` is an exceptional case for the SaveConfiguration behavior.\n for (const behavior of object._behaviors) {\n if (behavior instanceof gdjs.SaveConfigurationRuntimeBehavior) {\n // This object has a SaveConfiguration behavior. Check if the configuration is set to\n // persist it in one of the given profiles.\n if (\n (profileNames.includes('default') &&\n behavior.getDefaultProfilePersistence() === 'Persisted') ||\n profileNames.some((profileName) =>\n // TODO: avoid do it for every single object instance?\n behavior\n .getPersistedInProfiles()\n .split(',')\n .map((profileName) => profileName.trim())\n .includes(profileName)\n )\n ) {\n shouldPersist = true;\n } else {\n shouldPersist = false;\n }\n }\n }\n\n if (shouldPersist) {\n const objectSyncData = object.getNetworkSyncData(\n getNetworkSyncOptions\n );\n gameSaveState.layoutNetworkSyncDatas[index].objectDatas[object.id] =\n objectSyncData;\n }\n }\n\n // Collect scene data after the objects:\n const shouldPersistSceneData = checkIfIsPersistedInProfiles(\n options.profileNames,\n (runtimeSceneDataSaveConfiguration.get(runtimeGame) || {})[\n runtimeScene.getName()\n ]\n );\n if (shouldPersistSceneData) {\n const sceneData = runtimeScene.getNetworkSyncData(\n getNetworkSyncOptions\n );\n if (sceneData) {\n gameSaveState.layoutNetworkSyncDatas[index].sceneData = sceneData;\n }\n }\n });\n\n return gameSaveState;\n };\n\n export const createGameSaveStateInVariable = async function (\n runtimeScene: RuntimeScene,\n variable: gdjs.Variable,\n commaSeparatedProfileNames: string\n ) {\n try {\n const gameSaveState = createGameSaveState(runtimeScene.getGame(), {\n profileNames: parseCommaSeparatedProfileNamesOrDefault(\n commaSeparatedProfileNames\n ),\n });\n variable.fromJSObject(gameSaveState);\n markSaveJustSucceeded(runtimeScene);\n } catch (error) {\n logger.error('Error saving to variable:', error);\n markSaveJustFailed(runtimeScene);\n }\n };\n\n export const createGameSaveStateInStorage = async function (\n runtimeScene: RuntimeScene,\n storageKey: string,\n commaSeparatedProfileNames: string\n ) {\n try {\n const gameSaveState = createGameSaveState(runtimeScene.getGame(), {\n profileNames: parseCommaSeparatedProfileNamesOrDefault(\n commaSeparatedProfileNames\n ),\n });\n await gdjs.indexedDb.saveToIndexedDB(\n getIndexedDbDatabaseName(),\n getIndexedDbObjectStore(),\n getIndexedDbStorageKey(storageKey),\n gameSaveState\n );\n markSaveJustSucceeded(runtimeScene);\n } catch (error) {\n logger.error('Error saving to IndexedDB:', error);\n markSaveJustFailed(runtimeScene);\n }\n };\n\n const checkAndRestoreGameSaveStateAtEndOfFrame = function (\n runtimeScene: RuntimeScene\n ) {\n const runtimeGame = runtimeScene.getGame();\n\n if (!restoreRequestOptions) return;\n const { fromVariable, fromStorageName, profileNames, clearSceneStack } =\n restoreRequestOptions;\n\n // Reset it so we don't load it twice.\n restoreRequestOptions = null;\n\n if (fromVariable) {\n const saveState = fromVariable.toJSObject();\n\n try {\n restoreGameSaveState(runtimeGame, saveState, {\n profileNames,\n clearSceneStack,\n });\n markLoadJustSucceeded(runtimeScene);\n } catch (error) {\n logger.error('Error loading from variable:', error);\n markLoadJustFailed(runtimeScene);\n }\n } else if (fromStorageName) {\n gdjs.indexedDb\n .loadFromIndexedDB(\n getIndexedDbDatabaseName(),\n getIndexedDbObjectStore(),\n getIndexedDbStorageKey(fromStorageName)\n )\n .then((jsonData) => {\n const saveState = jsonData as GameSaveState;\n restoreGameSaveState(runtimeGame, saveState, {\n profileNames,\n clearSceneStack,\n });\n markLoadJustSucceeded(runtimeScene);\n })\n .catch((error) => {\n logger.error('Error loading from IndexedDB:', error);\n markLoadJustFailed(runtimeScene);\n });\n }\n };\n\n const getInstanceFromNetworkId = ({\n runtimeScene,\n objectName,\n networkId,\n }: {\n runtimeScene: gdjs.RuntimeScene;\n objectName: string;\n networkId: string;\n }): gdjs.RuntimeObject | null => {\n const instances = runtimeScene.getInstancesOf(objectName);\n if (!instances) {\n // object does not exist in the scene, cannot find the instance.\n return null;\n }\n let instance =\n instances.find((instance) => instance.networkId === networkId) || null;\n\n // Check if there is already an instance with the given network ID.\n if (instance) {\n debugLogger.info(\n `Found instance ${networkId}, will use it for restoring.`\n );\n return instance;\n }\n\n // Instance not found - it must have been deleted. Create it now.\n debugLogger.info(\n `Instance ${networkId} not found, creating instance ${objectName}.`\n );\n const newInstance = runtimeScene.createObject(objectName);\n if (!newInstance) {\n // Object does not exist in the scene, cannot create the instance.\n return null;\n }\n\n newInstance.networkId = networkId;\n return newInstance;\n };\n\n /**\n * Restore the game using the given Save State.\n *\n * `options.profileNames` is the list of profiles to restore: only objects, variables etc... tagged with at least\n * one of these profiles will be restored (or recreated if they don't exist, or deleted if not in the save state).\n * Others will be left untouched.\n *\n * If `options.clearSceneStack` is true, all the scenes will be unloaded and re-created\n * (meaning all instances will be re-created, variables will go back to their initial values, etc...).\n * Otherwise, the existing scenes will be updated (or unloaded or created if the save state has different scenes).\n */\n export const restoreGameSaveState = (\n runtimeGame: RuntimeGame,\n saveState: GameSaveState,\n options: {\n profileNames: string[];\n clearSceneStack: boolean;\n }\n ): void => {\n const getObjectNamesToRestoreForRuntimeScene = (\n runtimeScene: RuntimeScene\n ): Set<string> => {\n const allObjectData = [];\n runtimeScene._objects.values(allObjectData);\n return getObjectNamesIncludedInProfiles(\n allObjectData,\n options.profileNames\n );\n };\n\n const updateFromNetworkSyncDataOptions: UpdateFromNetworkSyncDataOptions =\n {\n clearSceneStack:\n options.clearSceneStack === undefined\n ? true\n : options.clearSceneStack,\n getExcludedObjectNames: getObjectNamesToRestoreForRuntimeScene,\n preventSoundsStoppingOnStartup: true,\n clearInputs: true,\n keepControl: true,\n ignoreVariableOwnership: true,\n shouldExcludeVariableFromUpdate: makeIsVariableExcludedFromSaveState(\n options.profileNames\n ),\n };\n\n // First update the game, which will update the variables,\n // and set the scene stack to update when ready.\n if (saveState.gameNetworkSyncData) {\n const shouldRestoreGameData = checkIfIsPersistedInProfiles(\n options.profileNames,\n runtimeGameDataSaveConfiguration.get(runtimeGame)\n );\n\n runtimeGame.updateFromNetworkSyncData(\n shouldRestoreGameData\n ? saveState.gameNetworkSyncData\n : {\n // Disable game data restoration if asked to, but\n // still always keep `ss` (scene stack) restoration as it's always needed.\n ss: saveState.gameNetworkSyncData.ss,\n },\n updateFromNetworkSyncDataOptions\n );\n }\n\n // Apply the scene stack updates, as we are at the end of a frame,\n // we can safely do it.\n const sceneStack = runtimeGame.getSceneStack();\n sceneStack.applyUpdateFromNetworkSyncDataIfAny(\n updateFromNetworkSyncDataOptions\n );\n\n // Then get all scenes, which we assume will be the expected ones\n // after the load has been done, so we can update them,\n // and create their objects.\n const runtimeScenes = sceneStack.getAllScenes();\n runtimeScenes.forEach((runtimeScene, index) => {\n const layoutSyncData = saveState.layoutNetworkSyncDatas[index];\n if (!layoutSyncData) return;\n\n // List names of objects that must be restored\n // (and only them - instances of others will be left alone).\n const objectNamesToRestore =\n getObjectNamesToRestoreForRuntimeScene(runtimeScene);\n\n // Create objects first, so they are available for the scene update,\n // especially so that they have a networkId defined.\n const allLoadedNetworkIds = new Set<string>();\n const objectDatas = layoutSyncData.objectDatas;\n for (const id in objectDatas) {\n const objectNetworkSyncData = objectDatas[id];\n const objectName = objectNetworkSyncData.n;\n if (!objectName) {\n logger.warn('Tried to recreate an object without a name.');\n continue;\n }\n if (!objectNamesToRestore.has(objectName)) {\n // Object is in the save state, but not in the profiles to restore, don't restore it.\n continue;\n }\n\n // Object is both in the save state and in the profiles to restore, restore it.\n // Either find the existing instance with the same networkId, or create a new one.\n const networkId = objectNetworkSyncData.networkId || '';\n allLoadedNetworkIds.add(networkId);\n\n const object = getInstanceFromNetworkId({\n runtimeScene,\n objectName: objectName,\n networkId,\n });\n if (object) {\n object.updateFromNetworkSyncData(\n objectNetworkSyncData,\n updateFromNetworkSyncDataOptions\n );\n }\n }\n\n // Clean instances of objects that are not in the profiles to restore but not in the save state\n // (i.e: those who don't have a networkId, or it's not in the save state: they must not exist).\n for (const objectName of objectNamesToRestore) {\n // /!\\ Clone the instances to avoid it being modified while iterating through them.\n const objects = [...runtimeScene.getInstancesOf(objectName)];\n for (const object of objects) {\n // This is an object instance that is part of the object that are being restored,\n // but it has not network id (created after the save state was created) or the network\n // id is not in the save state: it's not part of the save state and must be deleted.\n if (\n !object.networkId ||\n !allLoadedNetworkIds.has(object.networkId)\n ) {\n object.deleteFromScene();\n }\n }\n }\n\n // Update the rest of the scene last.\n if (\n checkIfIsPersistedInProfiles(\n options.profileNames,\n (runtimeSceneDataSaveConfiguration.get(runtimeGame) || {})[\n runtimeScene.getName()\n ]\n )\n ) {\n runtimeScene.updateFromNetworkSyncData(\n layoutSyncData.sceneData,\n updateFromNetworkSyncDataOptions\n );\n }\n });\n };\n\n const parseCommaSeparatedProfileNames = (\n commaSeparatedProfileNames: string\n ): string[] | null => {\n if (!commaSeparatedProfileNames) return null;\n\n return commaSeparatedProfileNames\n .split(',')\n .map((profileName) => profileName.trim());\n };\n\n const parseCommaSeparatedProfileNamesOrDefault = (\n commaSeparatedProfileNames: string\n ): string[] => {\n return (\n parseCommaSeparatedProfileNames(commaSeparatedProfileNames) || [\n 'default',\n ]\n );\n };\n\n export const restoreGameSaveStateFromVariable = async function (\n _: gdjs.RuntimeScene,\n variable: gdjs.Variable,\n commaSeparatedProfileNames: string,\n clearSceneStack: boolean\n ) {\n // The information is saved, so that the restore can be done\n // at the end of the frame,\n // and avoid possible conflicts with running events.\n restoreRequestOptions = {\n fromVariable: variable,\n profileNames: parseCommaSeparatedProfileNamesOrDefault(\n commaSeparatedProfileNames\n ),\n clearSceneStack,\n };\n };\n\n export const restoreGameSaveStateFromStorage = async function (\n _: gdjs.RuntimeScene,\n storageName: string,\n commaSeparatedProfileNames: string,\n clearSceneStack: boolean\n ) {\n // The information is saved, so that the restore can be done\n // at the end of the frame,\n // and avoid possible conflicts with running events.\n restoreRequestOptions = {\n fromStorageName: storageName,\n profileNames: parseCommaSeparatedProfileNamesOrDefault(\n commaSeparatedProfileNames\n ),\n clearSceneStack,\n };\n };\n\n /**\n * Compute, by looking at the \"static\" object data (i.e: in the Project Data),\n * the name of objects which must be restored, based on the given profiles.\n */\n const getObjectNamesIncludedInProfiles = (\n allObjectData: ObjectData[],\n profileNames: string[]\n ): Set<string> => {\n const objectNames = new Set<string>();\n for (const objectData of allObjectData) {\n // By default, an object which has no SaveConfiguration behavior is like\n // it has the default profile persistence set to \"Persisted\".\n let includedInProfiles = profileNames.includes('default');\n\n for (const behaviorData of objectData.behaviors) {\n if (behaviorData.type !== 'SaveState::SaveConfiguration') continue;\n\n const defaultProfilePersistence =\n behaviorData.defaultProfilePersistence === 'Persisted'\n ? 'Persisted'\n : 'DoNotSave';\n const persistedInProfiles =\n typeof behaviorData.persistedInProfiles === 'string'\n ? behaviorData.persistedInProfiles\n .split(',')\n .map((profileName: string) => profileName.trim())\n : [];\n\n // This object has a SaveConfiguration behavior. Check if the configuration is set to\n // persist it in one of the given profiles.\n includedInProfiles = false;\n\n if (\n (profileNames.includes('default') &&\n defaultProfilePersistence === 'Persisted') ||\n profileNames.some((profileName) =>\n persistedInProfiles.includes(profileName)\n )\n ) {\n // This object must be persisted in one of the given profile.\n includedInProfiles = true;\n }\n }\n\n if (includedInProfiles) {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n){class a extends n.RuntimeObject{constructor(e,i){super(e,i);this._opacity=255;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this._currentAnimationIndex=-1;this._animationSpeedScale=1;this._animationPaused=!1;this._isPausedFrameDirty=!1;this._animations=i.content.animations,this._originalScale=i.content.scale,this.spineResourceName=i.content.spineResourceName,this._animationMixingDuration=0,this._renderer=new n.SpineRuntimeObjectRenderer(this,e),this.setAnimationIndex(0),this._renderer.updateAnimation(0),this.onCreated()}update(e){if(this._animationPaused){this._isPausedFrameDirty&&(this._renderer.updateAnimation(0),this.invalidateHitboxes(),this._isPausedFrameDirty=!1);return}const i=this.getElapsedTime()/1e3;this._renderer.updateAnimation(i*this._animationSpeedScale),this.invalidateHitboxes()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,i){return super.updateFromObjectData(e,i),e.content.scale!==i.content.scale&&(this._originalScale=i.content.scale,this._renderer.updateScale(),this.invalidateHitboxes()),!0}getNetworkSyncData(){return{...super.getNetworkSyncData(),opa:this._opacity,scaX:this.getScaleX(),scaY:this.getScaleY(),flipX:this.isFlippedX(),flipY:this.isFlippedY(),ani:this.getAnimationIndex(),anmd:this.getAnimationMixingDuration(),anp:this.isAnimationPaused(),anss:this.getAnimationSpeedScale(),anet:this.getAnimationElapsedTime()}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e),e.opa!==void 0&&e.opa!==this._opacity&&this.setOpacity(e.opa),e.scaX!==void 0&&e.scaX!==this.getScaleX()&&this.setScaleX(e.scaX),e.scaY!==void 0&&e.scaY!==this.getScaleY()&&this.setScaleY(e.scaY),e.flipX!==void 0&&e.flipX!==this.isFlippedX()&&this.flipX(e.flipX),e.flipY!==void 0&&e.flipY!==this.isFlippedY()&&this.flipY(e.flipY),e.ani!==void 0&&e.ani!==this.getAnimationIndex()&&this.setAnimationIndex(e.ani),e.anmd!==void 0&&e.anmd!==this.getAnimationMixingDuration()&&this.setAnimationMixingDuration(e.anmd),e.anp!==void 0&&e.anp!==this.isAnimationPaused()&&(e.anp?this.pauseAnimation():this.resumeAnimation()),e.anss!==void 0&&e.anss!==this.getAnimationSpeedScale()&&this.setAnimationSpeedScale(e.anss),e.anet!==void 0&&e.anet!==this.getAnimationElapsedTime()&&this.setAnimationElapsedTime(e.anet)}extraInitializationFromInitialInstance(e){const i=e.numberProperties.find(t=>t.name==="animation"),s=i?i.value:this._currentAnimationIndex;this.setAnimationIndexWithMixing(s,0),e.customSize&&(this.setSize(e.width,e.height),this.invalidateHitboxes()),e.opacity!==void 0&&this.setOpacity(e.opacity),e.flippedX&&this.flipX(e.flippedX),e.flippedY&&this.flipY(e.flippedY)}getDrawableX(){const e=this._renderer.getOriginOffset();return this.getX()+e.x}getDrawableY(){const e=this._renderer.getOriginOffset();return this.getY()+e.y}getCenterX(){return-this._renderer.getOriginOffset().x}getCenterY(){return-this._renderer.getOriginOffset().y}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=Math.max(0,Math.min(255,e)),this._renderer.updateOpacity()}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}setWidth(e){const i=this._renderer.getUnscaledWidth();i!==0&&this.setScaleX(e/i)}setHeight(e){const i=this._renderer.getUnscaledHeight();i!==0&&this.setScaleY(e/i)}setSize(e,i){this.setWidth(e),this.setHeight(i)}setScale(e){e<0&&(e=0),!(e===Math.abs(this._scaleX)&&e===Math.abs(this._scaleY))&&(this._scaleX=e*(this._flippedX?-1:1),this._scaleY=e*(this._flippedY?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}setScaleX(e){e<0&&(e=0),e!==Math.abs(this._scaleX)&&(this._scaleX=e*(this._flippedX?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}setScaleY(e){e<0&&(e=0),e!==Math.abs(this._scaleY)&&(this._scaleY=e*(this._flippedY?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}getScale(){const e=Math.abs(this._scaleX),i=Math.abs(this._scaleY);return e===i?e:Math.sqrt(e*i)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}flipX(e){e!==this._flippedX&&(this._scaleX*=-1,this._flippedX=e,this.invalidateHitboxes(),this._renderer.updateScale())}flipY(e){e!==this._flippedY&&(this._scaleY*=-1,this._flippedY=e,this.invalidateHitboxes(),this._renderer.updateScale())}setAnimationIndex(e){this.setAnimationIndexWithMixing(e,this._animationMixingDuration)}setAnimationIndexWithMixing(e,i){if(this._animations.length===0||this._currentAnimationIndex===e||!this.isAnimationIndex(e))return;const s=this._animations[this._currentAnimationIndex],t=this._animations[e];this._currentAnimationIndex=e,s&&this._renderer.setMixing(s.source,t.source,i),this._renderer.setAnimation(t.source,t.loop),this._isPausedFrameDirty=!0}setAnimationName(e){this.setAnimationNameWithMixing(e,this._animationMixingDuration)}setAnimationNameWithMixing(e,i){this.setAnimationIndexWithMixing(this.getAnimationIndexFor(e),i)}getAnimationIndexFor(e){return this._animations.findIndex(i=>i.name===e)}getAnimationMixingDuration(){return this._animationMixingDuration}setAnimationMixingDuration(e){this._animationMixingDuration=e}getAnimationIndex(){return this._currentAnimationIndex}getAnimationName(){return this.isAnimationIndex(this._currentAnimationIndex)?this._animations[this._currentAnimationIndex].name:""}isAnimationIndex(e){return Number.isInteger(e)&&e>=0&&e<this._animations.length}hasAnimationEnded(){return this._renderer.isAnimationComplete()}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0}resumeAnimation(){this._animationPaused=!1}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(e){this._animationSpeedScale=e}getAnimationElapsedTime(){return this._animations.length===0?0:this._renderer.getAnimationElapsedTime()}setAnimationElapsedTime(e){this._animations.length!==0&&(this._renderer.setAnimationElapsedTime(e),this._isPausedFrameDirty=!0)}getPointAttachmentX(e,i){return this._renderer.getPointAttachmentPosition(e,i).x}getPointAttachmentY(e,i){return this._renderer.getPointAttachmentPosition(e,i).y}getAnimationDuration(){return this._animations.length===0?0:this._renderer.getAnimationDuration(this._animations[this._currentAnimationIndex].source)}}n.SpineRuntimeObject=a,n.registerObject("SpineObject::SpineObject",n.SpineRuntimeObject)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const s=class extends n.RuntimeObject{constructor(e,i){super(e,i);this._opacity=255;this._scaleX=1;this._scaleY=1;this._flippedX=!1;this._flippedY=!1;this._currentAnimationIndex=-1;this._animationSpeedScale=1;this._animationPaused=!1;this._isPausedFrameDirty=!1;this._animations=i.content.animations,this._originalScale=i.content.scale,this.spineResourceName=i.content.spineResourceName,this._animationMixingDuration=0,this._renderer=new n.SpineRuntimeObjectRenderer(this,e),this.setAnimationIndex(0),this._renderer.updateAnimation(0),s.isHitBoxesUpdateDisabled&&(this.hitBoxes.length=0),this.onCreated()}update(e){if(this._animationPaused){this._isPausedFrameDirty&&(this._renderer.updateAnimation(0),this.invalidateHitboxes(),this._isPausedFrameDirty=!1);return}const i=this.getElapsedTime()/1e3;this._renderer.updateAnimation(i*this._animationSpeedScale),this.invalidateHitboxes()}getRendererObject(){return this._renderer.getRendererObject()}updateFromObjectData(e,i){return super.updateFromObjectData(e,i),e.content.scale!==i.content.scale&&(this._originalScale=i.content.scale,this._renderer.updateScale(),this.invalidateHitboxes()),!0}getNetworkSyncData(e){return{...super.getNetworkSyncData(e),opa:this._opacity,scaX:this.getScaleX(),scaY:this.getScaleY(),flipX:this.isFlippedX(),flipY:this.isFlippedY(),ani:this.getAnimationIndex(),anmd:this.getAnimationMixingDuration(),anp:this.isAnimationPaused(),anss:this.getAnimationSpeedScale(),anet:this.getAnimationElapsedTime()}}updateFromNetworkSyncData(e,i){super.updateFromNetworkSyncData(e,i),e.opa!==void 0&&e.opa!==this._opacity&&this.setOpacity(e.opa),e.scaX!==void 0&&e.scaX!==this.getScaleX()&&this.setScaleX(e.scaX),e.scaY!==void 0&&e.scaY!==this.getScaleY()&&this.setScaleY(e.scaY),e.flipX!==void 0&&e.flipX!==this.isFlippedX()&&this.flipX(e.flipX),e.flipY!==void 0&&e.flipY!==this.isFlippedY()&&this.flipY(e.flipY),e.ani!==void 0&&e.ani!==this.getAnimationIndex()&&this.setAnimationIndex(e.ani),e.anmd!==void 0&&e.anmd!==this.getAnimationMixingDuration()&&this.setAnimationMixingDuration(e.anmd),e.anp!==void 0&&e.anp!==this.isAnimationPaused()&&(e.anp?this.pauseAnimation():this.resumeAnimation()),e.anss!==void 0&&e.anss!==this.getAnimationSpeedScale()&&this.setAnimationSpeedScale(e.anss),e.anet!==void 0&&e.anet!==this.getAnimationElapsedTime()&&this.setAnimationElapsedTime(e.anet)}updateHitBoxes(){s.isHitBoxesUpdateDisabled||super.updateHitBoxes()}extraInitializationFromInitialInstance(e){const i=e.numberProperties.find(t=>t.name==="animation"),a=i?i.value:this._currentAnimationIndex;this.setAnimationIndexWithMixing(a,0),e.customSize&&(this.setSize(e.width,e.height),this.invalidateHitboxes()),e.opacity!==void 0&&this.setOpacity(e.opacity),e.flippedX&&this.flipX(e.flippedX),e.flippedY&&this.flipY(e.flippedY)}getDrawableX(){const e=this._renderer.getOriginOffset();return this.getX()+e.x}getDrawableY(){const e=this._renderer.getOriginOffset();return this.getY()+e.y}getCenterX(){return-this._renderer.getOriginOffset().x}getCenterY(){return-this._renderer.getOriginOffset().y}onDestroyed(){super.onDestroyed(),this._renderer.onDestroy()}setX(e){super.setX(e),this._renderer.updatePosition()}setY(e){super.setY(e),this._renderer.updatePosition()}setAngle(e){super.setAngle(e),this._renderer.updateAngle()}setOpacity(e){this._opacity=Math.max(0,Math.min(255,e)),this._renderer.updateOpacity()}getOpacity(){return this._opacity}getWidth(){return this._renderer.getWidth()}getHeight(){return this._renderer.getHeight()}setWidth(e){const i=this._renderer.getUnscaledWidth();i!==0&&this.setScaleX(e/i)}setHeight(e){const i=this._renderer.getUnscaledHeight();i!==0&&this.setScaleY(e/i)}setSize(e,i){this.setWidth(e),this.setHeight(i)}setScale(e){e<0&&(e=0),!(e===Math.abs(this._scaleX)&&e===Math.abs(this._scaleY))&&(this._scaleX=e*(this._flippedX?-1:1),this._scaleY=e*(this._flippedY?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}setScaleX(e){e<0&&(e=0),e!==Math.abs(this._scaleX)&&(this._scaleX=e*(this._flippedX?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}setScaleY(e){e<0&&(e=0),e!==Math.abs(this._scaleY)&&(this._scaleY=e*(this._flippedY?-1:1),this._renderer.updateScale(),this.invalidateHitboxes())}getScale(){const e=Math.abs(this._scaleX),i=Math.abs(this._scaleY);return e===i?e:Math.sqrt(e*i)}getScaleY(){return Math.abs(this._scaleY)}getScaleX(){return Math.abs(this._scaleX)}isFlippedX(){return this._flippedX}isFlippedY(){return this._flippedY}flipX(e){e!==this._flippedX&&(this._scaleX*=-1,this._flippedX=e,this.invalidateHitboxes(),this._renderer.updateScale())}flipY(e){e!==this._flippedY&&(this._scaleY*=-1,this._flippedY=e,this.invalidateHitboxes(),this._renderer.updateScale())}setAnimationIndex(e){this.setAnimationIndexWithMixing(e,this._animationMixingDuration)}setAnimationIndexWithMixing(e,i){if(this._animations.length===0||this._currentAnimationIndex===e||!this.isAnimationIndex(e))return;const a=this._animations[this._currentAnimationIndex],t=this._animations[e];this._currentAnimationIndex=e,a&&this._renderer.setMixing(a.source,t.source,i),this._renderer.setAnimation(t.source,t.loop),this._isPausedFrameDirty=!0}setAnimationName(e){this.setAnimationNameWithMixing(e,this._animationMixingDuration)}setAnimationNameWithMixing(e,i){this.setAnimationIndexWithMixing(this.getAnimationIndexFor(e),i)}getAnimationIndexFor(e){return this._animations.findIndex(i=>i.name===e)}getAnimationMixingDuration(){return this._animationMixingDuration}setAnimationMixingDuration(e){this._animationMixingDuration=e}getAnimationIndex(){return this._currentAnimationIndex}getAnimationName(){return this.isAnimationIndex(this._currentAnimationIndex)?this._animations[this._currentAnimationIndex].name:""}isAnimationIndex(e){return Number.isInteger(e)&&e>=0&&e<this._animations.length}hasAnimationEnded(){return this._renderer.isAnimationComplete()}isAnimationPaused(){return this._animationPaused}pauseAnimation(){this._animationPaused=!0}resumeAnimation(){this._animationPaused=!1}getAnimationSpeedScale(){return this._animationSpeedScale}setAnimationSpeedScale(e){this._animationSpeedScale=e}getAnimationElapsedTime(){return this._animations.length===0?0:this._renderer.getAnimationElapsedTime()}setAnimationElapsedTime(e){this._animations.length!==0&&(this._renderer.setAnimationElapsedTime(e),this._isPausedFrameDirty=!0)}getPointAttachmentX(e,i){return this._renderer.getPointAttachmentPosition(e,i).x}getPointAttachmentY(e,i){return this._renderer.getPointAttachmentPosition(e,i).y}getAnimationDuration(){return this._animations.length===0?0:this._renderer.getAnimationDuration(this._animations[this._currentAnimationIndex].source)}};let r=s;r.isHitBoxesUpdateDisabled=!1,n.SpineRuntimeObject=r,n.registerObject("SpineObject::SpineObject",n.SpineRuntimeObject)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=spineruntimeobject.js.map