gdcore-tools 2.0.0-beta5 → 2.0.0-beta7

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 (170) hide show
  1. package/dist/Runtime/Cordova/config.xml +4 -0
  2. package/dist/Runtime/Cordova/package.json +12 -20
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js +1 -1
  6. package/dist/Runtime/CustomRuntimeObjectInstanceContainer.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  8. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/AmbientLight.js +1 -1
  10. package/dist/Runtime/Extensions/3D/AmbientLight.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  12. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  13. package/dist/Runtime/Extensions/3D/DirectionalLight.js +1 -1
  14. package/dist/Runtime/Extensions/3D/DirectionalLight.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/ExponentialFog.js +1 -1
  16. package/dist/Runtime/Extensions/3D/ExponentialFog.js.map +2 -2
  17. package/dist/Runtime/Extensions/3D/HemisphereLight.js +1 -1
  18. package/dist/Runtime/Extensions/3D/HemisphereLight.js.map +2 -2
  19. package/dist/Runtime/Extensions/3D/JsExtension.js +419 -228
  20. package/dist/Runtime/Extensions/3D/LinearFog.js +1 -1
  21. package/dist/Runtime/Extensions/3D/LinearFog.js.map +2 -2
  22. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  23. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  24. package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
  25. package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
  26. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js +1 -1
  27. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  28. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  29. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  30. package/dist/Runtime/Extensions/BBText/JsExtension.js +45 -42
  31. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  32. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +40 -49
  34. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  35. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/JsExtension.js +2 -2
  37. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js +1 -1
  38. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  39. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js +1 -1
  40. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  41. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js +1 -1
  42. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  43. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js +1 -1
  44. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  45. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js +1 -1
  46. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  47. package/dist/Runtime/Extensions/ExampleJsExtension/JsExtension.js +18 -21
  48. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js +1 -1
  49. package/dist/Runtime/Extensions/Firebase/B_firebasetools/C_firebasetools.js.map +2 -2
  50. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +8 -2
  51. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js +1 -1
  52. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  53. package/dist/Runtime/Extensions/Lighting/JsExtension.js +50 -38
  54. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js +1 -1
  55. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  56. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +112 -7
  57. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  58. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  59. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
  60. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
  61. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  62. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  63. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
  64. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  65. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js +1 -1
  66. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  67. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  68. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  69. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js +1 -1
  70. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  71. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  72. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +127 -40
  74. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  75. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  76. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  77. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  78. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  79. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  80. package/dist/Runtime/Extensions/Spine/JsExtension.js +77 -36
  81. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js +1 -1
  82. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
  83. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  84. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  85. package/dist/Runtime/Extensions/TextInput/JsExtension.js +55 -56
  86. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  87. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  88. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  89. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  90. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js +1 -1
  91. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  92. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  93. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  94. package/dist/Runtime/Extensions/TileMap/JsExtension.js +511 -287
  95. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js +1 -1
  96. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  97. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js +1 -1
  98. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  99. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  100. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  101. package/dist/Runtime/Extensions/TileMap/helper/dts/load/tiled/TiledTileMapLoader.d.ts.map +1 -1
  102. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +12 -1
  103. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts.map +1 -1
  104. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapManager.d.ts.map +1 -1
  105. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts +1 -0
  106. package/dist/Runtime/Extensions/TileMap/helper/dts/render/TileMapPixiHelper.d.ts.map +1 -1
  107. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  108. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  109. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  110. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  111. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  112. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  113. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  114. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  115. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  116. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  117. package/dist/Runtime/Extensions/TweenBehavior/JsExtension.js +1 -0
  118. package/dist/Runtime/Extensions/Video/JsExtension.js +35 -44
  119. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  120. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  121. package/dist/Runtime/ResourceLoader.js +1 -1
  122. package/dist/Runtime/ResourceLoader.js.map +2 -2
  123. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  124. package/dist/Runtime/SpriteAnimator.js +1 -1
  125. package/dist/Runtime/SpriteAnimator.js.map +2 -2
  126. package/dist/Runtime/debugger-client/InGameDebugger.js +1 -1
  127. package/dist/Runtime/debugger-client/InGameDebugger.js.map +2 -2
  128. package/dist/Runtime/debugger-client/abstract-debugger-client.js +1 -1
  129. package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
  130. package/dist/Runtime/debugger-client/hot-reloader.js +2 -1
  131. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  132. package/dist/Runtime/debugger-client/minimal-debugger-client.js +2 -0
  133. package/dist/Runtime/debugger-client/minimal-debugger-client.js.map +7 -0
  134. package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
  135. package/dist/Runtime/debugger-client/window-message-debugger-client.js.map +2 -2
  136. package/dist/Runtime/events-tools/inputtools.js +1 -1
  137. package/dist/Runtime/events-tools/inputtools.js.map +2 -2
  138. package/dist/Runtime/events-tools/objecttools.js +1 -1
  139. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  140. package/dist/Runtime/gd.js +1 -1
  141. package/dist/Runtime/gd.js.map +2 -2
  142. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  143. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  144. package/dist/Runtime/inputmanager.js +1 -1
  145. package/dist/Runtime/inputmanager.js.map +2 -2
  146. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js +1 -1
  147. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  148. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js +1 -1
  149. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  150. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  151. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  152. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js +1 -1
  153. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  154. package/dist/Runtime/runtimegame.js +1 -1
  155. package/dist/Runtime/runtimegame.js.map +2 -2
  156. package/dist/Runtime/runtimeobject.js +1 -1
  157. package/dist/Runtime/runtimeobject.js.map +2 -2
  158. package/dist/Runtime/runtimescene.js +1 -1
  159. package/dist/Runtime/runtimescene.js.map +2 -2
  160. package/dist/Runtime/scenestack.js +1 -1
  161. package/dist/Runtime/scenestack.js.map +2 -2
  162. package/dist/Runtime/spriteruntimeobject.js +1 -1
  163. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  164. package/dist/Runtime/types/project-data.d.ts +36 -8
  165. package/dist/Runtime/variablescontainer.js +1 -1
  166. package/dist/Runtime/variablescontainer.js.map +2 -2
  167. package/dist/lib/libGD.cjs +1 -1
  168. package/dist/lib/libGD.wasm +0 -0
  169. package/gd.d.ts +149 -75
  170. package/package.json +3 -3
@@ -136,7 +136,7 @@ module.exports = {
136
136
  }
137
137
 
