@zylem/behaviors 0.8.9 → 0.8.11
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/dist/acrobatics-2d.d.ts +25 -0
- package/dist/acrobatics-2d.js +37 -0
- package/dist/action-rpg.d.ts +21 -0
- package/dist/action-rpg.js +39 -0
- package/dist/adventure-tools.d.ts +22 -0
- package/dist/adventure-tools.js +39 -0
- package/dist/behavior-descriptor-NS_qnzzp.d.ts +4527 -0
- package/dist/behavior-metadata-Drm1zxI2.d.ts +13 -0
- package/dist/catalog.d.ts +2143 -0
- package/dist/catalog.js +9 -0
- package/dist/chunk-2BE5BW7D.js +130 -0
- package/dist/{chunk-CTSYM56P.js → chunk-2QCCLHJC.js} +10 -6
- package/dist/chunk-2UGT4MIF.js +94 -0
- package/dist/chunk-3J3ISPFQ.js +99 -0
- package/dist/chunk-3LBGEWT6.js +124 -0
- package/dist/{chunk-UUMH3DC3.js → chunk-3QBNWT7B.js} +5 -1
- package/dist/chunk-3T44EDXU.js +114 -0
- package/dist/chunk-5AJJ44QK.js +129 -0
- package/dist/{chunk-YDLO5M7S.js → chunk-5SMXQ6AU.js} +1 -0
- package/dist/chunk-5VJIP535.js +71 -0
- package/dist/chunk-6DTIJB7B.js +166 -0
- package/dist/chunk-73MHJY6R.js +78 -0
- package/dist/chunk-73YASAYS.js +137 -0
- package/dist/{chunk-LLDLVVG4.js → chunk-7HGDADLB.js} +25 -9
- package/dist/chunk-7IOQEXYR.js +92 -0
- package/dist/{chunk-OU2SW4U5.js → chunk-APAM55J3.js} +10 -6
- package/dist/chunk-BLTBZJPG.js +126 -0
- package/dist/chunk-BN6QZDR5.js +90 -0
- package/dist/chunk-BR33KT4Z.js +3186 -0
- package/dist/chunk-C5AYL42A.js +138 -0
- package/dist/{chunk-OBF6BIA2.js → chunk-CBQSC6W3.js} +2 -2
- package/dist/chunk-DDLZLJ7W.js +8 -0
- package/dist/chunk-DRIXFB4C.js +132 -0
- package/dist/{chunk-7CE6OHLW.js → chunk-DTLUKSX2.js} +6 -2
- package/dist/{chunk-TK3AXXXI.js → chunk-EMEA45JQ.js} +10 -6
- package/dist/chunk-EQFLPRF7.js +130 -0
- package/dist/{chunk-M25QJBDN.js → chunk-GNRMH7D3.js} +18 -6
- package/dist/chunk-GYEKT5AY.js +102 -0
- package/dist/{chunk-SHZZ2QRV.js → chunk-HCWLIPXP.js} +5 -1
- package/dist/{chunk-WHKPWIQO.js → chunk-HMVEQB2T.js} +1 -0
- package/dist/chunk-HQ2UFI3S.js +116 -0
- package/dist/chunk-I52PC5IU.js +128 -0
- package/dist/{chunk-CB3C7CRD.js → chunk-IAIJG2PB.js} +10 -6
- package/dist/{chunk-NDJO56BB.js → chunk-IJILTFEL.js} +5 -1
- package/dist/{chunk-7GGR26YA.js → chunk-IRNU4JGV.js} +10 -6
- package/dist/chunk-IRPBFVAK.js +141 -0
- package/dist/chunk-JFBR4FNX.js +140 -0
- package/dist/{chunk-ERS6SNA5.js → chunk-K34N2CBL.js} +5 -1
- package/dist/chunk-LMMF7KXF.js +178 -0
- package/dist/chunk-LWGJ3QQZ.js +107 -0
- package/dist/chunk-MPNGQLHZ.js +132 -0
- package/dist/chunk-OH5LJAEJ.js +135 -0
- package/dist/{chunk-57GLKGEX.js → chunk-P6TMZSWF.js} +32 -7
- package/dist/chunk-PDHHOVVQ.js +126 -0
- package/dist/{chunk-7TIIRJKF.js → chunk-RUBKGAPS.js} +5 -1
- package/dist/chunk-S44ZHYE6.js +1912 -0
- package/dist/chunk-SFMJNAW3.js +128 -0
- package/dist/{chunk-E2MOFIDH.js → chunk-SKKVOH6D.js} +13 -7
- package/dist/{chunk-RR3XNDKG.js → chunk-T2LAQQDS.js} +1 -1
- package/dist/chunk-TSYXRRS4.js +125 -0
- package/dist/chunk-TZHO6P22.js +150 -0
- package/dist/chunk-V26L6MY6.js +127 -0
- package/dist/chunk-V4M46BF6.js +105 -0
- package/dist/chunk-VSFWETXS.js +127 -0
- package/dist/chunk-VU4LTE2X.js +147 -0
- package/dist/chunk-WF6HC5U3.js +8 -0
- package/dist/chunk-WG5NCDS4.js +99 -0
- package/dist/{chunk-7LHXAEOZ.js → chunk-WUYHS6JZ.js} +6 -2
- package/dist/chunk-XNRY6NOC.js +120 -0
- package/dist/{chunk-55CFXXZH.js → chunk-XT47QZQ6.js} +32 -7
- package/dist/chunk-Y5CCNMJI.js +58 -0
- package/dist/chunk-YVVB6YMG.js +133 -0
- package/dist/chunk-ZZXTGVGN.js +131 -0
- package/dist/combat-ai.d.ts +21 -0
- package/dist/combat-ai.js +41 -0
- package/dist/{components--RTwuT4S.d.ts → components-ClmBORMP.d.ts} +1 -1
- package/dist/cooldown.d.ts +2 -8
- package/dist/cooldown.js +3 -2
- package/dist/coordinators/boundary-ricochet-3d.d.ts +3 -2
- package/dist/coordinators/boundary-ricochet-3d.js +2 -2
- package/dist/coordinators/boundary-ricochet.d.ts +3 -2
- package/dist/coordinators/boundary-ricochet.js +2 -2
- package/dist/coordinators/multidirectional-space-shooter.d.ts +3 -2
- package/dist/coordinators/multidirectional-space-shooter.js +2 -2
- package/dist/coordinators/top-down-shooter.d.ts +3 -2
- package/dist/coordinators/top-down-shooter.js +2 -2
- package/dist/core.d.ts +387 -26
- package/dist/core.js +1583 -6
- package/dist/destructible-3d.d.ts +3 -2
- package/dist/destructible-3d.js +3 -2
- package/dist/destructible-prebake.d.ts +1 -1
- package/dist/environmental-locomotion.d.ts +23 -0
- package/dist/environmental-locomotion.js +35 -0
- package/dist/first-person.d.ts +3 -2
- package/dist/first-person.js +25 -4
- package/dist/golf-racket.d.ts +21 -0
- package/dist/golf-racket.js +37 -0
- package/dist/index.d.ts +28 -6
- package/dist/index.js +766 -82
- package/dist/jumper-2d.d.ts +2 -1
- package/dist/jumper-2d.js +25 -4
- package/dist/jumper-3d.d.ts +2 -1
- package/dist/jumper-3d.js +25 -4
- package/dist/lane-defense.d.ts +21 -0
- package/dist/lane-defense.js +39 -0
- package/dist/life-simulation.d.ts +21 -0
- package/dist/life-simulation.js +39 -0
- package/dist/matching-pinball.d.ts +21 -0
- package/dist/matching-pinball.js +39 -0
- package/dist/melee-combat.d.ts +22 -0
- package/dist/melee-combat.js +45 -0
- package/dist/{moveable-CFOHmblC.d.ts → moveable-CXK2wEZL.d.ts} +2 -2
- package/dist/particle-emitter/presets.d.ts +1 -1
- package/dist/particle-emitter.d.ts +5 -4
- package/dist/particle-emitter.js +3 -2
- package/dist/{payload-BQzu-oY_.d.ts → payload-WEzfgjSL.d.ts} +1 -1
- package/dist/platformer-2d.d.ts +2 -1
- package/dist/platformer-2d.js +25 -4
- package/dist/platformer-3d.d.ts +2 -1
- package/dist/platformer-3d.js +25 -4
- package/dist/racing-vehicles.d.ts +21 -0
- package/dist/racing-vehicles.js +37 -0
- package/dist/rhythm-performance.d.ts +21 -0
- package/dist/rhythm-performance.js +39 -0
- package/dist/ricochet-2d.d.ts +2 -1
- package/dist/ricochet-2d.js +25 -4
- package/dist/ricochet-3d.d.ts +2 -1
- package/dist/ricochet-3d.js +25 -4
- package/dist/runtime-2d.d.ts +2 -1
- package/dist/runtime-2d.js +10 -1
- package/dist/screen-visibility.d.ts +2 -1
- package/dist/screen-visibility.js +3 -2
- package/dist/screen-wrap.d.ts +2 -7
- package/dist/screen-wrap.js +4 -3
- package/dist/shooter-2d.d.ts +3 -2
- package/dist/shooter-2d.js +3 -2
- package/dist/skate-snowboard.d.ts +21 -0
- package/dist/skate-snowboard.js +37 -0
- package/dist/{spark-C4Tp-52_.d.ts → spark-VoQoemz_.d.ts} +1 -1
- package/dist/spatial-puzzles.d.ts +21 -0
- package/dist/spatial-puzzles.js +35 -0
- package/dist/squad-rts.d.ts +21 -0
- package/dist/squad-rts.js +39 -0
- package/dist/stealth-city.d.ts +21 -0
- package/dist/stealth-city.js +41 -0
- package/dist/survival-resources.d.ts +21 -0
- package/dist/survival-resources.js +37 -0
- package/dist/tactical-grid.d.ts +21 -0
- package/dist/tactical-grid.js +39 -0
- package/dist/thruster.d.ts +2 -1
- package/dist/thruster.js +4 -3
- package/dist/top-down-movement.d.ts +2 -1
- package/dist/top-down-movement.js +24 -3
- package/dist/turn-based-rpg.d.ts +21 -0
- package/dist/turn-based-rpg.js +39 -0
- package/dist/{vector-DjhLUrak.d.ts → vector-s7GbCrVn.d.ts} +1 -1
- package/dist/weapon-systems.d.ts +22 -0
- package/dist/weapon-systems.js +45 -0
- package/dist/world-boundary-2d.d.ts +2 -1
- package/dist/world-boundary-2d.js +25 -4
- package/dist/world-boundary-3d.d.ts +2 -1
- package/dist/world-boundary-3d.js +26 -5
- package/package.json +90 -5
- package/dist/behavior-system-DkFAwLb_.d.ts +0 -914
- package/dist/chunk-GZ3DQIIZ.js +0 -888
- package/dist/{chunk-OSPQFWQF.js → chunk-4K37UL53.js} +3 -3
- package/dist/{chunk-DD4U42FG.js → chunk-AQB246W5.js} +3 -3
- package/dist/{chunk-UKGBQTHL.js → chunk-CXDNR4R4.js} +3 -3
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// src/lib/behaviors/golf-racket/types.ts
|
|
2
|
+
var SPORTS_ABILITIES = [
|
|
3
|
+
"swing-power-accuracy",
|
|
4
|
+
"club-shot-profile",
|
|
5
|
+
"wind-drag-ball-flight",
|
|
6
|
+
"landing-spin-transfer",
|
|
7
|
+
"slope-aware-putting",
|
|
8
|
+
"racket-contact-timing",
|
|
9
|
+
"racket-spin-shot",
|
|
10
|
+
"lob-and-drop-placement",
|
|
11
|
+
"serve-and-fault-sequence",
|
|
12
|
+
"rally-point-adjudication"
|
|
13
|
+
];
|
|
14
|
+
function sportsData(o) {
|
|
15
|
+
return [
|
|
16
|
+
o.swingDuration ?? 1,
|
|
17
|
+
o.idealImpactTime ?? 0.5,
|
|
18
|
+
o.accuracyWindow ?? 0.2,
|
|
19
|
+
o.ballRadius ?? 0.1,
|
|
20
|
+
o.drag ?? 0.04,
|
|
21
|
+
o.lift ?? 5e-3,
|
|
22
|
+
o.gravity ?? 9.81,
|
|
23
|
+
o.restitution ?? 0.5,
|
|
24
|
+
o.rollingResistance ?? 0.8,
|
|
25
|
+
o.cupRadius ?? 0.3,
|
|
26
|
+
o.cupMaximumSpeed ?? 1.5,
|
|
27
|
+
o.racketWindow ?? 0.15,
|
|
28
|
+
o.maximumSpin ?? 60,
|
|
29
|
+
o.maximumSpeed ?? 80,
|
|
30
|
+
o.courtHalfWidth ?? 4,
|
|
31
|
+
o.courtHalfLength ?? 10
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function sportsOperation(a) {
|
|
35
|
+
switch (a.type) {
|
|
36
|
+
case "swing-start":
|
|
37
|
+
return { op: 0, data: [] };
|
|
38
|
+
case "swing-power":
|
|
39
|
+
return { op: 1, data: [] };
|
|
40
|
+
case "swing-impact":
|
|
41
|
+
return { op: 2, data: [] };
|
|
42
|
+
case "swing-cancel":
|
|
43
|
+
return { op: 3, data: [] };
|
|
44
|
+
case "club-profile":
|
|
45
|
+
return { op: 4, data: [a.speed, a.loft, a.spin] };
|
|
46
|
+
case "club-shot":
|
|
47
|
+
return {
|
|
48
|
+
op: 5,
|
|
49
|
+
data: [...a.aim, a.power, a.error, a.lie, a.swingSerial]
|
|
50
|
+
};
|
|
51
|
+
case "flight-start":
|
|
52
|
+
return { op: 8, data: [...a.velocity, ...a.spin, a.shotSerial] };
|
|
53
|
+
case "wind":
|
|
54
|
+
return { op: 9, data: [...a.velocity, a.drag, a.lift] };
|
|
55
|
+
case "flight-stop":
|
|
56
|
+
return { op: 10, data: [] };
|
|
57
|
+
case "landing-spin":
|
|
58
|
+
return { op: 12, data: [...a.spin] };
|
|
59
|
+
case "spin-transfer":
|
|
60
|
+
return { op: 13, data: [] };
|
|
61
|
+
case "putt":
|
|
62
|
+
return { op: 16, data: [...a.velocity] };
|
|
63
|
+
case "putt-stop":
|
|
64
|
+
return { op: 17, data: [] };
|
|
65
|
+
case "racket-swing":
|
|
66
|
+
return { op: 20, data: [] };
|
|
67
|
+
case "racket-cancel":
|
|
68
|
+
return { op: 21, data: [] };
|
|
69
|
+
case "spin-shot":
|
|
70
|
+
return { op: 24, data: [...a.aim, a.mode, a.power, a.contactSerial] };
|
|
71
|
+
case "placement":
|
|
72
|
+
return { op: 28, data: [...a.position, a.apex] };
|
|
73
|
+
case "serve-start":
|
|
74
|
+
return { op: 32, data: [a.server, a.boxSide, a.serviceDepth] };
|
|
75
|
+
case "serve-strike":
|
|
76
|
+
return { op: 33, data: [] };
|
|
77
|
+
case "serve-contact":
|
|
78
|
+
return { op: 34, data: [a.kind === "net" ? 0 : 1] };
|
|
79
|
+
case "rally-start":
|
|
80
|
+
return { op: 36, data: [a.lastHitter] };
|
|
81
|
+
case "rally-hit":
|
|
82
|
+
return { op: 37, data: [a.player, a.contactSerial] };
|
|
83
|
+
case "rally-bounce":
|
|
84
|
+
return { op: 38, data: [] };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
SPORTS_ABILITIES,
|
|
90
|
+
sportsData,
|
|
91
|
+
sportsOperation
|
|
92
|
+
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SyncStateMachine,
|
|
3
|
-
import_typescript_fsm
|
|
4
|
-
} from "./chunk-OBF6BIA2.js";
|
|
5
1
|
import {
|
|
6
2
|
STAGE_INPUT_BUTTON_JUMP,
|
|
7
3
|
readBehaviorSnapshot
|
|
8
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BR33KT4Z.js";
|
|
5
|
+
import {
|
|
6
|
+
SyncStateMachine,
|
|
7
|
+
import_typescript_fsm
|
|
8
|
+
} from "./chunk-CBQSC6W3.js";
|
|
9
9
|
import {
|
|
10
10
|
defineBehavior
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5SMXQ6AU.js";
|
|
12
|
+
import {
|
|
13
|
+
BUILTIN_BEHAVIORS
|
|
14
|
+
} from "./chunk-S44ZHYE6.js";
|
|
12
15
|
|
|
13
16
|
// src/lib/behaviors/jumper-2d/components.ts
|
|
14
17
|
function createJumpConfig2D(options = {}) {
|
|
@@ -175,6 +178,7 @@ var Jumper2DBehaviorSystem = class {
|
|
|
175
178
|
};
|
|
176
179
|
var Jumper2DBehavior = defineBehavior({
|
|
177
180
|
name: "jumper-2d",
|
|
181
|
+
metadata: BUILTIN_BEHAVIORS["jumper-2d"],
|
|
178
182
|
defaultOptions,
|
|
179
183
|
systemFactory: (ctx) => new Jumper2DBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),
|
|
180
184
|
// Handles read the runtime snapshot buffer (previous-step values). The
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SPORTS_ABILITIES
|
|
3
|
+
} from "./chunk-7IOQEXYR.js";
|
|
4
|
+
import {
|
|
5
|
+
defineBehavior
|
|
6
|
+
} from "./chunk-5SMXQ6AU.js";
|
|
7
|
+
import {
|
|
8
|
+
BUILTIN_BEHAVIORS
|
|
9
|
+
} from "./chunk-S44ZHYE6.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/behaviors/golf-racket/index.ts
|
|
12
|
+
var SportsSystem = class {
|
|
13
|
+
constructor(key, abilities, runtime, links) {
|
|
14
|
+
this.key = key;
|
|
15
|
+
this.abilities = abilities;
|
|
16
|
+
this.runtime = runtime;
|
|
17
|
+
this.links = links;
|
|
18
|
+
}
|
|
19
|
+
key;
|
|
20
|
+
abilities;
|
|
21
|
+
runtime;
|
|
22
|
+
links;
|
|
23
|
+
attached = /* @__PURE__ */ new Map();
|
|
24
|
+
update() {
|
|
25
|
+
if (!this.runtime) return;
|
|
26
|
+
const links = [...this.links?.(this.key) ?? []];
|
|
27
|
+
for (const [entity, { slot, ref }] of this.attached) {
|
|
28
|
+
if (!links.some((link) => link.entity === entity && link.ref === ref) || entity.runtimeHandle !== slot)
|
|
29
|
+
this.detach({ entity, ref });
|
|
30
|
+
}
|
|
31
|
+
for (const link of links) {
|
|
32
|
+
const entity = link.entity;
|
|
33
|
+
entity.sportsState ??= null;
|
|
34
|
+
const slot = entity.runtimeHandle;
|
|
35
|
+
if (!Number.isInteger(slot) || slot < 0) continue;
|
|
36
|
+
if (!this.attached.has(entity)) {
|
|
37
|
+
if (!this.runtime.attachSports(
|
|
38
|
+
slot,
|
|
39
|
+
this.abilities,
|
|
40
|
+
link.ref.options
|
|
41
|
+
)) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"Sports attachment requires valid options and an available sports component slot."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
this.attached.set(entity, { slot, ref: link.ref });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
postUpdate() {
|
|
51
|
+
for (const [entity, { slot }] of this.attached)
|
|
52
|
+
entity.sportsState = this.runtime?.querySports(slot) ?? null;
|
|
53
|
+
}
|
|
54
|
+
detach(link) {
|
|
55
|
+
const slot = this.attached.get(link.entity)?.slot;
|
|
56
|
+
if (slot !== void 0 && this.runtime && !this.runtime.detachSports(slot) && this.runtime.querySports(slot))
|
|
57
|
+
throw new Error("Failed to detach sports policy.");
|
|
58
|
+
this.attached.delete(link.entity);
|
|
59
|
+
link.entity.sportsState = null;
|
|
60
|
+
}
|
|
61
|
+
destroy() {
|
|
62
|
+
for (const [entity, { ref }] of this.attached) this.detach({ entity, ref });
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
function descriptor(name, abilities) {
|
|
66
|
+
return defineBehavior({
|
|
67
|
+
name,
|
|
68
|
+
metadata: BUILTIN_BEHAVIORS[name],
|
|
69
|
+
defaultOptions: {
|
|
70
|
+
ballRadius: 0.1,
|
|
71
|
+
maximumSpeed: 80
|
|
72
|
+
},
|
|
73
|
+
systemFactory: (ctx) => new SportsSystem(
|
|
74
|
+
/* @__PURE__ */ Symbol.for(`zylem:behavior:${name}`),
|
|
75
|
+
abilities,
|
|
76
|
+
ctx.wasmStage ?? null,
|
|
77
|
+
ctx.getBehaviorLinks
|
|
78
|
+
)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
var GolfRacketBehavior = descriptor("golf-racket", SPORTS_ABILITIES);
|
|
82
|
+
var SwingPowerAccuracyBehavior = descriptor("swing-power-accuracy", [
|
|
83
|
+
"swing-power-accuracy"
|
|
84
|
+
]);
|
|
85
|
+
var ClubShotProfileBehavior = descriptor("club-shot-profile", [
|
|
86
|
+
"club-shot-profile"
|
|
87
|
+
]);
|
|
88
|
+
var WindDragBallFlightBehavior = descriptor("wind-drag-ball-flight", [
|
|
89
|
+
"wind-drag-ball-flight"
|
|
90
|
+
]);
|
|
91
|
+
var LandingSpinTransferBehavior = descriptor("landing-spin-transfer", [
|
|
92
|
+
"landing-spin-transfer"
|
|
93
|
+
]);
|
|
94
|
+
var SlopeAwarePuttingBehavior = descriptor("slope-aware-putting", [
|
|
95
|
+
"slope-aware-putting"
|
|
96
|
+
]);
|
|
97
|
+
var RacketContactTimingBehavior = descriptor("racket-contact-timing", [
|
|
98
|
+
"racket-contact-timing"
|
|
99
|
+
]);
|
|
100
|
+
var RacketSpinShotBehavior = descriptor("racket-spin-shot", [
|
|
101
|
+
"racket-spin-shot"
|
|
102
|
+
]);
|
|
103
|
+
var LobAndDropPlacementBehavior = descriptor("lob-and-drop-placement", [
|
|
104
|
+
"lob-and-drop-placement"
|
|
105
|
+
]);
|
|
106
|
+
var ServeAndFaultSequenceBehavior = descriptor("serve-and-fault-sequence", [
|
|
107
|
+
"serve-and-fault-sequence"
|
|
108
|
+
]);
|
|
109
|
+
var RallyPointAdjudicationBehavior = descriptor(
|
|
110
|
+
"rally-point-adjudication",
|
|
111
|
+
["rally-point-adjudication"]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
GolfRacketBehavior,
|
|
116
|
+
SwingPowerAccuracyBehavior,
|
|
117
|
+
ClubShotProfileBehavior,
|
|
118
|
+
WindDragBallFlightBehavior,
|
|
119
|
+
LandingSpinTransferBehavior,
|
|
120
|
+
SlopeAwarePuttingBehavior,
|
|
121
|
+
RacketContactTimingBehavior,
|
|
122
|
+
RacketSpinShotBehavior,
|
|
123
|
+
LobAndDropPlacementBehavior,
|
|
124
|
+
ServeAndFaultSequenceBehavior,
|
|
125
|
+
RallyPointAdjudicationBehavior
|
|
126
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ENVIRONMENT_ABILITIES
|
|
3
|
+
} from "./chunk-DDLZLJ7W.js";
|
|
4
|
+
import {
|
|
5
|
+
defineBehavior
|
|
6
|
+
} from "./chunk-5SMXQ6AU.js";
|
|
7
|
+
import {
|
|
8
|
+
BUILTIN_BEHAVIORS
|
|
9
|
+
} from "./chunk-S44ZHYE6.js";
|
|
10
|
+
|
|
11
|
+
// src/lib/behaviors/environmental-locomotion/index.ts
|
|
12
|
+
var EnvironmentSystem = class {
|
|
13
|
+
constructor(key, abilities, runtime, links) {
|
|
14
|
+
this.key = key;
|
|
15
|
+
this.abilities = abilities;
|
|
16
|
+
this.runtime = runtime;
|
|
17
|
+
this.links = links;
|
|
18
|
+
}
|
|
19
|
+
key;
|
|
20
|
+
abilities;
|
|
21
|
+
runtime;
|
|
22
|
+
links;
|
|
23
|
+
attached = /* @__PURE__ */ new Map();
|
|
24
|
+
update() {
|
|
25
|
+
if (!this.runtime) return;
|
|
26
|
+
const links = [...this.links?.(this.key) ?? []];
|
|
27
|
+
for (const [entity, { slot, ref }] of this.attached) {
|
|
28
|
+
if (!links.some((link) => link.entity === entity && link.ref === ref) || entity.runtimeHandle !== slot) this.detach({ entity, ref });
|
|
29
|
+
}
|
|
30
|
+
for (const link of links) {
|
|
31
|
+
const entity = link.entity;
|
|
32
|
+
entity.$environment ??= {};
|
|
33
|
+
entity.environmentState ??= null;
|
|
34
|
+
const slot = entity.runtimeHandle;
|
|
35
|
+
if (!Number.isInteger(slot) || slot < 0) continue;
|
|
36
|
+
if (!this.attached.has(entity)) {
|
|
37
|
+
if (!this.runtime.attachEnvironment(slot, this.abilities, link.ref.options)) {
|
|
38
|
+
throw new Error("Environmental locomotion requires exclusive motion ownership, a dynamic solid body with gravityScale=0, and compatible rotation locks.");
|
|
39
|
+
}
|
|
40
|
+
this.attached.set(entity, { slot, ref: link.ref });
|
|
41
|
+
}
|
|
42
|
+
this.runtime.writeEnvironmentInput(slot, entity.$environment);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
postUpdate() {
|
|
46
|
+
for (const [entity, { slot }] of this.attached) entity.environmentState = this.runtime?.queryEnvironment(slot) ?? null;
|
|
47
|
+
}
|
|
48
|
+
detach(link) {
|
|
49
|
+
const slot = this.attached.get(link.entity)?.slot;
|
|
50
|
+
if (slot !== void 0) this.runtime?.detachEnvironment(slot);
|
|
51
|
+
this.attached.delete(link.entity);
|
|
52
|
+
link.entity.environmentState = null;
|
|
53
|
+
}
|
|
54
|
+
destroy() {
|
|
55
|
+
for (const [entity, { ref }] of this.attached) this.detach({ entity, ref });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function descriptor(name, abilities) {
|
|
59
|
+
return defineBehavior({
|
|
60
|
+
name,
|
|
61
|
+
metadata: BUILTIN_BEHAVIORS[name],
|
|
62
|
+
defaultOptions: { gravity: 9.81, speed: 6, drag: 1.5, buoyancy: 1.6, turnRate: Math.PI, breathCapacity: 8, staminaCapacity: 5 },
|
|
63
|
+
systemFactory: (ctx) => new EnvironmentSystem(/* @__PURE__ */ Symbol.for(`zylem:behavior:${name}`), abilities, ctx.wasmStage ?? null, ctx.getBehaviorLinks)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
var EnvironmentalLocomotionBehavior = descriptor("environmental-locomotion", ENVIRONMENT_ABILITIES);
|
|
67
|
+
var LocalGravityFieldBehavior = descriptor("local-gravity-field", ["local-gravity-field"]);
|
|
68
|
+
var GravityFrameTransitionBehavior = descriptor("gravity-frame-transition", ["gravity-frame-transition"]);
|
|
69
|
+
var VolumeBuoyancyBehavior = descriptor("volume-buoyancy", ["volume-buoyancy"]);
|
|
70
|
+
var StrokeSwimmingBehavior = descriptor("stroke-swimming", ["stroke-swimming"]);
|
|
71
|
+
var SurfaceBreachJumpBehavior = descriptor("surface-breach-jump", ["surface-breach-jump"]);
|
|
72
|
+
var BreathAndDrowningBehavior = descriptor("breath-and-drowning", ["breath-and-drowning"]);
|
|
73
|
+
var WaterCurrentAdvectionBehavior = descriptor("water-current-advection", ["water-current-advection"]);
|
|
74
|
+
var WindDrivenSailingBehavior = descriptor("wind-driven-sailing", ["wind-driven-sailing"]);
|
|
75
|
+
var StaminaGlideAndUpdraftBehavior = descriptor("stamina-glide-and-updraft", ["stamina-glide-and-updraft"]);
|
|
76
|
+
var TubeSlideSteeringBehavior = descriptor("tube-slide-steering", ["tube-slide-steering"]);
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
EnvironmentalLocomotionBehavior,
|
|
80
|
+
LocalGravityFieldBehavior,
|
|
81
|
+
GravityFrameTransitionBehavior,
|
|
82
|
+
VolumeBuoyancyBehavior,
|
|
83
|
+
StrokeSwimmingBehavior,
|
|
84
|
+
SurfaceBreachJumpBehavior,
|
|
85
|
+
BreathAndDrowningBehavior,
|
|
86
|
+
WaterCurrentAdvectionBehavior,
|
|
87
|
+
WindDrivenSailingBehavior,
|
|
88
|
+
StaminaGlideAndUpdraftBehavior,
|
|
89
|
+
TubeSlideSteeringBehavior
|
|
90
|
+
};
|