gdcore-tools 2.0.0-gd-v5.4.219-autobuild → 2.0.0-gd-v5.4.220-autobuild

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +19 -19
  2. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +1 -1
  3. package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js +1 -1
  4. package/dist/Runtime/Extensions/Physics2Behavior/physics2tools.js.map +2 -2
  5. package/dist/Runtime/Extensions/Physics3DBehavior/JsExtension.js +2442 -0
  6. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +2 -0
  7. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +7 -0
  8. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js +2 -0
  9. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DTools.js.map +7 -0
  10. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +2 -0
  11. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +7 -0
  12. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.d.ts +4874 -0
  13. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js +2 -0
  14. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.js.map +7 -0
  15. package/dist/Runtime/Extensions/Physics3DBehavior/jolt-physics.wasm.wasm +0 -0
  16. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  17. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js +1 -1
  18. package/dist/Runtime/Extensions/TileMap/helper/TileMapHelper.js.map +1 -1
  19. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  20. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  21. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  22. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  23. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  24. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  25. package/dist/lib/libGD.cjs +1 -1
  26. package/dist/lib/libGD.wasm +0 -0
  27. package/gd.d.ts +4 -2
  28. package/package.json +1 -1
@@ -0,0 +1,2442 @@
1
+ //@ts-check
2
+ /// <reference path="../JsExtensionTypes.d.ts" />
3
+ /**
4
+ * This is a declaration of an extension for GDevelop 5.
5
+ *
6
+ * ℹ️ Changes in this file are watched and automatically imported if the editor
7
+ * is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
8
+ *
9
+ * The file must be named "JsExtension.js", otherwise GDevelop won't load it.
10
+ * ⚠️ If you make a change and the extension is not loaded, open the developer console
11
+ * and search for any errors.
12
+ *
13
+ * More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
14
+ */
15
+
16
+ /** @type {ExtensionModule} */
17
+ module.exports = {
18
+ createExtension: function (_, gd) {
19
+ const extension = new gd.PlatformExtension();
20
+ extension
21
+ .setExtensionInformation(
22
+ 'Physics3D',
23
+ _('3D Physics Engine'),
24
+ "The physics engine simulates realistic object physics, with gravity, forces, joints, etc. It's perfect for games that need to have realistic behaving objects and a gameplay centered around it.",
25
+ 'Florian Rival',
26
+ 'MIT'
27
+ )
28
+ .setExtensionHelpPath('/behaviors/physics3d')
29
+ .setCategory('Movement')
30
+ .setTags('physics, gravity, obstacle, collision');
31
+ extension
32
+ .addInstructionOrExpressionGroupMetadata(_('3D Physics Engine'))
33
+ .setIcon('JsPlatform/Extensions/physics3d.svg');
34
+ {
35
+ const behavior = new gd.BehaviorJsImplementation();
36
+ behavior.updateProperty = function (
37
+ behaviorContent,
38
+ propertyName,
39
+ newValue
40
+ ) {
41
+ if (propertyName === 'object3D') {
42
+ behaviorContent.getChild('object3D').setStringValue(newValue);
43
+ return true;
44
+ }
45
+
46
+ if (propertyName === 'bodyType') {
47
+ behaviorContent.getChild('bodyType').setStringValue(newValue);
48
+ return true;
49
+ }
50
+
51
+ if (propertyName === 'bullet') {
52
+ behaviorContent.getChild('bullet').setBoolValue(newValue === '1');
53
+ return true;
54
+ }
55
+
56
+ if (propertyName === 'fixedRotation') {
57
+ behaviorContent
58
+ .getChild('fixedRotation')
59
+ .setBoolValue(newValue === '1');
60
+ return true;
61
+ }
62
+
63
+ if (propertyName === 'shape') {
64
+ behaviorContent.getChild('shape').setStringValue(newValue);
65
+ return true;
66
+ }
67
+
68
+ if (propertyName === 'shapeOrientation') {
69
+ behaviorContent.getChild('shapeOrientation').setStringValue(newValue);
70
+ return true;
71
+ }
72
+
73
+ if (propertyName === 'shapeDimensionA') {
74
+ const newValueAsNumber = parseFloat(newValue);
75
+ if (newValueAsNumber !== newValueAsNumber) return false;
76
+ behaviorContent
77
+ .getChild('shapeDimensionA')
78
+ .setDoubleValue(newValueAsNumber);
79
+ return true;
80
+ }
81
+
82
+ if (propertyName === 'shapeDimensionB') {
83
+ const newValueAsNumber = parseFloat(newValue);
84
+ if (newValueAsNumber !== newValueAsNumber) return false;
85
+ behaviorContent
86
+ .getChild('shapeDimensionB')
87
+ .setDoubleValue(newValueAsNumber);
88
+ return true;
89
+ }
90
+
91
+ if (propertyName === 'shapeDimensionC') {
92
+ const newValueAsNumber = parseFloat(newValue);
93
+ if (newValueAsNumber !== newValueAsNumber) return false;
94
+ behaviorContent
95
+ .getChild('shapeDimensionC')
96
+ .setDoubleValue(newValueAsNumber);
97
+ return true;
98
+ }
99
+
100
+ if (propertyName === 'density') {
101
+ behaviorContent
102
+ .getChild('density')
103
+ .setDoubleValue(parseFloat(newValue));
104
+ return true;
105
+ }
106
+
107
+ if (propertyName === 'friction') {
108
+ const newValueAsNumber = parseFloat(newValue);
109
+ if (newValueAsNumber !== newValueAsNumber) return false;
110
+ behaviorContent.getChild('friction').setDoubleValue(newValueAsNumber);
111
+ return true;
112
+ }
113
+
114
+ if (propertyName === 'restitution') {
115
+ const newValueAsNumber = parseFloat(newValue);
116
+ if (newValueAsNumber !== newValueAsNumber) return false;
117
+ behaviorContent
118
+ .getChild('restitution')
119
+ .setDoubleValue(newValueAsNumber);
120
+ return true;
121
+ }
122
+
123
+ if (propertyName === 'linearDamping') {
124
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
125
+ if (newValueAsNumber !== newValueAsNumber) return false;
126
+ behaviorContent
127
+ .getChild('linearDamping')
128
+ .setDoubleValue(newValueAsNumber);
129
+ return true;
130
+ }
131
+
132
+ if (propertyName === 'angularDamping') {
133
+ const newValueAsNumber = Math.max(0, parseFloat(newValue));
134
+ if (newValueAsNumber !== newValueAsNumber) return false;
135
+ behaviorContent
136
+ .getChild('angularDamping')
137
+ .setDoubleValue(newValueAsNumber);
138
+ return true;
139
+ }
140
+
141
+ if (propertyName === 'gravityScale') {
142
+ const newValueAsNumber = parseFloat(newValue);
143
+ if (newValueAsNumber !== newValueAsNumber) return false;
144
+ behaviorContent
145
+ .getChild('gravityScale')
146
+ .setDoubleValue(newValueAsNumber);
147
+ return true;
148
+ }
149
+
150
+ if (propertyName === 'layers') {
151
+ behaviorContent
152
+ .getChild('layers')
153
+ .setIntValue(parseInt(newValue, 10));
154
+ return true;
155
+ }
156
+
157
+ if (propertyName === 'masks') {
158
+ behaviorContent.getChild('masks').setIntValue(parseInt(newValue, 10));
159
+ return true;
160
+ }
161
+
162
+ return false;
163
+ };
164
+ behavior.getProperties = function (behaviorContent) {
165
+ const behaviorProperties = new gd.MapStringPropertyDescriptor();
166
+
167
+ behaviorProperties
168
+ .getOrCreate('object3D')
169
+ .setValue(behaviorContent.getChild('Object3D').getStringValue())
170
+ .setType('Behavior')
171
+ .setLabel('3D capability')
172
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
173
+ .addExtraInfo('Scene3D::Base3DBehavior');
174
+
175
+ behaviorProperties
176
+ .getOrCreate('bodyType')
177
+ .setValue(behaviorContent.getChild('bodyType').getStringValue())
178
+ .setType('Choice')
179
+ .setLabel('Type')
180
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
181
+ .addExtraInfo('Static')
182
+ .addExtraInfo('Dynamic')
183
+ .addExtraInfo('Kinematic')
184
+ .setDescription(
185
+ _(
186
+ "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)."
187
+ )
188
+ );
189
+ behaviorProperties
190
+ .getOrCreate('bullet')
191
+ .setValue(
192
+ behaviorContent.getChild('bullet').getBoolValue() ? 'true' : 'false'
193
+ )
194
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
195
+ .setType('Boolean')
196
+ .setLabel(_('Considered as a bullet'))
197
+ .setDescription(
198
+ _(
199
+ 'Useful for fast moving objects which requires a more accurate collision detection.'
200
+ )
201
+ )
202
+ .setGroup(_('Physics body advanced settings'))
203
+ .setAdvanced(true);
204
+ behaviorProperties
205
+ .getOrCreate('fixedRotation')
206
+ .setValue(
207
+ behaviorContent.getChild('fixedRotation').getBoolValue()
208
+ ? 'true'
209
+ : 'false'
210
+ )
211
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
212
+ .setType('Boolean')
213
+ .setLabel('Fixed Rotation')
214
+ .setDescription(
215
+ _(
216
+ "If enabled, the object won't rotate and will stay at the same angle. Useful for characters for example."
217
+ )
218
+ )
219
+ .setGroup(_('Movement'));
220
+ behaviorProperties
221
+ .getOrCreate('shape')
222
+ .setValue(behaviorContent.getChild('shape').getStringValue())
223
+ .setType('Choice')
224
+ .setLabel('Shape')
225
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
226
+ .addExtraInfo('Box')
227
+ .addExtraInfo('Capsule')
228
+ .addExtraInfo('Cylinder')
229
+ .addExtraInfo('Sphere');
230
+ behaviorProperties
231
+ .getOrCreate('shapeOrientation')
232
+ .setValue(
233
+ behaviorContent.getChild('shapeOrientation').getStringValue()
234
+ )
235
+ .setType('Choice')
236
+ .setLabel('Shape orientation')
237
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
238
+ .addExtraInfo('Z')
239
+ .addExtraInfo('Y')
240
+ .addExtraInfo('X');
241
+ behaviorProperties
242
+ .getOrCreate('shapeDimensionA')
243
+ .setValue(
244
+ behaviorContent
245
+ .getChild('shapeDimensionA')
246
+ .getDoubleValue()
247
+ .toString(10)
248
+ )
249
+ .setType('Number')
250
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
251
+ .setLabel('Shape Dimension A')
252
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
253
+ .setHidden(true); // Hidden as required to be changed in the full editor.
254
+ behaviorProperties
255
+ .getOrCreate('shapeDimensionB')
256
+ .setValue(
257
+ behaviorContent
258
+ .getChild('shapeDimensionB')
259
+ .getDoubleValue()
260
+ .toString(10)
261
+ )
262
+ .setType('Number')
263
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
264
+ .setLabel('Shape Dimension B')
265
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
266
+ .setHidden(true); // Hidden as required to be changed in the full editor.
267
+ behaviorProperties
268
+ .getOrCreate('shapeDimensionC')
269
+ .setValue(
270
+ behaviorContent
271
+ .getChild('shapeDimensionC')
272
+ .getDoubleValue()
273
+ .toString(10)
274
+ )
275
+ .setType('Number')
276
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
277
+ .setLabel('Shape Dimension C')
278
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
279
+ .setHidden(true); // Hidden as required to be changed in the full editor.
280
+ behaviorProperties
281
+ .getOrCreate('density')
282
+ .setValue(
283
+ behaviorContent.getChild('density').getDoubleValue().toString(10)
284
+ )
285
+ .setType('Number')
286
+ .setLabel(_('Density'))
287
+ .setDescription(
288
+ _(
289
+ 'Define the weight of the object, according to its size. The bigger the density, the heavier the object.'
290
+ )
291
+ );
292
+ behaviorProperties
293
+ .getOrCreate('friction')
294
+ .setValue(
295
+ behaviorContent.getChild('friction').getDoubleValue().toString(10)
296
+ )
297
+ .setType('Number')
298
+ .setLabel(_('Friction'))
299
+ .setDescription(
300
+ _(
301
+ 'The friction applied when touching other objects. The higher the value, the more friction.'
302
+ )
303
+ );
304
+ behaviorProperties
305
+ .getOrCreate('restitution')
306
+ .setValue(
307
+ behaviorContent
308
+ .getChild('restitution')
309
+ .getDoubleValue()
310
+ .toString(10)
311
+ )
312
+ .setType('Number')
313
+ .setLabel(_('Restitution'))
314
+ .setDescription(
315
+ _(
316
+ 'The "bounciness" of the object. The higher the value, the more other objects will bounce against it.'
317
+ )
318
+ );
319
+ behaviorProperties
320
+ .getOrCreate('linearDamping')
321
+ .setValue(
322
+ behaviorContent
323
+ .getChild('linearDamping')
324
+ .getDoubleValue()
325
+ .toString(10)
326
+ )
327
+ .setType('Number')
328
+ .setLabel(_('Linear Damping'))
329
+ .setGroup(_('Movement'));
330
+
331
+ behaviorProperties
332
+ .getOrCreate('angularDamping')
333
+ .setValue(
334
+ behaviorContent
335
+ .getChild('angularDamping')
336
+ .getDoubleValue()
337
+ .toString(10)
338
+ )
339
+ .setType('Number')
340
+ .setLabel(_('Angular Damping'))
341
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
342
+ .setGroup(_('Movement'));
343
+ behaviorProperties
344
+ .getOrCreate('gravityScale')
345
+ .setValue(
346
+ behaviorContent
347
+ .getChild('gravityScale')
348
+ .getDoubleValue()
349
+ .toString(10)
350
+ )
351
+ .setType('Number')
352
+ .setLabel('Gravity Scale')
353
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
354
+ .setGroup(_('Gravity'))
355
+ .setAdvanced(true);
356
+ behaviorProperties
357
+ .getOrCreate('layers')
358
+ .setValue(
359
+ behaviorContent.getChild('layers').getIntValue().toString(10)
360
+ )
361
+ .setType('Number')
362
+ .setLabel('Layers')
363
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
364
+ .setHidden(true); // Hidden as required to be changed in the full editor.
365
+ behaviorProperties
366
+ .getOrCreate('masks')
367
+ .setValue(
368
+ behaviorContent.getChild('masks').getIntValue().toString(10)
369
+ )
370
+ .setType('Number')
371
+ .setLabel('Masks')
372
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
373
+ .setHidden(true); // Hidden as required to be changed in the full editor.
374
+
375
+ return behaviorProperties;
376
+ };
377
+
378
+ behavior.initializeContent = function (behaviorContent) {
379
+ behaviorContent.addChild('object3D').setStringValue('');
380
+ behaviorContent.addChild('bodyType').setStringValue('Dynamic');
381
+ behaviorContent.addChild('bullet').setBoolValue(false);
382
+ behaviorContent.addChild('fixedRotation').setBoolValue(false);
383
+ behaviorContent.addChild('shape').setStringValue('Box');
384
+ behaviorContent.addChild('shapeOrientation').setStringValue('Z');
385
+ behaviorContent.addChild('shapeDimensionA').setDoubleValue(0);
386
+ behaviorContent.addChild('shapeDimensionB').setDoubleValue(0);
387
+ behaviorContent.addChild('shapeDimensionC').setDoubleValue(0);
388
+ behaviorContent.addChild('density').setDoubleValue(1.0);
389
+ behaviorContent.addChild('friction').setDoubleValue(0.3);
390
+ behaviorContent.addChild('restitution').setDoubleValue(0.1);
391
+ behaviorContent.addChild('linearDamping').setDoubleValue(0.1);
392
+ behaviorContent.addChild('angularDamping').setDoubleValue(0.1);
393
+ behaviorContent.addChild('gravityScale').setDoubleValue(1);
394
+ behaviorContent.addChild('layers').setIntValue((1 << 4) | (1 << 0));
395
+ behaviorContent.addChild('masks').setIntValue((1 << 4) | (1 << 0));
396
+ };
397
+
398
+ const sharedData = new gd.BehaviorSharedDataJsImplementation();
399
+ sharedData.updateProperty = function (
400
+ sharedContent,
401
+ propertyName,
402
+ newValue
403
+ ) {
404
+ if (propertyName === 'gravityX') {
405
+ const newValueAsNumber = parseFloat(newValue);
406
+ if (newValueAsNumber !== newValueAsNumber) return false;
407
+ sharedContent.getChild('gravityX').setDoubleValue(newValueAsNumber);
408
+ return true;
409
+ }
410
+
411
+ if (propertyName === 'gravityY') {
412
+ const newValueAsNumber = parseFloat(newValue);
413
+ if (newValueAsNumber !== newValueAsNumber) return false;
414
+ sharedContent.getChild('gravityY').setDoubleValue(newValueAsNumber);
415
+ return true;
416
+ }
417
+
418
+ if (propertyName === 'gravityZ') {
419
+ const newValueAsNumber = parseFloat(newValue);
420
+ if (newValueAsNumber !== newValueAsNumber) return false;
421
+ sharedContent.getChild('gravityZ').setDoubleValue(newValueAsNumber);
422
+ return true;
423
+ }
424
+
425
+ if (propertyName === 'worldScale') {
426
+ const newValueAsNumber = parseInt(newValue, 10);
427
+ if (newValueAsNumber !== newValueAsNumber) return false;
428
+ if (!sharedContent.hasChild('worldScale')) {
429
+ sharedContent.addChild('worldScale');
430
+ }
431
+ sharedContent.getChild('worldScale').setDoubleValue(newValueAsNumber);
432
+ return true;
433
+ }
434
+ return false;
435
+ };
436
+ sharedData.getProperties = function (sharedContent) {
437
+ const sharedProperties = new gd.MapStringPropertyDescriptor();
438
+
439
+ sharedProperties
440
+ .getOrCreate('gravityX')
441
+ .setValue(
442
+ sharedContent.getChild('gravityX').getDoubleValue().toString(10)
443
+ )
444
+ .setType('Number')
445
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
446
+ sharedProperties
447
+ .getOrCreate('gravityY')
448
+ .setValue(
449
+ sharedContent.getChild('gravityY').getDoubleValue().toString(10)
450
+ )
451
+ .setType('Number')
452
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
453
+ sharedProperties
454
+ .getOrCreate('gravityZ')
455
+ .setValue(
456
+ sharedContent.getChild('gravityZ').getDoubleValue().toString(10)
457
+ )
458
+ .setType('Number')
459
+ .setMeasurementUnit(gd.MeasurementUnit.getNewton());
460
+
461
+ sharedProperties
462
+ .getOrCreate('worldScale')
463
+ .setValue(
464
+ sharedContent.getChild('worldScale').getDoubleValue().toString(10)
465
+ )
466
+ .setType('Number');
467
+
468
+ return sharedProperties;
469
+ };
470
+ sharedData.initializeContent = function (behaviorContent) {
471
+ behaviorContent.addChild('gravityX').setDoubleValue(0);
472
+ behaviorContent.addChild('gravityY').setDoubleValue(0);
473
+ behaviorContent.addChild('gravityZ').setDoubleValue(-9.8);
474
+ behaviorContent.addChild('worldScale').setDoubleValue(100);
475
+ };
476
+
477
+ const aut = extension
478
+ .addBehavior(
479
+ 'Physics3DBehavior',
480
+ _('3D physics engine'),
481
+ 'Physics3D',
482
+ _('Simulate realistic object physics with gravity, forces, etc.'),
483
+ '',
484
+ 'JsPlatform/Extensions/physics3d.svg',
485
+ 'Physics3DBehavior',
486
+ //@ts-ignore The class hierarchy is incorrect leading to a type error, but this is valid.
487
+ behavior,
488
+ sharedData
489
+ )
490
+ .addIncludeFile(
491
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
492
+ )
493
+ .addRequiredFile('Extensions/Physics3DBehavior/jolt-physics.wasm.js')
494
+ .addRequiredFile('Extensions/Physics3DBehavior/jolt-physics.wasm.wasm')
495
+ .setOpenFullEditorLabel(_('Edit shape and advanced settings'));
496
+
497
+ // Global
498
+ aut
499
+ .addExpression(
500
+ 'WorldScale',
501
+ _('World scale'),
502
+ _('Return the world scale.'),
503
+ _('Global'),
504
+ 'JsPlatform/Extensions/physics3d.svg'
505
+ )
506
+ .addParameter('object', _('Object'), '', false)
507
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
508
+ .getCodeExtraInformation()
509
+ .setFunctionName('getWorldScale');
510
+
511
+ aut
512
+ .addExpressionAndConditionAndAction(
513
+ 'number',
514
+ 'GravityX',
515
+ _('World gravity on X axis'),
516
+ _('the world gravity on X axis') +
517
+ ' ' +
518
+ _(
519
+ 'While an object is needed, this will apply to all objects using the behavior.'
520
+ ),
521
+ _('the world gravity on X axis'),
522
+ _('Global'),
523
+ 'JsPlatform/Extensions/physics3d.svg'
524
+ )
525
+ .addParameter('object', _('Object'), '', false)
526
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
527
+ .useStandardParameters(
528
+ 'number',
529
+ gd.ParameterOptions.makeNewOptions().setDescription(
530
+ _('Gravity (in Newton)')
531
+ )
532
+ )
533
+ .setFunctionName('setGravityX')
534
+ .setGetter('getGravityX');
535
+
536
+ aut
537
+ .addExpressionAndConditionAndAction(
538
+ 'number',
539
+ 'GravityY',
540
+ _('World gravity on Y axis'),
541
+ _('the world gravity on Y axis') +
542
+ ' ' +
543
+ _(
544
+ 'While an object is needed, this will apply to all objects using the behavior.'
545
+ ),
546
+ _('the world gravity on Y axis'),
547
+ _('Global'),
548
+ 'JsPlatform/Extensions/physics3d.svg'
549
+ )
550
+ .addParameter('object', _('Object'), '', false)
551
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
552
+ .useStandardParameters(
553
+ 'number',
554
+ gd.ParameterOptions.makeNewOptions().setDescription(
555
+ _('Gravity (in Newton)')
556
+ )
557
+ )
558
+ .setFunctionName('setGravityY')
559
+ .setGetter('getGravityY');
560
+
561
+ aut
562
+ .addExpressionAndConditionAndAction(
563
+ 'number',
564
+ 'GravityZ',
565
+ _('World gravity on Z axis'),
566
+ _('the world gravity on Z axis') +
567
+ ' ' +
568
+ _(
569
+ 'While an object is needed, this will apply to all objects using the behavior.'
570
+ ),
571
+ _('the world gravity on Z axis'),
572
+ _('Global'),
573
+ 'JsPlatform/Extensions/physics3d.svg'
574
+ )
575
+ .addParameter('object', _('Object'), '', false)
576
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
577
+ .useStandardParameters(
578
+ 'number',
579
+ gd.ParameterOptions.makeNewOptions().setDescription(
580
+ _('Gravity (in Newton)')
581
+ )
582
+ )
583
+ .setFunctionName('setGravityZ')
584
+ .setGetter('getGravityZ');
585
+
586
+ aut
587
+ .addScopedCondition(
588
+ 'IsDynamic',
589
+ _('Is dynamic'),
590
+ _('Check if an object is dynamic.'),
591
+ _('_PARAM0_ is dynamic'),
592
+ _('Dynamics'),
593
+ 'JsPlatform/Extensions/physics3d.svg',
594
+ 'JsPlatform/Extensions/physics3d.svg'
595
+ )
596
+ .addParameter('object', _('Object'), '', false)
597
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
598
+ .getCodeExtraInformation()
599
+ .setFunctionName('isDynamic');
600
+
601
+ aut
602
+ .addScopedCondition(
603
+ 'IsStatic',
604
+ _('Is static'),
605
+ _('Check if an object is static.'),
606
+ _('_PARAM0_ is static'),
607
+ _('Dynamics'),
608
+ 'JsPlatform/Extensions/physics3d.svg',
609
+ 'JsPlatform/Extensions/physics3d.svg'
610
+ )
611
+ .addParameter('object', _('Object'), '', false)
612
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
613
+ .getCodeExtraInformation()
614
+ .setFunctionName('isStatic');
615
+
616
+ aut
617
+ .addScopedCondition(
618
+ 'IsKinematic',
619
+ _('Is kinematic'),
620
+ _('Check if an object is kinematic.'),
621
+ _('_PARAM0_ is kinematic'),
622
+ _('Dynamics'),
623
+ 'JsPlatform/Extensions/physics3d.svg',
624
+ 'JsPlatform/Extensions/physics3d.svg'
625
+ )
626
+ .addParameter('object', _('Object'), '', false)
627
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
628
+ .getCodeExtraInformation()
629
+ .setFunctionName('isKinematic');
630
+
631
+ aut
632
+ .addScopedCondition(
633
+ 'IsBullet',
634
+ _('Is treated as a bullet'),
635
+ _('Check if the object is being treated as a bullet.'),
636
+ _('_PARAM0_ is treated as a bullet'),
637
+ _('Dynamics'),
638
+ 'JsPlatform/Extensions/physics3d.svg',
639
+ 'JsPlatform/Extensions/physics3d.svg'
640
+ )
641
+ .addParameter('object', _('Object'), '', false)
642
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
643
+ .getCodeExtraInformation()
644
+ .setFunctionName('isBullet');
645
+
646
+ aut
647
+ .addScopedAction(
648
+ 'SetBullet',
649
+ _('Treat as bullet'),
650
+ _(
651
+ 'Treat the object as a bullet. Better collision handling on high speeds at cost of some performance.'
652
+ ),
653
+ _('Treat _PARAM0_ as bullet: _PARAM2_'),
654
+ _('Dynamics'),
655
+ 'JsPlatform/Extensions/physics3d.svg',
656
+ 'JsPlatform/Extensions/physics3d.svg'
657
+ )
658
+ .addParameter('object', _('Object'), '', false)
659
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
660
+ .addParameter('yesorno', _('Treat as bullet?'), '', false)
661
+ .setDefaultValue('false')
662
+ .getCodeExtraInformation()
663
+ .setFunctionName('setBullet');
664
+
665
+ aut
666
+ .addScopedCondition(
667
+ 'HasFixedRotation',
668
+ _('Has fixed rotation'),
669
+ _('Check if an object has fixed rotation.'),
670
+ _('_PARAM0_ has fixed rotation'),
671
+ _('Dynamics'),
672
+ 'JsPlatform/Extensions/physics3d.svg',
673
+ 'JsPlatform/Extensions/physics3d.svg'
674
+ )
675
+ .addParameter('object', _('Object'), '', false)
676
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
677
+ .getCodeExtraInformation()
678
+ .setFunctionName('hasFixedRotation');
679
+
680
+ aut
681
+ .addScopedAction(
682
+ 'SetFixedRotation',
683
+ _('Fixed rotation'),
684
+ _(
685
+ "Enable or disable an object fixed rotation. If enabled the object won't be able to rotate."
686
+ ),
687
+ _('Set _PARAM0_ fixed rotation: _PARAM2_'),
688
+ _('Dynamics'),
689
+ 'JsPlatform/Extensions/physics3d.svg',
690
+ 'JsPlatform/Extensions/physics3d.svg'
691
+ )
692
+ .addParameter('object', _('Object'), '', false)
693
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
694
+ .addParameter('yesorno', _('Fixed rotation?'), '', false)
695
+ .setDefaultValue('false')
696
+ .getCodeExtraInformation()
697
+ .setFunctionName('setFixedRotation');
698
+
699
+ // Body settings
700
+ aut
701
+ .addScopedAction(
702
+ 'ShapeScale',
703
+ _('Shape scale'),
704
+ _(
705
+ 'Modify an object shape scale. It affects custom shape dimensions, if custom dimensions are not set the body will be scaled automatically to the object size.'
706
+ ),
707
+ _('the shape scale'),
708
+ _('Body settings'),
709
+ 'JsPlatform/Extensions/physics3d.svg',
710
+ 'JsPlatform/Extensions/physics3d.svg'
711
+ )
712
+ .addParameter('object', _('Object'), '', false)
713
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
714
+ .useStandardOperatorParameters(
715
+ 'number',
716
+ gd.ParameterOptions.makeNewOptions().setDescription(
717
+ _('Scale (1 by default)')
718
+ )
719
+ )
720
+ .getCodeExtraInformation()
721
+ .setFunctionName('setShapeScale')
722
+ .setGetter('getShapeScale');
723
+
724
+ aut
725
+ .addExpressionAndConditionAndAction(
726
+ 'number',
727
+ 'Density',
728
+ _('Density'),
729
+ _(
730
+ "the object density. The body's density and volume determine its mass."
731
+ ),
732
+ _('the density'),
733
+ _('Body settings'),
734
+ 'JsPlatform/Extensions/physics3d.svg'
735
+ )
736
+ .addParameter('object', _('Object'), '', false)
737
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
738
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
739
+ .setFunctionName('setDensity')
740
+ .setGetter('getDensity');
741
+
742
+ aut
743
+ .addExpressionAndConditionAndAction(
744
+ 'number',
745
+ 'Friction',
746
+ _('Friction'),
747
+ _(
748
+ "the object friction. How much energy is lost from the movement of one object over another. The combined friction from two bodies is calculated as 'sqrt(bodyA.friction * bodyB.friction)'."
749
+ ),
750
+ _('the friction'),
751
+ _('Body settings'),
752
+ 'JsPlatform/Extensions/physics3d.svg'
753
+ )
754
+ .addParameter('object', _('Object'), '', false)
755
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
756
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
757
+ .setFunctionName('setFriction')
758
+ .setGetter('getFriction');
759
+
760
+ aut
761
+ .addExpressionAndConditionAndAction(
762
+ 'number',
763
+ 'Restitution',
764
+ _('Restitution'),
765
+ _(
766
+ "the object restitution. Energy conservation on collision. The combined restitution from two bodies is calculated as 'max(bodyA.restitution, bodyB.restitution)'."
767
+ ),
768
+ _('the restitution'),
769
+ _('Body settings'),
770
+ 'JsPlatform/Extensions/physics3d.svg'
771
+ )
772
+ .addParameter('object', _('Object'), '', false)
773
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
774
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
775
+ .setFunctionName('setRestitution')
776
+ .setGetter('getRestitution');
777
+
778
+ aut
779
+ .addExpressionAndConditionAndAction(
780
+ 'number',
781
+ 'LinearDamping',
782
+ _('Linear damping'),
783
+ _(
784
+ 'the object linear damping. How much movement speed is lost across the time.'
785
+ ),
786
+ _('the linear damping'),
787
+ _('Body settings'),
788
+ 'JsPlatform/Extensions/physics3d.svg'
789
+ )
790
+ .addParameter('object', _('Object'), '', false)
791
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
792
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
793
+ .setFunctionName('setLinearDamping')
794
+ .setGetter('getLinearDamping');
795
+
796
+ aut
797
+ .addExpressionAndConditionAndAction(
798
+ 'number',
799
+ 'AngularDamping',
800
+ _('Angular damping'),
801
+ _(
802
+ 'the object angular damping. How much angular speed is lost across the time.'
803
+ ),
804
+ _('the angular damping'),
805
+ _('Body settings'),
806
+ 'JsPlatform/Extensions/physics3d.svg'
807
+ )
808
+ .addParameter('object', _('Object'), '', false)
809
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
810
+ .useStandardParameters('number', gd.ParameterOptions.makeNewOptions())
811
+ .setFunctionName('setAngularDamping')
812
+ .setGetter('getAngularDamping');
813
+
814
+ aut
815
+ .addExpressionAndConditionAndAction(
816
+ 'number',
817
+ 'GravityScale',
818
+ _('Gravity scale'),
819
+ _(
820
+ 'the object gravity scale. The gravity applied to an object is the world gravity multiplied by the object gravity scale.'
821
+ ),
822
+ _('the gravity scale'),
823
+ _('Body settings'),
824
+ 'JsPlatform/Extensions/physics3d.svg'
825
+ )
826
+ .addParameter('object', _('Object'), '', false)
827
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
828
+ .useStandardParameters(
829
+ 'number',
830
+ gd.ParameterOptions.makeNewOptions().setDescription(
831
+ _('Scale (1 by default)')
832
+ )
833
+ )
834
+ .setFunctionName('setGravityScale')
835
+ .setGetter('getGravityScale');
836
+
837
+ // Filtering
838
+ aut
839
+ .addScopedCondition(
840
+ 'LayerEnabled',
841
+ _('Layer enabled'),
842
+ _('Check if an object has a specific layer enabled.'),
843
+ _('_PARAM0_ has layer _PARAM2_ enabled'),
844
+ _('Filtering'),
845
+ 'JsPlatform/Extensions/physics3d.svg',
846
+ 'JsPlatform/Extensions/physics3d.svg'
847
+ )
848
+ .addParameter('object', _('Object'), '', false)
849
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
850
+ .addParameter('expression', _('Layer (1 - 8)'))
851
+ .getCodeExtraInformation()
852
+ .setFunctionName('layerEnabled');
853
+
854
+ aut
855
+ .addScopedAction(
856
+ 'EnableLayer',
857
+ _('Enable layer'),
858
+ _(
859
+ 'Enable or disable a layer for an object. Two objects collide if any layer of the first object matches any mask of the second one and vice versa.'
860
+ ),
861
+ _('Enable layer _PARAM2_ for _PARAM0_: _PARAM3_'),
862
+ _('Filtering'),
863
+ 'JsPlatform/Extensions/physics3d.svg',
864
+ 'JsPlatform/Extensions/physics3d.svg'
865
+ )
866
+ .addParameter('object', _('Object'), '', false)
867
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
868
+ .addParameter('expression', _('Layer (1 - 8)'))
869
+ .addParameter('yesorno', _('Enable?'), '', false)
870
+ .setDefaultValue('true')
871
+ .getCodeExtraInformation()
872
+ .setFunctionName('enableLayer');
873
+
874
+ aut
875
+ .addScopedCondition(
876
+ 'MaskEnabled',
877
+ _('Mask enabled'),
878
+ _('Check if an object has a specific mask enabled.'),
879
+ _('_PARAM0_ has mask _PARAM2_ enabled'),
880
+ _('Filtering'),
881
+ 'JsPlatform/Extensions/physics3d.svg',
882
+ 'JsPlatform/Extensions/physics3d.svg'
883
+ )
884
+ .addParameter('object', _('Object'), '', false)
885
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
886
+ .addParameter('expression', _('Mask (1 - 8)'))
887
+ .getCodeExtraInformation()
888
+ .setFunctionName('maskEnabled');
889
+
890
+ aut
891
+ .addScopedAction(
892
+ 'EnableMask',
893
+ _('Enable mask'),
894
+ _(
895
+ 'Enable or disable a mask for an object. Two objects collide if any layer of the first object matches any mask of the second one and vice versa.'
896
+ ),
897
+ _('Enable mask _PARAM2_ for _PARAM0_: _PARAM3_'),
898
+ _('Filtering'),
899
+ 'JsPlatform/Extensions/physics3d.svg',
900
+ 'JsPlatform/Extensions/physics3d.svg'
901
+ )
902
+ .addParameter('object', _('Object'), '', false)
903
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
904
+ .addParameter('expression', _('Mask (1 - 8)'))
905
+ .addParameter('yesorno', _('Enable?'), '', false)
906
+ .setDefaultValue('true')
907
+ .getCodeExtraInformation()
908
+ .setFunctionName('enableMask');
909
+
910
+ // Velocity
911
+ aut
912
+ .addExpressionAndConditionAndAction(
913
+ 'number',
914
+ 'LinearVelocityX',
915
+ _('Linear velocity X'),
916
+ _('the object linear velocity on X.'),
917
+ _('the linear velocity on X'),
918
+ _('Velocity'),
919
+ 'JsPlatform/Extensions/physics3d.svg'
920
+ )
921
+ .addParameter('object', _('Object'), '', false)
922
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
923
+ .useStandardParameters(
924
+ 'number',
925
+ gd.ParameterOptions.makeNewOptions().setDescription(
926
+ _('Speed (in pixels per second)')
927
+ )
928
+ )
929
+ .setFunctionName('setLinearVelocityX')
930
+ .setGetter('getLinearVelocityX');
931
+
932
+ aut
933
+ .addExpressionAndConditionAndAction(
934
+ 'number',
935
+ 'LinearVelocityY',
936
+ _('Linear velocity Y'),
937
+ _('the object linear velocity on Y.'),
938
+ _('the linear velocity on Y'),
939
+ _('Velocity'),
940
+ 'JsPlatform/Extensions/physics3d.svg'
941
+ )
942
+ .addParameter('object', _('Object'), '', false)
943
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
944
+ .useStandardParameters(
945
+ 'number',
946
+ gd.ParameterOptions.makeNewOptions().setDescription(
947
+ _('Speed (in pixels per second)')
948
+ )
949
+ )
950
+ .setFunctionName('setLinearVelocityY')
951
+ .setGetter('getLinearVelocityY');
952
+
953
+ aut
954
+ .addExpressionAndConditionAndAction(
955
+ 'number',
956
+ 'LinearVelocityZ',
957
+ _('Linear velocity Z'),
958
+ _('the object linear velocity on Z.'),
959
+ _('the linear velocity on Z'),
960
+ _('Velocity'),
961
+ 'JsPlatform/Extensions/physics3d.svg'
962
+ )
963
+ .addParameter('object', _('Object'), '', false)
964
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
965
+ .useStandardParameters(
966
+ 'number',
967
+ gd.ParameterOptions.makeNewOptions().setDescription(
968
+ _('Speed (in pixels per second)')
969
+ )
970
+ )
971
+ .setFunctionName('setLinearVelocityZ')
972
+ .setGetter('getLinearVelocityZ');
973
+
974
+ aut
975
+ .addExpressionAndCondition(
976
+ 'number',
977
+ 'LinearVelocityLength',
978
+ _('Linear velocity'),
979
+ _('the object linear velocity length.'),
980
+ _('the linear velocity length'),
981
+ _('Velocity'),
982
+ 'JsPlatform/Extensions/physics3d.svg'
983
+ )
984
+ .addParameter('object', _('Object'), '', false)
985
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
986
+ .useStandardParameters(
987
+ 'number',
988
+ gd.ParameterOptions.makeNewOptions().setDescription(
989
+ _('Speed to compare to (in pixels per second)')
990
+ )
991
+ )
992
+ .setFunctionName('getLinearVelocityLength');
993
+
994
+ aut
995
+ .addExpressionAndConditionAndAction(
996
+ 'number',
997
+ 'AngularVelocityX',
998
+ _('Angular velocity X'),
999
+ _('the object angular velocity on X.'),
1000
+ _('the angular velocity on X'),
1001
+ _('Velocity'),
1002
+ 'JsPlatform/Extensions/physics3d.svg'
1003
+ )
1004
+ .addParameter('object', _('Object'), '', false)
1005
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1006
+ .useStandardParameters(
1007
+ 'number',
1008
+ gd.ParameterOptions.makeNewOptions().setDescription(
1009
+ _('Angular speed (in degrees per second)')
1010
+ )
1011
+ )
1012
+ .setFunctionName('setAngularVelocityX')
1013
+ .setGetter('getAngularVelocityX');
1014
+
1015
+ aut
1016
+ .addExpressionAndConditionAndAction(
1017
+ 'number',
1018
+ 'AngularVelocityY',
1019
+ _('Angular velocity Y'),
1020
+ _('the object angular velocity on Y.'),
1021
+ _('the angular velocity on Y'),
1022
+ _('Velocity'),
1023
+ 'JsPlatform/Extensions/physics3d.svg'
1024
+ )
1025
+ .addParameter('object', _('Object'), '', false)
1026
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1027
+ .useStandardParameters(
1028
+ 'number',
1029
+ gd.ParameterOptions.makeNewOptions().setDescription(
1030
+ _('Angular speed (in degrees per second)')
1031
+ )
1032
+ )
1033
+ .setFunctionName('setAngularVelocityY')
1034
+ .setGetter('getAngularVelocityY');
1035
+
1036
+ aut
1037
+ .addExpressionAndConditionAndAction(
1038
+ 'number',
1039
+ 'AngularVelocityZ',
1040
+ _('Angular velocity Z'),
1041
+ _('the object angular velocity on Z.'),
1042
+ _('the angular velocity on Z'),
1043
+ _('Velocity'),
1044
+ 'JsPlatform/Extensions/physics3d.svg'
1045
+ )
1046
+ .addParameter('object', _('Object'), '', false)
1047
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1048
+ .useStandardParameters(
1049
+ 'number',
1050
+ gd.ParameterOptions.makeNewOptions().setDescription(
1051
+ _('Angular speed (in degrees per second)')
1052
+ )
1053
+ )
1054
+ .setFunctionName('setAngularVelocityZ')
1055
+ .setGetter('getAngularVelocityZ');
1056
+
1057
+ // Forces and impulses
1058
+ aut
1059
+ .addScopedAction(
1060
+ 'ApplyForce',
1061
+ _('Apply force (at a point)'),
1062
+ _(
1063
+ 'Apply a force to the object over time. It "accelerates" an object and must be used every frame during a time period.'
1064
+ ),
1065
+ _(
1066
+ 'Apply a force of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ at _PARAM5_ ; _PARAM6_ ; _PARAM7_'
1067
+ ),
1068
+ _('Forces & impulses'),
1069
+ 'JsPlatform/Extensions/physics3d.svg',
1070
+ 'JsPlatform/Extensions/physics3d.svg'
1071
+ )
1072
+ .addParameter('object', _('Object'), '', false)
1073
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1074
+ .addParameter('expression', _('X component (N)'))
1075
+ .addParameter('expression', _('Y component (N)'))
1076
+ .addParameter('expression', _('Z component (N)'))
1077
+ .setParameterLongDescription(
1078
+ _('A force is like an acceleration but depends on the mass.')
1079
+ )
1080
+ .addParameter('expression', _('Application point on X axis'))
1081
+ .addParameter('expression', _('Application point on Y axis'))
1082
+ .addParameter('expression', _('Application point on Z axis'))
1083
+ .setParameterLongDescription(
1084
+ _(
1085
+ 'Use `MassCenterX` and `MassCenterY` expressions to avoid any rotation.'
1086
+ )
1087
+ )
1088
+ .getCodeExtraInformation()
1089
+ .setFunctionName('applyForce');
1090
+
1091
+ aut
1092
+ .addScopedAction(
1093
+ 'ApplyForceAtCenter',
1094
+ _('Apply force (at center)'),
1095
+ _(
1096
+ 'Apply a force to the object over time. It "accelerates" an object and must be used every frame during a time period.'
1097
+ ),
1098
+ _(
1099
+ 'Apply a force of _PARAM2_ ; _PARAM3_ ; _PARAM4_ at the center of _PARAM0_'
1100
+ ),
1101
+ _('Forces & impulses'),
1102
+ 'JsPlatform/Extensions/physics3d.svg',
1103
+ 'JsPlatform/Extensions/physics3d.svg'
1104
+ )
1105
+ .addParameter('object', _('Object'), '', false)
1106
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1107
+ .addParameter('expression', _('X component (N)'))
1108
+ .addParameter('expression', _('Y component (N)'))
1109
+ .addParameter('expression', _('Z component (N)'))
1110
+ .setParameterLongDescription(
1111
+ _('A force is like an acceleration but depends on the mass.')
1112
+ )
1113
+ .getCodeExtraInformation()
1114
+ .setFunctionName('applyForceAtCenter');
1115
+
1116
+ aut
1117
+ .addScopedAction(
1118
+ 'ApplyForceTowardPosition',
1119
+ _('Apply force toward position'),
1120
+ _(
1121
+ 'Apply a force to the object over time to move it toward a position. It "accelerates" an object and must be used every frame during a time period.'
1122
+ ),
1123
+ _(
1124
+ 'Apply to _PARAM0_ a force of length _PARAM2_ towards _PARAM3_ ; _PARAM4_ ; _PARAM5_'
1125
+ ),
1126
+ _('Forces & impulses'),
1127
+ 'JsPlatform/Extensions/physics3d.svg',
1128
+ 'JsPlatform/Extensions/physics3d.svg'
1129
+ )
1130
+ .addParameter('object', _('Object'), '', false)
1131
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1132
+ .addParameter('expression', _('Length (N)'))
1133
+ .setParameterLongDescription(
1134
+ _('A force is like an acceleration but depends on the mass.')
1135
+ )
1136
+ .addParameter('expression', _('X position'))
1137
+ .addParameter('expression', _('Y position'))
1138
+ .addParameter('expression', _('Z position'))
1139
+ .getCodeExtraInformation()
1140
+ .setFunctionName('applyForceTowardPosition');
1141
+
1142
+ aut
1143
+ .addScopedAction(
1144
+ 'ApplyImpulse',
1145
+ _('Apply impulse (at a point)'),
1146
+ _(
1147
+ 'Apply an impulse to the object. It instantly changes the speed, to give an initial speed for instance.'
1148
+ ),
1149
+ _(
1150
+ 'Apply an impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ at _PARAM5_ ; _PARAM6_ ; _PARAM7_'
1151
+ ),
1152
+ _('Forces & impulses'),
1153
+ 'JsPlatform/Extensions/physics3d.svg',
1154
+ 'JsPlatform/Extensions/physics3d.svg'
1155
+ )
1156
+ .addParameter('object', _('Object'), '', false)
1157
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1158
+ .addParameter('expression', _('X component (N·s or kg·m·s⁻¹)'))
1159
+ .addParameter('expression', _('Y component (N·s or kg·m·s⁻¹)'))
1160
+ .addParameter('expression', _('Z component (N·s or kg·m·s⁻¹)'))
1161
+ .setParameterLongDescription(
1162
+ _('An impulse is like a speed addition but depends on the mass.')
1163
+ )
1164
+ .addParameter('expression', _('Application point on X axis'))
1165
+ .addParameter('expression', _('Application point on Y axis'))
1166
+ .addParameter('expression', _('Application point on Z axis'))
1167
+ .setParameterLongDescription(
1168
+ _(
1169
+ 'Use `MassCenterX`, `MassCenterY` and `MassCenterZ` expressions to avoid any rotation.'
1170
+ )
1171
+ )
1172
+ .getCodeExtraInformation()
1173
+ .setFunctionName('applyImpulse');
1174
+
1175
+ aut
1176
+ .addScopedAction(
1177
+ 'ApplyImpulseAtCenter',
1178
+ _('Apply impulse (at center)'),
1179
+ _(
1180
+ 'Apply an impulse to the object. It instantly changes the speed, to give an initial speed for instance.'
1181
+ ),
1182
+ _(
1183
+ 'Apply an impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ at the center of _PARAM0_'
1184
+ ),
1185
+ _('Forces & impulses'),
1186
+ 'JsPlatform/Extensions/physics3d.svg',
1187
+ 'JsPlatform/Extensions/physics3d.svg'
1188
+ )
1189
+ .addParameter('object', _('Object'), '', false)
1190
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1191
+ .addParameter('expression', _('X component (N·s or kg·m·s⁻¹)'))
1192
+ .addParameter('expression', _('Y component (N·s or kg·m·s⁻¹)'))
1193
+ .addParameter('expression', _('Z component (N·s or kg·m·s⁻¹)'))
1194
+ .setParameterLongDescription(
1195
+ _('An impulse is like a speed addition but depends on the mass.')
1196
+ )
1197
+ .getCodeExtraInformation()
1198
+ .setFunctionName('applyImpulseAtCenter');
1199
+
1200
+ aut
1201
+ .addScopedAction(
1202
+ 'ApplyImpulseTowardPosition',
1203
+ _('Apply impulse toward position'),
1204
+ _(
1205
+ 'Apply an impulse to the object to move it toward a position. It instantly changes the speed, to give an initial speed for instance.'
1206
+ ),
1207
+ _(
1208
+ 'Apply to _PARAM0_ an impulse of length _PARAM2_ towards _PARAM3_ ; _PARAM4_ ; _PARAM5_'
1209
+ ),
1210
+ _('Forces & impulses'),
1211
+ 'JsPlatform/Extensions/physics3d.svg',
1212
+ 'JsPlatform/Extensions/physics3d.svg'
1213
+ )
1214
+ .addParameter('object', _('Object'), '', false)
1215
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1216
+ .addParameter('expression', _('Length (N·s or kg·m·s⁻¹)'))
1217
+ .setParameterLongDescription(
1218
+ _('An impulse is like a speed addition but depends on the mass.')
1219
+ )
1220
+ .addParameter('expression', _('X position'))
1221
+ .addParameter('expression', _('Y position'))
1222
+ .addParameter('expression', _('Z position'))
1223
+ .getCodeExtraInformation()
1224
+ .setFunctionName('applyImpulseTowardPosition');
1225
+
1226
+ aut
1227
+ .addScopedAction(
1228
+ 'ApplyTorque',
1229
+ _('Apply torque (rotational force)'),
1230
+ _(
1231
+ 'Apply a torque (also called "rotational force") to the object. It "accelerates" an object rotation and must be used every frame during a time period.'
1232
+ ),
1233
+ _('Apply a torque of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ an'),
1234
+ _('Forces & impulses'),
1235
+ 'JsPlatform/Extensions/physics3d.svg',
1236
+ 'JsPlatform/Extensions/physics3d.svg'
1237
+ )
1238
+ .addParameter('object', _('Object'), '', false)
1239
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1240
+ .addParameter('expression', _('Torque around X (N·m)'))
1241
+ .addParameter('expression', _('Torque around Y (N·m)'))
1242
+ .addParameter('expression', _('Torque around Z (N·m)'))
1243
+ .setParameterLongDescription(
1244
+ _('A torque is like a rotation acceleration but depends on the mass.')
1245
+ )
1246
+ .getCodeExtraInformation()
1247
+ .setFunctionName('applyTorque');
1248
+
1249
+ aut
1250
+ .addScopedAction(
1251
+ 'ApplyAngularImpulse',
1252
+ _('Apply angular impulse (rotational impulse)'),
1253
+ _(
1254
+ 'Apply an angular impulse (also called a "rotational impulse") to the object. It instantly changes the rotation speed, to give an initial speed for instance.'
1255
+ ),
1256
+ _(
1257
+ 'Apply angular impulse of _PARAM2_ ; _PARAM3_ ; _PARAM4_ to _PARAM0_ an'
1258
+ ),
1259
+ _('Forces & impulses'),
1260
+ 'JsPlatform/Extensions/physics3d.svg',
1261
+ 'JsPlatform/Extensions/physics3d.svg'
1262
+ )
1263
+ .addParameter('object', _('Object'), '', false)
1264
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1265
+ .addParameter('expression', _('Angular impulse around X (N·m·s)'))
1266
+ .addParameter('expression', _('Angular impulse around Y (N·m·s)'))
1267
+ .addParameter('expression', _('Angular impulse around Z (N·m·s)'))
1268
+ .setParameterLongDescription(
1269
+ _(
1270
+ 'An impulse is like a rotation speed addition but depends on the mass.'
1271
+ )
1272
+ )
1273
+ .getCodeExtraInformation()
1274
+ .setFunctionName('applyAngularImpulse');
1275
+
1276
+ aut
1277
+ .addExpression(
1278
+ 'Mass',
1279
+ _('Mass'),
1280
+ _('Return the mass of the object (in kilograms)'),
1281
+ '',
1282
+ 'JsPlatform/Extensions/physics3d.svg'
1283
+ )
1284
+ .addParameter('object', _('Object'), '', false)
1285
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1286
+ .getCodeExtraInformation()
1287
+ .setFunctionName('getMass');
1288
+
1289
+ aut
1290
+ .addExpression(
1291
+ 'InertiaAroundX',
1292
+ _('Inertia around X'),
1293
+ _(
1294
+ 'Return the inertia around X axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
1295
+ ),
1296
+ '',
1297
+ 'JsPlatform/Extensions/physics3d.svg'
1298
+ )
1299
+ .addParameter('object', _('Object'), '', false)
1300
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1301
+ .getCodeExtraInformation()
1302
+ .setFunctionName('getInertiaAroundX');
1303
+
1304
+ aut
1305
+ .addExpression(
1306
+ 'InertiaAroundY',
1307
+ _('Inertia around Y'),
1308
+ _(
1309
+ 'Return the inertia around Y axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
1310
+ ),
1311
+ '',
1312
+ 'JsPlatform/Extensions/physics3d.svg'
1313
+ )
1314
+ .addParameter('object', _('Object'), '', false)
1315
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1316
+ .getCodeExtraInformation()
1317
+ .setFunctionName('getInertiaAroundY');
1318
+
1319
+ aut
1320
+ .addExpression(
1321
+ 'InertiaAroundZ',
1322
+ _('Inertia around Z'),
1323
+ _(
1324
+ 'Return the inertia around Z axis of the object (in kilograms · meters²) when for its default rotation is (0°; 0°; 0°)'
1325
+ ),
1326
+ '',
1327
+ 'JsPlatform/Extensions/physics3d.svg'
1328
+ )
1329
+ .addParameter('object', _('Object'), '', false)
1330
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1331
+ .getCodeExtraInformation()
1332
+ .setFunctionName('getInertiaAroundZ');
1333
+
1334
+ aut
1335
+ .addExpression(
1336
+ 'MassCenterX',
1337
+ _('Mass center X'),
1338
+ _('Mass center X'),
1339
+ '',
1340
+ 'JsPlatform/Extensions/physics3d.svg'
1341
+ )
1342
+ .addParameter('object', _('Object'), '', false)
1343
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1344
+ .getCodeExtraInformation()
1345
+ .setFunctionName('getMassCenterX');
1346
+
1347
+ aut
1348
+ .addExpression(
1349
+ 'MassCenterY',
1350
+ _('Mass center Y'),
1351
+ _('Mass center Y'),
1352
+ '',
1353
+ 'JsPlatform/Extensions/physics3d.svg'
1354
+ )
1355
+ .addParameter('object', _('Object'), '', false)
1356
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1357
+ .getCodeExtraInformation()
1358
+ .setFunctionName('getMassCenterY');
1359
+ }
1360
+ // Collision
1361
+ extension
1362
+ .addCondition(
1363
+ 'Collision',
1364
+ _('Collision'),
1365
+ _('Check if two objects collide.'),
1366
+ _('_PARAM0_ is colliding with _PARAM2_'),
1367
+ '',
1368
+ 'JsPlatform/Extensions/physics3d.svg',
1369
+ 'JsPlatform/Extensions/physics3d.svg'
1370
+ )
1371
+ .addParameter('objectList', _('Object'), '', false)
1372
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1373
+ .addParameter('objectList', _('Object'), '', false)
1374
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1375
+ .addCodeOnlyParameter('conditionInverted', '')
1376
+ .getCodeExtraInformation()
1377
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
1378
+ .addIncludeFile(
1379
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
1380
+ )
1381
+ .setFunctionName('gdjs.physics3d.areObjectsColliding');
1382
+
1383
+ extension
1384
+ .addCondition(
1385
+ 'CollisionStarted',
1386
+ _('Collision started'),
1387
+ _('Check if two objects just started colliding during this frame.'),
1388
+ _('_PARAM0_ started colliding with _PARAM2_'),
1389
+ _('Collision'),
1390
+ 'JsPlatform/Extensions/physics3d.svg',
1391
+ 'JsPlatform/Extensions/physics3d.svg'
1392
+ )
1393
+ .addParameter('objectList', _('Object'), '', false)
1394
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1395
+ .addParameter('objectList', _('Object'), '', false)
1396
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1397
+ .addCodeOnlyParameter('conditionInverted', '')
1398
+ .getCodeExtraInformation()
1399
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
1400
+ .addIncludeFile(
1401
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
1402
+ )
1403
+ .setFunctionName('gdjs.physics3d.haveObjectsStartedColliding');
1404
+
1405
+ extension
1406
+ .addCondition(
1407
+ 'CollisionStopped',
1408
+ _('Collision stopped'),
1409
+ _('Check if two objects just stopped colliding at this frame.'),
1410
+ _('_PARAM0_ stopped colliding with _PARAM2_'),
1411
+ _('Collision'),
1412
+ 'JsPlatform/Extensions/physics3d.svg',
1413
+ 'JsPlatform/Extensions/physics3d.svg'
1414
+ )
1415
+ .addParameter('objectList', _('Object'), '', false)
1416
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1417
+ .addParameter('objectList', _('Object'), '', false)
1418
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
1419
+ .addCodeOnlyParameter('conditionInverted', '')
1420
+ .getCodeExtraInformation()
1421
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js')
1422
+ .addIncludeFile(
1423
+ 'Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js'
1424
+ )
1425
+ .setFunctionName('gdjs.physics3d.haveObjectsStoppedColliding');
1426
+
1427
+ {
1428
+ const behavior = new gd.BehaviorJsImplementation();
1429
+ behavior.updateProperty = function (
1430
+ behaviorContent,
1431
+ propertyName,
1432
+ newValue
1433
+ ) {
1434
+ if (propertyName === 'physics3D') {
1435
+ behaviorContent.getChild('physics3D').setStringValue(newValue);
1436
+ return true;
1437
+ }
1438
+
1439
+ if (propertyName === 'jumpHeight') {
1440
+ const newValueAsNumber = parseFloat(newValue);
1441
+ if (newValueAsNumber !== newValueAsNumber) return false;
1442
+ behaviorContent
1443
+ .getChild('jumpHeight')
1444
+ .setDoubleValue(newValueAsNumber);
1445
+ return true;
1446
+ }
1447
+
1448
+ if (propertyName === 'jumpSustainTime') {
1449
+ const newValueAsNumber = parseFloat(newValue);
1450
+ if (newValueAsNumber !== newValueAsNumber) return false;
1451
+ behaviorContent
1452
+ .getChild('jumpSustainTime')
1453
+ .setDoubleValue(newValueAsNumber);
1454
+ return true;
1455
+ }
1456
+
1457
+ if (propertyName === 'gravity') {
1458
+ const newValueAsNumber = parseFloat(newValue);
1459
+ if (newValueAsNumber !== newValueAsNumber) return false;
1460
+ behaviorContent.getChild('gravity').setDoubleValue(newValueAsNumber);
1461
+ return true;
1462
+ }
1463
+
1464
+ if (propertyName === 'fallingSpeedMax') {
1465
+ const newValueAsNumber = parseFloat(newValue);
1466
+ if (newValueAsNumber !== newValueAsNumber) return false;
1467
+ behaviorContent
1468
+ .getChild('fallingSpeedMax')
1469
+ .setDoubleValue(newValueAsNumber);
1470
+ return true;
1471
+ }
1472
+
1473
+ if (propertyName === 'forwardAcceleration') {
1474
+ const newValueAsNumber = parseFloat(newValue);
1475
+ if (newValueAsNumber !== newValueAsNumber) return false;
1476
+ behaviorContent
1477
+ .getChild('forwardAcceleration')
1478
+ .setDoubleValue(newValueAsNumber);
1479
+ return true;
1480
+ }
1481
+
1482
+ if (propertyName === 'forwardDeceleration') {
1483
+ const newValueAsNumber = parseFloat(newValue);
1484
+ if (newValueAsNumber !== newValueAsNumber) return false;
1485
+ behaviorContent
1486
+ .getChild('forwardDeceleration')
1487
+ .setDoubleValue(newValueAsNumber);
1488
+ return true;
1489
+ }
1490
+
1491
+ if (propertyName === 'forwardSpeedMax') {
1492
+ const newValueAsNumber = parseFloat(newValue);
1493
+ if (newValueAsNumber !== newValueAsNumber) return false;
1494
+ behaviorContent
1495
+ .getChild('forwardSpeedMax')
1496
+ .setDoubleValue(newValueAsNumber);
1497
+ return true;
1498
+ }
1499
+
1500
+ if (propertyName === 'sidewaysAcceleration') {
1501
+ const newValueAsNumber = parseFloat(newValue);
1502
+ if (newValueAsNumber !== newValueAsNumber) return false;
1503
+ behaviorContent
1504
+ .getChild('sidewaysAcceleration')
1505
+ .setDoubleValue(newValueAsNumber);
1506
+ return true;
1507
+ }
1508
+
1509
+ if (propertyName === 'sidewaysDeceleration') {
1510
+ const newValueAsNumber = parseFloat(newValue);
1511
+ if (newValueAsNumber !== newValueAsNumber) return false;
1512
+ behaviorContent
1513
+ .getChild('sidewaysDeceleration')
1514
+ .setDoubleValue(newValueAsNumber);
1515
+ return true;
1516
+ }
1517
+
1518
+ if (propertyName === 'sidewaysSpeedMax') {
1519
+ const newValueAsNumber = parseFloat(newValue);
1520
+ if (newValueAsNumber !== newValueAsNumber) return false;
1521
+ behaviorContent
1522
+ .getChild('sidewaysSpeedMax')
1523
+ .setDoubleValue(newValueAsNumber);
1524
+ return true;
1525
+ }
1526
+
1527
+ if (propertyName === 'slopeMaxAngle') {
1528
+ const newValueAsNumber = parseFloat(newValue);
1529
+ if (newValueAsNumber !== newValueAsNumber) return false;
1530
+ behaviorContent
1531
+ .getChild('slopeMaxAngle')
1532
+ .setDoubleValue(newValueAsNumber);
1533
+ return true;
1534
+ }
1535
+
1536
+ if (propertyName === 'shouldBindObjectAndForwardAngle') {
1537
+ behaviorContent
1538
+ .getChild('shouldBindObjectAndForwardAngle')
1539
+ .setBoolValue(newValue === '1');
1540
+ return true;
1541
+ }
1542
+
1543
+ return false;
1544
+ };
1545
+ behavior.getProperties = function (behaviorContent) {
1546
+ const behaviorProperties = new gd.MapStringPropertyDescriptor();
1547
+
1548
+ behaviorProperties
1549
+ .getOrCreate('physics3D')
1550
+ .setValue(behaviorContent.getChild('physics3D').getStringValue())
1551
+ .setType('Behavior')
1552
+ .setLabel('3D capability')
1553
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
1554
+ .addExtraInfo('Physics3D::Physics3DBehavior');
1555
+
1556
+ behaviorProperties
1557
+ .getOrCreate('jumpHeight')
1558
+ .setLabel(_('Jump height'))
1559
+ .setGroup(_('Jump'))
1560
+ .setType('Number')
1561
+ .setMeasurementUnit(gd.MeasurementUnit.getPixel())
1562
+ .setValue(
1563
+ behaviorContent.getChild('jumpHeight').getDoubleValue().toString(10)
1564
+ );
1565
+
1566
+ behaviorProperties
1567
+ .getOrCreate('jumpSustainTime')
1568
+ .setLabel(_('Jump sustain time'))
1569
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden)
1570
+ .setGroup(_('Jump'))
1571
+ .setType('Number')
1572
+ .setMeasurementUnit(gd.MeasurementUnit.getSecond())
1573
+ .setValue(
1574
+ behaviorContent
1575
+ .getChild('jumpSustainTime')
1576
+ .getDoubleValue()
1577
+ .toString(10)
1578
+ )
1579
+ .setDescription(
1580
+ _(
1581
+ 'Maximum time (in seconds) during which the jump strength is sustained if the jump key is held - allowing variable height jumps.'
1582
+ )
1583
+ );
1584
+
1585
+ behaviorProperties
1586
+ .getOrCreate('gravity')
1587
+ .setLabel(_('Gravity'))
1588
+ .setGroup(_('Jump'))
1589
+ .setType('Number')
1590
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
1591
+ .setValue(
1592
+ behaviorContent.getChild('gravity').getDoubleValue().toString(10)
1593
+ );
1594
+
1595
+ behaviorProperties
1596
+ .getOrCreate('fallingSpeedMax')
1597
+ .setLabel(_('Max. falling speed'))
1598
+ .setGroup(_('Jump'))
1599
+ .setType('Number')
1600
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
1601
+ .setValue(
1602
+ behaviorContent
1603
+ .getChild('fallingSpeedMax')
1604
+ .getDoubleValue()
1605
+ .toString(10)
1606
+ );
1607
+
1608
+ behaviorProperties
1609
+ .getOrCreate('forwardAcceleration')
1610
+ .setLabel(_('Forward acceleration'))
1611
+ .setGroup(_('Walk'))
1612
+ .setType('Number')
1613
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
1614
+ .setValue(
1615
+ behaviorContent
1616
+ .getChild('forwardAcceleration')
1617
+ .getDoubleValue()
1618
+ .toString(10)
1619
+ );
1620
+
1621
+ behaviorProperties
1622
+ .getOrCreate('forwardDeceleration')
1623
+ .setLabel(_('Forward deceleration'))
1624
+ .setGroup(_('Walk'))
1625
+ .setType('Number')
1626
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
1627
+ .setValue(
1628
+ behaviorContent
1629
+ .getChild('forwardDeceleration')
1630
+ .getDoubleValue()
1631
+ .toString(10)
1632
+ );
1633
+
1634
+ behaviorProperties
1635
+ .getOrCreate('forwardSpeedMax')
1636
+ .setLabel(_('Max. forward speed'))
1637
+ .setGroup(_('Walk'))
1638
+ .setType('Number')
1639
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
1640
+ .setValue(
1641
+ behaviorContent
1642
+ .getChild('forwardSpeedMax')
1643
+ .getDoubleValue()
1644
+ .toString(10)
1645
+ );
1646
+
1647
+ behaviorProperties
1648
+ .getOrCreate('sidewaysAcceleration')
1649
+ .setLabel(_('Sideways acceleration'))
1650
+ .setGroup(_('Walk'))
1651
+ .setType('Number')
1652
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
1653
+ .setValue(
1654
+ behaviorContent
1655
+ .getChild('sidewaysAcceleration')
1656
+ .getDoubleValue()
1657
+ .toString(10)
1658
+ )
1659
+ .setAdvanced(true);
1660
+
1661
+ behaviorProperties
1662
+ .getOrCreate('sidewaysDeceleration')
1663
+ .setLabel(_('Sideways deceleration'))
1664
+ .setGroup(_('Walk'))
1665
+ .setType('Number')
1666
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelAcceleration())
1667
+ .setValue(
1668
+ behaviorContent
1669
+ .getChild('sidewaysDeceleration')
1670
+ .getDoubleValue()
1671
+ .toString(10)
1672
+ )
1673
+ .setAdvanced(true);
1674
+
1675
+ behaviorProperties
1676
+ .getOrCreate('sidewaysSpeedMax')
1677
+ .setLabel(_('Max. sideways speed'))
1678
+ .setGroup(_('Walk'))
1679
+ .setType('Number')
1680
+ .setMeasurementUnit(gd.MeasurementUnit.getPixelSpeed())
1681
+ .setValue(
1682
+ behaviorContent
1683
+ .getChild('sidewaysSpeedMax')
1684
+ .getDoubleValue()
1685
+ .toString(10)
1686
+ )
1687
+ .setAdvanced(true);
1688
+
1689
+ behaviorProperties
1690
+ .getOrCreate('slopeMaxAngle')
1691
+ .setLabel('Slope max. angle')
1692
+ .setGroup(_('Walk'))
1693
+ .setType('Number')
1694
+ .setMeasurementUnit(gd.MeasurementUnit.getDegreeAngle())
1695
+ .setValue(
1696
+ behaviorContent
1697
+ .getChild('slopeMaxAngle')
1698
+ .getDoubleValue()
1699
+ .toString(10)
1700
+ )
1701
+ .setAdvanced(true)
1702
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden);
1703
+
1704
+ behaviorProperties
1705
+ .getOrCreate('shouldBindObjectAndForwardAngle')
1706
+ .setLabel('Keep object angle and forward direction the same')
1707
+ .setGroup(_('Walk'))
1708
+ .setType('Boolean')
1709
+ .setValue(
1710
+ behaviorContent
1711
+ .getChild('shouldBindObjectAndForwardAngle')
1712
+ .getBoolValue()
1713
+ ? 'true'
1714
+ : 'false'
1715
+ )
1716
+ .setAdvanced(true)
1717
+ .setQuickCustomizationVisibility(gd.QuickCustomization.Hidden);
1718
+
1719
+ return behaviorProperties;
1720
+ };
1721
+
1722
+ behavior.initializeContent = function (behaviorContent) {
1723
+ behaviorContent.addChild('physics3D').setStringValue('');
1724
+ behaviorContent.addChild('jumpHeight').setDoubleValue(200);
1725
+ behaviorContent.addChild('jumpSustainTime').setDoubleValue(0.2);
1726
+ behaviorContent.addChild('gravity').setDoubleValue(1000);
1727
+ behaviorContent.addChild('fallingSpeedMax').setDoubleValue(700);
1728
+ behaviorContent.addChild('forwardAcceleration').setDoubleValue(1200);
1729
+ behaviorContent.addChild('forwardDeceleration').setDoubleValue(1200);
1730
+ behaviorContent.addChild('forwardSpeedMax').setDoubleValue(600);
1731
+ behaviorContent.addChild('sidewaysAcceleration').setDoubleValue(800);
1732
+ behaviorContent.addChild('sidewaysDeceleration').setDoubleValue(800);
1733
+ behaviorContent.addChild('sidewaysSpeedMax').setDoubleValue(400);
1734
+ behaviorContent.addChild('slopeMaxAngle').setDoubleValue(50);
1735
+ behaviorContent
1736
+ .addChild('shouldBindObjectAndForwardAngle')
1737
+ .setBoolValue(true);
1738
+ };
1739
+
1740
+ const aut = extension
1741
+ .addBehavior(
1742
+ 'PhysicsCharacter3D',
1743
+ _('3D physics character'),
1744
+ 'PhysicsCharacter3D',
1745
+ _('Jump and run on platforms.'),
1746
+ '',
1747
+ 'JsPlatform/Extensions/physics_character3d.svg',
1748
+ 'PhysicsCharacter3D',
1749
+ //@ts-ignore The class hierarchy is incorrect leading to a type error, but this is valid.
1750
+ behavior,
1751
+ new gd.BehaviorsSharedData()
1752
+ )
1753
+ .addIncludeFile(
1754
+ 'Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js'
1755
+ );
1756
+
1757
+ aut
1758
+ .addScopedAction(
1759
+ 'SimulateForwardKey',
1760
+ _('Simulate move forward key press'),
1761
+ _('Simulate a press of the move forward key.'),
1762
+ _('Simulate pressing Forward key for _PARAM0_'),
1763
+ _('Character controls'),
1764
+ 'JsPlatform/Extensions/physics_character3d.svg',
1765
+ 'JsPlatform/Extensions/physics_character3d.svg'
1766
+ )
1767
+ .addParameter('object', _('Object'), '', false)
1768
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1769
+ .setFunctionName('simulateForwardKey');
1770
+
1771
+ aut
1772
+ .addScopedAction(
1773
+ 'SimulateBackwardKey',
1774
+ _('Simulate move backward key press'),
1775
+ _('Simulate a press of the move backward key.'),
1776
+ _('Simulate pressing Backward key for _PARAM0_'),
1777
+ _('Character controls'),
1778
+ 'JsPlatform/Extensions/physics_character3d.svg',
1779
+ 'JsPlatform/Extensions/physics_character3d.svg'
1780
+ )
1781
+ .addParameter('object', _('Object'), '', false)
1782
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1783
+ .setFunctionName('simulateBackwardKey');
1784
+
1785
+ aut
1786
+ .addScopedAction(
1787
+ 'SimulateRightKey',
1788
+ _('Simulate move right key press'),
1789
+ _('Simulate a press of the move right key.'),
1790
+ _('Simulate pressing Right key for _PARAM0_'),
1791
+ _('Character controls'),
1792
+ 'JsPlatform/Extensions/physics_character3d.svg',
1793
+ 'JsPlatform/Extensions/physics_character3d.svg'
1794
+ )
1795
+ .addParameter('object', _('Object'), '', false)
1796
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1797
+ .setFunctionName('simulateRightKey');
1798
+
1799
+ aut
1800
+ .addScopedAction(
1801
+ 'SimulateLeftKey',
1802
+ _('Simulate move left key press'),
1803
+ _('Simulate a press of the move left key.'),
1804
+ _('Simulate pressing Left key for _PARAM0_'),
1805
+ _('Character controls'),
1806
+ 'JsPlatform/Extensions/physics_character3d.svg',
1807
+ 'JsPlatform/Extensions/physics_character3d.svg'
1808
+ )
1809
+ .addParameter('object', _('Object'), '', false)
1810
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1811
+ .setFunctionName('simulateLeftKey');
1812
+
1813
+ aut
1814
+ .addScopedAction(
1815
+ 'SimulateJumpKey',
1816
+ _('Simulate jump key press'),
1817
+ _('Simulate a press of the jump key.'),
1818
+ _('Simulate pressing Jump key for _PARAM0_'),
1819
+ _('Character controls'),
1820
+ 'JsPlatform/Extensions/physics_character3d.svg',
1821
+ 'JsPlatform/Extensions/physics_character3d.svg'
1822
+ )
1823
+ .addParameter('object', _('Object'), '', false)
1824
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1825
+ .setFunctionName('simulateJumpKey');
1826
+
1827
+ aut
1828
+ .addScopedAction(
1829
+ 'SimulateStick',
1830
+ _('Simulate stick control'),
1831
+ _('Simulate a stick control.'),
1832
+ _(
1833
+ 'Simulate a stick control for _PARAM0_ with a _PARAM2_ angle and a _PARAM3_ force'
1834
+ ),
1835
+ _('Character controls'),
1836
+ 'JsPlatform/Extensions/physics_character3d.svg',
1837
+ 'JsPlatform/Extensions/physics_character3d.svg'
1838
+ )
1839
+ .addParameter('object', _('Object'), '', false)
1840
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1841
+ .addParameter('expression', _('Stick angle (in degrees)'))
1842
+ .addParameter('expression', _('Stick force (between 0 and 1)'))
1843
+ .markAsAdvanced()
1844
+ .setFunctionName('simulateStick');
1845
+
1846
+ aut
1847
+ .addScopedAction(
1848
+ 'SetCanJump',
1849
+ _('Allow jumping again'),
1850
+ _(
1851
+ "When this action is executed, the object is able to jump again, even if it is in the air: this can be useful to allow a double jump for example. This is not a permanent effect: you must call again this action every time you want to allow the object to jump (apart if it's on the floor)."
1852
+ ),
1853
+ _('Allow _PARAM0_ to jump again'),
1854
+ _('Character state'),
1855
+ 'JsPlatform/Extensions/physics_character3d.svg',
1856
+ 'JsPlatform/Extensions/physics_character3d.svg'
1857
+ )
1858
+ .addParameter('object', _('Object'), '', false)
1859
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1860
+ .markAsSimple()
1861
+ .setFunctionName('setCanJump');
1862
+
1863
+ aut
1864
+ .addScopedAction(
1865
+ 'SetCanNotAirJump',
1866
+ _('Forbid jumping again in the air'),
1867
+ _(
1868
+ 'This revokes the effect of "Allow jumping again". The object is made unable to jump while in mid air. This has no effect if the object is not in the air.'
1869
+ ),
1870
+ _('Forbid _PARAM0_ to air jump'),
1871
+ _('Character state'),
1872
+ 'JsPlatform/Extensions/physics_character3d.svg',
1873
+ 'JsPlatform/Extensions/physics_character3d.svg'
1874
+ )
1875
+ .addParameter('object', _('Object'), '', false)
1876
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1877
+ .setFunctionName('setCanNotAirJump');
1878
+
1879
+ aut
1880
+ .addScopedAction(
1881
+ 'AbortJump',
1882
+ _('Abort jump'),
1883
+ _(
1884
+ "Abort the current jump and stop the object vertically. This action doesn't have any effect when the character is not jumping."
1885
+ ),
1886
+ _('Abort the current jump of _PARAM0_'),
1887
+ _('Character state'),
1888
+ 'JsPlatform/Extensions/physics_character3d.svg',
1889
+ 'JsPlatform/Extensions/physics_character3d.svg'
1890
+ )
1891
+ .addParameter('object', _('Object'), '', false)
1892
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1893
+ .setFunctionName('abortJump');
1894
+
1895
+ aut
1896
+ .addScopedCondition(
1897
+ 'CanJump',
1898
+ _('Can jump'),
1899
+ _('Check if the object can jump.'),
1900
+ _('_PARAM0_ can jump'),
1901
+ _('Character state'),
1902
+ 'JsPlatform/Extensions/physics_character3d.svg',
1903
+ 'JsPlatform/Extensions/physics_character3d.svg'
1904
+ )
1905
+ .addParameter('object', _('Object'), '', false)
1906
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1907
+ .markAsSimple()
1908
+ .setFunctionName('canJump');
1909
+
1910
+ aut
1911
+ .addScopedCondition(
1912
+ 'IsMovingEvenALittle',
1913
+ _('Is moving'),
1914
+ _(
1915
+ 'Check if the object is moving (whether it is on the floor or in the air).'
1916
+ ),
1917
+ _('_PARAM0_ is moving'),
1918
+ _('Character state'),
1919
+ 'JsPlatform/Extensions/physics_character3d.svg',
1920
+ 'JsPlatform/Extensions/physics_character3d.svg'
1921
+ )
1922
+ .addParameter('object', _('Object'), '', false)
1923
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1924
+ .markAsSimple()
1925
+ .setFunctionName('isMovingEvenALittle');
1926
+
1927
+ aut
1928
+ .addScopedCondition(
1929
+ 'IsOnFloor',
1930
+ _('Is on floor'),
1931
+ _('Check if the object is on a platform.'),
1932
+ _('_PARAM0_ is on floor'),
1933
+ _('Character state'),
1934
+ 'JsPlatform/Extensions/physics_character3d.svg',
1935
+ 'JsPlatform/Extensions/physics_character3d.svg'
1936
+ )
1937
+ .addParameter('object', _('Object'), '', false)
1938
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1939
+ .markAsSimple()
1940
+ .setFunctionName('isOnFloor');
1941
+
1942
+ aut
1943
+ .addScopedCondition(
1944
+ 'IsJumping',
1945
+ _('Is jumping'),
1946
+ _('Check if the object is jumping.'),
1947
+ _('_PARAM0_ is jumping'),
1948
+ _('Character state'),
1949
+ 'JsPlatform/Extensions/physics_character3d.svg',
1950
+ 'JsPlatform/Extensions/physics_character3d.svg'
1951
+ )
1952
+ .addParameter('object', _('Object'), '', false)
1953
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1954
+ .markAsSimple()
1955
+ .setFunctionName('isJumping');
1956
+
1957
+ aut
1958
+ .addScopedCondition(
1959
+ 'IsFalling',
1960
+ _('Is falling'),
1961
+ _(
1962
+ 'Check if the object is falling.\nNote that the object can be flagged as jumping and falling at the same time: at the end of a jump, the fall speed becomes higher than the jump speed.'
1963
+ ),
1964
+ _('_PARAM0_ is falling'),
1965
+ _('Character state'),
1966
+ 'JsPlatform/Extensions/physics_character3d.svg',
1967
+ 'JsPlatform/Extensions/physics_character3d.svg'
1968
+ )
1969
+ .addParameter('object', _('Object'), '', false)
1970
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1971
+ .setFunctionName('isFalling');
1972
+
1973
+ aut
1974
+ .addScopedCondition(
1975
+ 'ShouldBindObjectAndForwardAngle',
1976
+ _('Should bind object and forward angle'),
1977
+ _(
1978
+ 'Check if the object angle and forward angle should be kept the same.'
1979
+ ),
1980
+ _('Keep _PARAM0_ angle and forward angle the same'),
1981
+ _('Character configuration'),
1982
+ 'JsPlatform/Extensions/physics_character3d.svg',
1983
+ 'JsPlatform/Extensions/physics_character3d.svg'
1984
+ )
1985
+ .addParameter('object', _('Object'), '', false)
1986
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
1987
+ .getCodeExtraInformation()
1988
+ .setFunctionName('shouldBindObjectAndForwardAngle');
1989
+
1990
+ aut
1991
+ .addScopedAction(
1992
+ 'SetShouldBindObjectAndForwardAngle',
1993
+ _('Should bind object and forward angle'),
1994
+ _(
1995
+ 'Enable or disable keeping the object angle and forward angle the same.'
1996
+ ),
1997
+ _('Should bind _PARAM0_ angle and forward angle: _PARAM2_'),
1998
+ _('Character configuration'),
1999
+ 'JsPlatform/Extensions/physics_character3d.svg',
2000
+ 'JsPlatform/Extensions/physics_character3d.svg'
2001
+ )
2002
+ .addParameter('object', _('Object'), '', false)
2003
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2004
+ .addParameter(
2005
+ 'yesorno',
2006
+ _('Keep object angle and forward direction the same'),
2007
+ '',
2008
+ false
2009
+ )
2010
+ .setDefaultValue('false')
2011
+ .getCodeExtraInformation()
2012
+ .setFunctionName('setShouldBindObjectAndForwardAngle');
2013
+
2014
+ aut
2015
+ .addScopedCondition(
2016
+ 'IsForwardAngleAround',
2017
+ _('Forward angle'),
2018
+ _('Compare the angle used by the character to go forward.'),
2019
+ _('Forward angle of _PARAM0_ is _PARAM2_ ± _PARAM3_°'),
2020
+ _('Character state'),
2021
+ 'JsPlatform/Extensions/physics_character3d.svg',
2022
+ 'JsPlatform/Extensions/physics_character3d.svg'
2023
+ )
2024
+ .addParameter('object', _('Object'), '', false)
2025
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2026
+ .addParameter('expression', _('Angle (in degrees)'))
2027
+ .addParameter('expression', _('Tolerance (in degrees)'))
2028
+ .setFunctionName('isForwardAngleAround');
2029
+
2030
+ aut
2031
+ .addScopedAction(
2032
+ 'SetForwardAngle',
2033
+ _('Forward angle'),
2034
+ _('Change the angle used by the character to go forward.'),
2035
+ _('the forward angle'),
2036
+ _('Character state'),
2037
+ 'JsPlatform/Extensions/physics_character3d.svg',
2038
+ 'JsPlatform/Extensions/physics_character3d.svg'
2039
+ )
2040
+ .addParameter('object', _('Object'), '', false)
2041
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2042
+ .useStandardOperatorParameters(
2043
+ 'number',
2044
+ gd.ParameterOptions.makeNewOptions().setDescription(
2045
+ _('Angle (in degrees)')
2046
+ )
2047
+ )
2048
+ .setFunctionName('setForwardAngle')
2049
+ .setGetter('getForwardAngle');
2050
+
2051
+ aut
2052
+ .addExpression(
2053
+ 'ForwardAngle',
2054
+ _('Forward angle of the character'),
2055
+ _('Return the angle used by the character to go forward.'),
2056
+ _('Character state'),
2057
+ 'JsPlatform/Extensions/physics_character3d.svg'
2058
+ )
2059
+ .addParameter('object', _('Object'), '', false)
2060
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2061
+ .setFunctionName('getForwardAngle');
2062
+
2063
+ aut
2064
+ .addExpressionAndConditionAndAction(
2065
+ 'number',
2066
+ 'CurrentForwardSpeed',
2067
+ _('Current forward speed'),
2068
+ _(
2069
+ 'the current forward speed of the object. The object moves backward with negative values and forward with positive ones'
2070
+ ),
2071
+ _('the current forward speed'),
2072
+ _('Character state'),
2073
+ 'JsPlatform/Extensions/physics_character3d.svg'
2074
+ )
2075
+ .addParameter('object', _('Object'), '', false)
2076
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2077
+ .useStandardParameters(
2078
+ 'number',
2079
+ gd.ParameterOptions.makeNewOptions().setDescription(
2080
+ _('Speed (in pixels per second)')
2081
+ )
2082
+ )
2083
+ .setFunctionName('setCurrentForwardSpeed')
2084
+ .setGetter('getCurrentForwardSpeed');
2085
+
2086
+ aut
2087
+ .addExpressionAndConditionAndAction(
2088
+ 'number',
2089
+ 'ForwardAcceleration',
2090
+ _('Forward acceleration'),
2091
+ _('the forward acceleration of an object.'),
2092
+ _('the forward acceleration'),
2093
+ _('Character configuration'),
2094
+ 'JsPlatform/Extensions/physics_character3d.svg'
2095
+ )
2096
+ .addParameter('object', _('Object'), '', false)
2097
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2098
+ .useStandardParameters(
2099
+ 'number',
2100
+ gd.ParameterOptions.makeNewOptions().setDescription(
2101
+ _('Acceleration (in pixels per second per second)')
2102
+ )
2103
+ )
2104
+ .markAsAdvanced()
2105
+ .setFunctionName('setForwardAcceleration')
2106
+ .setGetter('getForwardAcceleration');
2107
+
2108
+ aut
2109
+ .addExpressionAndConditionAndAction(
2110
+ 'number',
2111
+ 'ForwardDeceleration',
2112
+ _('Forward deceleration'),
2113
+ _('the forward deceleration of an object.'),
2114
+ _('the forward deceleration'),
2115
+ _('Character configuration'),
2116
+ 'JsPlatform/Extensions/physics_character3d.svg'
2117
+ )
2118
+ .addParameter('object', _('Object'), '', false)
2119
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2120
+ .useStandardParameters(
2121
+ 'number',
2122
+ gd.ParameterOptions.makeNewOptions().setDescription(
2123
+ _('Deceleration (in pixels per second per second)')
2124
+ )
2125
+ )
2126
+ .markAsAdvanced()
2127
+ .setFunctionName('setForwardDeceleration')
2128
+ .setGetter('getForwardDeceleration');
2129
+
2130
+ aut
2131
+ .addExpressionAndConditionAndAction(
2132
+ 'number',
2133
+ 'ForwardSpeedMax',
2134
+ _('Forward max speed'),
2135
+ _('the forward max speed of the object.'),
2136
+ _('the forward max speed'),
2137
+ _('Character configuration'),
2138
+ 'JsPlatform/Extensions/physics_character3d.svg'
2139
+ )
2140
+ .addParameter('object', _('Object'), '', false)
2141
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2142
+ .useStandardParameters(
2143
+ 'number',
2144
+ gd.ParameterOptions.makeNewOptions().setDescription(
2145
+ _('Speed (in pixels per second)')
2146
+ )
2147
+ )
2148
+ .setFunctionName('setForwardSpeedMax')
2149
+ .setGetter('getForwardSpeedMax');
2150
+
2151
+ aut
2152
+ .addExpressionAndConditionAndAction(
2153
+ 'number',
2154
+ 'CurrentSidewaysSpeed',
2155
+ _('Current sideways speed'),
2156
+ _(
2157
+ 'the current sideways speed of the object. The object moves to the left with negative values and to the right with positive ones'
2158
+ ),
2159
+ _('the current sideways speed'),
2160
+ _('Character state'),
2161
+ 'JsPlatform/Extensions/physics_character3d.svg'
2162
+ )
2163
+ .addParameter('object', _('Object'), '', false)
2164
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2165
+ .useStandardParameters(
2166
+ 'number',
2167
+ gd.ParameterOptions.makeNewOptions().setDescription(
2168
+ _('Speed (in pixels per second)')
2169
+ )
2170
+ )
2171
+ .setFunctionName('setCurrentSidewaysSpeed')
2172
+ .setGetter('getCurrentSidewaysSpeed');
2173
+
2174
+ aut
2175
+ .addExpressionAndConditionAndAction(
2176
+ 'number',
2177
+ 'SidewaysAcceleration',
2178
+ _('Sideways acceleration'),
2179
+ _('the sideways acceleration of an object.'),
2180
+ _('the sideways acceleration'),
2181
+ _('Character configuration'),
2182
+ 'JsPlatform/Extensions/physics_character3d.svg'
2183
+ )
2184
+ .addParameter('object', _('Object'), '', false)
2185
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2186
+ .useStandardParameters(
2187
+ 'number',
2188
+ gd.ParameterOptions.makeNewOptions().setDescription(
2189
+ _('Acceleration (in pixels per second per second)')
2190
+ )
2191
+ )
2192
+ .markAsAdvanced()
2193
+ .setFunctionName('setSidewaysAcceleration')
2194
+ .setGetter('getSidewaysAcceleration');
2195
+
2196
+ aut
2197
+ .addExpressionAndConditionAndAction(
2198
+ 'number',
2199
+ 'SidewaysDeceleration',
2200
+ _('Sideways deceleration'),
2201
+ _('the sideways deceleration of an object.'),
2202
+ _('the sideways deceleration'),
2203
+ _('Character configuration'),
2204
+ 'JsPlatform/Extensions/physics_character3d.svg'
2205
+ )
2206
+ .addParameter('object', _('Object'), '', false)
2207
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2208
+ .useStandardParameters(
2209
+ 'number',
2210
+ gd.ParameterOptions.makeNewOptions().setDescription(
2211
+ _('Deceleration (in pixels per second per second)')
2212
+ )
2213
+ )
2214
+ .markAsAdvanced()
2215
+ .setFunctionName('setSidewaysDeceleration')
2216
+ .setGetter('getSidewaysDeceleration');
2217
+
2218
+ aut
2219
+ .addExpressionAndConditionAndAction(
2220
+ 'number',
2221
+ 'SidewaysSpeedMax',
2222
+ _('Sideways max speed'),
2223
+ _('the sideways max speed of the object.'),
2224
+ _('the sideways max speed'),
2225
+ _('Character configuration'),
2226
+ 'JsPlatform/Extensions/physics_character3d.svg'
2227
+ )
2228
+ .addParameter('object', _('Object'), '', false)
2229
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2230
+ .useStandardParameters(
2231
+ 'number',
2232
+ gd.ParameterOptions.makeNewOptions().setDescription(
2233
+ _('Speed (in pixels per second)')
2234
+ )
2235
+ )
2236
+ .setFunctionName('setSidewaysSpeedMax')
2237
+ .setGetter('getSidewaysSpeedMax');
2238
+
2239
+ aut
2240
+ .addExpressionAndConditionAndAction(
2241
+ 'number',
2242
+ 'CurrentFallSpeed',
2243
+ _('Current falling speed'),
2244
+ _(
2245
+ 'Compare the current falling speed of the object. Its value is always positive.'
2246
+ ),
2247
+ _('the current falling speed'),
2248
+ _('Character state'),
2249
+ 'JsPlatform/Extensions/physics_character3d.svg'
2250
+ )
2251
+ .addParameter('object', _('Object'), '', false)
2252
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2253
+ .useStandardParameters(
2254
+ 'number',
2255
+ gd.ParameterOptions.makeNewOptions().setDescription(
2256
+ _('Speed to compare to (in pixels per second)')
2257
+ )
2258
+ )
2259
+ .markAsAdvanced()
2260
+ .setFunctionName('setCurrentFallSpeed')
2261
+ .setGetter('getCurrentFallSpeed');
2262
+
2263
+ aut
2264
+ .addExpressionAndConditionAndAction(
2265
+ 'number',
2266
+ 'CurrentJumpSpeed',
2267
+ _('Current jump speed'),
2268
+ _(
2269
+ 'Compare the current jump speed of the object. Its value is always positive.'
2270
+ ),
2271
+ _('the current jump speed'),
2272
+ _('Character state'),
2273
+ 'JsPlatform/Extensions/physics_character3d.svg'
2274
+ )
2275
+ .addParameter('object', _('Object'), '', false)
2276
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2277
+ .useStandardParameters(
2278
+ 'number',
2279
+ gd.ParameterOptions.makeNewOptions().setDescription(
2280
+ _('Speed to compare to (in pixels per second)')
2281
+ )
2282
+ )
2283
+ .markAsAdvanced()
2284
+ .setFunctionName('setCurrentJumpSpeed')
2285
+ .setGetter('getCurrentJumpSpeed');
2286
+
2287
+ aut
2288
+ .addExpressionAndConditionAndAction(
2289
+ 'number',
2290
+ 'JumpSpeed',
2291
+ _('Jump speed'),
2292
+ _('the jump speed of an object. Its value is always positive.'),
2293
+ _('the jump speed'),
2294
+ _('Character configuration'),
2295
+ 'JsPlatform/Extensions/physics_character3d.svg'
2296
+ )
2297
+ .addParameter('object', _('Object'), '', false)
2298
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2299
+ .useStandardParameters(
2300
+ 'number',
2301
+ gd.ParameterOptions.makeNewOptions().setDescription(
2302
+ _('Speed (in pixels per second)')
2303
+ )
2304
+ )
2305
+ .setFunctionName('setJumpSpeed')
2306
+ .setGetter('getJumpSpeed');
2307
+
2308
+ aut
2309
+ .addExpressionAndConditionAndAction(
2310
+ 'number',
2311
+ 'JumpSustainTime',
2312
+ _('Jump sustain time'),
2313
+ _(
2314
+ 'the jump sustain time of an object. This is the time during which keeping the jump button held allow the initial jump speed to be maintained.'
2315
+ ),
2316
+ _('the jump sustain time'),
2317
+ _('Character configuration'),
2318
+ 'JsPlatform/Extensions/physics_character3d.svg'
2319
+ )
2320
+ .addParameter('object', _('Object'), '', false)
2321
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2322
+ .useStandardParameters(
2323
+ 'number',
2324
+ gd.ParameterOptions.makeNewOptions().setDescription(
2325
+ _('Duration (in seconds)')
2326
+ )
2327
+ )
2328
+ .setFunctionName('setJumpSustainTime')
2329
+ .setGetter('getJumpSustainTime');
2330
+
2331
+ aut
2332
+ .addExpressionAndConditionAndAction(
2333
+ 'number',
2334
+ 'Gravity',
2335
+ _('Gravity'),
2336
+ _('the gravity applied on an object.'),
2337
+ _('the gravity'),
2338
+ _('Character configuration'),
2339
+ 'JsPlatform/Extensions/physics_character3d.svg'
2340
+ )
2341
+ .addParameter('object', _('Object'), '', false)
2342
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2343
+ .useStandardParameters(
2344
+ 'number',
2345
+ gd.ParameterOptions.makeNewOptions().setDescription(
2346
+ _('Gravity (in pixels per second per second)')
2347
+ )
2348
+ )
2349
+ .markAsAdvanced()
2350
+ .setFunctionName('setGravity')
2351
+ .setGetter('getGravity');
2352
+
2353
+ aut
2354
+ .addExpressionAndCondition(
2355
+ 'number',
2356
+ 'FallingSpeedMax',
2357
+ _('Maximum falling speed'),
2358
+ _('the maximum falling speed of an object.'),
2359
+ _('the maximum falling speed'),
2360
+ _('Character configuration'),
2361
+ 'JsPlatform/Extensions/physics_character3d.svg'
2362
+ )
2363
+ .addParameter('object', _('Object'), '', false)
2364
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2365
+ .useStandardParameters(
2366
+ 'number',
2367
+ gd.ParameterOptions.makeNewOptions().setDescription(
2368
+ _('Max speed (in pixels per second)')
2369
+ )
2370
+ )
2371
+ .markAsAdvanced()
2372
+ .setFunctionName('getMaxFallingSpeed');
2373
+
2374
+ aut
2375
+ .addScopedAction(
2376
+ 'FallingSpeedMax',
2377
+ _('Maximum falling speed'),
2378
+ _('Change the maximum falling speed of an object.'),
2379
+ _('the maximum falling speed'),
2380
+ _('Character configuration'),
2381
+ 'JsPlatform/Extensions/physics_character3d.svg',
2382
+ 'JsPlatform/Extensions/physics_character3d.svg'
2383
+ )
2384
+ .addParameter('object', _('Object'), '', false)
2385
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2386
+ .useStandardOperatorParameters(
2387
+ 'number',
2388
+ gd.ParameterOptions.makeNewOptions().setDescription(
2389
+ _('Max speed (in pixels per second)')
2390
+ )
2391
+ )
2392
+ .addParameter(
2393
+ 'yesorno',
2394
+ _('If jumping, try to preserve the current speed in the air')
2395
+ )
2396
+ .markAsAdvanced()
2397
+ .setFunctionName('setMaxFallingSpeed')
2398
+ .setGetter('getMaxFallingSpeed');
2399
+ }
2400
+
2401
+ extension
2402
+ .addCondition(
2403
+ 'IsObjectOnGivenFloor',
2404
+ _('Character is on given platform'),
2405
+ _('Check if a 3D physics character is on a given platform.'),
2406
+ _('_PARAM0_ is on platform _PARAM2_'),
2407
+ _('Collision'),
2408
+ 'JsPlatform/Extensions/physics_character3d.svg',
2409
+ 'JsPlatform/Extensions/physics_character3d.svg'
2410
+ )
2411
+ .addParameter('objectList', _('Object'), '', false)
2412
+ .addParameter('behavior', _('Behavior'), 'PhysicsCharacter3D')
2413
+ .addParameter('objectList', _('Platforms'), '', false)
2414
+ .addParameter('behavior', _('Behavior'), 'Physics3DBehavior')
2415
+ .addCodeOnlyParameter('conditionInverted', '')
2416
+ .setFunctionName('gdjs.physics3d.isOnPlatform')
2417
+ .addIncludeFile('Extensions/Physics3DBehavior/Physics3DTools.js');
2418
+
2419
+ return extension;
2420
+ },
2421
+
2422
+ runExtensionSanityTests: function (gd, extension) {
2423
+ const dummyBehavior = extension
2424
+ .getBehaviorMetadata('Physics3D::Physics3DBehavior')
2425
+ .get();
2426
+ const sharedData = extension
2427
+ .getBehaviorMetadata('Physics3D::Physics3DBehavior')
2428
+ .getSharedDataInstance();
2429
+ return [
2430
+ gd.ProjectHelper.sanityCheckBehaviorProperty(
2431
+ dummyBehavior,
2432
+ 'density',
2433
+ '123'
2434
+ ),
2435
+ gd.ProjectHelper.sanityCheckBehaviorsSharedDataProperty(
2436
+ sharedData,
2437
+ 'gravityY',
2438
+ '456'
2439
+ ),
2440
+ ];
2441
+ },
2442
+ };