138
138
  if (propertyName === 'linearDamping') {
139
- const newValueAsNumber = parseFloat(newValue);
139
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
140
140
  if (newValueAsNumber !== newValueAsNumber) return false;
141
141
  behaviorContent
142
142
  .getChild('linearDamping')
@@ -145,7 +145,7 @@ module.exports = {
145
145
  }
146
146
 
147
147
  if (propertyName === 'angularDamping') {
148
- const newValueAsNumber = parseFloat(newValue);
148
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
149
149
  if (newValueAsNumber !== newValueAsNumber) return false;
150
150
  behaviorContent
151
151
  .getChild('angularDamping')
@@ -182,16 +182,30 @@ module.exports = {
182
182
  .setValue(behaviorContent.getChild('bodyType').getStringValue())
183
183
  .setType('Choice')
184
184
  .setLabel('Type')
185
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
185
186
  .addExtraInfo('Static')
186
187
  .addExtraInfo('Dynamic')
187
- .addExtraInfo('Kinematic');
188
+ .addExtraInfo('Kinematic')
189
+ .setDescription(
190
+ _(
191
+ "A static object won't move (perfect for obstacles). Dynamic objects can move. Kinematic will move according to forces applied to it only (useful for characters or specific mechanisms)."
192
+ )
193
+ );
188
194
  behaviorProperties
189
195
  .getOrCreate('bullet')
190
196
  .setValue(
191
197
  behaviorContent.getChild('bullet').getBoolValue() ? 'true' : 'false'
192
198
  )
199
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
193
200
  .setType('Boolean')
194
- .setLabel('Bullet');
201
+ .setLabel(_('Considered as a bullet'))
202
+ .setDescription(
203
+ _(
204
+ 'Useful for fast moving objects which requires a more accurate collision detection.'
205
+ )
206
+ )
207
+ .setGroup(_('Physics body advanced settings'))
208
+ .setAdvanced(true);
195
209
  behaviorProperties
196
210
  .getOrCreate('fixedRotation')
197
211
  .setValue(
@@ -199,20 +213,36 @@ module.exports = {
199
213
  ? 'true'
200
214
  : 'false'
201
215
  )
216
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
202
217
  .setType('Boolean')
203
- .setLabel('Fixed Rotation');
218
+ .setLabel('Fixed Rotation')
219
+ .setDescription(
220
+ _(
221
+ "If enabled, the object won't rotate and will stay at the same angle. Useful for characters for example."
222
+ )
223
+ )
224
+ .setGroup(_('Movement'));
204
225
  behaviorProperties
205
226
  .getOrCreate('canSleep')
206
227
  .setValue(
207
228
  behaviorContent.getChild('canSleep').getBoolValue() ? 'true' : 'false'
208
229
  )
230
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
209
231
  .setType('Boolean')
210
- .setLabel('Can Sleep');
232
+ .setLabel(_('Can be put to sleep by the engine'))
233
+ .setDescription(
234
+ _(
235
+ "Allows the physics engine to stop computing interaction with the object when it's not touched. It's recommended to keep this on."
236
+ )
237
+ )
238
+ .setGroup(_('Physics body advanced settings'))
239
+ .setAdvanced(true);
211
240
  behaviorProperties
212
241
  .getOrCreate('shape')
213
242
  .setValue(behaviorContent.getChild('shape').getStringValue())
214
243
  .setType('Choice')
215
244
  .setLabel('Shape')
245
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
216
246
  .addExtraInfo('Box')
217
247
  .addExtraInfo('Circle')
218
248
  .addExtraInfo('Edge')
@@ -227,7 +257,9 @@ module.exports = {
227
257
  )
228
258
  .setType('Number')
229
259
  .setMeasurementUnit(gd.MeasurementUnit.getPixel())
230
- .setLabel('Shape Dimension A');
260
+ .setLabel('Shape Dimension A')
261
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
262
+ .setHidden(true); // Hidden as required to be changed in the full editor.
231
263
  behaviorProperties
232
264
  .getOrCreate('shapeDimensionB')
233
265
  .setValue(
@@ -238,7 +270,9 @@ module.exports = {
238
270
  )
239
271
  .setType('Number')
240
272
  .setMeasurementUnit(gd.MeasurementUnit.getPixel())
241
- .setLabel('Shape Dimension B');
273
+ .setLabel('Shape Dimension B')
274
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
275
+ .setHidden(true); // Hidden as required to be changed in the full editor.
242
276
  behaviorProperties
243
277
  .getOrCreate('shapeOffsetX')
244
278
  .setValue(
@@ -246,7 +280,9 @@ module.exports = {
246
280
  )
247
281
  .setType('Number')
248
282
  .setMeasurementUnit(gd.MeasurementUnit.getPixel())
249
- .setLabel('Shape Offset X');
283
+ .setLabel('Shape Offset X')
284
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
285
+ .setHidden(true); // Hidden as required to be changed in the full editor.
250
286
  behaviorProperties
251
287
  .getOrCreate('shapeOffsetY')
252
288
  .setValue(
@@ -254,7 +290,9 @@ module.exports = {
254
290
  )
255
291
  .setType('Number')
256
292
  .setMeasurementUnit(gd.MeasurementUnit.getPixel())
257
- .setLabel('Shape Offset Y');
293
+ .setLabel('Shape Offset Y')
294
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
295
+ .setHidden(true); // Hidden as required to be changed in the full editor.
258
296
  behaviorProperties
259
297
  .getOrCreate('polygonOrigin')
260
298
  .setValue(
@@ -266,7 +304,9 @@ module.exports = {
266
304
  .setLabel('Polygon Origin')
267
305
  .addExtraInfo('Center')
268
306
  .addExtraInfo('Origin')
269
- .addExtraInfo('TopLeft');
307
+ .addExtraInfo('TopLeft')
308
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
309
+ .setHidden(true); // Hidden as required to be changed in the full editor.
270
310
  behaviorProperties
271
311
  .getOrCreate('vertices')
272
312
  .setValue(
@@ -274,28 +314,45 @@ module.exports = {
274
314
  ? gd.Serializer.toJSON(behaviorContent.getChild('vertices'))
275
315
  : '[]'
276
316
  )
277
- .setLabel('Vertices');
317
+ .setLabel('Vertices')
318
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
319
+ .setHidden(true); // Hidden as required to be changed in the full editor.
278
320
  behaviorProperties
279
321
  .getOrCreate('density')
280
322
  .setValue(
281
323
  behaviorContent.getChild('density').getDoubleValue().toString(10)
282
324
  )
283
325
  .setType('Number')
284
- .setLabel('Density');
326
+ .setLabel(_('Density'))
327
+ .setDescription(
328
+ _(
329
+ 'Define the weight of the object, according to its size. The biggeer the density, the heavier the object.'
330
+ )
331
+ );
285
332
  behaviorProperties
286
333
  .getOrCreate('friction')
287
334
  .setValue(
288
335
  behaviorContent.getChild('friction').getDoubleValue().toString(10)
289
336
  )
290
337
  .setType('Number')
291
- .setLabel('Friction');
338
+ .setLabel(_('Friction'))
339
+ .setDescription(
340
+ _(
341
+ 'The friction applied when touching other objects. The higher the value, the more friction.'
342
+ )
343
+ );
292
344
  behaviorProperties
293
345
  .getOrCreate('restitution')
294
346
  .setValue(
295
347
  behaviorContent.getChild('restitution').getDoubleValue().toString(10)
296
348
  )
297
349
  .setType('Number')
298
- .setLabel('Restitution');
350
+ .setLabel(_('Restitution'))
351
+ .setDescription(
352
+ _(
353
+ 'The "bounciness" of the object. The higher the value, the more other objects will bounce against it.'
354
+ )
355
+ );
299
356
  behaviorProperties
300
357
  .getOrCreate('linearDamping')
301
358
  .setValue(
@@ -305,7 +362,9 @@ module.exports = {
305
362
  .toString(10)
306
363
  )
307
364
  .setType('Number')
308
- .setLabel('Linear Damping');
365
+ .setLabel(_('Linear Damping'))
366
+ .setGroup(_('Movement'));
367
+
309
368
  behaviorProperties
310
369
  .getOrCreate('angularDamping')
311
370
  .setValue(
@@ -315,24 +374,33 @@ module.exports = {
315
374
  .toString(10)
316
375
  )
317
376
  .setType('Number')
318
- .setLabel('Angular Damping');
377
+ .setLabel(_('Angular Damping'))
378
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
379
+ .setGroup(_('Movement'));
319
380
  behaviorProperties
320
381
  .getOrCreate('gravityScale')
321
382
  .setValue(
322
383
  behaviorContent.getChild('gravityScale').getDoubleValue().toString(10)
323
384
  )
324
385
  .setType('Number')
325
- .setLabel('Gravity Scale');
386
+ .setLabel('Gravity Scale')
387
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
388
+ .setGroup(_('Gravity'))
389
+ .setAdvanced(true);
326
390
  behaviorProperties
327
391
  .getOrCreate('layers')
328
392
  .setValue(behaviorContent.getChild('layers').getIntValue().toString(10))
329
393
  .setType('Number')
330
- .setLabel('Layers');
394
+ .setLabel('Layers')
395
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
396
+ .setHidden(true); // Hidden as required to be changed in the full editor.
331
397
  behaviorProperties
332
398
  .getOrCreate('masks')
333
399
  .setValue(behaviorContent.getChild('masks').getIntValue().toString(10))
334
400
  .setType('Number')
335
- .setLabel('Masks');
401
+ .setLabel('Masks')
402
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
403
+ .setHidden(true); // Hidden as required to be changed in the full editor.
336
404
 
337
405
  return behaviorProperties;
338
406
  };
@@ -379,16 +447,15 @@ module.exports = {
379
447
  return true;
380
448
  }
381
449
 
382
- if (propertyName === 'scaleX') {
450
+ if (propertyName === 'worldScale') {
383
451
  const newValueAsNumber = parseInt(newValue, 10);
384
452
  if (newValueAsNumber !== newValueAsNumber) return false;
453
+ if (!sharedContent.hasChild('worldScale')) {
454
+ sharedContent.addChild('worldScale');
455
+ }
456
+ sharedContent.getChild('worldScale').setDoubleValue(newValueAsNumber);
457
+ // Set deprecated properties for compatibility with 5.4.209-
385
458
  sharedContent.getChild('scaleX').setDoubleValue(newValueAsNumber);
386
- return true;
387
- }
388
-
389
- if (propertyName === 'scaleY') {
390
- const newValueAsNumber = parseInt(newValue, 10);
391
- if (newValueAsNumber !== newValueAsNumber) return false;
392
459
  sharedContent.getChild('scaleY').setDoubleValue(newValueAsNumber);
393
460
  return true;
394
461
  }
@@ -412,16 +479,22 @@ module.exports = {
412
479
  )
413
480
  .setType('Number')
414
481
  .setMeasurementUnit(gd.MeasurementUnit.getNewton());
482
+
483
+ if (!sharedContent.hasChild('worldScale')) {
484
+ sharedContent.addChild('worldScale');
485
+ sharedContent
486
+ .getChild('worldScale')
487
+ .setDoubleValue(
488
+ Math.sqrt(
489
+ sharedContent.getChild('scaleX').getDoubleValue() *
490
+ sharedContent.getChild('scaleY').getDoubleValue()
491
+ )
492
+ );
493
+ }
415
494
  sharedProperties
416
- .getOrCreate('scaleX')
417
- .setValue(
418
- sharedContent.getChild('scaleX').getDoubleValue().toString(10)
419
- )
420
- .setType('Number');
421
- sharedProperties
422
- .getOrCreate('scaleY')
495
+ .getOrCreate('worldScale')
423
496
  .setValue(
424
- sharedContent.getChild('scaleY').getDoubleValue().toString(10)
497
+ sharedContent.getChild('worldScale').getDoubleValue().toString(10)
425
498
  )
426
499
  .setType('Number');
427
500
 
@@ -430,6 +503,8 @@ module.exports = {
430
503
  sharedData.initializeContent = function (behaviorContent) {
431
504
  behaviorContent.addChild('gravityX').setDoubleValue(0);
432
505
  behaviorContent.addChild('gravityY').setDoubleValue(9.8);
506
+ behaviorContent.addChild('worldScale').setDoubleValue(100);
507
+ // Set deprecated properties for compatibility with 5.4.209-
433
508
  behaviorContent.addChild('scaleX').setDoubleValue(100);
434
509
  behaviorContent.addChild('scaleY').setDoubleValue(100);
435
510
  };
@@ -452,11 +527,23 @@ module.exports = {
452
527
  )
453
528
  .setIncludeFile('Extensions/Physics2Behavior/physics2runtimebehavior.js')
454
529
  .addIncludeFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.js')
455
- .addRequiredFile(
456
- 'Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm'
457
- );
530
+ .addRequiredFile('Extensions/Physics2Behavior/Box2D_v2.3.1_min.wasm.wasm')
531
+ .setOpenFullEditorLabel(_('Edit shape and advanced settings'));
458
532
 
459
533
  // Global
534
+ aut
535
+ .addExpression(
536
+ 'WorldScale',
537
+ _('World scale'),
538
+ _('Return the world scale.'),
539
+ _('Global'),
540
+ 'res/physics32.png'
541
+ )
542
+ .addParameter('object', _('Object'), '', false)
543
+ .addParameter('behavior', _('Behavior'), 'Physics2Behavior')
544
+ .getCodeExtraInformation()
545
+ .setFunctionName('getWorldScale');
546
+
460
547
  aut
461
548
  .addCondition(
462
549
  'GravityX',
@@ -1742,7 +1829,7 @@ module.exports = {
1742
1829
  )
1743
1830
  .addParameter('object', _('Object'), '', false)
1744
1831
  .addParameter('behavior', _('Behavior'), 'Physics2Behavior')
1745
- .addParameter('expression', _('Angular impulse (N·m·s'))
1832
+ .addParameter('expression', _('Angular impulse (N·m·s)'))
1746
1833
  .setParameterLongDescription(
1747
1834
  _(
1748
1835
  'An impulse is like a rotation speed addition but depends on the mass.'
@@ -1769,7 +1856,7 @@ module.exports = {
1769
1856
  'Inertia',
1770
1857
  _('Inertia'),
1771
1858
  _(
1772
- 'Return the rotational inertia of the object (in kilograms * meters * meters)'
1859
+ 'Return the rotational inertia of the object (in kilograms · meters²)'
1773
1860
  ),
1774
1861
  '',
1775
1862
  'res/physics32.png'
@@ -1,2 +1,2 @@
1
- var gdjs;(function(h){class m{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX===0?100:t.scaleX,this.scaleY=t.scaleY===0?100:t.scaleY,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.timeStep=1/60,this.world=new Box2D.b2World(new Box2D.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new h.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}resetStartedAndEndedCollisions(){for(const e of this._registeredBehaviors)e.contactsStartedThisFrame.length=0,e.contactsEndedThisFrame.length=0}updateBodiesFromObjects(){for(const e of this._registeredBehaviors)e.updateBodyFromObject()}step(e){this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}h.Physics2SharedData=m,h.registerRuntimeSceneUnloadedCallback(function(J){J.physics2SharedData&&J.physics2SharedData.world&&Box2D.destroy(J.physics2SharedData.world)});const B=class extends h.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=t.linearDamping,this.angularDamping=t.angularDamping,this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=m.getSharedData(e.getScene(),t.name),this._tempb2Vec2=new Box2D.b2Vec2,this._tempb2Vec2Sec=new Box2D.b2Vec2,this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){return this._tempb2Vec2.set_x(e),this._tempb2Vec2.set_y(t),this._tempb2Vec2}b2Vec2Sec(e,t){return this._tempb2Vec2Sec.set_x(e),this._tempb2Vec2Sec.set_y(t),this._tempb2Vec2Sec}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),this._body=null),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this.destroyedDuringFrameLogic=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new h.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.invScaleX:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.invScaleY:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(this.shapeDimensionA*this.shapeScale*this._sharedData.invScaleX);else{const n=(this.owner.getWidth()*this._sharedData.invScaleX+this.owner.getHeight()*this._sharedData.invScaleY)/4;i.set_m_radius(n>0?n:1)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){let n=(this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.invScaleX,a=(this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.invScaleY;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let l=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+l>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.invScaleX+e,Box2D.HEAPF32[this._verticesBuffer+(l+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.invScaleY+t,l+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.invScaleX;let a=this.owner.getHeight()>0?this.owner.getHeight()*this._sharedData.invScaleY:0;const l=this.shapeDimensionB?h.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(l)+e,a/2-n/2*Math.sin(l)+t),this.b2Vec2Sec(n/2*Math.cos(l)+e,a/2+n/2*Math.sin(l)+t))}else{i=new Box2D.b2PolygonShape;let n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.invScaleX,a=(this.shapeDimensionB>0?this.shapeDimensionB*this.shapeScale:this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.invScaleY;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef;return e.set_position(this.b2Vec2((this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.invScaleX,(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.invScaleY)),e.set_angle(h.toRad(this.owner.getAngle())),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&(this._sharedData.resetStartedAndEndedCollisions(),this._sharedData.updateBodiesFromObjects(),this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)),this._body!==null&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.scaleX-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.scaleY-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(h.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=this.b2Vec2((this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.invScaleX,(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.invScaleY);e.SetTransform(t,h.toRad(this.owner.getAngle())),e.SetAwake(!0)}}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.scaleX}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.invScaleX,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.scaleY}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.invScaleY))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.scaleX,e.GetLinearVelocity().get_y()*this._sharedData.scaleY).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return h.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.scaleY,e.GetLinearVelocity().get_x()*this._sharedData.scaleX))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=h.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.invScaleX,t*Math.sin(e)*this._sharedData.invScaleY))}isLinearVelocityAngleAround(e,t){return Math.abs(h.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return h.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(h.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.invScaleX,o*this._sharedData.invScaleY),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=h.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.invScaleX,o*this._sharedData.invScaleY),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.invScaleY-n.GetPosition().get_y(),t*this._sharedData.invScaleX-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.invScaleX,o*this._sharedData.invScaleY),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=h.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.invScaleX,o*this._sharedData.invScaleY),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.invScaleY-n.GetPosition().get_y(),t*this._sharedData.invScaleX-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.scaleX}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.scaleY}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,l,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const g=new Box2D.b2DistanceJointDef;g.set_bodyA(u),g.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),g.set_bodyB(r),g.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),g.set_length(n>0?n*this._sharedData.invScaleX:this.b2Vec2((o-e)*this._sharedData.invScaleX,(s-t)*this._sharedData.invScaleY).Length()),g.set_frequencyHz(a>=0?a:0),g.set_dampingRatio(l>=0?l:1),g.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.scaleX}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.invScaleX),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,l,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),r.set_enableLimit(i),r.set_referenceAngle(h.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(h.toRad(s)),r.set_upperAngle(h.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(h.toRad(l)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(g)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,l,d,c,u,r,g,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=this._body,f=new Box2D.b2RevoluteJointDef;if(f.set_bodyA(_),f.set_localAnchorA(_.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),f.set_bodyB(b),f.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),f.set_enableLimit(n),f.set_referenceAngle(h.toRad(a)),d<l){const p=l;l=d,d=p}f.set_lowerAngle(h.toRad(l)),f.set_upperAngle(h.toRad(d)),f.set_enableMotor(c),f.set_motorSpeed(h.toRad(u)),f.set_maxMotorTorque(r>=0?r:0),f.set_collideConnected(g);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2RevoluteJoint));D.setNumber(y)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(h.toRad(t),h.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:h.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(h.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,l,d,c,u,r,g,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const f=this._body,y=new Box2D.b2PrismaticJointDef;if(y.set_bodyA(f),y.set_localAnchorA(f.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),y.set_bodyB(_),y.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),n=h.toRad(n)-f.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_referenceAngle(h.toRad(a)),y.set_enableLimit(l),c<d){const S=d;d=c,c=S}y.set_lowerTranslation(d<0?d*this._sharedData.invScaleX:0),y.set_upperTranslation(c>0?c*this._sharedData.invScaleX:0),y.set_enableMotor(u),y.set_motorSpeed(r*this._sharedData.invScaleX),y.set_maxMotorForce(g),y.set_collideConnected(D);const p=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2PrismaticJoint));b.setNumber(p)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:h.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:h.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.scaleX}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.scaleX}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.scaleX}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.scaleX}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.invScaleX,i*this._sharedData.invScaleX)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.scaleX}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.invScaleX)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,l,d,c,u,r,g,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const f=new Box2D.b2PulleyJointDef;f.set_bodyA(b),f.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),f.set_bodyB(_),f.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),f.set_groundAnchorA(this.b2Vec2(n*this._sharedData.invScaleX,a*this._sharedData.invScaleY)),f.set_groundAnchorB(this.b2Vec2(l*this._sharedData.invScaleX,d*this._sharedData.invScaleY)),f.set_lengthA(c>0?c*this._sharedData.invScaleX:this.b2Vec2((n-e)*this._sharedData.invScaleX,(a-t)*this._sharedData.invScaleY).Length()),f.set_lengthB(u>0?u*this._sharedData.invScaleX:this.b2Vec2((l-o)*this._sharedData.invScaleX,(d-s)*this._sharedData.invScaleY).Length()),f.set_ratio(r>0?r:1),f.set_collideConnected(g);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2PulleyJoint));D.setNumber(y)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.scaleX}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.scaleY}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.scaleX}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.scaleY}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.scaleX}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.scaleX}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const l=this._sharedData.getJoint(t);if(l===null||l.GetType()!==Box2D.e_revoluteJoint&&l.GetType()!==Box2D.e_prismaticJoint||a===l)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(l),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,l=new Box2D.b2MouseJointDef;l.set_bodyA(this._sharedData.staticBody),l.set_bodyB(a),l.set_target(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY)),l.set_maxForce(i>=0?i:0),l.set_frequencyHz(o>0?o:1),l.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(l),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.scaleX}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.scaleY}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.invScaleX,i*this._sharedData.invScaleY)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,l,d,c,u,r,g){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=new Box2D.b2WheelJointDef;_.set_bodyA(D),_.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),_.set_bodyB(b),_.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),n=h.toRad(n)-D.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_frequencyHz(a>0?a:1),_.set_dampingRatio(l>=0?l:0),_.set_enableMotor(d),_.set_motorSpeed(h.toRad(c)),_.set_maxMotorTorque(u),_.set_collideConnected(r);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2WheelJoint));g.setNumber(f)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:h.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.scaleX}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:h.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:h.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(h.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,l,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,g=new Box2D.b2WeldJointDef;g.set_bodyA(r),g.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),g.set_bodyB(u),g.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),g.set_referenceAngle(h.toRad(n)),g.set_frequencyHz(a>0?a:1),g.set_dampingRatio(l>=0?l:0),g.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2WeldJoint);D.referenceAngle=g.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:h.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,l){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),u.set_maxLength(n>0?n*this._sharedData.invScaleX:this.b2Vec2((o-e)*this._sharedData.invScaleX,(s-t)*this._sharedData.invScaleY).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));l.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.scaleX}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.invScaleX),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,l,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.invScaleX,t*this._sharedData.invScaleY))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.invScaleX,s*this._sharedData.invScaleY))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(l);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(g)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,l,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.invScaleX,i*this._sharedData.invScaleY)),r.set_angularOffset(h.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(l);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(g)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.scaleX}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.scaleY}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.invScaleX,i*this._sharedData.invScaleY))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:h.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(h.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let x=B;x.collisionTest=B.areObjectsColliding,h.Physics2RuntimeBehavior=x,h.registerBehavior("Physics2::Physics2Behavior",h.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
1
+ var gdjs;(function(l){class x{constructor(e,t){this.frameTime=0;this.stepped=!1;this.timeScale=1;this._nextJointId=1;this.joints={};this._registeredBehaviors=new Set,this.gravityX=t.gravityX,this.gravityY=t.gravityY,this.scaleX=t.scaleX||100,this.scaleY=t.scaleY||100,this.invScaleX=1/this.scaleX,this.invScaleY=1/this.scaleY,this.worldScale=t.worldScale||Math.sqrt(this.scaleX*this.scaleY),this.worldInvScale=1/this.worldScale,this.timeStep=1/60,this.world=new Box2D.b2World(new Box2D.b2Vec2(this.gravityX,this.gravityY)),this.world.SetAutoClearForces(!1),this.staticBody=this.world.CreateBody(new Box2D.b2BodyDef),this.contactListener=new Box2D.JSContactListener,this.contactListener.BeginContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactBegin(n),n.onContactBegin(s))},this.contactListener.EndContact=function(i){const o=Box2D.wrapPointer(i,Box2D.b2Contact);if(o.GetFixtureA().GetBody()===null||o.GetFixtureB().GetBody()===null)return;const s=o.GetFixtureA().GetBody().gdjsAssociatedBehavior,n=o.GetFixtureB().GetBody().gdjsAssociatedBehavior;!s||!n||(s.onContactEnd(n),n.onContactEnd(s))},this.contactListener.PreSolve=function(){},this.contactListener.PostSolve=function(){},this.world.SetContactListener(this.contactListener)}static getSharedData(e,t){if(!e.physics2SharedData){const i=e.getInitialSharedDataForBehavior(t);e.physics2SharedData=new l.Physics2SharedData(e,i)}return e.physics2SharedData}addToBehaviorsList(e){this._registeredBehaviors.add(e)}removeFromBehaviorsList(e){this._registeredBehaviors.delete(e)}resetStartedAndEndedCollisions(){for(const e of this._registeredBehaviors)e.contactsStartedThisFrame.length=0,e.contactsEndedThisFrame.length=0}updateBodiesFromObjects(){for(const e of this._registeredBehaviors)e.updateBodyFromObject()}step(e){this.frameTime+=e;let t=Math.max(0,Math.round(this.frameTime/this.timeStep));this.frameTime-=t*this.timeStep,t>5&&(t=5);for(let i=0;i<t;i++)this.world.Step(this.timeStep*this.timeScale,8,10);this.world.ClearForces(),this.stepped=!0}clearBodyJoints(e){for(const t in this.joints)this.joints.hasOwnProperty(t)&&(this.joints[t].GetBodyA()===e||this.joints[t].GetBodyB()===e)&&this.removeJoint(t)}addJoint(e){return this.joints[this._nextJointId.toString(10)]=e,this._nextJointId++}getJoint(e){return e=e.toString(10),this.joints.hasOwnProperty(e)?this.joints[e]:null}getJointId(e){for(const t in this.joints)if(this.joints.hasOwnProperty(t)&&this.joints[t]===e)return parseInt(t,10);return 0}removeJoint(e){if(e=e.toString(10),this.joints.hasOwnProperty(e)){const t=this.joints[e];if(t.GetType()===Box2D.e_revoluteJoint||t.GetType()===Box2D.e_prismaticJoint)for(const i in this.joints)this.joints.hasOwnProperty(i)&&this.joints[i].GetType()===Box2D.e_gearJoint&&(Box2D.getPointer(this.joints[i].GetJoint1())===Box2D.getPointer(t)||Box2D.getPointer(this.joints[i].GetJoint2())===Box2D.getPointer(t))&&this.removeJoint(parseInt(i,10));this.world.DestroyJoint(t),delete this.joints[e]}}}l.Physics2SharedData=x,l.registerRuntimeSceneUnloadedCallback(function(J){J.physics2SharedData&&J.physics2SharedData.world&&Box2D.destroy(J.physics2SharedData.world)});const B=class extends l.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this.shapeScale=1;this._body=null;this._objectOldX=0;this._objectOldY=0;this._objectOldAngle=0;this._objectOldWidth=0;this._objectOldHeight=0;this._verticesBuffer=0;this.bodyType=t.bodyType,this.bullet=t.bullet,this.fixedRotation=t.fixedRotation,this.canSleep=t.canSleep,this.shape=t.shape,this.shapeDimensionA=t.shapeDimensionA,this.shapeDimensionB=t.shapeDimensionB,this.shapeOffsetX=t.shapeOffsetX,this.shapeOffsetY=t.shapeOffsetY,this.polygonOrigin=t.polygonOrigin,this.polygon=this.shape==="Polygon"?B.getPolygon(t.vertices):null,this.density=t.density,this.friction=t.friction,this.restitution=t.restitution,this.linearDamping=Math.max(0,t.linearDamping),this.angularDamping=Math.max(0,t.angularDamping),this.gravityScale=t.gravityScale,this.layers=t.layers,this.masks=t.masks,this.contactsStartedThisFrame=[],this.contactsEndedThisFrame=[],this.currentContacts=[],this.currentContacts.length=0,this.destroyedDuringFrameLogic=!1,this._sharedData=x.getSharedData(e.getScene(),t.name),this._tempb2Vec2=new Box2D.b2Vec2,this._tempb2Vec2Sec=new Box2D.b2Vec2,this._sharedData.addToBehaviorsList(this)}b2Vec2(e,t){return this._tempb2Vec2.set_x(e),this._tempb2Vec2.set_y(t),this._tempb2Vec2}b2Vec2Sec(e,t){return this._tempb2Vec2Sec.set_x(e),this._tempb2Vec2Sec.set_y(t),this._tempb2Vec2Sec}updateFromBehaviorData(e,t){return e.bullet!==t.bullet&&this.setBullet(t.bullet),e.fixedRotation!==t.fixedRotation&&this.setFixedRotation(t.fixedRotation),e.canSleep!==t.canSleep&&this.setSleepingAllowed(t.canSleep),e.shapeDimensionA!==t.shapeDimensionA&&(this.shapeDimensionA=t.shapeDimensionA,this.recreateShape()),e.shapeDimensionB!==t.shapeDimensionB&&(this.shapeDimensionB=t.shapeDimensionB,this.recreateShape()),e.shapeOffsetX!==t.shapeOffsetX&&(this.shapeOffsetX=t.shapeOffsetX,this.recreateShape()),e.shapeOffsetY!==t.shapeOffsetY&&(this.shapeOffsetY=t.shapeOffsetY,this.recreateShape()),e.polygonOrigin!==t.polygonOrigin&&(this.polygonOrigin=t.polygonOrigin,this.recreateShape()),e.density!==t.density&&this.setDensity(t.density),e.friction!==t.friction&&this.setFriction(t.friction),e.restitution!==t.restitution&&this.setRestitution(t.restitution),e.linearDamping!==t.linearDamping&&this.setLinearDamping(t.linearDamping),e.angularDamping!==t.angularDamping&&this.setAngularDamping(t.angularDamping),e.gravityScale!==t.gravityScale&&this.setGravityScale(t.gravityScale),!(e.layers!==t.layers||e.masks!==t.masks||e.vertices!==t.vertices||e.bodyType!==t.bodyType||e.shape!==t.shape)}getNetworkSyncData(){const e=this._body?{tpx:this._body.GetTransform().get_p().get_x(),tpy:this._body.GetTransform().get_p().get_y(),tqa:this._body.GetTransform().get_q().GetAngle(),lvx:this._body.GetLinearVelocity().get_x(),lvy:this._body.GetLinearVelocity().get_y(),av:this._body.GetAngularVelocity(),aw:this._body.IsAwake()}:{tpx:void 0,tpy:void 0,tqa:void 0,lvx:void 0,lvy:void 0,av:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...e,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;t.tpx!==void 0&&t.tpy!==void 0&&t.tqa!==void 0&&this._body&&this._body.SetTransform(this.b2Vec2(t.tpx,t.tpy),t.tqa),t.lvx!==void 0&&t.lvy!==void 0&&this._body&&this._body.SetLinearVelocity(this.b2Vec2(t.lvx,t.lvy)),t.av!==void 0&&this._body&&this._body.SetAngularVelocity(t.av),t.aw!==void 0&&this._body&&this._body.SetAwake(t.aw),t.layers!==void 0&&(this.layers=t.layers),t.masks!==void 0&&(this.masks=t.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.clearBodyJoints(this._body),this._verticesBuffer&&(Box2D._free(this._verticesBuffer),this._verticesBuffer=0),this._sharedData.world.DestroyBody(this._body),this._body=null),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this.contactsEndedThisFrame.length=0,this.contactsStartedThisFrame.length=0,this.currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this.destroyedDuringFrameLogic=!0,this.onDeActivate()}static getPolygon(e){if(!e)return null;const t=new l.Polygon,i=8;for(let o=0,s=e.length;o<Math.min(s,i);o++)t.vertices.push([e[o].x,e[o].y]);return t}static isPolygonConvex(e){if(!e.isConvex())return!1;let t=!0,i=!0;for(let o=0;o<e.vertices.length-1;++o){for(let s=o+1;s<e.vertices.length;++s)if(e.vertices[o][0]===e.vertices[s][0]&&e.vertices[o][1]===e.vertices[s][1])return!1;e.vertices[o][0]!==e.vertices[o+1][0]&&(t=!1),e.vertices[o][1]!==e.vertices[o+1][1]&&(i=!1)}return!(t||i)}createShape(){const e=this.shapeOffsetX?this.shapeOffsetX*this.shapeScale*this._sharedData.worldInvScale:0,t=this.shapeOffsetY?this.shapeOffsetY*this.shapeScale*this._sharedData.worldInvScale:0;let i;if(this.shape==="Circle"){if(i=new Box2D.b2CircleShape,this.shapeDimensionA>0)i.set_m_radius(this.shapeDimensionA*this.shapeScale*this._sharedData.worldInvScale);else{const n=(this.owner.getWidth()*this._sharedData.worldInvScale+this.owner.getHeight()*this._sharedData.worldInvScale)/4;i.set_m_radius(n>0?n:1)}i.set_m_p(this.b2Vec2(e,t))}else if(this.shape==="Polygon")if(i=new Box2D.b2PolygonShape,!this.polygon||!B.isPolygonConvex(this.polygon)){let n=(this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale,a=(this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}else{let n=0,a=0;if(this.polygonOrigin==="Origin"?(n=(this.owner.getWidth()>0?-this.owner.getWidth()/2:0)+(this.owner.getX()-this.owner.getDrawableX()),a=(this.owner.getHeight()>0?-this.owner.getHeight()/2:0)+(this.owner.getY()-this.owner.getDrawableY())):this.polygonOrigin==="TopLeft"&&(n=this.owner.getWidth()>0?-this.owner.getWidth()/2:0,a=this.owner.getHeight()>0?-this.owner.getHeight()/2:0),!this._verticesBuffer){const c=Box2D._malloc(this.polygon.vertices.length*8,"float",Box2D.ALLOC_STACK);this._verticesBuffer=c}let h=0;for(let c=0,u=this.polygon.vertices.length;c<u;c++)Box2D.HEAPF32[this._verticesBuffer+h>>2]=(this.polygon.vertices[c][0]*this.shapeScale+n)*this._sharedData.worldInvScale+e,Box2D.HEAPF32[this._verticesBuffer+(h+4)>>2]=(this.polygon.vertices[c][1]*this.shapeScale+a)*this._sharedData.worldInvScale+t,h+=8;const d=Box2D.wrapPointer(this._verticesBuffer,Box2D.b2Vec2);i.Set(d,this.polygon.vertices.length)}else if(this.shape==="Edge"){i=new Box2D.b2EdgeShape;const n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale;let a=this.owner.getHeight()>0?this.owner.getHeight()*this._sharedData.worldInvScale:0;const h=this.shapeDimensionB?l.toRad(this.shapeDimensionB):0;i.Set(this.b2Vec2(-n/2*Math.cos(h)+e,a/2-n/2*Math.sin(h)+t),this.b2Vec2Sec(n/2*Math.cos(h)+e,a/2+n/2*Math.sin(h)+t))}else{i=new Box2D.b2PolygonShape;let n=(this.shapeDimensionA>0?this.shapeDimensionA*this.shapeScale:this.owner.getWidth()>0?this.owner.getWidth():1)*this._sharedData.worldInvScale,a=(this.shapeDimensionB>0?this.shapeDimensionB*this.shapeScale:this.owner.getHeight()>0?this.owner.getHeight():1)*this._sharedData.worldInvScale;i.SetAsBox(n/2,a/2,this.b2Vec2(e,t),0)}const o=new Box2D.b2Filter;o.set_categoryBits(this.layers),o.set_maskBits(this.masks);const s=new Box2D.b2FixtureDef;return s.set_shape(i),s.set_filter(o),this.density<0&&(this.density=0),s.set_density(this.density),this.friction<0&&(this.friction=0),s.set_friction(this.friction),this.restitution<0&&(this.restitution=0),s.set_restitution(this.restitution),s}recreateShape(){if(this._body===null&&!this.createBody())return;const e=this._body;e.DestroyFixture(e.GetFixtureList()),e.CreateFixture(this.createShape()),this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight()}getShapeScale(){return this.shapeScale}setShapeScale(e){e!==this.shapeScale&&e>0&&(this.shapeScale=e,this.recreateShape())}getBody(){return this._body===null&&this.createBody(),this._body}createBody(){if(!this.activated()||this.destroyedDuringFrameLogic)return!1;const e=new Box2D.b2BodyDef,t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale;e.set_position(this.b2Vec2(Number.isFinite(t)?t:0,Number.isFinite(i)?i:0));const o=l.toRad(this.owner.getAngle());return Number.isFinite(o)&&e.set_angle(o),e.set_type(this.bodyType==="Static"?Box2D.b2_staticBody:this.bodyType==="Kinematic"?Box2D.b2_kinematicBody:Box2D.b2_dynamicBody),e.set_bullet(this.bullet),e.set_fixedRotation(this.fixedRotation),e.set_allowSleep(this.canSleep),e.set_linearDamping(this.linearDamping),e.set_angularDamping(this.angularDamping),e.set_gravityScale(this.gravityScale),this._body=this._sharedData.world.CreateBody(e),this._body.CreateFixture(this.createShape()),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner.getWidth(),this._objectOldHeight=this.owner.getHeight(),!0}doStepPreEvents(e){!this._sharedData.stepped&&!e.getScene().getTimeManager().isFirstFrame()&&(this._sharedData.resetStartedAndEndedCollisions(),this._sharedData.updateBodiesFromObjects(),this._sharedData.step(e.getScene().getTimeManager().getElapsedTime()/1e3)),this._body!==null&&(this.owner.setX(this._body.GetPosition().get_x()*this._sharedData.worldScale-this.owner.getWidth()/2+this.owner.getX()-this.owner.getDrawableX()),this.owner.setY(this._body.GetPosition().get_y()*this._sharedData.worldScale-this.owner.getHeight()/2+this.owner.getY()-this.owner.getDrawableY()),this.owner.setAngle(l.toDegrees(this._body.GetAngle()))),this._objectOldX=this.owner.getX(),this._objectOldY=this.owner.getY(),this._objectOldAngle=this.owner.getAngle()}doStepPostEvents(e){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}updateBodyFromObject(){if(this._body===null&&!this.createBody())return;const e=this._body;if((this._objectOldWidth!==this.owner.getWidth()&&this.shapeDimensionA<=0||this._objectOldHeight!==this.owner.getHeight()&&this.shape!=="Edge"&&!(this.shape==="Box"&&this.shapeDimensionB>0)&&!(this.shape==="Circle"&&this.shapeDimensionA>0))&&this.recreateShape(),this._objectOldX!==this.owner.getX()||this._objectOldY!==this.owner.getY()||this._objectOldAngle!==this.owner.getAngle()){const t=(this.owner.getDrawableX()+this.owner.getWidth()/2)*this._sharedData.worldInvScale,i=(this.owner.getDrawableY()+this.owner.getHeight()/2)*this._sharedData.worldInvScale,o=this.b2Vec2(Number.isFinite(t)?t:e.GetPosition().x,Number.isFinite(i)?i:e.GetPosition().y),s=l.toRad(this.owner.getAngle());e.SetTransform(o,Number.isFinite(s)?s:e.GetAngle()),e.SetAwake(!0)}}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}setGravity(e,t){this._sharedData.gravityX===e&&this._sharedData.gravityY===t||(this._sharedData.gravityX=e,this._sharedData.gravityY=t,this._sharedData.world.SetGravity(this.b2Vec2(this._sharedData.gravityX,this._sharedData.gravityY)))}getTimeScale(){return this._sharedData.timeScale}setTimeScale(e){e<0||(this._sharedData.timeScale=e)}static setTimeScaleFromObject(e,t,i){e===null||!e.hasBehavior(t)||e.getBehavior(t).setTimeScale(i)}isDynamic(){return this.bodyType==="Dynamic"}setDynamic(){if(this.bodyType==="Dynamic"||(this.bodyType="Dynamic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_dynamicBody),e.SetAwake(!0)}isStatic(){return this.bodyType==="Static"}setStatic(){if(this.bodyType==="Static"||(this.bodyType="Static",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_staticBody),e.SetAwake(!0)}isKinematic(){return this.bodyType==="Kinematic"}setKinematic(){if(this.bodyType==="Kinematic"||(this.bodyType="Kinematic",this._body===null&&!this.createBody()))return;const e=this._body;e.SetType(Box2D.b2_kinematicBody),e.SetAwake(!0)}isBullet(){return this.bullet}setBullet(e){if(this.bullet===e||(this.bullet=e,this._body===null&&!this.createBody()))return;this._body.SetBullet(this.bullet)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(e){if(this.fixedRotation=e,this._body===null&&!this.createBody())return;this._body.SetFixedRotation(this.fixedRotation)}isSleepingAllowed(){return this.canSleep}setSleepingAllowed(e){if(this.canSleep=e,this._body===null&&!this.createBody())return;this._body.SetSleepingAllowed(this.canSleep)}isSleeping(){return this._body===null&&!this.createBody()?!0:!this._body.IsAwake()}getDensity(){return this.density}setDensity(e){if(e<0&&(e=0),this.density===e||(this.density=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetDensity(this.density),t.ResetMassData()}getFriction(){return this.friction}setFriction(e){if(e<0&&(e=0),this.friction===e||(this.friction=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetFriction(this.friction);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetFriction(),i=i.get_next()}getRestitution(){return this.restitution}setRestitution(e){if(e<0&&(e=0),this.restitution===e||(this.restitution=e,this._body===null&&!this.createBody()))return;const t=this._body;t.GetFixtureList().SetRestitution(this.restitution);let i=t.GetContactList();for(;Box2D.getPointer(i);)i.get_contact().ResetRestitution(),i=i.get_next()}getLinearDamping(){return this.linearDamping}setLinearDamping(e){if(e<0&&(e=0),this.linearDamping===e||(this.linearDamping=e,this._body===null&&!this.createBody()))return;this._body.SetLinearDamping(this.linearDamping)}getAngularDamping(){return this.angularDamping}setAngularDamping(e){if(e<0&&(e=0),this.angularDamping===e||(this.angularDamping=e,this._body===null&&!this.createBody()))return;this._body.SetAngularDamping(this.angularDamping)}getGravityScale(){return this.gravityScale}setGravityScale(e){if(this.gravityScale===e||(this.gravityScale=e,this._body===null&&!this.createBody()))return;this._body.SetGravityScale(this.gravityScale)}layerEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.layers&1<<e-1)}enableLayer(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.layers|=1<<e-1:this.layers&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_categoryBits(this.layers),i.GetFixtureList().SetFilterData(o)}maskEnabled(e){return e=Math.floor(e),e<1||e>16?!1:!!(this.masks&1<<e-1)}enableMask(e,t){if(e=Math.floor(e),e<1||e>16||(t?this.masks|=1<<e-1:this.masks&=~(1<<e-1),this._body===null&&!this.createBody()))return;const i=this._body,o=i.GetFixtureList().GetFilterData();o.set_maskBits(this.masks),i.GetFixtureList().SetFilterData(o)}getLinearVelocityX(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_x()*this._sharedData.worldScale}setLinearVelocityX(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(e*this._sharedData.worldInvScale,t.GetLinearVelocity().get_y()))}getLinearVelocityY(){return this._body===null&&!this.createBody()?0:this._body.GetLinearVelocity().get_y()*this._sharedData.worldScale}setLinearVelocityY(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetLinearVelocity(this.b2Vec2(t.GetLinearVelocity().get_x(),e*this._sharedData.worldInvScale))}getLinearVelocityLength(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return this.b2Vec2(e.GetLinearVelocity().get_x()*this._sharedData.worldScale,e.GetLinearVelocity().get_y()*this._sharedData.worldScale).Length()}getLinearVelocityAngle(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(Math.atan2(e.GetLinearVelocity().get_y()*this._sharedData.worldScale,e.GetLinearVelocity().get_x()*this._sharedData.worldScale))}setLinearVelocityAngle(e,t){if(this._body===null&&!this.createBody())return;const i=this._body;e=l.toRad(e),i.SetLinearVelocity(this.b2Vec2(t*Math.cos(e)*this._sharedData.worldInvScale,t*Math.sin(e)*this._sharedData.worldInvScale))}isLinearVelocityAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this.getLinearVelocityAngle(),e))<=t}getAngularVelocity(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return l.toDegrees(e.GetAngularVelocity())}setAngularVelocity(e){if(this._body===null&&!this.createBody())return;this._body.SetAngularVelocity(l.toRad(e))}applyForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyForce(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarForce(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyForce(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyForceTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyForce(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),s.ApplyLinearImpulse(this.b2Vec2(e,t),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyPolarImpulse(e,t,i,o){if(this._body===null&&!this.createBody())return;const s=this._body;s.SetAwake(!0),e=l.toRad(e),s.ApplyLinearImpulse(this.b2Vec2(t*Math.cos(e),t*Math.sin(e)),this.b2Vec2Sec(i*this._sharedData.worldInvScale,o*this._sharedData.worldInvScale),!1)}applyImpulseTowardPosition(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body;n.SetAwake(!0);const a=Math.atan2(i*this._sharedData.worldInvScale-n.GetPosition().get_y(),t*this._sharedData.worldInvScale-n.GetPosition().get_x());n.ApplyLinearImpulse(this.b2Vec2(e*Math.cos(a),e*Math.sin(a)),this.b2Vec2Sec(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale),!1)}applyTorque(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyTorque(e,!1)}applyAngularImpulse(e){if(this._body===null&&!this.createBody())return;const t=this._body;t.SetAwake(!0),t.ApplyAngularImpulse(e,!1)}getMass(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetMass()}getInertia(){if(this._body===null&&!this.createBody())return 0;const e=this._body;return e.SetAwake(!0),e.GetInertia()}getMassCenterX(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_x()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this.createBody()?0:this._body.GetWorldCenter().get_y()*this._sharedData.worldScale}isJointFirstObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyA()===this._body}isJointSecondObject(e){if(this._body===null&&!this.createBody())return!1;const t=this._sharedData.getJoint(e);return t===null?!1:t.GetBodyB()===this._body}getJointFirstAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_x()}getJointFirstAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyA().GetWorldPoint(t.GetLocalAnchorA()).get_y()}getJointSecondAnchorX(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_x()}getJointSecondAnchorY(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetBodyB().GetWorldPoint(t.GetLocalAnchorB()).get_y()}getJointReactionForce(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionForce(1/this._sharedData.timeStep).Length()}getJointReactionTorque(e){const t=this._sharedData.getJoint(e);return t===null?0:t.GetReactionTorque(1/this._sharedData.timeStep)}removeJoint(e){this._sharedData.removeJoint(e)}addDistanceJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body;if(i==null||!i.hasBehavior(this.name))return;const r=i.getBehavior(this.name).getBody();if(this._body===r)return;const f=new Box2D.b2DistanceJointDef;f.set_bodyA(u),f.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(r),f.set_localAnchorB(r.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_length(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),f.set_frequencyHz(a>=0?a:0),f.set_dampingRatio(h>=0?h:1),f.set_collideConnected(d);const D=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2DistanceJoint));c.setNumber(D)}getDistanceJointLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetLength()*this._sharedData.worldScale}setDistanceJointLength(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||(i.SetLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getDistanceJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetFrequency()}setDistanceJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint||i.SetFrequency(t)}getDistanceJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_distanceJoint?0:t.GetDampingRatio()}setDistanceJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_distanceJoint,i.SetDampingRatio(t)}addRevoluteJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody())return;const u=this._body,r=new Box2D.b2RevoluteJointDef;if(r.set_bodyA(this._sharedData.staticBody),r.set_localAnchorA(this._sharedData.staticBody.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(u),r.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_enableLimit(i),r.set_referenceAngle(l.toRad(o)),n<s){const D=s;s=n,n=D}r.set_lowerAngle(l.toRad(s)),r.set_upperAngle(l.toRad(n)),r.set_enableMotor(a),r.set_motorSpeed(l.toRad(h)),r.set_maxMotorTorque(d>=0?d:0),r.set_collideConnected(!1);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2RevoluteJoint));c.setNumber(f)}addRevoluteJointBetweenTwoBodies(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=this._body,g=new Box2D.b2RevoluteJointDef;if(g.set_bodyA(_),g.set_localAnchorA(_.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(b),g.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_enableLimit(n),g.set_referenceAngle(l.toRad(a)),d<h){const p=h;h=d,d=p}g.set_lowerAngle(l.toRad(h)),g.set_upperAngle(l.toRad(d)),g.set_enableMotor(c),g.set_motorSpeed(l.toRad(u)),g.set_maxMotorTorque(r>=0?r:0),g.set_collideConnected(f);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2RevoluteJoint));D.setNumber(y)}getRevoluteJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetReferenceAngle())}getRevoluteJointAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointAngle())}getRevoluteJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetJointSpeed())}isRevoluteJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsLimitEnabled()}enableRevoluteJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableLimit(t)}getRevoluteJointMinAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetLowerLimit())}getRevoluteJointMaxAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetUpperLimit())}setRevoluteJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_revoluteJoint)){if(i<t){const s=t;t=i,i=s}o.SetLimits(l.toRad(t),l.toRad(i))}}isRevoluteJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?!1:t.IsMotorEnabled()}enableRevoluteJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.EnableMotor(t)}getRevoluteJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:l.toDegrees(t.GetMotorSpeed())}setRevoluteJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMotorSpeed(l.toRad(t))}getRevoluteJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMaxMotorTorque()}setRevoluteJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_revoluteJoint||i.SetMaxMotorTorque(t)}getRevoluteJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_revoluteJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}addPrismaticJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D,b){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const g=this._body,y=new Box2D.b2PrismaticJointDef;if(y.set_bodyA(g),y.set_localAnchorA(g.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),y.set_bodyB(_),y.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-g.GetAngle(),y.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),y.set_referenceAngle(l.toRad(a)),y.set_enableLimit(h),c<d){const m=d;d=c,c=m}y.set_lowerTranslation(d<0?d*this._sharedData.worldInvScale:0),y.set_upperTranslation(c>0?c*this._sharedData.worldInvScale:0),y.set_enableMotor(u),y.set_motorSpeed(r*this._sharedData.worldInvScale),y.set_maxMotorForce(f),y.set_collideConnected(D);const p=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(y),Box2D.b2PrismaticJoint));b.setNumber(p)}getPrismaticJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getPrismaticJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:l.toDegrees(t.GetReferenceAngle())}getPrismaticJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getPrismaticJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetJointSpeed()*this._sharedData.worldScale}isPrismaticJointLimitsEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsLimitEnabled()}enablePrismaticJointLimits(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableLimit(t)}getPrismaticJointMinTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetLowerLimit()*this._sharedData.worldScale}getPrismaticJointMaxTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetUpperLimit()*this._sharedData.worldScale}setPrismaticJointLimits(e,t,i){const o=this._sharedData.getJoint(e);if(!(o===null||o.GetType()!==Box2D.e_prismaticJoint)){if(i<t){const s=t;t=i,i=s}t=t<0?t:0,i=i>0?i:0,o.SetLimits(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)}}isPrismaticJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?!1:t.IsMotorEnabled()}enablePrismaticJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.EnableMotor(t)}getPrismaticJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorSpeed()*this._sharedData.worldScale}setPrismaticJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMotorSpeed(t*this._sharedData.worldInvScale)}getPrismaticJointMaxMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMaxMotorForce()}setPrismaticJointMaxMotorForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_prismaticJoint||i.SetMaxMotorForce(t)}getPrismaticJointMotorForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_prismaticJoint?0:t.GetMotorForce(1/this._sharedData.timeStep)}addPulleyJoint(e,t,i,o,s,n,a,h,d,c,u,r,f,D){if(this._body===null&&!this.createBody())return;const b=this._body;if(i==null||!i.hasBehavior(this.name))return;const _=i.getBehavior(this.name).getBody();if(this._body===_)return;const g=new Box2D.b2PulleyJointDef;g.set_bodyA(b),g.set_localAnchorA(b.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),g.set_bodyB(_),g.set_localAnchorB(_.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),g.set_groundAnchorA(this.b2Vec2(n*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale)),g.set_groundAnchorB(this.b2Vec2(h*this._sharedData.worldInvScale,d*this._sharedData.worldInvScale)),g.set_lengthA(c>0?c*this._sharedData.worldInvScale:this.b2Vec2((n-e)*this._sharedData.worldInvScale,(a-t)*this._sharedData.worldInvScale).Length()),g.set_lengthB(u>0?u*this._sharedData.worldInvScale:this.b2Vec2((h-o)*this._sharedData.worldInvScale,(d-s)*this._sharedData.worldInvScale).Length()),g.set_ratio(r>0?r:1),g.set_collideConnected(f);const y=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(g),Box2D.b2PulleyJoint));D.setNumber(y)}getPulleyJointFirstGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_x()*this._sharedData.worldScale}getPulleyJointFirstGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorA().get_y()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_x()*this._sharedData.worldScale}getPulleyJointSecondGroundAnchorY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetGroundAnchorB().get_y()*this._sharedData.worldScale}getPulleyJointFirstLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthA()*this._sharedData.worldScale}getPulleyJointSecondLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetCurrentLengthB()*this._sharedData.worldScale}getPulleyJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_pulleyJoint?0:t.GetRatio()}addGearJoint(e,t,i,o,s){if(this._body===null&&!this.createBody())return;const n=this._body,a=this._sharedData.getJoint(e);if(a===null||a.GetType()!==Box2D.e_revoluteJoint&&a.GetType()!==Box2D.e_prismaticJoint)return;const h=this._sharedData.getJoint(t);if(h===null||h.GetType()!==Box2D.e_revoluteJoint&&h.GetType()!==Box2D.e_prismaticJoint||a===h)return;const d=new Box2D.b2GearJointDef;d.set_bodyA(this._sharedData.staticBody),d.set_bodyB(n),d.set_joint1(a),d.set_joint2(h),d.set_ratio(i),d.set_collideConnected(o);const c=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(d),Box2D.b2GearJoint));s.setNumber(c)}getGearJointFirstJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint1())}getGearJointSecondJoint(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:this._sharedData.getJointId(t.GetJoint2())}getGearJointRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_gearJoint?0:t.GetRatio()}setGearJointRatio(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_gearJoint||(i.SetRatio(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addMouseJoint(e,t,i,o,s,n){if(this._body===null&&!this.createBody())return;const a=this._body,h=new Box2D.b2MouseJointDef;h.set_bodyA(this._sharedData.staticBody),h.set_bodyB(a),h.set_target(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale)),h.set_maxForce(i>=0?i:0),h.set_frequencyHz(o>0?o:1),h.set_dampingRatio(s>=0?s:0);const d=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(h),Box2D.b2MouseJoint));n.setNumber(d)}getMouseJointTargetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_x()*this._sharedData.worldScale}getMouseJointTargetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetTarget().get_y()*this._sharedData.worldScale}setMouseJointTarget(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_mouseJoint||(o.SetTarget(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),o.GetBodyB().SetAwake(!0))}getMouseJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetMaxForce()}setMouseJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetMaxForce(t)}getMouseJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetFrequency()}setMouseJointFrequency(e,t){if(t<=0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetFrequency(t)}getMouseJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_mouseJoint?0:t.GetDampingRatio()}setMouseJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_mouseJoint||i.SetDampingRatio(t)}addWheelJoint(e,t,i,o,s,n,a,h,d,c,u,r,f){if(this._body===null&&!this.createBody())return;const D=this._body;if(i==null||!i.hasBehavior(this.name))return;const b=i.getBehavior(this.name).getBody();if(this._body===b)return;const _=new Box2D.b2WheelJointDef;_.set_bodyA(D),_.set_localAnchorA(D.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),_.set_bodyB(b),_.set_localAnchorB(b.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),n=l.toRad(n)-D.GetAngle(),_.set_localAxisA(this.b2Vec2(Math.cos(n),Math.sin(n))),_.set_frequencyHz(a>0?a:1),_.set_dampingRatio(h>=0?h:0),_.set_enableMotor(d),_.set_motorSpeed(l.toRad(c)),_.set_maxMotorTorque(u),_.set_collideConnected(r);const g=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(_),Box2D.b2WheelJoint));f.setNumber(g)}getWheelJointAxisAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(Math.atan2(t.GetLocalAxisA().get_y(),t.GetLocalAxisA().get_x())+t.GetBodyA().GetAngle())}getWheelJointTranslation(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetJointTranslation()*this._sharedData.worldScale}getWheelJointSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetJointSpeed())}isWheelJointMotorEnabled(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?!1:t.IsMotorEnabled()}enableWheelJointMotor(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.EnableMotor(t)}getWheelJointMotorSpeed(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:l.toDegrees(t.GetMotorSpeed())}setWheelJointMotorSpeed(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMotorSpeed(l.toRad(t))}getWheelJointMaxMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMaxMotorTorque()}setWheelJointMaxMotorTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetMaxMotorTorque(t)}getWheelJointMotorTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetMotorTorque(1/this._sharedData.timeStep)}getWheelJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringFrequencyHz()}setWheelJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringFrequencyHz(t)}getWheelJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_wheelJoint?0:t.GetSpringDampingRatio()}setWheelJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_wheelJoint||i.SetSpringDampingRatio(t)}addWeldJoint(e,t,i,o,s,n,a,h,d,c){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const u=i.getBehavior(this.name).getBody();if(this._body===u)return;const r=this._body,f=new Box2D.b2WeldJointDef;f.set_bodyA(r),f.set_localAnchorA(r.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),f.set_bodyB(u),f.set_localAnchorB(u.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),f.set_referenceAngle(l.toRad(n)),f.set_frequencyHz(a>0?a:1),f.set_dampingRatio(h>=0?h:0),f.set_collideConnected(d);const D=Box2D.castObject(this._sharedData.world.CreateJoint(f),Box2D.b2WeldJoint);D.referenceAngle=f.get_referenceAngle(),c.setNumber(this._sharedData.addJoint(D))}getWeldJointReferenceAngle(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:l.toDegrees(t.referenceAngle)}getWeldJointFrequency(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetFrequency()}setWeldJointFrequency(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetFrequency(t)}getWeldJointDampingRatio(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_weldJoint?0:t.GetDampingRatio()}setWeldJointDampingRatio(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_weldJoint||i.SetDampingRatio(t)}addRopeJoint(e,t,i,o,s,n,a,h){if(this._body===null&&!this.createBody())return;const d=this._body;if(i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=new Box2D.b2RopeJointDef;u.set_bodyA(d),u.set_localAnchorA(d.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),u.set_bodyB(c),u.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),u.set_maxLength(n>0?n*this._sharedData.worldInvScale:this.b2Vec2((o-e)*this._sharedData.worldInvScale,(s-t)*this._sharedData.worldInvScale).Length()),u.set_collideConnected(a);const r=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(u),Box2D.b2RopeJoint));h.setNumber(r)}getRopeJointMaxLength(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_ropeJoint?0:t.GetMaxLength()*this._sharedData.worldScale}setRopeJointMaxLength(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_ropeJoint||(i.SetMaxLength(t*this._sharedData.worldInvScale),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}addFrictionJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody()||i==null||!i.hasBehavior(this.name))return;const c=i.getBehavior(this.name).getBody();if(this._body===c)return;const u=this._body,r=new Box2D.b2FrictionJointDef;r.set_bodyA(u),r.set_localAnchorA(u.GetLocalPoint(this.b2Vec2(e*this._sharedData.worldInvScale,t*this._sharedData.worldInvScale))),r.set_bodyB(c),r.set_localAnchorB(c.GetLocalPoint(this.b2Vec2(o*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale))),r.set_maxForce(n>=0?n:0),r.set_maxTorque(a>=0?a:0),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2FrictionJoint));d.setNumber(f)}getFrictionJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxForce()}setFrictionJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxForce(t)}getFrictionJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_frictionJoint?0:t.GetMaxTorque()}setFrictionJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_frictionJoint||i.SetMaxTorque(t)}addMotorJoint(e,t,i,o,s,n,a,h,d){if(this._body===null&&!this.createBody())return;const c=this._body;if(e==null||!e.hasBehavior(this.name))return;const u=e.getBehavior(this.name).getBody();if(this._body===u)return;const r=new Box2D.b2MotorJointDef;r.set_bodyA(c),r.set_bodyB(u),r.set_linearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale)),r.set_angularOffset(l.toRad(o)),r.set_maxForce(s>=0?s:0),r.set_maxTorque(n>=0?n:0),r.set_correctionFactor(a<0?0:a>1?1:a),r.set_collideConnected(h);const f=this._sharedData.addJoint(Box2D.castObject(this._sharedData.world.CreateJoint(r),Box2D.b2MotorJoint));d.setNumber(f)}getMotorJointOffsetX(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_x()*this._sharedData.worldScale}getMotorJointOffsetY(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetLinearOffset().get_y()*this._sharedData.worldScale}setMotorJointOffset(e,t,i){const o=this._sharedData.getJoint(e);o===null||o.GetType()!==Box2D.e_motorJoint||o.SetLinearOffset(this.b2Vec2(t*this._sharedData.worldInvScale,i*this._sharedData.worldInvScale))}getMotorJointAngularOffset(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:l.toDegrees(t.GetAngularOffset())}setMotorJointAngularOffset(e,t){const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetAngularOffset(l.toRad(t))}getMotorJointMaxForce(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxForce()}setMotorJointMaxForce(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||i.SetMaxForce(t)}getMotorJointMaxTorque(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetMaxTorque()}setMotorJointMaxTorque(e,t){if(t<0)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetMaxTorque(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}getMotorJointCorrectionFactor(e){const t=this._sharedData.getJoint(e);return t===null||t.GetType()!==Box2D.e_motorJoint?0:t.GetCorrectionFactor()}setMotorJointCorrectionFactor(e,t){if(t<0||t>1)return;const i=this._sharedData.getJoint(e);i===null||i.GetType()!==Box2D.e_motorJoint||(i.SetCorrectionFactor(t),i.GetBodyA().SetAwake(!0),i.GetBodyB().SetAwake(!0))}onContactBegin(e){this.currentContacts.push(e);let t=this.contactsEndedThisFrame.indexOf(e);t!==-1?this.contactsEndedThisFrame.splice(t,1):this.contactsStartedThisFrame.push(e)}onContactEnd(e){this.contactsEndedThisFrame.push(e);const t=this.currentContacts.indexOf(e);t!==-1&&this.currentContacts.splice(t,1)}static areObjectsColliding(e,t,i){const o=e.getBehavior(i);return o?!!(o.currentContacts.some(s=>s.owner===t)||o.contactsStartedThisFrame.some(s=>s.owner===t)):!1}static hasCollisionStartedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsStartedThisFrame.some(s=>s.owner===t):!1}static hasCollisionStoppedBetween(e,t,i){const o=e.getBehavior(i);return o?o.contactsEndedThisFrame.some(s=>s.owner===t):!1}};let S=B;S.collisionTest=B.areObjectsColliding,l.Physics2RuntimeBehavior=S,l.registerBehavior("Physics2::Physics2Behavior",l.Physics2RuntimeBehavior)})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=physics2runtimebehavior.js.map