@driftengine/script 4.7.3 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/capabilities.json +229 -54
- package/dist/bindings/behavior.js +10 -6
- package/dist/bindings/chemistry.d.ts +4 -0
- package/dist/bindings/chemistry.js +40 -4
- package/dist/bindings/core.js +23 -4
- package/dist/bindings/editor.d.ts +10 -7
- package/dist/bindings/editor.js +72 -40
- package/dist/bindings/entities.js +16 -4
- package/dist/bindings/variants.d.ts +25 -0
- package/dist/bindings/variants.js +9 -0
- package/dist/bindings/xr.js +27 -14
- package/dist/entityHost.js +1 -1
- package/package.json +13 -13
- package/src/bindings/behavior.ts +19 -7
- package/src/bindings/chemistry.ts +54 -6
- package/src/bindings/core.ts +38 -6
- package/src/bindings/editor.ts +118 -44
- package/src/bindings/entities.ts +16 -4
- package/src/bindings/variants.ts +41 -0
- package/src/bindings/xr.ts +52 -25
- package/src/entityHost.ts +1 -1
- package/src/host.ts +0 -1
package/README.md
CHANGED
|
@@ -13,10 +13,15 @@ quoting a stale one is a red suite rather than a thing somebody notices.
|
|
|
13
13
|
scene, no mesh, no mix bus. This package is the other half — it describes each engine subsystem as
|
|
14
14
|
capabilities a script may call, and supplies the implementations at link time.
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
Every `drift/*` module a script can import, and every function in each with its signature and
|
|
17
|
+
whether it is deterministic, is listed in the manual's
|
|
18
|
+
[What a script can reach](https://driftengine.dev/docs/scripting/reach), which is written from
|
|
19
|
+
`capabilities.json` and so cannot fall behind it. **`drift/core` is deliberately unbound**, because
|
|
20
|
+
its provider is `startLoop`, which drives a script rather than being called by one.
|
|
21
|
+
|
|
22
|
+
**Using DriftScript in a game**, what belongs in a script and what stays in TypeScript, binding,
|
|
23
|
+
hot reload, testing and the patterns the examples share, is the manual's
|
|
24
|
+
[DriftScript section](https://driftengine.dev/docs/scripting/driftscript).
|
|
20
25
|
|
|
21
26
|
**Four of `drift/ecs`'s capabilities are ones nobody writes by hand.** `query`, `next`, `view` and
|
|
22
27
|
`without` are what a `for … in query<…>()` loop compiles to, so their documentation describes the
|
package/capabilities.json
CHANGED
|
@@ -1124,32 +1124,32 @@
|
|
|
1124
1124
|
{
|
|
1125
1125
|
"module": "drift/behavior",
|
|
1126
1126
|
"name": "tick",
|
|
1127
|
-
"signature": "fn(behavior: Behavior) ->
|
|
1127
|
+
"signature": "fn(behavior: Behavior) -> TreeStatus",
|
|
1128
1128
|
"params": [
|
|
1129
1129
|
{
|
|
1130
1130
|
"name": "behavior",
|
|
1131
1131
|
"type": "Behavior"
|
|
1132
1132
|
}
|
|
1133
1133
|
],
|
|
1134
|
-
"returns": "
|
|
1134
|
+
"returns": "TreeStatus",
|
|
1135
1135
|
"effects": [
|
|
1136
1136
|
"behavior.write"
|
|
1137
1137
|
],
|
|
1138
1138
|
"deterministic": false,
|
|
1139
|
-
"doc": "Advance the routine one tick
|
|
1139
|
+
"doc": "Advance the routine one tick, and answer whether it failed, finished or is still going. Does nothing while paused.",
|
|
1140
1140
|
"implementation": "drift/behavior.tick"
|
|
1141
1141
|
},
|
|
1142
1142
|
{
|
|
1143
1143
|
"module": "drift/behavior",
|
|
1144
1144
|
"name": "step",
|
|
1145
|
-
"signature": "fn(behavior: Behavior) ->
|
|
1145
|
+
"signature": "fn(behavior: Behavior) -> TreeStatus",
|
|
1146
1146
|
"params": [
|
|
1147
1147
|
{
|
|
1148
1148
|
"name": "behavior",
|
|
1149
1149
|
"type": "Behavior"
|
|
1150
1150
|
}
|
|
1151
1151
|
],
|
|
1152
|
-
"returns": "
|
|
1152
|
+
"returns": "TreeStatus",
|
|
1153
1153
|
"effects": [
|
|
1154
1154
|
"behavior.write"
|
|
1155
1155
|
],
|
|
@@ -1218,14 +1218,14 @@
|
|
|
1218
1218
|
{
|
|
1219
1219
|
"module": "drift/behavior",
|
|
1220
1220
|
"name": "status",
|
|
1221
|
-
"signature": "fn(behavior: Behavior) ->
|
|
1221
|
+
"signature": "fn(behavior: Behavior) -> TreeStatus",
|
|
1222
1222
|
"params": [
|
|
1223
1223
|
{
|
|
1224
1224
|
"name": "behavior",
|
|
1225
1225
|
"type": "Behavior"
|
|
1226
1226
|
}
|
|
1227
1227
|
],
|
|
1228
|
-
"returns": "
|
|
1228
|
+
"returns": "TreeStatus",
|
|
1229
1229
|
"effects": [
|
|
1230
1230
|
"behavior.read"
|
|
1231
1231
|
],
|
|
@@ -1664,7 +1664,7 @@
|
|
|
1664
1664
|
{
|
|
1665
1665
|
"module": "drift/chemistry",
|
|
1666
1666
|
"name": "phase",
|
|
1667
|
-
"signature": "fn(chem: Chemistry, parcel: i32) ->
|
|
1667
|
+
"signature": "fn(chem: Chemistry, parcel: i32) -> MatterPhase",
|
|
1668
1668
|
"params": [
|
|
1669
1669
|
{
|
|
1670
1670
|
"name": "chem",
|
|
@@ -1675,12 +1675,12 @@
|
|
|
1675
1675
|
"type": "i32"
|
|
1676
1676
|
}
|
|
1677
1677
|
],
|
|
1678
|
-
"returns": "
|
|
1678
|
+
"returns": "MatterPhase",
|
|
1679
1679
|
"effects": [
|
|
1680
1680
|
"chemistry.read"
|
|
1681
1681
|
],
|
|
1682
1682
|
"deterministic": true,
|
|
1683
|
-
"doc": "
|
|
1683
|
+
"doc": "Whether the parcel is solid, liquid, gas or mixed. Mixed is a real answer: wet wood is a solid and a liquid at once.",
|
|
1684
1684
|
"implementation": "drift/chemistry.phase"
|
|
1685
1685
|
},
|
|
1686
1686
|
{
|
|
@@ -2542,7 +2542,7 @@
|
|
|
2542
2542
|
{
|
|
2543
2543
|
"module": "drift/chemistry",
|
|
2544
2544
|
"name": "eventKind",
|
|
2545
|
-
"signature": "fn(chem: Chemistry, index: i32) ->
|
|
2545
|
+
"signature": "fn(chem: Chemistry, index: i32) -> ChemistryEvent",
|
|
2546
2546
|
"params": [
|
|
2547
2547
|
{
|
|
2548
2548
|
"name": "chem",
|
|
@@ -2553,12 +2553,12 @@
|
|
|
2553
2553
|
"type": "i32"
|
|
2554
2554
|
}
|
|
2555
2555
|
],
|
|
2556
|
-
"returns": "
|
|
2556
|
+
"returns": "ChemistryEvent",
|
|
2557
2557
|
"effects": [
|
|
2558
2558
|
"chemistry.read"
|
|
2559
2559
|
],
|
|
2560
2560
|
"deterministic": true,
|
|
2561
|
-
"doc": "
|
|
2561
|
+
"doc": "What happened in one of this tick’s events. An index outside `eventCount` is refused, naming both.",
|
|
2562
2562
|
"implementation": "drift/chemistry.eventKind"
|
|
2563
2563
|
},
|
|
2564
2564
|
{
|
|
@@ -3026,19 +3026,19 @@
|
|
|
3026
3026
|
{
|
|
3027
3027
|
"module": "drift/editor",
|
|
3028
3028
|
"name": "gizmoMode",
|
|
3029
|
-
"signature": "fn(gizmo: Gizmo) ->
|
|
3029
|
+
"signature": "fn(gizmo: Gizmo) -> GizmoMode",
|
|
3030
3030
|
"params": [
|
|
3031
3031
|
{
|
|
3032
3032
|
"name": "gizmo",
|
|
3033
3033
|
"type": "Gizmo"
|
|
3034
3034
|
}
|
|
3035
3035
|
],
|
|
3036
|
-
"returns": "
|
|
3036
|
+
"returns": "GizmoMode",
|
|
3037
3037
|
"effects": [
|
|
3038
3038
|
"editor"
|
|
3039
3039
|
],
|
|
3040
3040
|
"deterministic": false,
|
|
3041
|
-
"doc": "Which of the three the gizmo is:
|
|
3041
|
+
"doc": "Which of the three the gizmo is: translate, rotate or scale.",
|
|
3042
3042
|
"implementation": "drift/editor.gizmoMode"
|
|
3043
3043
|
},
|
|
3044
3044
|
{
|
|
@@ -3080,19 +3080,19 @@
|
|
|
3080
3080
|
{
|
|
3081
3081
|
"module": "drift/editor",
|
|
3082
3082
|
"name": "space",
|
|
3083
|
-
"signature": "fn(gizmo: Gizmo) ->
|
|
3083
|
+
"signature": "fn(gizmo: Gizmo) -> GizmoSpace",
|
|
3084
3084
|
"params": [
|
|
3085
3085
|
{
|
|
3086
3086
|
"name": "gizmo",
|
|
3087
3087
|
"type": "Gizmo"
|
|
3088
3088
|
}
|
|
3089
3089
|
],
|
|
3090
|
-
"returns": "
|
|
3090
|
+
"returns": "GizmoSpace",
|
|
3091
3091
|
"effects": [
|
|
3092
3092
|
"editor"
|
|
3093
3093
|
],
|
|
3094
3094
|
"deterministic": false,
|
|
3095
|
-
"doc": "Which the handles are pointing along:
|
|
3095
|
+
"doc": "Which the handles are pointing along: the world or the object.",
|
|
3096
3096
|
"implementation": "drift/editor.space"
|
|
3097
3097
|
},
|
|
3098
3098
|
{
|
|
@@ -3138,19 +3138,19 @@
|
|
|
3138
3138
|
{
|
|
3139
3139
|
"module": "drift/editor",
|
|
3140
3140
|
"name": "hovered",
|
|
3141
|
-
"signature": "fn(gizmo: Gizmo) ->
|
|
3141
|
+
"signature": "fn(gizmo: Gizmo) -> GizmoHandle",
|
|
3142
3142
|
"params": [
|
|
3143
3143
|
{
|
|
3144
3144
|
"name": "gizmo",
|
|
3145
3145
|
"type": "Gizmo"
|
|
3146
3146
|
}
|
|
3147
3147
|
],
|
|
3148
|
-
"returns": "
|
|
3148
|
+
"returns": "GizmoHandle",
|
|
3149
3149
|
"effects": [
|
|
3150
3150
|
"editor"
|
|
3151
3151
|
],
|
|
3152
3152
|
"deterministic": false,
|
|
3153
|
-
"doc": "What the pointer is over
|
|
3153
|
+
"doc": "What the pointer is over: `None`, or a handle such as `TranslateX`, `TranslateYZ`, `RotateY` or `ScaleUniform`.",
|
|
3154
3154
|
"implementation": "drift/editor.hovered"
|
|
3155
3155
|
},
|
|
3156
3156
|
{
|
|
@@ -3402,19 +3402,19 @@
|
|
|
3402
3402
|
{
|
|
3403
3403
|
"module": "drift/editor",
|
|
3404
3404
|
"name": "mode",
|
|
3405
|
-
"signature": "fn(editor: Editor) ->
|
|
3405
|
+
"signature": "fn(editor: Editor) -> EditorMode",
|
|
3406
3406
|
"params": [
|
|
3407
3407
|
{
|
|
3408
3408
|
"name": "editor",
|
|
3409
3409
|
"type": "Editor"
|
|
3410
3410
|
}
|
|
3411
3411
|
],
|
|
3412
|
-
"returns": "
|
|
3412
|
+
"returns": "EditorMode",
|
|
3413
3413
|
"effects": [
|
|
3414
3414
|
"editor"
|
|
3415
3415
|
],
|
|
3416
3416
|
"deterministic": false,
|
|
3417
|
-
"doc": "What the editor is doing:
|
|
3417
|
+
"doc": "What the editor is doing: editing, playing or paused.",
|
|
3418
3418
|
"implementation": "drift/editor.mode"
|
|
3419
3419
|
},
|
|
3420
3420
|
{
|
|
@@ -3740,7 +3740,7 @@
|
|
|
3740
3740
|
{
|
|
3741
3741
|
"module": "drift/editor",
|
|
3742
3742
|
"name": "fieldKind",
|
|
3743
|
-
"signature": "fn(editor: Editor, field: i32) ->
|
|
3743
|
+
"signature": "fn(editor: Editor, field: i32) -> FieldKind",
|
|
3744
3744
|
"params": [
|
|
3745
3745
|
{
|
|
3746
3746
|
"name": "editor",
|
|
@@ -3751,12 +3751,12 @@
|
|
|
3751
3751
|
"type": "i32"
|
|
3752
3752
|
}
|
|
3753
3753
|
],
|
|
3754
|
-
"returns": "
|
|
3754
|
+
"returns": "FieldKind",
|
|
3755
3755
|
"effects": [
|
|
3756
3756
|
"editor"
|
|
3757
3757
|
],
|
|
3758
3758
|
"deterministic": false,
|
|
3759
|
-
"doc": "How to show a field:
|
|
3759
|
+
"doc": "How to show a field: a number, an integer, a boolean, text, an entity or an enum. Taken from the declared type, because a read cannot tell them apart. A field outside `fieldCount` is refused, naming both.",
|
|
3760
3760
|
"implementation": "drift/editor.fieldKind"
|
|
3761
3761
|
},
|
|
3762
3762
|
{
|
|
@@ -4965,19 +4965,19 @@
|
|
|
4965
4965
|
{
|
|
4966
4966
|
"module": "drift/persistence",
|
|
4967
4967
|
"name": "saveStatus",
|
|
4968
|
-
"signature": "fn(store: Store) ->
|
|
4968
|
+
"signature": "fn(store: Store) -> SaveStatus",
|
|
4969
4969
|
"params": [
|
|
4970
4970
|
{
|
|
4971
4971
|
"name": "store",
|
|
4972
4972
|
"type": "Store"
|
|
4973
4973
|
}
|
|
4974
4974
|
],
|
|
4975
|
-
"returns": "
|
|
4975
|
+
"returns": "SaveStatus",
|
|
4976
4976
|
"effects": [
|
|
4977
4977
|
"persistence.read"
|
|
4978
4978
|
],
|
|
4979
4979
|
"deterministic": false,
|
|
4980
|
-
"doc": "Whether writes have landed:
|
|
4980
|
+
"doc": "Whether writes have landed: idle, pending, saving or failed. A store that writes synchronously is always idle, which is the true answer rather than a stub.",
|
|
4981
4981
|
"implementation": "drift/persistence.saveStatus"
|
|
4982
4982
|
},
|
|
4983
4983
|
{
|
|
@@ -5719,7 +5719,7 @@
|
|
|
5719
5719
|
{
|
|
5720
5720
|
"module": "drift/physics",
|
|
5721
5721
|
"name": "contactKind",
|
|
5722
|
-
"signature": "fn(world: PhysicsWorld, index: i32) ->
|
|
5722
|
+
"signature": "fn(world: PhysicsWorld, index: i32) -> ContactKind",
|
|
5723
5723
|
"params": [
|
|
5724
5724
|
{
|
|
5725
5725
|
"name": "world",
|
|
@@ -5730,12 +5730,12 @@
|
|
|
5730
5730
|
"type": "i32"
|
|
5731
5731
|
}
|
|
5732
5732
|
],
|
|
5733
|
-
"returns": "
|
|
5733
|
+
"returns": "ContactKind",
|
|
5734
5734
|
"effects": [
|
|
5735
5735
|
"physics.read"
|
|
5736
5736
|
],
|
|
5737
5737
|
"deterministic": true,
|
|
5738
|
-
"doc": "An event's kind:
|
|
5738
|
+
"doc": "An event's kind: the two bodies began touching, are still touching, or have parted.",
|
|
5739
5739
|
"implementation": "drift/physics.contactKind"
|
|
5740
5740
|
},
|
|
5741
5741
|
{
|
|
@@ -6344,11 +6344,11 @@
|
|
|
6344
6344
|
{
|
|
6345
6345
|
"module": "drift/xr",
|
|
6346
6346
|
"name": "trigger",
|
|
6347
|
-
"signature": "fn(hand:
|
|
6347
|
+
"signature": "fn(hand: Hand) -> f32",
|
|
6348
6348
|
"params": [
|
|
6349
6349
|
{
|
|
6350
6350
|
"name": "hand",
|
|
6351
|
-
"type": "
|
|
6351
|
+
"type": "Hand"
|
|
6352
6352
|
}
|
|
6353
6353
|
],
|
|
6354
6354
|
"returns": "f32",
|
|
@@ -6362,11 +6362,11 @@
|
|
|
6362
6362
|
{
|
|
6363
6363
|
"module": "drift/xr",
|
|
6364
6364
|
"name": "squeeze",
|
|
6365
|
-
"signature": "fn(hand:
|
|
6365
|
+
"signature": "fn(hand: Hand) -> f32",
|
|
6366
6366
|
"params": [
|
|
6367
6367
|
{
|
|
6368
6368
|
"name": "hand",
|
|
6369
|
-
"type": "
|
|
6369
|
+
"type": "Hand"
|
|
6370
6370
|
}
|
|
6371
6371
|
],
|
|
6372
6372
|
"returns": "f32",
|
|
@@ -6380,11 +6380,11 @@
|
|
|
6380
6380
|
{
|
|
6381
6381
|
"module": "drift/xr",
|
|
6382
6382
|
"name": "holding",
|
|
6383
|
-
"signature": "fn(hand:
|
|
6383
|
+
"signature": "fn(hand: Hand) -> bool",
|
|
6384
6384
|
"params": [
|
|
6385
6385
|
{
|
|
6386
6386
|
"name": "hand",
|
|
6387
|
-
"type": "
|
|
6387
|
+
"type": "Hand"
|
|
6388
6388
|
}
|
|
6389
6389
|
],
|
|
6390
6390
|
"returns": "bool",
|
|
@@ -6398,15 +6398,15 @@
|
|
|
6398
6398
|
{
|
|
6399
6399
|
"module": "drift/xr",
|
|
6400
6400
|
"name": "jointX",
|
|
6401
|
-
"signature": "fn(hand:
|
|
6401
|
+
"signature": "fn(hand: Hand, joint: HandJoint) -> f32",
|
|
6402
6402
|
"params": [
|
|
6403
6403
|
{
|
|
6404
6404
|
"name": "hand",
|
|
6405
|
-
"type": "
|
|
6405
|
+
"type": "Hand"
|
|
6406
6406
|
},
|
|
6407
6407
|
{
|
|
6408
6408
|
"name": "joint",
|
|
6409
|
-
"type": "
|
|
6409
|
+
"type": "HandJoint"
|
|
6410
6410
|
}
|
|
6411
6411
|
],
|
|
6412
6412
|
"returns": "f32",
|
|
@@ -6414,21 +6414,21 @@
|
|
|
6414
6414
|
"input.read"
|
|
6415
6415
|
],
|
|
6416
6416
|
"deterministic": false,
|
|
6417
|
-
"doc": "Where a
|
|
6417
|
+
"doc": "Where a hand joint is, in metres. Zero for a joint that is not tracked.",
|
|
6418
6418
|
"implementation": "XrRuntime.jointX"
|
|
6419
6419
|
},
|
|
6420
6420
|
{
|
|
6421
6421
|
"module": "drift/xr",
|
|
6422
6422
|
"name": "jointY",
|
|
6423
|
-
"signature": "fn(hand:
|
|
6423
|
+
"signature": "fn(hand: Hand, joint: HandJoint) -> f32",
|
|
6424
6424
|
"params": [
|
|
6425
6425
|
{
|
|
6426
6426
|
"name": "hand",
|
|
6427
|
-
"type": "
|
|
6427
|
+
"type": "Hand"
|
|
6428
6428
|
},
|
|
6429
6429
|
{
|
|
6430
6430
|
"name": "joint",
|
|
6431
|
-
"type": "
|
|
6431
|
+
"type": "HandJoint"
|
|
6432
6432
|
}
|
|
6433
6433
|
],
|
|
6434
6434
|
"returns": "f32",
|
|
@@ -6436,21 +6436,21 @@
|
|
|
6436
6436
|
"input.read"
|
|
6437
6437
|
],
|
|
6438
6438
|
"deterministic": false,
|
|
6439
|
-
"doc": "Where a
|
|
6439
|
+
"doc": "Where a hand joint is, in metres. Zero for a joint that is not tracked.",
|
|
6440
6440
|
"implementation": "XrRuntime.jointY"
|
|
6441
6441
|
},
|
|
6442
6442
|
{
|
|
6443
6443
|
"module": "drift/xr",
|
|
6444
6444
|
"name": "jointZ",
|
|
6445
|
-
"signature": "fn(hand:
|
|
6445
|
+
"signature": "fn(hand: Hand, joint: HandJoint) -> f32",
|
|
6446
6446
|
"params": [
|
|
6447
6447
|
{
|
|
6448
6448
|
"name": "hand",
|
|
6449
|
-
"type": "
|
|
6449
|
+
"type": "Hand"
|
|
6450
6450
|
},
|
|
6451
6451
|
{
|
|
6452
6452
|
"name": "joint",
|
|
6453
|
-
"type": "
|
|
6453
|
+
"type": "HandJoint"
|
|
6454
6454
|
}
|
|
6455
6455
|
],
|
|
6456
6456
|
"returns": "f32",
|
|
@@ -6458,17 +6458,17 @@
|
|
|
6458
6458
|
"input.read"
|
|
6459
6459
|
],
|
|
6460
6460
|
"deterministic": false,
|
|
6461
|
-
"doc": "Where a
|
|
6461
|
+
"doc": "Where a hand joint is, in metres. Zero for a joint that is not tracked.",
|
|
6462
6462
|
"implementation": "XrRuntime.jointZ"
|
|
6463
6463
|
},
|
|
6464
6464
|
{
|
|
6465
6465
|
"module": "drift/xr",
|
|
6466
6466
|
"name": "pinching",
|
|
6467
|
-
"signature": "fn(hand:
|
|
6467
|
+
"signature": "fn(hand: Hand) -> bool",
|
|
6468
6468
|
"params": [
|
|
6469
6469
|
{
|
|
6470
6470
|
"name": "hand",
|
|
6471
|
-
"type": "
|
|
6471
|
+
"type": "Hand"
|
|
6472
6472
|
}
|
|
6473
6473
|
],
|
|
6474
6474
|
"returns": "bool",
|
|
@@ -7811,6 +7811,45 @@
|
|
|
7811
7811
|
"name": "Species",
|
|
7812
7812
|
"doc": "A registered chemical species, such as `O2` or `cellulose`."
|
|
7813
7813
|
},
|
|
7814
|
+
{
|
|
7815
|
+
"module": "drift/chemistry",
|
|
7816
|
+
"name": "MatterPhase",
|
|
7817
|
+
"doc": "What a parcel is made of now. Mixed is a real answer: wet wood is a solid and a liquid at once.",
|
|
7818
|
+
"variants": [
|
|
7819
|
+
"Solid",
|
|
7820
|
+
"Liquid",
|
|
7821
|
+
"Gas",
|
|
7822
|
+
"Mixed"
|
|
7823
|
+
]
|
|
7824
|
+
},
|
|
7825
|
+
{
|
|
7826
|
+
"module": "drift/chemistry",
|
|
7827
|
+
"name": "ChemistryEvent",
|
|
7828
|
+
"doc": "What happened to a parcel this tick: it caught, went out, melted, boiled and the rest.",
|
|
7829
|
+
"variants": [
|
|
7830
|
+
"Ignited",
|
|
7831
|
+
"Extinguished",
|
|
7832
|
+
"SmoulderStart",
|
|
7833
|
+
"SmoulderEnd",
|
|
7834
|
+
"Consumed",
|
|
7835
|
+
"Charred",
|
|
7836
|
+
"StructuralFail",
|
|
7837
|
+
"Frozen",
|
|
7838
|
+
"Melted",
|
|
7839
|
+
"Boiled",
|
|
7840
|
+
"Condensed",
|
|
7841
|
+
"Sublimed",
|
|
7842
|
+
"Corroded",
|
|
7843
|
+
"Calcined",
|
|
7844
|
+
"Dissolved",
|
|
7845
|
+
"Denatured",
|
|
7846
|
+
"Browned",
|
|
7847
|
+
"Caramelised",
|
|
7848
|
+
"Fermented",
|
|
7849
|
+
"Decayed",
|
|
7850
|
+
"Exploded"
|
|
7851
|
+
]
|
|
7852
|
+
},
|
|
7814
7853
|
{
|
|
7815
7854
|
"module": "drift/scene",
|
|
7816
7855
|
"name": "Node",
|
|
@@ -7856,6 +7895,27 @@
|
|
|
7856
7895
|
"name": "Store",
|
|
7857
7896
|
"doc": "A key-value store the consumer supplied."
|
|
7858
7897
|
},
|
|
7898
|
+
{
|
|
7899
|
+
"module": "drift/physics",
|
|
7900
|
+
"name": "ContactKind",
|
|
7901
|
+
"doc": "Whether two bodies began touching this step, are still touching, or have parted.",
|
|
7902
|
+
"variants": [
|
|
7903
|
+
"Enter",
|
|
7904
|
+
"Stay",
|
|
7905
|
+
"Exit"
|
|
7906
|
+
]
|
|
7907
|
+
},
|
|
7908
|
+
{
|
|
7909
|
+
"module": "drift/persistence",
|
|
7910
|
+
"name": "SaveStatus",
|
|
7911
|
+
"doc": "Whether a store’s writes have landed: idle, waiting to send, sending, or failed.",
|
|
7912
|
+
"variants": [
|
|
7913
|
+
"Idle",
|
|
7914
|
+
"Pending",
|
|
7915
|
+
"Saving",
|
|
7916
|
+
"Failed"
|
|
7917
|
+
]
|
|
7918
|
+
},
|
|
7859
7919
|
{
|
|
7860
7920
|
"module": "drift/ecs",
|
|
7861
7921
|
"name": "World",
|
|
@@ -7876,6 +7936,16 @@
|
|
|
7876
7936
|
"name": "Behavior",
|
|
7877
7937
|
"doc": "One agent running one behaviour tree: where it is in its routine."
|
|
7878
7938
|
},
|
|
7939
|
+
{
|
|
7940
|
+
"module": "drift/behavior",
|
|
7941
|
+
"name": "TreeStatus",
|
|
7942
|
+
"doc": "What a behaviour tree answered: it failed, it finished, or it is still going.",
|
|
7943
|
+
"variants": [
|
|
7944
|
+
"Failure",
|
|
7945
|
+
"Success",
|
|
7946
|
+
"Running"
|
|
7947
|
+
]
|
|
7948
|
+
},
|
|
7879
7949
|
{
|
|
7880
7950
|
"module": "drift/navigation",
|
|
7881
7951
|
"name": "NavGraph",
|
|
@@ -7921,6 +7991,69 @@
|
|
|
7921
7991
|
"name": "Editor",
|
|
7922
7992
|
"doc": "An editing session: what is selected, the tree of what exists, and whether the world is playing."
|
|
7923
7993
|
},
|
|
7994
|
+
{
|
|
7995
|
+
"module": "drift/editor",
|
|
7996
|
+
"name": "GizmoMode",
|
|
7997
|
+
"doc": "Which tool a gizmo is: it moves, turns or scales.",
|
|
7998
|
+
"variants": [
|
|
7999
|
+
"Translate",
|
|
8000
|
+
"Rotate",
|
|
8001
|
+
"Scale"
|
|
8002
|
+
]
|
|
8003
|
+
},
|
|
8004
|
+
{
|
|
8005
|
+
"module": "drift/editor",
|
|
8006
|
+
"name": "GizmoSpace",
|
|
8007
|
+
"doc": "Which axes a gizmo’s handles point along: the world’s or the object’s own.",
|
|
8008
|
+
"variants": [
|
|
8009
|
+
"World",
|
|
8010
|
+
"Local"
|
|
8011
|
+
]
|
|
8012
|
+
},
|
|
8013
|
+
{
|
|
8014
|
+
"module": "drift/editor",
|
|
8015
|
+
"name": "GizmoHandle",
|
|
8016
|
+
"doc": "Which handle the pointer is over, or `None`.",
|
|
8017
|
+
"variants": [
|
|
8018
|
+
"None",
|
|
8019
|
+
"TranslateX",
|
|
8020
|
+
"TranslateY",
|
|
8021
|
+
"TranslateZ",
|
|
8022
|
+
"TranslateYZ",
|
|
8023
|
+
"TranslateZX",
|
|
8024
|
+
"TranslateXY",
|
|
8025
|
+
"RotateX",
|
|
8026
|
+
"RotateY",
|
|
8027
|
+
"RotateZ",
|
|
8028
|
+
"ScaleX",
|
|
8029
|
+
"ScaleY",
|
|
8030
|
+
"ScaleZ",
|
|
8031
|
+
"ScaleUniform"
|
|
8032
|
+
]
|
|
8033
|
+
},
|
|
8034
|
+
{
|
|
8035
|
+
"module": "drift/editor",
|
|
8036
|
+
"name": "EditorMode",
|
|
8037
|
+
"doc": "Whether the editor is editing, playing the world, or paused part way through playing it.",
|
|
8038
|
+
"variants": [
|
|
8039
|
+
"Edit",
|
|
8040
|
+
"Play",
|
|
8041
|
+
"Paused"
|
|
8042
|
+
]
|
|
8043
|
+
},
|
|
8044
|
+
{
|
|
8045
|
+
"module": "drift/editor",
|
|
8046
|
+
"name": "FieldKind",
|
|
8047
|
+
"doc": "How an inspector field is shown, taken from the type it was declared with.",
|
|
8048
|
+
"variants": [
|
|
8049
|
+
"Number",
|
|
8050
|
+
"Integer",
|
|
8051
|
+
"Boolean",
|
|
8052
|
+
"Text",
|
|
8053
|
+
"Entity",
|
|
8054
|
+
"Enum"
|
|
8055
|
+
]
|
|
8056
|
+
},
|
|
7924
8057
|
{
|
|
7925
8058
|
"module": "drift/network",
|
|
7926
8059
|
"name": "Session",
|
|
@@ -7935,6 +8068,48 @@
|
|
|
7935
8068
|
"module": "drift/render",
|
|
7936
8069
|
"name": "Renderer",
|
|
7937
8070
|
"doc": "The renderer drawing this frame. Reaches a script through `uses`."
|
|
8071
|
+
},
|
|
8072
|
+
{
|
|
8073
|
+
"module": "drift/xr",
|
|
8074
|
+
"name": "Hand",
|
|
8075
|
+
"doc": "Which hand: left, right, or the input source with no side.",
|
|
8076
|
+
"variants": [
|
|
8077
|
+
"Left",
|
|
8078
|
+
"Right",
|
|
8079
|
+
"None"
|
|
8080
|
+
]
|
|
8081
|
+
},
|
|
8082
|
+
{
|
|
8083
|
+
"module": "drift/xr",
|
|
8084
|
+
"name": "HandJoint",
|
|
8085
|
+
"doc": "One of the twenty-five joints WebXR tracks on a hand, from the wrist to each fingertip.",
|
|
8086
|
+
"variants": [
|
|
8087
|
+
"Wrist",
|
|
8088
|
+
"ThumbMetacarpal",
|
|
8089
|
+
"ThumbPhalanxProximal",
|
|
8090
|
+
"ThumbPhalanxDistal",
|
|
8091
|
+
"ThumbTip",
|
|
8092
|
+
"IndexFingerMetacarpal",
|
|
8093
|
+
"IndexFingerPhalanxProximal",
|
|
8094
|
+
"IndexFingerPhalanxIntermediate",
|
|
8095
|
+
"IndexFingerPhalanxDistal",
|
|
8096
|
+
"IndexFingerTip",
|
|
8097
|
+
"MiddleFingerMetacarpal",
|
|
8098
|
+
"MiddleFingerPhalanxProximal",
|
|
8099
|
+
"MiddleFingerPhalanxIntermediate",
|
|
8100
|
+
"MiddleFingerPhalanxDistal",
|
|
8101
|
+
"MiddleFingerTip",
|
|
8102
|
+
"RingFingerMetacarpal",
|
|
8103
|
+
"RingFingerPhalanxProximal",
|
|
8104
|
+
"RingFingerPhalanxIntermediate",
|
|
8105
|
+
"RingFingerPhalanxDistal",
|
|
8106
|
+
"RingFingerTip",
|
|
8107
|
+
"PinkyFingerMetacarpal",
|
|
8108
|
+
"PinkyFingerPhalanxProximal",
|
|
8109
|
+
"PinkyFingerPhalanxIntermediate",
|
|
8110
|
+
"PinkyFingerPhalanxDistal",
|
|
8111
|
+
"PinkyFingerTip"
|
|
8112
|
+
]
|
|
7938
8113
|
}
|
|
7939
8114
|
],
|
|
7940
8115
|
"manifest": {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BehaviorRunner } from '@driftengine/core';
|
|
2
2
|
import { defineCapability } from 'driftscript';
|
|
3
|
+
import { hostEnum } from './variants.js';
|
|
3
4
|
export const BEHAVIOR_MODULE = 'drift/behavior';
|
|
5
|
+
/** What a tick answered, in the engine's own order: `FAILURE`, `SUCCESS`, `RUNNING`. */
|
|
6
|
+
const TREE_STATUS = hostEnum(BEHAVIOR_MODULE, 'TreeStatus', ['Failure', 'Success', 'Running'], 'What a behaviour tree answered: it failed, it finished, or it is still going.');
|
|
4
7
|
/**
|
|
5
8
|
* `drift/behavior` — driving and watching a behaviour tree from a script.
|
|
6
9
|
*
|
|
@@ -27,6 +30,7 @@ export const BEHAVIOR_TYPES = [
|
|
|
27
30
|
name: 'Behavior',
|
|
28
31
|
doc: 'One agent running one behaviour tree: where it is in its routine.',
|
|
29
32
|
},
|
|
33
|
+
TREE_STATUS.type,
|
|
30
34
|
];
|
|
31
35
|
const define = (name, params, returns, effects, doc, deterministic = true) => defineCapability({
|
|
32
36
|
module: BEHAVIOR_MODULE,
|
|
@@ -40,15 +44,15 @@ const define = (name, params, returns, effects, doc, deterministic = true) => de
|
|
|
40
44
|
implementation: `${BEHAVIOR_MODULE}.${name}`,
|
|
41
45
|
});
|
|
42
46
|
export const BEHAVIOR_CAPABILITIES = [
|
|
43
|
-
define('tick', [{ name: 'behavior', type: 'Behavior' }], '
|
|
44
|
-
define('step', [{ name: 'behavior', type: 'Behavior' }], '
|
|
47
|
+
define('tick', [{ name: 'behavior', type: 'Behavior' }], 'TreeStatus', ['behavior.write'], 'Advance the routine one tick, and answer whether it failed, finished or is still going. Does nothing while paused.', false),
|
|
48
|
+
define('step', [{ name: 'behavior', type: 'Behavior' }], 'TreeStatus', ['behavior.write'], 'Advance one tick even while paused, which is what a step button is.', false),
|
|
45
49
|
define('restart', [{ name: 'behavior', type: 'Behavior' }], 'void', ['behavior.write'], 'Forget where the routine had got to, so the next tick starts it from the top.', false),
|
|
46
50
|
define('setPaused', [
|
|
47
51
|
{ name: 'behavior', type: 'Behavior' },
|
|
48
52
|
{ name: 'paused', type: 'bool' },
|
|
49
53
|
], 'void', ['behavior.write'], 'Hold this one agent while the world carries on.', false),
|
|
50
54
|
define('paused', [{ name: 'behavior', type: 'Behavior' }], 'bool', ['behavior.read'], 'Whether it is being held.'),
|
|
51
|
-
define('status', [{ name: 'behavior', type: 'Behavior' }], '
|
|
55
|
+
define('status', [{ name: 'behavior', type: 'Behavior' }], 'TreeStatus', ['behavior.read'], 'What the last tick answered, without ticking again.'),
|
|
52
56
|
/*
|
|
53
57
|
* **The reason a tree beats a loop, from a script's side.** A hand-written routine keeps its
|
|
54
58
|
* state where nothing else can see it, so a script that wants to react to what an agent is doing
|
|
@@ -65,14 +69,14 @@ export function behaviorImplementation(services) {
|
|
|
65
69
|
tick by anything watching an agent. */
|
|
66
70
|
let scratch = new Uint32Array(32);
|
|
67
71
|
return {
|
|
68
|
-
tick: (character) => character.tick(services.context(character)),
|
|
69
|
-
step: (character) => character.stepOnce(services.context(character)),
|
|
72
|
+
tick: (character) => TREE_STATUS.of[character.tick(services.context(character))],
|
|
73
|
+
step: (character) => TREE_STATUS.of[character.stepOnce(services.context(character))],
|
|
70
74
|
restart: (character) => character.reset(),
|
|
71
75
|
setPaused: (character, paused) => {
|
|
72
76
|
character.paused = paused;
|
|
73
77
|
},
|
|
74
78
|
paused: (character) => character.paused,
|
|
75
|
-
status: (character) => character.status,
|
|
79
|
+
status: (character) => TREE_STATUS.of[character.status],
|
|
76
80
|
depth(character) {
|
|
77
81
|
scratch = fit(scratch, character);
|
|
78
82
|
return character.activePath(scratch);
|