@zylem/behaviors 0.3.1 → 0.4.1
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/behavior-system-y8SGrGWy.d.ts +580 -0
- package/dist/{chunk-ARJWUNRE.js → chunk-27UPCP5B.js} +10 -10
- package/dist/{chunk-ARJWUNRE.js.map → chunk-27UPCP5B.js.map} +1 -1
- package/dist/{chunk-YUO6SKJD.js → chunk-4L36OPY2.js} +33 -23
- package/dist/chunk-4L36OPY2.js.map +1 -0
- package/dist/{chunk-DYLH6K7B.js → chunk-4WH2ZN7P.js} +1 -1
- package/dist/{chunk-DYLH6K7B.js.map → chunk-4WH2ZN7P.js.map} +1 -1
- package/dist/{chunk-ZPSAXX73.js → chunk-5SM5SH5O.js} +26 -26
- package/dist/chunk-5SM5SH5O.js.map +1 -0
- package/dist/{chunk-STCCNLPC.js → chunk-5XZWTFGF.js} +5 -3
- package/dist/chunk-5XZWTFGF.js.map +1 -0
- package/dist/{chunk-JAN34G6S.js → chunk-67XLJ26X.js} +152 -168
- package/dist/chunk-67XLJ26X.js.map +1 -0
- package/dist/{chunk-2CLT36VB.js → chunk-75FJIUIG.js} +22 -23
- package/dist/chunk-75FJIUIG.js.map +1 -0
- package/dist/{chunk-OYWFPIHF.js → chunk-A4CA35DQ.js} +20 -17
- package/dist/chunk-A4CA35DQ.js.map +1 -0
- package/dist/{chunk-SS7ELMJ7.js → chunk-F72WX4MH.js} +49 -33
- package/dist/chunk-F72WX4MH.js.map +1 -0
- package/dist/{chunk-RTRVBEIB.js → chunk-FTDZAKZW.js} +5 -18
- package/dist/chunk-FTDZAKZW.js.map +1 -0
- package/dist/{chunk-XIJNE67Y.js → chunk-GFARAJV2.js} +3 -5
- package/dist/{chunk-XIJNE67Y.js.map → chunk-GFARAJV2.js.map} +1 -1
- package/dist/{chunk-VAN4WW3F.js → chunk-H4TJ7X4O.js} +4 -7
- package/dist/chunk-H4TJ7X4O.js.map +1 -0
- package/dist/{chunk-KS72RZHX.js → chunk-IZJFUAXB.js} +1 -1
- package/dist/{chunk-KS72RZHX.js.map → chunk-IZJFUAXB.js.map} +1 -1
- package/dist/{chunk-SVLNF434.js → chunk-JXMF4NUI.js} +51 -3
- package/dist/chunk-JXMF4NUI.js.map +1 -0
- package/dist/chunk-KFFETUAL.js +40 -0
- package/dist/chunk-KFFETUAL.js.map +1 -0
- package/dist/chunk-LL4FLHIY.js +12 -0
- package/dist/chunk-LL4FLHIY.js.map +1 -0
- package/dist/{chunk-RTVRUNYR.js → chunk-OTLSUYQQ.js} +2 -2
- package/dist/chunk-OTLSUYQQ.js.map +1 -0
- package/dist/{chunk-Y6UJOUE5.js → chunk-Q75LKHDF.js} +14 -2
- package/dist/chunk-Q75LKHDF.js.map +1 -0
- package/dist/{chunk-KOZUNIIE.js → chunk-QDCJLJUV.js} +10 -10
- package/dist/{chunk-KOZUNIIE.js.map → chunk-QDCJLJUV.js.map} +1 -1
- package/dist/{chunk-LD5SMIB3.js → chunk-QVCMJ4Q2.js} +1 -1
- package/dist/{chunk-LD5SMIB3.js.map → chunk-QVCMJ4Q2.js.map} +1 -1
- package/dist/{chunk-F3KRX2V4.js → chunk-RDHSHEZM.js} +46 -24
- package/dist/chunk-RDHSHEZM.js.map +1 -0
- package/dist/chunk-UIG7MWS2.js +518 -0
- package/dist/chunk-UIG7MWS2.js.map +1 -0
- package/dist/{chunk-6C6NXNEW.js → chunk-UL6Q5HDP.js} +25 -3
- package/dist/chunk-UL6Q5HDP.js.map +1 -0
- package/dist/{chunk-XG2YMCJW.js → chunk-VMQHNJJI.js} +6 -8
- package/dist/{chunk-XG2YMCJW.js.map → chunk-VMQHNJJI.js.map} +1 -1
- package/dist/{chunk-GCNRXAKH.js → chunk-XP3ASVGJ.js} +13 -10
- package/dist/chunk-XP3ASVGJ.js.map +1 -0
- package/dist/{chunk-ID5QJYF5.js → chunk-Y7YIAWPW.js} +11 -1
- package/dist/chunk-Y7YIAWPW.js.map +1 -0
- package/dist/{chunk-4I6E6DGV.js → chunk-Z72F2ENM.js} +6 -8
- package/dist/{chunk-4I6E6DGV.js.map → chunk-Z72F2ENM.js.map} +1 -1
- package/dist/{chunk-FPTWVCPN.js → chunk-ZA43LPRM.js} +4 -24
- package/dist/chunk-ZA43LPRM.js.map +1 -0
- package/dist/{chunk-K3UNLQ7W.js → chunk-ZRQWSURL.js} +2 -2
- package/dist/chunk-ZRQWSURL.js.map +1 -0
- package/dist/cooldown.d.ts +2 -1
- package/dist/cooldown.js +1 -1
- package/dist/coordinators/boundary-ricochet-3d.d.ts +12 -5
- package/dist/coordinators/boundary-ricochet-3d.js +2 -1
- package/dist/coordinators/boundary-ricochet.d.ts +9 -7
- package/dist/coordinators/boundary-ricochet.js +2 -1
- package/dist/coordinators/first-person-shooter.d.ts +9 -8
- package/dist/coordinators/first-person-shooter.js +3 -3
- package/dist/coordinators/multidirectional-space-shooter.d.ts +12 -9
- package/dist/coordinators/multidirectional-space-shooter.js +4 -4
- package/dist/coordinators/top-down-shooter.d.ts +9 -8
- package/dist/coordinators/top-down-shooter.js +3 -3
- package/dist/core.d.ts +4 -4
- package/dist/core.js +17 -39
- package/dist/core.js.map +1 -1
- package/dist/destructible-3d.d.ts +2 -1
- package/dist/first-person.d.ts +12 -12
- package/dist/first-person.js +9 -8
- package/dist/index.d.ts +37 -14
- package/dist/index.js +73 -44
- package/dist/jumper-2d.d.ts +7 -6
- package/dist/jumper-2d.js +6 -5
- package/dist/jumper-3d.d.ts +12 -11
- package/dist/jumper-3d.js +7 -6
- package/dist/{moveable-BCRpjAQb.d.ts → moveable-Cl9h-_w7.d.ts} +2 -78
- package/dist/particle-emitter.d.ts +1 -1
- package/dist/particle-emitter.js +1 -1
- package/dist/platformer-2d.d.ts +306 -0
- package/dist/platformer-2d.js +24 -0
- package/dist/platformer-3d.d.ts +74 -87
- package/dist/platformer-3d.js +5 -4
- package/dist/ricochet-2d.d.ts +1 -1
- package/dist/ricochet-2d.js +2 -2
- package/dist/ricochet-3d.d.ts +1 -1
- package/dist/ricochet-3d.js +2 -2
- package/dist/runtime-2d.d.ts +93 -2
- package/dist/runtime-2d.js +145 -22
- package/dist/runtime-2d.js.map +1 -1
- package/dist/screen-visibility.d.ts +2 -1
- package/dist/screen-wrap.d.ts +2 -1
- package/dist/screen-wrap.js +1 -1
- package/dist/shooter-2d.d.ts +5 -3
- package/dist/shooter-2d.js +2 -2
- package/dist/shooter-fire-DGripl0z.d.ts +55 -0
- package/dist/thruster.d.ts +8 -18
- package/dist/thruster.js +6 -6
- package/dist/top-down-movement.d.ts +7 -4
- package/dist/top-down-movement.js +5 -5
- package/dist/{use-behavior-D_82jAL3.d.ts → use-behavior-B85d5u7-.d.ts} +1 -1
- package/dist/world-boundary-2d.d.ts +2 -1
- package/dist/world-boundary-2d.js +2 -2
- package/dist/world-boundary-3d.d.ts +2 -1
- package/dist/world-boundary-3d.js +2 -2
- package/package.json +7 -5
- package/dist/behavior-system-DYbx-x_-.d.ts +0 -307
- package/dist/chunk-2C3Z5GE7.js +0 -176
- package/dist/chunk-2C3Z5GE7.js.map +0 -1
- package/dist/chunk-2CLT36VB.js.map +0 -1
- package/dist/chunk-3PYGRHAL.js +0 -35
- package/dist/chunk-3PYGRHAL.js.map +0 -1
- package/dist/chunk-6C6NXNEW.js.map +0 -1
- package/dist/chunk-F3KRX2V4.js.map +0 -1
- package/dist/chunk-FPTWVCPN.js.map +0 -1
- package/dist/chunk-GCNRXAKH.js.map +0 -1
- package/dist/chunk-ID5QJYF5.js.map +0 -1
- package/dist/chunk-JAN34G6S.js.map +0 -1
- package/dist/chunk-K3UNLQ7W.js.map +0 -1
- package/dist/chunk-OYWFPIHF.js.map +0 -1
- package/dist/chunk-RTRVBEIB.js.map +0 -1
- package/dist/chunk-RTVRUNYR.js.map +0 -1
- package/dist/chunk-SS7ELMJ7.js.map +0 -1
- package/dist/chunk-STCCNLPC.js.map +0 -1
- package/dist/chunk-SVLNF434.js.map +0 -1
- package/dist/chunk-VAN4WW3F.js.map +0 -1
- package/dist/chunk-Y6UJOUE5.js.map +0 -1
- package/dist/chunk-YUO6SKJD.js.map +0 -1
- package/dist/chunk-ZPSAXX73.js.map +0 -1
- package/dist/runtime-pong.d.ts +0 -92
- package/dist/runtime-pong.js +0 -38
- /package/dist/{runtime-pong.js.map → platformer-2d.js.map} +0 -0
package/dist/runtime-2d.d.ts
CHANGED
|
@@ -1,2 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { a as BehaviorDescriptor, d as BehaviorRef } from './behavior-system-y8SGrGWy.js';
|
|
2
|
+
import '@dimforge/rapier3d-compat';
|
|
3
|
+
|
|
4
|
+
interface RuntimeDynamicCircleBody2DOptions {
|
|
5
|
+
initialVelocity: readonly [number, number];
|
|
6
|
+
}
|
|
7
|
+
interface RuntimeDynamicCircleBody2DHandle {
|
|
8
|
+
setRuntimePosition(x: number, y: number, z?: number): void;
|
|
9
|
+
setRuntimeVelocity(x: number, y: number): void;
|
|
10
|
+
getRuntimePosition(): {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
interface RuntimePlayerInput2DOptions {
|
|
17
|
+
player: 'p1' | 'p2';
|
|
18
|
+
speed: number;
|
|
19
|
+
}
|
|
20
|
+
interface RuntimeBoundary2DOptions {
|
|
21
|
+
boundaries: {
|
|
22
|
+
left: number;
|
|
23
|
+
right: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
top: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface RuntimeRicochet2DOptions {
|
|
29
|
+
minSpeed: number;
|
|
30
|
+
maxSpeed: number;
|
|
31
|
+
speedMultiplier: number;
|
|
32
|
+
reflectionMode: 'simple' | 'angled';
|
|
33
|
+
maxAngleDeg: number;
|
|
34
|
+
}
|
|
35
|
+
interface RuntimeRicochet2DEvent {
|
|
36
|
+
kind: 'wall' | 'paddle';
|
|
37
|
+
}
|
|
38
|
+
interface RuntimeRicochet2DHandle {
|
|
39
|
+
onRicochet(callback: (event: RuntimeRicochet2DEvent) => void): () => void;
|
|
40
|
+
}
|
|
41
|
+
/** Registers a gameplay2d trigger AABB (sensor); wasm reports overlap via {@link emitRuntimeTriggerRegionEnter}. */
|
|
42
|
+
interface RuntimeTriggerRegion2DOptions {
|
|
43
|
+
triggerId: number;
|
|
44
|
+
halfExtents: readonly [number, number];
|
|
45
|
+
}
|
|
46
|
+
interface RuntimeTriggerRegion2DEvent {
|
|
47
|
+
triggerId: number;
|
|
48
|
+
}
|
|
49
|
+
interface RuntimeTriggerRegion2DHandle {
|
|
50
|
+
onRegionEnter(callback: (event: RuntimeTriggerRegion2DEvent) => void): () => void;
|
|
51
|
+
}
|
|
52
|
+
interface RuntimeGoalZone2DOptions {
|
|
53
|
+
scorer: 'p1' | 'p2';
|
|
54
|
+
}
|
|
55
|
+
interface RuntimeGoalZone2DEvent {
|
|
56
|
+
scorer: 'p1' | 'p2';
|
|
57
|
+
}
|
|
58
|
+
interface RuntimeGoalZone2DHandle {
|
|
59
|
+
onGoal(callback: (event: RuntimeGoalZone2DEvent) => void): () => void;
|
|
60
|
+
}
|
|
61
|
+
declare const RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY: unique symbol;
|
|
62
|
+
declare const RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY: unique symbol;
|
|
63
|
+
declare const RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY: unique symbol;
|
|
64
|
+
declare const RUNTIME_RICOCHET_2D_BEHAVIOR_KEY: unique symbol;
|
|
65
|
+
declare const RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY: unique symbol;
|
|
66
|
+
declare const RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY: unique symbol;
|
|
67
|
+
declare const RuntimeDynamicCircleBody2DBehavior: BehaviorDescriptor<RuntimeDynamicCircleBody2DOptions, RuntimeDynamicCircleBody2DHandle, unknown>;
|
|
68
|
+
declare const RuntimePlayerInput2DBehavior: BehaviorDescriptor<RuntimePlayerInput2DOptions, Record<string, never>, unknown>;
|
|
69
|
+
declare const RuntimeBoundary2DBehavior: BehaviorDescriptor<{
|
|
70
|
+
boundaries: {
|
|
71
|
+
left: number;
|
|
72
|
+
right: number;
|
|
73
|
+
bottom: number;
|
|
74
|
+
top: number;
|
|
75
|
+
};
|
|
76
|
+
}, Record<string, never>, unknown>;
|
|
77
|
+
declare const RuntimeRicochet2DBehavior: BehaviorDescriptor<RuntimeRicochet2DOptions, RuntimeRicochet2DHandle, unknown>;
|
|
78
|
+
declare const RuntimeTriggerRegion2DBehavior: BehaviorDescriptor<RuntimeTriggerRegion2DOptions, RuntimeTriggerRegion2DHandle, unknown>;
|
|
79
|
+
declare const RuntimeGoalZone2DBehavior: BehaviorDescriptor<RuntimeGoalZone2DOptions, RuntimeGoalZone2DHandle, unknown>;
|
|
80
|
+
declare function emitRuntimeRicochet(ref: BehaviorRef<RuntimeRicochet2DOptions>, event: RuntimeRicochet2DEvent): void;
|
|
81
|
+
declare function emitRuntimeTriggerRegionEnter(ref: BehaviorRef<RuntimeTriggerRegion2DOptions>, event: RuntimeTriggerRegion2DEvent): void;
|
|
82
|
+
declare function emitRuntimeGoal(ref: BehaviorRef<RuntimeGoalZone2DOptions>, event: RuntimeGoalZone2DEvent): void;
|
|
83
|
+
declare function bindRuntimeDynamicCircleBody2DHandle(ref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>, controls: {
|
|
84
|
+
setPosition: (x: number, y: number, z: number) => void;
|
|
85
|
+
setVelocity: (x: number, y: number) => void;
|
|
86
|
+
getPosition: () => {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
z: number;
|
|
90
|
+
} | null;
|
|
91
|
+
}): void;
|
|
92
|
+
|
|
93
|
+
export { RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY, RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY, RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY, RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY, RUNTIME_RICOCHET_2D_BEHAVIOR_KEY, RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY, RuntimeBoundary2DBehavior, type RuntimeBoundary2DOptions, RuntimeDynamicCircleBody2DBehavior, type RuntimeDynamicCircleBody2DHandle, type RuntimeDynamicCircleBody2DOptions, RuntimeGoalZone2DBehavior, type RuntimeGoalZone2DEvent, type RuntimeGoalZone2DHandle, type RuntimeGoalZone2DOptions, RuntimePlayerInput2DBehavior, type RuntimePlayerInput2DOptions, RuntimeRicochet2DBehavior, type RuntimeRicochet2DEvent, type RuntimeRicochet2DHandle, type RuntimeRicochet2DOptions, RuntimeTriggerRegion2DBehavior, type RuntimeTriggerRegion2DEvent, type RuntimeTriggerRegion2DHandle, type RuntimeTriggerRegion2DOptions, bindRuntimeDynamicCircleBody2DHandle, emitRuntimeGoal, emitRuntimeRicochet, emitRuntimeTriggerRegionEnter };
|
package/dist/runtime-2d.js
CHANGED
|
@@ -1,31 +1,154 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
defineBehavior
|
|
3
|
+
} from "./chunk-EZNCCO4L.js";
|
|
4
|
+
|
|
5
|
+
// src/lib/behaviors/runtime-2d/runtime-2d.descriptor.ts
|
|
6
|
+
var runtimeNoopSystemFactory = () => ({
|
|
7
|
+
update(_ecs, _delta) {
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
var RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-dynamic-circle-body-2d");
|
|
11
|
+
var RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-player-input-2d");
|
|
12
|
+
var RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-boundary-2d");
|
|
13
|
+
var RUNTIME_RICOCHET_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-ricochet-2d");
|
|
14
|
+
var RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-trigger-region-2d");
|
|
15
|
+
var RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-goal-zone-2d");
|
|
16
|
+
var RICOCHET_LISTENERS = /* @__PURE__ */ Symbol("runtime-ricochet-listeners");
|
|
17
|
+
var TRIGGER_REGION_LISTENERS = /* @__PURE__ */ Symbol("runtime-trigger-region-listeners");
|
|
18
|
+
var GOAL_LISTENERS = /* @__PURE__ */ Symbol("runtime-goal-listeners");
|
|
19
|
+
var CIRCLE_BODY_SET_POSITION = /* @__PURE__ */ Symbol("runtime-circle-body-set-position");
|
|
20
|
+
var CIRCLE_BODY_SET_VELOCITY = /* @__PURE__ */ Symbol("runtime-circle-body-set-velocity");
|
|
21
|
+
var CIRCLE_BODY_GET_POSITION = /* @__PURE__ */ Symbol("runtime-circle-body-get-position");
|
|
22
|
+
function getListeners(ref, slot) {
|
|
23
|
+
let listeners = ref[slot];
|
|
24
|
+
if (!listeners) {
|
|
25
|
+
listeners = [];
|
|
26
|
+
ref[slot] = listeners;
|
|
27
|
+
}
|
|
28
|
+
return listeners;
|
|
29
|
+
}
|
|
30
|
+
function addListener(ref, slot, callback) {
|
|
31
|
+
const listeners = getListeners(ref, slot);
|
|
32
|
+
listeners.push(callback);
|
|
33
|
+
return () => {
|
|
34
|
+
const index = listeners.indexOf(callback);
|
|
35
|
+
if (index >= 0) {
|
|
36
|
+
listeners.splice(index, 1);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function emit(ref, slot, event) {
|
|
41
|
+
const listeners = ref[slot];
|
|
42
|
+
if (!listeners) return;
|
|
43
|
+
for (const listener of listeners) {
|
|
44
|
+
listener(event);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var RuntimeDynamicCircleBody2DBehavior = defineBehavior({
|
|
48
|
+
name: "runtime-dynamic-circle-body-2d",
|
|
49
|
+
defaultOptions: {
|
|
50
|
+
initialVelocity: [0, 0]
|
|
51
|
+
},
|
|
52
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
53
|
+
createHandle: (ref) => ({
|
|
54
|
+
setRuntimePosition(x, y, z = 0) {
|
|
55
|
+
const callback = ref[CIRCLE_BODY_SET_POSITION];
|
|
56
|
+
callback?.(x, y, z);
|
|
57
|
+
},
|
|
58
|
+
setRuntimeVelocity(x, y) {
|
|
59
|
+
const callback = ref[CIRCLE_BODY_SET_VELOCITY];
|
|
60
|
+
callback?.(x, y);
|
|
61
|
+
},
|
|
62
|
+
getRuntimePosition() {
|
|
63
|
+
const callback = ref[CIRCLE_BODY_GET_POSITION];
|
|
64
|
+
return callback?.() ?? null;
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
var RuntimePlayerInput2DBehavior = defineBehavior({
|
|
69
|
+
name: "runtime-player-input-2d",
|
|
70
|
+
defaultOptions: {
|
|
71
|
+
player: "p1",
|
|
72
|
+
speed: 5
|
|
73
|
+
},
|
|
74
|
+
systemFactory: runtimeNoopSystemFactory
|
|
75
|
+
});
|
|
76
|
+
var RuntimeBoundary2DBehavior = defineBehavior({
|
|
77
|
+
name: "runtime-boundary-2d",
|
|
78
|
+
defaultOptions: {
|
|
79
|
+
boundaries: {
|
|
80
|
+
left: 0,
|
|
81
|
+
right: 0,
|
|
82
|
+
bottom: 0,
|
|
83
|
+
top: 0
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
systemFactory: runtimeNoopSystemFactory
|
|
87
|
+
});
|
|
88
|
+
var RuntimeRicochet2DBehavior = defineBehavior({
|
|
89
|
+
name: "runtime-ricochet-2d",
|
|
90
|
+
defaultOptions: {
|
|
91
|
+
minSpeed: 2,
|
|
92
|
+
maxSpeed: 20,
|
|
93
|
+
speedMultiplier: 1.05,
|
|
94
|
+
reflectionMode: "angled",
|
|
95
|
+
maxAngleDeg: 60
|
|
96
|
+
},
|
|
97
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
98
|
+
createHandle: (ref) => ({
|
|
99
|
+
onRicochet: (callback) => addListener(ref, RICOCHET_LISTENERS, callback)
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
var RuntimeTriggerRegion2DBehavior = defineBehavior({
|
|
103
|
+
name: "runtime-trigger-region-2d",
|
|
104
|
+
defaultOptions: {
|
|
105
|
+
triggerId: 0,
|
|
106
|
+
halfExtents: [0.5, 2.5]
|
|
107
|
+
},
|
|
108
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
109
|
+
createHandle: (ref) => ({
|
|
110
|
+
onRegionEnter: (callback) => addListener(ref, TRIGGER_REGION_LISTENERS, callback)
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
var RuntimeGoalZone2DBehavior = defineBehavior({
|
|
114
|
+
name: "runtime-goal-zone-2d",
|
|
115
|
+
defaultOptions: {
|
|
116
|
+
scorer: "p1"
|
|
117
|
+
},
|
|
118
|
+
systemFactory: runtimeNoopSystemFactory,
|
|
119
|
+
createHandle: (ref) => ({
|
|
120
|
+
onGoal: (callback) => addListener(ref, GOAL_LISTENERS, callback)
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
function emitRuntimeRicochet(ref, event) {
|
|
124
|
+
emit(ref, RICOCHET_LISTENERS, event);
|
|
125
|
+
}
|
|
126
|
+
function emitRuntimeTriggerRegionEnter(ref, event) {
|
|
127
|
+
emit(ref, TRIGGER_REGION_LISTENERS, event);
|
|
128
|
+
}
|
|
129
|
+
function emitRuntimeGoal(ref, event) {
|
|
130
|
+
emit(ref, GOAL_LISTENERS, event);
|
|
131
|
+
}
|
|
132
|
+
function bindRuntimeDynamicCircleBody2DHandle(ref, controls) {
|
|
133
|
+
ref[CIRCLE_BODY_SET_POSITION] = controls.setPosition;
|
|
134
|
+
ref[CIRCLE_BODY_SET_VELOCITY] = controls.setVelocity;
|
|
135
|
+
ref[CIRCLE_BODY_GET_POSITION] = controls.getPosition;
|
|
136
|
+
}
|
|
17
137
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
138
|
+
RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY,
|
|
139
|
+
RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY,
|
|
140
|
+
RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,
|
|
141
|
+
RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY,
|
|
21
142
|
RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,
|
|
22
143
|
RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
144
|
+
RuntimeBoundary2DBehavior,
|
|
145
|
+
RuntimeDynamicCircleBody2DBehavior,
|
|
146
|
+
RuntimeGoalZone2DBehavior,
|
|
147
|
+
RuntimePlayerInput2DBehavior,
|
|
26
148
|
RuntimeRicochet2DBehavior,
|
|
27
149
|
RuntimeTriggerRegion2DBehavior,
|
|
28
|
-
|
|
150
|
+
bindRuntimeDynamicCircleBody2DHandle,
|
|
151
|
+
emitRuntimeGoal,
|
|
29
152
|
emitRuntimeRicochet,
|
|
30
153
|
emitRuntimeTriggerRegionEnter
|
|
31
154
|
};
|
package/dist/runtime-2d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/behaviors/runtime-2d/runtime-2d.descriptor.ts"],"sourcesContent":["/**\n * Runtime 2D Behavior Descriptors\n *\n * Marker descriptors for entities managed entirely by the wasm gameplay-2d\n * runtime (paddle-and-ball style games, boundaries, trigger regions, goal\n * zones). The descriptors carry configuration and event wiring only — all\n * per-frame simulation happens inside the wasm runtime, so their systems are\n * no-ops. The host runtime binds concrete callbacks onto the behavior refs\n * (see {@link bindRuntimeDynamicCircleBody2DHandle} and the emit helpers).\n */\n\nimport {\n\tdefineBehavior,\n\ttype BehaviorRef,\n} from '../behavior-descriptor';\nimport type { BehaviorSystem } from '../behavior-system';\n\nexport interface RuntimeDynamicCircleBody2DOptions {\n\tinitialVelocity: readonly [number, number];\n}\n\nexport interface RuntimeDynamicCircleBody2DHandle {\n\tsetRuntimePosition(x: number, y: number, z?: number): void;\n\tsetRuntimeVelocity(x: number, y: number): void;\n\tgetRuntimePosition(): { x: number; y: number; z: number } | null;\n}\n\nexport interface RuntimePlayerInput2DOptions {\n\tplayer: 'p1' | 'p2';\n\tspeed: number;\n}\n\nexport interface RuntimeBoundary2DOptions {\n\tboundaries: {\n\t\tleft: number;\n\t\tright: number;\n\t\tbottom: number;\n\t\ttop: number;\n\t};\n}\n\nexport interface RuntimeRicochet2DOptions {\n\tminSpeed: number;\n\tmaxSpeed: number;\n\tspeedMultiplier: number;\n\treflectionMode: 'simple' | 'angled';\n\tmaxAngleDeg: number;\n}\n\nexport interface RuntimeRicochet2DEvent {\n\tkind: 'wall' | 'paddle';\n}\n\nexport interface RuntimeRicochet2DHandle {\n\tonRicochet(callback: (event: RuntimeRicochet2DEvent) => void): () => void;\n}\n\n/** Registers a gameplay2d trigger AABB (sensor); wasm reports overlap via {@link emitRuntimeTriggerRegionEnter}. */\nexport interface RuntimeTriggerRegion2DOptions {\n\ttriggerId: number;\n\thalfExtents: readonly [number, number];\n}\n\nexport interface RuntimeTriggerRegion2DEvent {\n\ttriggerId: number;\n}\n\nexport interface RuntimeTriggerRegion2DHandle {\n\tonRegionEnter(callback: (event: RuntimeTriggerRegion2DEvent) => void): () => void;\n}\n\nexport interface RuntimeGoalZone2DOptions {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DEvent {\n\tscorer: 'p1' | 'p2';\n}\n\nexport interface RuntimeGoalZone2DHandle {\n\tonGoal(callback: (event: RuntimeGoalZone2DEvent) => void): () => void;\n}\n\nconst runtimeNoopSystemFactory = (): BehaviorSystem => ({\n\tupdate(_ecs: unknown, _delta: number) {},\n});\n\nexport const RUNTIME_DYNAMIC_CIRCLE_BODY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-dynamic-circle-body-2d');\nexport const RUNTIME_PLAYER_INPUT_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-player-input-2d');\nexport const RUNTIME_BOUNDARY_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-boundary-2d');\nexport const RUNTIME_RICOCHET_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-ricochet-2d');\nexport const RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-trigger-region-2d');\nexport const RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY = Symbol.for('zylem:behavior:runtime-goal-zone-2d');\n\nconst RICOCHET_LISTENERS = Symbol('runtime-ricochet-listeners');\nconst TRIGGER_REGION_LISTENERS = Symbol('runtime-trigger-region-listeners');\nconst GOAL_LISTENERS = Symbol('runtime-goal-listeners');\nconst CIRCLE_BODY_SET_POSITION = Symbol('runtime-circle-body-set-position');\nconst CIRCLE_BODY_SET_VELOCITY = Symbol('runtime-circle-body-set-velocity');\nconst CIRCLE_BODY_GET_POSITION = Symbol('runtime-circle-body-get-position');\n\nfunction getListeners<E>(ref: BehaviorRef<any>, slot: symbol): Array<(event: E) => void> {\n\tlet listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) {\n\t\tlisteners = [];\n\t\t(ref as any)[slot] = listeners;\n\t}\n\treturn listeners;\n}\n\nfunction addListener<E>(ref: BehaviorRef<any>, slot: symbol, callback: (event: E) => void): () => void {\n\tconst listeners = getListeners<E>(ref, slot);\n\tlisteners.push(callback);\n\treturn () => {\n\t\tconst index = listeners.indexOf(callback);\n\t\tif (index >= 0) {\n\t\t\tlisteners.splice(index, 1);\n\t\t}\n\t};\n}\n\nfunction emit<E>(ref: BehaviorRef<any>, slot: symbol, event: E): void {\n\tconst listeners = (ref as any)[slot] as Array<(event: E) => void> | undefined;\n\tif (!listeners) return;\n\tfor (const listener of listeners) {\n\t\tlistener(event);\n\t}\n}\n\nexport const RuntimeDynamicCircleBody2DBehavior = defineBehavior<\n\tRuntimeDynamicCircleBody2DOptions,\n\tRuntimeDynamicCircleBody2DHandle\n>({\n\tname: 'runtime-dynamic-circle-body-2d',\n\tdefaultOptions: {\n\t\tinitialVelocity: [0, 0] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>) => ({\n\t\tsetRuntimePosition(x: number, y: number, z: number = 0): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_POSITION] as\n\t\t\t\t| ((x: number, y: number, z: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y, z);\n\t\t},\n\t\tsetRuntimeVelocity(x: number, y: number): void {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_SET_VELOCITY] as\n\t\t\t\t| ((x: number, y: number) => void)\n\t\t\t\t| undefined;\n\t\t\tcallback?.(x, y);\n\t\t},\n\t\tgetRuntimePosition(): { x: number; y: number; z: number } | null {\n\t\t\tconst callback = (ref as any)[CIRCLE_BODY_GET_POSITION] as\n\t\t\t\t| (() => { x: number; y: number; z: number } | null)\n\t\t\t\t| undefined;\n\t\t\treturn callback?.() ?? null;\n\t\t},\n\t}),\n});\n\nexport const RuntimePlayerInput2DBehavior = defineBehavior<RuntimePlayerInput2DOptions>({\n\tname: 'runtime-player-input-2d',\n\tdefaultOptions: {\n\t\tplayer: 'p1',\n\t\tspeed: 5,\n\t} as RuntimePlayerInput2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeBoundary2DBehavior = defineBehavior({\n\tname: 'runtime-boundary-2d',\n\tdefaultOptions: {\n\t\tboundaries: {\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\tbottom: 0,\n\t\t\ttop: 0,\n\t\t},\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n});\n\nexport const RuntimeRicochet2DBehavior = defineBehavior<\n\tRuntimeRicochet2DOptions,\n\tRuntimeRicochet2DHandle\n>({\n\tname: 'runtime-ricochet-2d',\n\tdefaultOptions: {\n\t\tminSpeed: 2,\n\t\tmaxSpeed: 20,\n\t\tspeedMultiplier: 1.05,\n\t\treflectionMode: 'angled' as const,\n\t\tmaxAngleDeg: 60,\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeRicochet2DOptions>) => ({\n\t\tonRicochet: (callback: (event: RuntimeRicochet2DEvent) => void) =>\n\t\t\taddListener(ref, RICOCHET_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeTriggerRegion2DBehavior = defineBehavior<\n\tRuntimeTriggerRegion2DOptions,\n\tRuntimeTriggerRegion2DHandle\n>({\n\tname: 'runtime-trigger-region-2d',\n\tdefaultOptions: {\n\t\ttriggerId: 0,\n\t\thalfExtents: [0.5, 2.5] as [number, number],\n\t},\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeTriggerRegion2DOptions>) => ({\n\t\tonRegionEnter: (callback: (event: RuntimeTriggerRegion2DEvent) => void) =>\n\t\t\taddListener(ref, TRIGGER_REGION_LISTENERS, callback),\n\t}),\n});\n\nexport const RuntimeGoalZone2DBehavior = defineBehavior<\n\tRuntimeGoalZone2DOptions,\n\tRuntimeGoalZone2DHandle\n>({\n\tname: 'runtime-goal-zone-2d',\n\tdefaultOptions: {\n\t\tscorer: 'p1',\n\t} as RuntimeGoalZone2DOptions,\n\tsystemFactory: runtimeNoopSystemFactory,\n\tcreateHandle: (ref: BehaviorRef<RuntimeGoalZone2DOptions>) => ({\n\t\tonGoal: (callback: (event: RuntimeGoalZone2DEvent) => void) =>\n\t\t\taddListener(ref, GOAL_LISTENERS, callback),\n\t}),\n});\n\nexport function emitRuntimeRicochet(\n\tref: BehaviorRef<RuntimeRicochet2DOptions>,\n\tevent: RuntimeRicochet2DEvent,\n): void {\n\temit(ref, RICOCHET_LISTENERS, event);\n}\n\nexport function emitRuntimeTriggerRegionEnter(\n\tref: BehaviorRef<RuntimeTriggerRegion2DOptions>,\n\tevent: RuntimeTriggerRegion2DEvent,\n): void {\n\temit(ref, TRIGGER_REGION_LISTENERS, event);\n}\n\nexport function emitRuntimeGoal(\n\tref: BehaviorRef<RuntimeGoalZone2DOptions>,\n\tevent: RuntimeGoalZone2DEvent,\n): void {\n\temit(ref, GOAL_LISTENERS, event);\n}\n\nexport function bindRuntimeDynamicCircleBody2DHandle(\n\tref: BehaviorRef<RuntimeDynamicCircleBody2DOptions>,\n\tcontrols: {\n\t\tsetPosition: (x: number, y: number, z: number) => void;\n\t\tsetVelocity: (x: number, y: number) => void;\n\t\tgetPosition: () => { x: number; y: number; z: number } | null;\n\t},\n): void {\n\t(ref as any)[CIRCLE_BODY_SET_POSITION] = controls.setPosition;\n\t(ref as any)[CIRCLE_BODY_SET_VELOCITY] = controls.setVelocity;\n\t(ref as any)[CIRCLE_BODY_GET_POSITION] = controls.getPosition;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor, G as GameEntity } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor, G as GameEntity } from './behavior-system-y8SGrGWy.js';
|
|
2
|
+
import '@dimforge/rapier3d-compat';
|
|
2
3
|
|
|
3
4
|
interface ScreenVisibilitySnapshot {
|
|
4
5
|
initialized: boolean;
|
package/dist/screen-wrap.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
2
2
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
3
|
+
import '@dimforge/rapier3d-compat';
|
|
3
4
|
import 'typescript-fsm';
|
|
4
5
|
|
|
5
6
|
/**
|
package/dist/screen-wrap.js
CHANGED
package/dist/shooter-2d.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
2
2
|
import { i as Vec3Input } from './vector-Bm65-FOG.js';
|
|
3
|
-
import 'three';
|
|
4
3
|
import '@dimforge/rapier3d-compat';
|
|
4
|
+
import 'three';
|
|
5
5
|
|
|
6
6
|
interface Shooter2DStateComponent {
|
|
7
7
|
cooldownRemainingMs: number;
|
|
@@ -23,7 +23,9 @@ interface Shooter2DProjectileEntity {
|
|
|
23
23
|
z: number;
|
|
24
24
|
};
|
|
25
25
|
dirty: {
|
|
26
|
-
|
|
26
|
+
velocityX: boolean;
|
|
27
|
+
velocityY: boolean;
|
|
28
|
+
velocityZ: boolean;
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
31
|
prependSetup(callback: (params: {
|
package/dist/shooter-2d.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Shooter2DBehavior,
|
|
3
3
|
createShooter2DStateComponent
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-5XZWTFGF.js";
|
|
5
|
+
import "./chunk-Y7YIAWPW.js";
|
|
6
6
|
import "./chunk-WWVD5DR5.js";
|
|
7
7
|
import "./chunk-EZNCCO4L.js";
|
|
8
8
|
export {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Shooter2DSourceEntity, Shooter2DHandle, Shooter2DStageLike } from './shooter-2d.js';
|
|
2
|
+
|
|
3
|
+
interface ResolvedAim2D {
|
|
4
|
+
angle: number;
|
|
5
|
+
direction: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
hasAimInput: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Minimal entity slice needed to derive a 2D facing angle. Structurally
|
|
13
|
+
* satisfied by `Shooter2DSourceEntity` and the engine entity.
|
|
14
|
+
*/
|
|
15
|
+
interface FacingAngle2DEntity {
|
|
16
|
+
topDownMovementState?: {
|
|
17
|
+
facingAngle: number;
|
|
18
|
+
};
|
|
19
|
+
body?: {
|
|
20
|
+
rotation?: () => {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
z: number;
|
|
24
|
+
w: number;
|
|
25
|
+
};
|
|
26
|
+
} | null;
|
|
27
|
+
/** Cached Z rotation maintained by 2D rotation helpers. */
|
|
28
|
+
_rotation2DAngle?: number;
|
|
29
|
+
}
|
|
30
|
+
declare function getEntityFacingAngle2D(entity: FacingAngle2DEntity): number;
|
|
31
|
+
declare function resolveAim2D(aimX: number, aimY: number, fallbackAngle: number): ResolvedAim2D;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Aim + fire input fields shared by the 2D shooter coordinators
|
|
35
|
+
* (top-down-shooter, multidirectional-space-shooter).
|
|
36
|
+
*/
|
|
37
|
+
interface Shooter2DAimFireInput {
|
|
38
|
+
aimX: number;
|
|
39
|
+
aimY: number;
|
|
40
|
+
shootPressed: boolean;
|
|
41
|
+
shootHeld: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fire the entity's Shooter2D behavior when the input requests it.
|
|
45
|
+
*
|
|
46
|
+
* Resolves the 2D aim (explicit aim axes, falling back to the entity's
|
|
47
|
+
* current facing) and fires toward a point one unit along the aim direction.
|
|
48
|
+
* Pass a pre-resolved `aim` to avoid recomputing when the coordinator already
|
|
49
|
+
* resolved it for rotation.
|
|
50
|
+
*
|
|
51
|
+
* @returns true when a fire attempt was issued
|
|
52
|
+
*/
|
|
53
|
+
declare function fireShooter2DIfRequested(entity: Shooter2DSourceEntity, shooter: Shooter2DHandle, stage: Shooter2DStageLike, input: Shooter2DAimFireInput, aim?: ResolvedAim2D): boolean;
|
|
54
|
+
|
|
55
|
+
export { type FacingAngle2DEntity as F, type ResolvedAim2D as R, type Shooter2DAimFireInput as S, fireShooter2DIfRequested as f, getEntityFacingAngle2D as g, resolveAim2D as r };
|
package/dist/thruster.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { T as ThrusterInputComponent, a as ThrusterMovementComponent } from './components-B29WHGQN.js';
|
|
2
2
|
export { b as ThrusterStateComponent, c as createThrusterInputComponent, d as createThrusterMovementComponent, e as createThrusterStateComponent } from './components-B29WHGQN.js';
|
|
3
3
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
4
|
-
import {
|
|
4
|
+
import { Z as ZylemWorld, a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
5
5
|
import { P as PhysicsBodyComponent } from './components-BWG1GkZA.js';
|
|
6
6
|
import 'typescript-fsm';
|
|
7
7
|
import '@dimforge/rapier3d-compat';
|
|
@@ -11,7 +11,7 @@ import 'three';
|
|
|
11
11
|
* ThrusterFSM
|
|
12
12
|
*
|
|
13
13
|
* State machine controller for thruster behavior.
|
|
14
|
-
* FSM does NOT touch physics or
|
|
14
|
+
* FSM does NOT touch physics or ThrusterSystem - it only writes ThrusterInputComponent.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
declare enum ThrusterState {
|
|
@@ -60,23 +60,13 @@ declare class ThrusterFSM {
|
|
|
60
60
|
update(playerInput: PlayerInput): void;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
interface ZylemWorld {
|
|
64
|
-
collisionMap?: Map<string, GameEntity<any>>;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
63
|
/**
|
|
68
|
-
*
|
|
64
|
+
* ThrusterSystem
|
|
69
65
|
*
|
|
70
66
|
* This is the heart of the thruster movement system - a pure, stateless force generator.
|
|
71
67
|
* Works identically for player, AI, and replay.
|
|
72
68
|
*/
|
|
73
69
|
|
|
74
|
-
/**
|
|
75
|
-
* Zylem-style Behavior interface
|
|
76
|
-
*/
|
|
77
|
-
interface Behavior {
|
|
78
|
-
update(dt: number): void;
|
|
79
|
-
}
|
|
80
70
|
/**
|
|
81
71
|
* Entity with thruster components
|
|
82
72
|
*/
|
|
@@ -86,16 +76,16 @@ interface ThrusterEntity {
|
|
|
86
76
|
$thruster: ThrusterInputComponent;
|
|
87
77
|
}
|
|
88
78
|
/**
|
|
89
|
-
*
|
|
79
|
+
* ThrusterSystem - Force generator for thruster-equipped entities
|
|
90
80
|
*
|
|
91
81
|
* Responsibilities:
|
|
92
82
|
* - Query entities with PhysicsBody, ThrusterMovement, and ThrusterInput components
|
|
93
83
|
* - Apply velocities based on thrust input (2D mode)
|
|
94
84
|
* - Apply angular velocity based on rotation input
|
|
95
85
|
*/
|
|
96
|
-
declare class
|
|
86
|
+
declare class ThrusterSystem {
|
|
97
87
|
private world;
|
|
98
|
-
constructor(world: ZylemWorld);
|
|
88
|
+
constructor(world: ZylemWorld | null);
|
|
99
89
|
/**
|
|
100
90
|
* Update a single thruster-enabled entity.
|
|
101
91
|
*/
|
|
@@ -117,7 +107,7 @@ interface ThrusterBehaviorOptions {
|
|
|
117
107
|
/**
|
|
118
108
|
* ThrusterBehavior - typed descriptor for thruster movement.
|
|
119
109
|
*
|
|
120
|
-
* Uses the existing
|
|
110
|
+
* Uses the existing ThrusterSystem under the hood.
|
|
121
111
|
*
|
|
122
112
|
* @example
|
|
123
113
|
* ```typescript
|
|
@@ -129,4 +119,4 @@ interface ThrusterBehaviorOptions {
|
|
|
129
119
|
*/
|
|
130
120
|
declare const ThrusterBehavior: BehaviorDescriptor<ThrusterBehaviorOptions, Record<string, never>, ThrusterEntity>;
|
|
131
121
|
|
|
132
|
-
export { type
|
|
122
|
+
export { type PlayerInput, ThrusterBehavior, type ThrusterBehaviorOptions, type ThrusterEntity, ThrusterEvent, ThrusterFSM, type ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementComponent, ThrusterState, ThrusterSystem };
|
package/dist/thruster.js
CHANGED
|
@@ -2,23 +2,23 @@ import {
|
|
|
2
2
|
ThrusterBehavior,
|
|
3
3
|
ThrusterEvent,
|
|
4
4
|
ThrusterFSM,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
5
|
+
ThrusterState,
|
|
6
|
+
ThrusterSystem
|
|
7
|
+
} from "./chunk-75FJIUIG.js";
|
|
8
8
|
import {
|
|
9
9
|
createThrusterInputComponent,
|
|
10
10
|
createThrusterMovementComponent,
|
|
11
11
|
createThrusterStateComponent
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-IZJFUAXB.js";
|
|
13
|
+
import "./chunk-Y7YIAWPW.js";
|
|
14
14
|
import "./chunk-4URF65BR.js";
|
|
15
15
|
import "./chunk-EZNCCO4L.js";
|
|
16
16
|
export {
|
|
17
17
|
ThrusterBehavior,
|
|
18
18
|
ThrusterEvent,
|
|
19
19
|
ThrusterFSM,
|
|
20
|
-
ThrusterMovementBehavior,
|
|
21
20
|
ThrusterState,
|
|
21
|
+
ThrusterSystem,
|
|
22
22
|
createThrusterInputComponent,
|
|
23
23
|
createThrusterMovementComponent,
|
|
24
24
|
createThrusterStateComponent
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { T as TopDownMovementComponent, a as TopDownMovementInputComponent, b as TopDownMovementStateComponent } from './components-XCpL6IYt.js';
|
|
2
2
|
export { c as createTopDownMovementComponent, d as createTopDownMovementInputComponent, e as createTopDownMovementStateComponent } from './components-XCpL6IYt.js';
|
|
3
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
3
|
+
import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
4
|
+
import '@dimforge/rapier3d-compat';
|
|
4
5
|
|
|
5
6
|
interface TopDownMovementEntity {
|
|
6
7
|
body: {
|
|
@@ -17,7 +18,9 @@ interface TopDownMovementEntity {
|
|
|
17
18
|
z: number;
|
|
18
19
|
};
|
|
19
20
|
dirty: {
|
|
20
|
-
|
|
21
|
+
velocityX: boolean;
|
|
22
|
+
velocityY: boolean;
|
|
23
|
+
velocityZ: boolean;
|
|
21
24
|
};
|
|
22
25
|
};
|
|
23
26
|
setRotationZ?: (angle: number) => void;
|
|
@@ -25,7 +28,7 @@ interface TopDownMovementEntity {
|
|
|
25
28
|
$topDownMovement: TopDownMovementInputComponent;
|
|
26
29
|
topDownMovementState: TopDownMovementStateComponent;
|
|
27
30
|
}
|
|
28
|
-
declare class
|
|
31
|
+
declare class TopDownMovementSystem {
|
|
29
32
|
updateEntity(entity: TopDownMovementEntity, _delta: number): void;
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -37,4 +40,4 @@ interface TopDownMovementHandle {
|
|
|
37
40
|
}
|
|
38
41
|
declare const TopDownMovementBehavior: BehaviorDescriptor<TopDownMovementBehaviorOptions, TopDownMovementHandle, TopDownMovementEntity>;
|
|
39
42
|
|
|
40
|
-
export { TopDownMovementBehavior, type TopDownMovementBehaviorOptions, TopDownMovementComponent, type TopDownMovementEntity, type TopDownMovementHandle, TopDownMovementInputComponent,
|
|
43
|
+
export { TopDownMovementBehavior, type TopDownMovementBehaviorOptions, TopDownMovementComponent, type TopDownMovementEntity, type TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementStateComponent, TopDownMovementSystem };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TopDownMovementBehavior,
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
TopDownMovementSystem
|
|
4
|
+
} from "./chunk-A4CA35DQ.js";
|
|
5
5
|
import {
|
|
6
6
|
createTopDownMovementComponent,
|
|
7
7
|
createTopDownMovementInputComponent,
|
|
8
8
|
createTopDownMovementStateComponent
|
|
9
9
|
} from "./chunk-EIWQM6U3.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-Y7YIAWPW.js";
|
|
11
|
+
import "./chunk-Q75LKHDF.js";
|
|
12
12
|
import "./chunk-EZNCCO4L.js";
|
|
13
13
|
export {
|
|
14
14
|
TopDownMovementBehavior,
|
|
15
|
-
|
|
15
|
+
TopDownMovementSystem,
|
|
16
16
|
createTopDownMovementComponent,
|
|
17
17
|
createTopDownMovementInputComponent,
|
|
18
18
|
createTopDownMovementStateComponent
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-
|
|
1
|
+
import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type-safe helper to apply a behavior to an entity and return the entity cast to the behavior's interface.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
2
2
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
3
|
+
import '@dimforge/rapier3d-compat';
|
|
3
4
|
import 'typescript-fsm';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
WorldBoundary2DState,
|
|
6
6
|
computeWorldBoundary2DHits,
|
|
7
7
|
hasAnyWorldBoundary2DHit
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VMQHNJJI.js";
|
|
9
9
|
import "./chunk-KDY5N6J4.js";
|
|
10
|
-
import "./chunk-Y6UJOUE5.js";
|
|
11
10
|
import "./chunk-4URF65BR.js";
|
|
11
|
+
import "./chunk-Q75LKHDF.js";
|
|
12
12
|
import "./chunk-EZNCCO4L.js";
|
|
13
13
|
export {
|
|
14
14
|
WorldBoundary2DBehavior,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as BehaviorDescriptor } from './behavior-system-
|
|
1
|
+
import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
|
|
2
2
|
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
3
|
+
import '@dimforge/rapier3d-compat';
|
|
3
4
|
import 'typescript-fsm';
|
|
4
5
|
|
|
5
6
|
interface Bounds3DPoint {
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
WorldBoundary3DState,
|
|
6
6
|
computeWorldBoundary3DHits,
|
|
7
7
|
hasAnyWorldBoundary3DHit
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-Z72F2ENM.js";
|
|
9
9
|
import "./chunk-OHCPV2NT.js";
|
|
10
|
-
import "./chunk-Y6UJOUE5.js";
|
|
11
10
|
import "./chunk-4URF65BR.js";
|
|
11
|
+
import "./chunk-Q75LKHDF.js";
|
|
12
12
|
import "./chunk-EZNCCO4L.js";
|
|
13
13
|
export {
|
|
14
14
|
WorldBoundary3DBehavior,
|