@zylem/behaviors 0.4.1 → 0.5.2

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 (148) hide show
  1. package/README.md +13 -1
  2. package/dist/{behavior-system-y8SGrGWy.d.ts → behavior-system-CldqNUgr.d.ts} +334 -19
  3. package/dist/{chunk-GFARAJV2.js → chunk-2PAHQZZD.js} +44 -73
  4. package/dist/chunk-2PAHQZZD.js.map +1 -0
  5. package/dist/chunk-4CEW64HO.js +210 -0
  6. package/dist/chunk-4CEW64HO.js.map +1 -0
  7. package/dist/chunk-4LLK2FJI.js +344 -0
  8. package/dist/chunk-4LLK2FJI.js.map +1 -0
  9. package/dist/chunk-4MZ57HPD.js +323 -0
  10. package/dist/chunk-4MZ57HPD.js.map +1 -0
  11. package/dist/chunk-52FJIDGL.js +30 -0
  12. package/dist/chunk-52FJIDGL.js.map +1 -0
  13. package/dist/{chunk-UYFOLI2X.js → chunk-5A5AYP2C.js} +1 -1
  14. package/dist/{chunk-UYFOLI2X.js.map → chunk-5A5AYP2C.js.map} +1 -1
  15. package/dist/chunk-5WRI5ZAA.js +31 -0
  16. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  17. package/dist/{chunk-ZRQWSURL.js → chunk-5XPPLTC7.js} +2 -2
  18. package/dist/chunk-5XPPLTC7.js.map +1 -0
  19. package/dist/{chunk-VMQHNJJI.js → chunk-7DGXUAPV.js} +17 -23
  20. package/dist/chunk-7DGXUAPV.js.map +1 -0
  21. package/dist/{chunk-5SM5SH5O.js → chunk-7JLWZXPA.js} +2 -2
  22. package/dist/{chunk-QDCJLJUV.js → chunk-7W3KY55G.js} +22 -13
  23. package/dist/chunk-7W3KY55G.js.map +1 -0
  24. package/dist/chunk-AS3HR7AS.js +188 -0
  25. package/dist/chunk-AS3HR7AS.js.map +1 -0
  26. package/dist/chunk-BAXJ7XHJ.js +155 -0
  27. package/dist/chunk-BAXJ7XHJ.js.map +1 -0
  28. package/dist/chunk-DZ4LLQON.js +867 -0
  29. package/dist/chunk-DZ4LLQON.js.map +1 -0
  30. package/dist/{chunk-4L36OPY2.js → chunk-G2KUXVU6.js} +81 -135
  31. package/dist/chunk-G2KUXVU6.js.map +1 -0
  32. package/dist/{chunk-BXP4K7RF.js → chunk-JVADRLWX.js} +57 -186
  33. package/dist/chunk-JVADRLWX.js.map +1 -0
  34. package/dist/{chunk-ZA43LPRM.js → chunk-KIYUUSPK.js} +2 -2
  35. package/dist/chunk-LZIHSJZR.js +191 -0
  36. package/dist/chunk-LZIHSJZR.js.map +1 -0
  37. package/dist/{chunk-WWVD5DR5.js → chunk-M3QDKKDF.js} +2 -8
  38. package/dist/chunk-M3QDKKDF.js.map +1 -0
  39. package/dist/{chunk-FTDZAKZW.js → chunk-NQPYMUDF.js} +7 -5
  40. package/dist/{chunk-FTDZAKZW.js.map → chunk-NQPYMUDF.js.map} +1 -1
  41. package/dist/{chunk-XP3ASVGJ.js → chunk-NW4SE5XW.js} +2 -2
  42. package/dist/{chunk-KDY5N6J4.js → chunk-OPZ2LVS2.js} +1 -22
  43. package/dist/{chunk-KDY5N6J4.js.map → chunk-OPZ2LVS2.js.map} +1 -1
  44. package/dist/{chunk-5XZWTFGF.js → chunk-PLIXVF7B.js} +3 -3
  45. package/dist/chunk-PLIXVF7B.js.map +1 -0
  46. package/dist/{chunk-27UPCP5B.js → chunk-QS3VXWVO.js} +22 -13
  47. package/dist/chunk-QS3VXWVO.js.map +1 -0
  48. package/dist/{chunk-Y7YIAWPW.js → chunk-SGHIGTVZ.js} +1 -11
  49. package/dist/{chunk-Y7YIAWPW.js.map → chunk-SGHIGTVZ.js.map} +1 -1
  50. package/dist/{chunk-UL6Q5HDP.js → chunk-TBUKJKY6.js} +3 -25
  51. package/dist/chunk-TBUKJKY6.js.map +1 -0
  52. package/dist/{chunk-Z72F2ENM.js → chunk-WU6XXL3D.js} +17 -26
  53. package/dist/chunk-WU6XXL3D.js.map +1 -0
  54. package/dist/{chunk-A4CA35DQ.js → chunk-Y4PHT2HG.js} +25 -45
  55. package/dist/chunk-Y4PHT2HG.js.map +1 -0
  56. package/dist/components-BmievOxF.d.ts +30 -0
  57. package/dist/cooldown.d.ts +2 -2
  58. package/dist/cooldown.js +2 -1
  59. package/dist/coordinators/boundary-ricochet-3d.d.ts +4 -4
  60. package/dist/coordinators/boundary-ricochet-3d.js +1 -0
  61. package/dist/coordinators/boundary-ricochet.d.ts +4 -4
  62. package/dist/coordinators/boundary-ricochet.js +3 -2
  63. package/dist/coordinators/first-person-shooter.js +1 -0
  64. package/dist/coordinators/multidirectional-space-shooter.d.ts +3 -3
  65. package/dist/coordinators/multidirectional-space-shooter.js +5 -3
  66. package/dist/coordinators/top-down-shooter.d.ts +3 -3
  67. package/dist/coordinators/top-down-shooter.js +5 -3
  68. package/dist/core.d.ts +298 -8
  69. package/dist/core.js +502 -14
  70. package/dist/core.js.map +1 -1
  71. package/dist/destructible-3d.d.ts +32 -4
  72. package/dist/destructible-3d.js +2 -1
  73. package/dist/destructible-prebake.js +1 -0
  74. package/dist/{entity-types-CmtQ-IBp.d.ts → entity-types-DhfsZbSK.d.ts} +5 -3
  75. package/dist/first-person.d.ts +27 -38
  76. package/dist/first-person.js +8 -8
  77. package/dist/index.d.ts +14 -15
  78. package/dist/index.js +38 -53
  79. package/dist/jumper-2d.d.ts +3 -17
  80. package/dist/jumper-2d.js +4 -9
  81. package/dist/jumper-3d.d.ts +5 -39
  82. package/dist/jumper-3d.js +5 -10
  83. package/dist/{moveable-Cl9h-_w7.d.ts → moveable-rdIvWiak.d.ts} +21 -4
  84. package/dist/particle-emitter/presets.js +1 -0
  85. package/dist/particle-emitter.d.ts +3 -3
  86. package/dist/particle-emitter.js +3 -2
  87. package/dist/platformer-2d.d.ts +21 -82
  88. package/dist/platformer-2d.js +4 -5
  89. package/dist/platformer-3d.d.ts +21 -78
  90. package/dist/platformer-3d.js +4 -5
  91. package/dist/ricochet-2d.d.ts +3 -3
  92. package/dist/ricochet-2d.js +4 -3
  93. package/dist/ricochet-3d.d.ts +3 -3
  94. package/dist/ricochet-3d.js +4 -3
  95. package/dist/runtime-2d.d.ts +2 -2
  96. package/dist/runtime-2d.js +1 -0
  97. package/dist/runtime-2d.js.map +1 -1
  98. package/dist/screen-visibility.d.ts +2 -2
  99. package/dist/screen-visibility.js +1 -0
  100. package/dist/screen-wrap.d.ts +2 -2
  101. package/dist/screen-wrap.js +4 -3
  102. package/dist/shooter-2d.d.ts +3 -3
  103. package/dist/shooter-2d.js +4 -3
  104. package/dist/thruster.d.ts +5 -34
  105. package/dist/thruster.js +4 -6
  106. package/dist/top-down-movement.d.ts +9 -27
  107. package/dist/top-down-movement.js +6 -6
  108. package/dist/{vector-Bm65-FOG.d.ts → vector-DjhLUrak.d.ts} +2 -4
  109. package/dist/world-boundary-2d.d.ts +2 -2
  110. package/dist/world-boundary-2d.js +5 -4
  111. package/dist/world-boundary-3d.d.ts +2 -2
  112. package/dist/world-boundary-3d.js +4 -3
  113. package/package.json +4 -5
  114. package/dist/chunk-27UPCP5B.js.map +0 -1
  115. package/dist/chunk-4L36OPY2.js.map +0 -1
  116. package/dist/chunk-4URF65BR.js +0 -44
  117. package/dist/chunk-4URF65BR.js.map +0 -1
  118. package/dist/chunk-5XZWTFGF.js.map +0 -1
  119. package/dist/chunk-67XLJ26X.js +0 -536
  120. package/dist/chunk-67XLJ26X.js.map +0 -1
  121. package/dist/chunk-75FJIUIG.js +0 -240
  122. package/dist/chunk-75FJIUIG.js.map +0 -1
  123. package/dist/chunk-A4CA35DQ.js.map +0 -1
  124. package/dist/chunk-BXP4K7RF.js.map +0 -1
  125. package/dist/chunk-F72WX4MH.js +0 -422
  126. package/dist/chunk-F72WX4MH.js.map +0 -1
  127. package/dist/chunk-GFARAJV2.js.map +0 -1
  128. package/dist/chunk-JXMF4NUI.js +0 -309
  129. package/dist/chunk-JXMF4NUI.js.map +0 -1
  130. package/dist/chunk-OTLSUYQQ.js +0 -29
  131. package/dist/chunk-OTLSUYQQ.js.map +0 -1
  132. package/dist/chunk-Q75LKHDF.js +0 -56
  133. package/dist/chunk-Q75LKHDF.js.map +0 -1
  134. package/dist/chunk-QDCJLJUV.js.map +0 -1
  135. package/dist/chunk-RDHSHEZM.js +0 -479
  136. package/dist/chunk-RDHSHEZM.js.map +0 -1
  137. package/dist/chunk-UIG7MWS2.js +0 -518
  138. package/dist/chunk-UIG7MWS2.js.map +0 -1
  139. package/dist/chunk-UL6Q5HDP.js.map +0 -1
  140. package/dist/chunk-VMQHNJJI.js.map +0 -1
  141. package/dist/chunk-WWVD5DR5.js.map +0 -1
  142. package/dist/chunk-Z72F2ENM.js.map +0 -1
  143. package/dist/chunk-ZRQWSURL.js.map +0 -1
  144. package/dist/components-BWG1GkZA.d.ts +0 -20
  145. package/dist/use-behavior-B85d5u7-.d.ts +0 -13
  146. /package/dist/{chunk-5SM5SH5O.js.map → chunk-7JLWZXPA.js.map} +0 -0
  147. /package/dist/{chunk-ZA43LPRM.js.map → chunk-KIYUUSPK.js.map} +0 -0
  148. /package/dist/{chunk-XP3ASVGJ.js.map → chunk-NW4SE5XW.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  directionFromAngle2D,
4
4
  getRotationAngle2D,
5
5
  normalizeDirection2D
6
- } from "./chunk-Y7YIAWPW.js";
6
+ } from "./chunk-SGHIGTVZ.js";
7
7
 
8
8
  // src/lib/coordinators/shared/top-down-aim.ts
9
9
  function getEntityFacingAngle2D(entity) {
@@ -31,30 +31,8 @@ function resolveAim2D(aimX, aimY, fallbackAngle) {
31
31
  };
32
32
  }
33
33
 
34
- // src/lib/coordinators/shared/shooter-fire.ts
35
- function fireShooter2DIfRequested(entity, shooter, stage, input, aim) {
36
- if (!input.shootPressed && !input.shootHeld) {
37
- return false;
38
- }
39
- const sourcePosition = entity.body?.translation();
40
- if (!sourcePosition) {
41
- return false;
42
- }
43
- const resolved = aim ?? resolveAim2D(input.aimX, input.aimY, getEntityFacingAngle2D(entity));
44
- void shooter.fire({
45
- source: entity,
46
- stage,
47
- target: {
48
- x: sourcePosition.x + resolved.direction.x,
49
- y: sourcePosition.y + resolved.direction.y
50
- }
51
- });
52
- return true;
53
- }
54
-
55
34
  export {
56
35
  getEntityFacingAngle2D,
57
- resolveAim2D,
58
- fireShooter2DIfRequested
36
+ resolveAim2D
59
37
  };
60
- //# sourceMappingURL=chunk-UL6Q5HDP.js.map
38
+ //# sourceMappingURL=chunk-TBUKJKY6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/coordinators/shared/top-down-aim.ts"],"sourcesContent":["import {\n\tangleFromDirection2D,\n\tdirectionFromAngle2D,\n\tgetRotationAngle2D,\n\tnormalizeDirection2D,\n} from '../../behaviors/shared/direction-2d';\n\nexport interface ResolvedAim2D {\n\tangle: number;\n\tdirection: { x: number; y: number };\n\thasAimInput: boolean;\n}\n\n/**\n * Minimal entity slice needed to derive a 2D facing angle. Structurally\n * satisfied by `Shooter2DSourceEntity` and the engine entity.\n */\nexport interface FacingAngle2DEntity {\n\ttopDownMovementState?: { facingAngle: number };\n\tbody?: {\n\t\trotation?: () => { x: number; y: number; z: number; w: number };\n\t} | null;\n\t/** Cached Z rotation maintained by 2D rotation helpers. */\n\t_rotation2DAngle?: number;\n}\n\nexport function getEntityFacingAngle2D(entity: FacingAngle2DEntity): number {\n\tif (entity.topDownMovementState) {\n\t\treturn entity.topDownMovementState.facingAngle;\n\t}\n\n\tif (entity.body?.rotation) {\n\t\treturn getRotationAngle2D(entity.body.rotation());\n\t}\n\n\treturn entity._rotation2DAngle ?? 0;\n}\n\nexport function resolveAim2D(\n\taimX: number,\n\taimY: number,\n\tfallbackAngle: number,\n): ResolvedAim2D {\n\tconst direction = normalizeDirection2D(aimX, aimY);\n\tif (direction) {\n\t\treturn {\n\t\t\tangle: angleFromDirection2D(direction),\n\t\t\tdirection,\n\t\t\thasAimInput: true,\n\t\t};\n\t}\n\n\treturn {\n\t\tangle: fallbackAngle,\n\t\tdirection: directionFromAngle2D(fallbackAngle),\n\t\thasAimInput: false,\n\t};\n}\n"],"mappings":";;;;;;;;AA0BO,SAAS,uBAAuB,QAAqC;AAC3E,MAAI,OAAO,sBAAsB;AAChC,WAAO,OAAO,qBAAqB;AAAA,EACpC;AAEA,MAAI,OAAO,MAAM,UAAU;AAC1B,WAAO,mBAAmB,OAAO,KAAK,SAAS,CAAC;AAAA,EACjD;AAEA,SAAO,OAAO,oBAAoB;AACnC;AAEO,SAAS,aACf,MACA,MACA,eACgB;AAChB,QAAM,YAAY,qBAAqB,MAAM,IAAI;AACjD,MAAI,WAAW;AACd,WAAO;AAAA,MACN,OAAO,qBAAqB,SAAS;AAAA,MACrC;AAAA,MACA,aAAa;AAAA,IACd;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,WAAW,qBAAqB,aAAa;AAAA,IAC7C,aAAa;AAAA,EACd;AACD;","names":[]}
@@ -7,11 +7,11 @@ import {
7
7
  } from "./chunk-OHCPV2NT.js";
8
8
  import {
9
9
  SyncStateMachine,
10
- t
11
- } from "./chunk-4URF65BR.js";
10
+ import_typescript_fsm
11
+ } from "./chunk-AS3HR7AS.js";
12
12
  import {
13
13
  StageBoundaryDim
14
- } from "./chunk-Q75LKHDF.js";
14
+ } from "./chunk-DZ4LLQON.js";
15
15
  import {
16
16
  defineBehavior
17
17
  } from "./chunk-EZNCCO4L.js";
@@ -57,10 +57,10 @@ var WorldBoundary3DFSM = class {
57
57
  this.machine = new SyncStateMachine(
58
58
  "inside" /* Inside */,
59
59
  [
60
- t("inside" /* Inside */, "touch-boundary" /* TouchBoundary */, "touching" /* Touching */),
61
- t("touching" /* Touching */, "enter-inside" /* EnterInside */, "inside" /* Inside */),
62
- t("inside" /* Inside */, "enter-inside" /* EnterInside */, "inside" /* Inside */),
63
- t("touching" /* Touching */, "touch-boundary" /* TouchBoundary */, "touching" /* Touching */)
60
+ (0, import_typescript_fsm.t)("inside" /* Inside */, "touch-boundary" /* TouchBoundary */, "touching" /* Touching */),
61
+ (0, import_typescript_fsm.t)("touching" /* Touching */, "enter-inside" /* EnterInside */, "inside" /* Inside */),
62
+ (0, import_typescript_fsm.t)("inside" /* Inside */, "enter-inside" /* EnterInside */, "inside" /* Inside */),
63
+ (0, import_typescript_fsm.t)("touching" /* Touching */, "touch-boundary" /* TouchBoundary */, "touching" /* Touching */)
64
64
  ]
65
65
  );
66
66
  }
@@ -153,25 +153,16 @@ var WorldBoundary3DSystem = class {
153
153
  boundaryRef.fsm = new WorldBoundary3DFSM();
154
154
  }
155
155
  const handle = gameEntity.runtimeHandle ?? -1;
156
- if (this.wasmStage && handle >= 0) {
157
- this.ensureWasmAttached(handle, options);
158
- const query = this.wasmStage.queryWorldBoundary(handle);
159
- if (query) {
160
- boundaryRef.fsm.update(
161
- { x: query.clamped[0], y: query.clamped[1], z: query.clamped[2] },
162
- options.boundaries,
163
- options.padding
164
- );
165
- continue;
166
- }
156
+ if (!this.wasmStage || handle < 0) continue;
157
+ this.ensureWasmAttached(handle, options);
158
+ const query = this.wasmStage.queryWorldBoundary(handle);
159
+ if (query) {
160
+ boundaryRef.fsm.update(
161
+ { x: query.clamped[0], y: query.clamped[1], z: query.clamped[2] },
162
+ options.boundaries,
163
+ options.padding
164
+ );
167
165
  }
168
- if (!gameEntity.body) continue;
169
- const pos = gameEntity.body.translation();
170
- boundaryRef.fsm.update(
171
- { x: pos.x, y: pos.y, z: pos.z },
172
- options.boundaries,
173
- options.padding
174
- );
175
166
  }
176
167
  }
177
168
  ensureWasmAttached(handle, options) {
@@ -207,4 +198,4 @@ export {
207
198
  WorldBoundary3DFSM,
208
199
  WorldBoundary3DBehavior
209
200
  };
210
- //# sourceMappingURL=chunk-Z72F2ENM.js.map
201
+ //# sourceMappingURL=chunk-WU6XXL3D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/behaviors/world-boundary-3d/world-boundary-3d-fsm.ts","../src/lib/behaviors/world-boundary-3d/world-boundary-3d.descriptor.ts"],"sourcesContent":["import { SyncStateMachine, t } from '../../core/utility/sync-state-machine';\nimport {\n\tclampPointToBounds3D,\n\tcomputeBounds3DHits,\n\tconstrainMovementToBounds3D,\n\thasAnyBounds3DHit,\n\tinsetBounds3D,\n\ttype Bounds3DPaddingInput,\n\ttype Bounds3DPoint,\n} from '../shared/bounds-3d';\n\nexport type WorldBoundary3DHit =\n\t| 'top'\n\t| 'bottom'\n\t| 'left'\n\t| 'right'\n\t| 'back'\n\t| 'front';\n\nexport type WorldBoundary3DHits = Record<WorldBoundary3DHit, boolean>;\n\nexport interface WorldBoundary3DPosition extends Bounds3DPoint {}\n\nexport interface WorldBoundary3DBounds {\n\ttop: number;\n\tbottom: number;\n\tleft: number;\n\tright: number;\n\tback: number;\n\tfront: number;\n}\n\nexport enum WorldBoundary3DState {\n\tInside = 'inside',\n\tTouching = 'touching',\n}\n\nexport enum WorldBoundary3DEvent {\n\tEnterInside = 'enter-inside',\n\tTouchBoundary = 'touch-boundary',\n}\n\nexport function computeWorldBoundary3DHits(\n\tposition: WorldBoundary3DPosition,\n\tbounds: WorldBoundary3DBounds,\n\tpadding?: Bounds3DPaddingInput,\n): WorldBoundary3DHits {\n\treturn computeBounds3DHits(position, insetBounds3D({\n\t\tminX: bounds.left,\n\t\tmaxX: bounds.right,\n\t\tminY: bounds.bottom,\n\t\tmaxY: bounds.top,\n\t\tminZ: bounds.back,\n\t\tmaxZ: bounds.front,\n\t}, padding));\n}\n\nexport function hasAnyWorldBoundary3DHit(hits: WorldBoundary3DHits): boolean {\n\treturn hasAnyBounds3DHit(hits);\n}\n\nexport class WorldBoundary3DFSM {\n\tpublic readonly machine: SyncStateMachine<WorldBoundary3DState, WorldBoundary3DEvent, never>;\n\n\tprivate lastHits: WorldBoundary3DHits = {\n\t\ttop: false,\n\t\tbottom: false,\n\t\tleft: false,\n\t\tright: false,\n\t\tback: false,\n\t\tfront: false,\n\t};\n\tprivate lastPosition: WorldBoundary3DPosition | null = null;\n\tprivate lastClampedPosition: WorldBoundary3DPosition | null = null;\n\tprivate lastUpdatedAtMs: number | null = null;\n\n\tconstructor() {\n\t\tthis.machine = new SyncStateMachine<WorldBoundary3DState, WorldBoundary3DEvent, never>(\n\t\t\tWorldBoundary3DState.Inside,\n\t\t\t[\n\t\t\t\tt(WorldBoundary3DState.Inside, WorldBoundary3DEvent.TouchBoundary, WorldBoundary3DState.Touching),\n\t\t\t\tt(WorldBoundary3DState.Touching, WorldBoundary3DEvent.EnterInside, WorldBoundary3DState.Inside),\n\t\t\t\tt(WorldBoundary3DState.Inside, WorldBoundary3DEvent.EnterInside, WorldBoundary3DState.Inside),\n\t\t\t\tt(WorldBoundary3DState.Touching, WorldBoundary3DEvent.TouchBoundary, WorldBoundary3DState.Touching),\n\t\t\t],\n\t\t);\n\t}\n\n\tgetState(): WorldBoundary3DState {\n\t\treturn this.machine.getState();\n\t}\n\n\tgetLastHits(): WorldBoundary3DHits {\n\t\treturn this.lastHits;\n\t}\n\n\tgetMovement(\n\t\tmoveX: number,\n\t\tmoveY: number,\n\t\tmoveZ: number,\n\t): { moveX: number; moveY: number; moveZ: number } {\n\t\treturn constrainMovementToBounds3D(this.lastHits, moveX, moveY, moveZ);\n\t}\n\n\tgetLastPosition(): WorldBoundary3DPosition | null {\n\t\treturn this.lastPosition;\n\t}\n\n\tgetLastClampedPosition(): WorldBoundary3DPosition | null {\n\t\treturn this.lastClampedPosition;\n\t}\n\n\tgetLastUpdatedAtMs(): number | null {\n\t\treturn this.lastUpdatedAtMs;\n\t}\n\n\tupdate(\n\t\tposition: WorldBoundary3DPosition,\n\t\tbounds: WorldBoundary3DBounds,\n\t\tpadding?: Bounds3DPaddingInput,\n\t): WorldBoundary3DHits {\n\t\tconst effectiveBounds = insetBounds3D({\n\t\t\tminX: bounds.left,\n\t\t\tmaxX: bounds.right,\n\t\t\tminY: bounds.bottom,\n\t\t\tmaxY: bounds.top,\n\t\t\tminZ: bounds.back,\n\t\t\tmaxZ: bounds.front,\n\t\t}, padding);\n\n\t\tconst hits = computeBounds3DHits(position, effectiveBounds);\n\t\tthis.lastHits = hits;\n\t\tthis.lastPosition = { x: position.x, y: position.y, z: position.z };\n\t\tthis.lastClampedPosition = clampPointToBounds3D(position, effectiveBounds);\n\t\tthis.lastUpdatedAtMs = Date.now();\n\n\t\tif (hasAnyWorldBoundary3DHit(hits)) {\n\t\t\tthis.dispatch(WorldBoundary3DEvent.TouchBoundary);\n\t\t} else {\n\t\t\tthis.dispatch(WorldBoundary3DEvent.EnterInside);\n\t\t}\n\n\t\treturn hits;\n\t}\n\n\tprivate dispatch(event: WorldBoundary3DEvent): void {\n\t\tif (this.machine.can(event)) {\n\t\t\tthis.machine.syncDispatch(event);\n\t\t}\n\t}\n}\n","import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport type { Bounds3DPaddingInput } from '../shared/bounds-3d';\nimport {\n\tWorldBoundary3DFSM,\n\ttype WorldBoundary3DBounds,\n\ttype WorldBoundary3DHits,\n\ttype WorldBoundary3DPosition,\n} from './world-boundary-3d-fsm';\nimport {\n\tStageBoundaryDim,\n\ttype BehaviorRuntime,\n} from '../../runtime/wasm-stage-runtime';\n\nexport interface WorldBoundary3DOptions {\n\tboundaries: WorldBoundary3DBounds;\n\tpadding?: Bounds3DPaddingInput;\n}\n\nexport interface WorldBoundary3DHandle {\n\tgetLastHits(): WorldBoundary3DHits | null;\n\tgetMovement(\n\t\tmoveX: number,\n\t\tmoveY: number,\n\t\tmoveZ: number,\n\t): { moveX: number; moveY: number; moveZ: number };\n\tgetLastClampedPosition(): WorldBoundary3DPosition | null;\n}\n\nconst defaultOptions: WorldBoundary3DOptions = {\n\tboundaries: { top: 0, bottom: 0, left: 0, right: 0, back: 0, front: 0 },\n\tpadding: 0,\n};\n\nconst WORLD_BOUNDARY_3D_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:world-boundary-3d',\n);\n\nfunction createWorldBoundary3DHandle(\n\tref: BehaviorRef<WorldBoundary3DOptions>,\n): WorldBoundary3DHandle {\n\treturn {\n\t\tgetLastHits: () => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getLastHits() ?? null;\n\t\t},\n\t\tgetMovement: (moveX: number, moveY: number, moveZ: number) => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getMovement(moveX, moveY, moveZ) ?? { moveX, moveY, moveZ };\n\t\t},\n\t\tgetLastClampedPosition: () => {\n\t\t\tconst fsm = ref.fsm as WorldBoundary3DFSM | undefined;\n\t\t\treturn fsm?.getLastClampedPosition() ?? null;\n\t\t},\n\t};\n}\n\nclass WorldBoundary3DSystem implements BehaviorSystem {\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, _delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(WORLD_BOUNDARY_3D_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst gameEntity = link.entity as any;\n\t\t\tconst boundaryRef = link.ref as any;\n\t\t\tconst options = boundaryRef.options as WorldBoundary3DOptions;\n\t\t\tif (!boundaryRef.fsm) {\n\t\t\t\tboundaryRef.fsm = new WorldBoundary3DFSM();\n\t\t\t}\n\n\t\t\tconst handle = (gameEntity.runtimeHandle ?? -1) as number;\n\t\t\tif (!this.wasmStage || handle < 0) continue;\n\n\t\t\tthis.ensureWasmAttached(handle, options);\n\t\t\tconst query = this.wasmStage.queryWorldBoundary(handle);\n\t\t\tif (query) {\n\t\t\t\tboundaryRef.fsm.update(\n\t\t\t\t\t{ x: query.clamped[0], y: query.clamped[1], z: query.clamped[2] },\n\t\t\t\t\toptions.boundaries,\n\t\t\t\t\toptions.padding,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: WorldBoundary3DOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tconst padding = typeof options.padding === 'number' ? options.padding : 0;\n\t\tthis.wasmStage.attachWorldBoundary(handle, StageBoundaryDim.Three, {\n\t\t\ttop: options.boundaries.top,\n\t\t\tbottom: options.boundaries.bottom,\n\t\t\tleft: options.boundaries.left,\n\t\t\tright: options.boundaries.right,\n\t\t\tfront: options.boundaries.front,\n\t\t\tback: options.boundaries.back,\n\t\t\tpadding,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const WorldBoundary3DBehavior = defineBehavior({\n\tname: 'world-boundary-3d',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew WorldBoundary3DSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createWorldBoundary3DHandle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCO,IAAK,uBAAL,kBAAKA,0BAAL;AACN,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,cAAW;AAFA,SAAAA;AAAA,GAAA;AAKL,IAAK,uBAAL,kBAAKC,0BAAL;AACN,EAAAA,sBAAA,iBAAc;AACd,EAAAA,sBAAA,mBAAgB;AAFL,SAAAA;AAAA,GAAA;AAKL,SAAS,2BACf,UACA,QACA,SACsB;AACtB,SAAO,oBAAoB,UAAU,cAAc;AAAA,IAClD,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,IACb,MAAM,OAAO;AAAA,EACd,GAAG,OAAO,CAAC;AACZ;AAEO,SAAS,yBAAyB,MAAoC;AAC5E,SAAO,kBAAkB,IAAI;AAC9B;AAEO,IAAM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ownMovementStateComponent
5
5
  } from "./chunk-EIWQM6U3.js";
6
6
  import {
7
- angleFromDirection2D,
8
- normalizeDirection2DInto
9
- } from "./chunk-Y7YIAWPW.js";
7
+ resolveAim2D
8
+ } from "./chunk-TBUKJKY6.js";
10
9
  import {
11
10
  StageTopDownPlane
12
- } from "./chunk-Q75LKHDF.js";
11
+ } from "./chunk-DZ4LLQON.js";
13
12
  import {
14
13
  defineBehavior
15
14
  } from "./chunk-EZNCCO4L.js";
16
15
 
17
- // src/lib/behaviors/top-down-movement/top-down-movement.system.ts
18
- var _moveDirection = { x: 0, y: 0 };
19
- var _facingDirection = { x: 0, y: 0 };
20
- var TopDownMovementSystem = class {
21
- updateEntity(entity, _delta) {
22
- if (!entity.body || !entity.transformStore || !entity.topDownMovement || !entity.$topDownMovement || !entity.topDownMovementState) {
23
- return;
24
- }
25
- const movement = entity.topDownMovement;
26
- const input = entity.$topDownMovement;
27
- const state = entity.topDownMovementState;
28
- const isMoving = normalizeDirection2DInto(input.moveX, input.moveY, _moveDirection);
29
- const velocity = entity.body.linvel();
30
- state.moving = isMoving;
31
- entity.transformStore.velocity.x = isMoving ? _moveDirection.x * movement.moveSpeed : 0;
32
- entity.transformStore.velocity.y = isMoving ? _moveDirection.y * movement.moveSpeed : 0;
33
- entity.transformStore.velocity.z = velocity.z;
34
- entity.transformStore.dirty.velocityX = true;
35
- entity.transformStore.dirty.velocityY = true;
36
- entity.transformStore.dirty.velocityZ = true;
37
- if (normalizeDirection2DInto(input.faceX, input.faceY, _facingDirection)) {
38
- state.facingAngle = angleFromDirection2D(_facingDirection);
39
- }
40
- entity.setRotationZ?.(state.facingAngle);
41
- }
42
- };
43
-
44
16
  // src/lib/behaviors/top-down-movement/top-down-movement.descriptor.ts
45
17
  var defaultOptions = {
46
- moveSpeed: 8
18
+ moveSpeed: 8,
19
+ faceMovement: false
47
20
  };
48
21
  var TOP_DOWN_MOVEMENT_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for(
49
22
  "zylem:behavior:top-down-movement"
@@ -60,9 +33,8 @@ var TopDownMovementBehaviorSystem = class {
60
33
  }
61
34
  wasmStage;
62
35
  getBehaviorLinks;
63
- behavior = new TopDownMovementSystem();
64
36
  attachedRuntimeSlots = /* @__PURE__ */ new Set();
65
- update(_ecs, delta) {
37
+ update(_ecs, _delta) {
66
38
  const links = this.getBehaviorLinks?.(TOP_DOWN_MOVEMENT_BEHAVIOR_KEY);
67
39
  if (!links) return;
68
40
  for (const link of links) {
@@ -79,16 +51,25 @@ var TopDownMovementBehaviorSystem = class {
79
51
  }
80
52
  ref.__entity = entity;
81
53
  const handle = entity.runtimeHandle ?? -1;
82
- if (this.wasmStage && handle >= 0) {
83
- this.ensureWasmAttached(handle, ref.options);
84
- const input = entity.$topDownMovement;
85
- if (input) {
86
- this.wasmStage.writeInputAxes(handle, input.moveX ?? 0, input.moveY ?? input.moveZ ?? 0);
54
+ if (!this.wasmStage || handle < 0) continue;
55
+ this.ensureWasmAttached(handle, ref.options);
56
+ const input = entity.$topDownMovement;
57
+ const state = entity.topDownMovementState;
58
+ if (input) {
59
+ const moveX = input.moveX ?? 0;
60
+ const moveY = input.moveY ?? input.moveZ ?? 0;
61
+ this.wasmStage.writeInputAxes(handle, moveX, moveY);
62
+ state.moving = Math.hypot(moveX, moveY) > 1e-3;
63
+ const aim = resolveAim2D(
64
+ input.faceX ?? 0,
65
+ input.faceY ?? 0,
66
+ state.facingAngle
67
+ );
68
+ if (aim.hasAimInput) {
69
+ state.facingAngle = aim.angle;
70
+ entity.setRotationZ?.(aim.angle);
87
71
  }
88
- continue;
89
72
  }
90
- if (!entity.body || !entity.transformStore) continue;
91
- this.behavior.updateEntity(entity, delta);
92
73
  }
93
74
  }
94
75
  ensureWasmAttached(handle, options) {
@@ -96,7 +77,7 @@ var TopDownMovementBehaviorSystem = class {
96
77
  this.wasmStage.attachTopDown(handle, {
97
78
  plane: StageTopDownPlane.Xy,
98
79
  speed: options.moveSpeed ?? defaultOptions.moveSpeed,
99
- faceMovement: true
80
+ faceMovement: options.faceMovement ?? defaultOptions.faceMovement
100
81
  });
101
82
  this.attachedRuntimeSlots.add(handle);
102
83
  }
@@ -112,7 +93,6 @@ var TopDownMovementBehavior = defineBehavior({
112
93
  });
113
94
 
114
95
  export {
115
- TopDownMovementSystem,
116
96
  TopDownMovementBehavior
117
97
  };
118
- //# sourceMappingURL=chunk-A4CA35DQ.js.map
98
+ //# sourceMappingURL=chunk-Y4PHT2HG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/behaviors/top-down-movement/top-down-movement.descriptor.ts"],"sourcesContent":["import { defineBehavior, type BehaviorRef } from '../behavior-descriptor';\nimport type { BehaviorEntityLink, BehaviorSystem } from '../behavior-system';\nimport {\n\tcreateTopDownMovementComponent,\n\tcreateTopDownMovementInputComponent,\n\tcreateTopDownMovementStateComponent,\n} from './components';\nimport type {\n\tTopDownMovementComponent,\n\tTopDownMovementInputComponent,\n\tTopDownMovementStateComponent,\n} from './components';\nimport {\n\tStageTopDownPlane,\n\ttype BehaviorRuntime,\n} from '../../runtime/wasm-stage-runtime';\nimport { resolveAim2D } from '../../coordinators/shared/top-down-aim';\n\n/**\n * Entity with top-down movement components (input written by the game,\n * simulation owned by the wasm runtime).\n */\nexport interface TopDownMovementEntity {\n\ttopDownMovement: TopDownMovementComponent;\n\t$topDownMovement: TopDownMovementInputComponent;\n\ttopDownMovementState: TopDownMovementStateComponent;\n}\n\nexport interface TopDownMovementBehaviorOptions {\n\tmoveSpeed?: number;\n\t/** When true, WASM rotates toward velocity; default false for twin-stick face axes. */\n\tfaceMovement?: boolean;\n}\n\nexport interface TopDownMovementHandle {\n\tgetFacingAngle(): number;\n}\n\nconst defaultOptions: TopDownMovementBehaviorOptions = {\n\tmoveSpeed: 8,\n\tfaceMovement: false,\n};\n\nconst TOP_DOWN_MOVEMENT_BEHAVIOR_KEY = Symbol.for(\n\t'zylem:behavior:top-down-movement',\n);\n\nfunction createTopDownMovementHandle(\n\tref: BehaviorRef<TopDownMovementBehaviorOptions>,\n): TopDownMovementHandle {\n\treturn {\n\t\tgetFacingAngle: () =>\n\t\t\t(ref as any).__entity?.topDownMovementState?.facingAngle ?? 0,\n\t};\n}\n\nclass TopDownMovementBehaviorSystem implements BehaviorSystem {\n\tprivate attachedRuntimeSlots = new Set<number>();\n\n\tconstructor(\n\t\tprivate wasmStage: BehaviorRuntime | null,\n\t\tprivate getBehaviorLinks?: (key: symbol) => Iterable<BehaviorEntityLink>,\n\t) {}\n\n\tupdate(_ecs: unknown, _delta: number): void {\n\t\tconst links = this.getBehaviorLinks?.(TOP_DOWN_MOVEMENT_BEHAVIOR_KEY);\n\t\tif (!links) return;\n\n\t\tfor (const link of links) {\n\t\t\tconst entity = link.entity as any;\n\t\t\tconst ref = link.ref as any;\n\n\t\t\tif (!entity.topDownMovement) {\n\t\t\t\tentity.topDownMovement = createTopDownMovementComponent(ref.options);\n\t\t\t}\n\t\t\tif (!entity.$topDownMovement) {\n\t\t\t\tentity.$topDownMovement = createTopDownMovementInputComponent();\n\t\t\t}\n\t\t\tif (!entity.topDownMovementState) {\n\t\t\t\tentity.topDownMovementState = createTopDownMovementStateComponent();\n\t\t\t}\n\n\t\t\tref.__entity = entity;\n\n\t\t\tconst handle = (entity.runtimeHandle ?? -1) as number;\n\t\t\tif (!this.wasmStage || handle < 0) continue;\n\n\t\t\tthis.ensureWasmAttached(handle, ref.options as TopDownMovementBehaviorOptions);\n\t\t\tconst input = entity.$topDownMovement;\n\t\t\tconst state = entity.topDownMovementState;\n\t\t\tif (input) {\n\t\t\t\tconst moveX = input.moveX ?? 0;\n\t\t\t\tconst moveY = input.moveY ?? input.moveZ ?? 0;\n\t\t\t\tthis.wasmStage.writeInputAxes(handle, moveX, moveY);\n\t\t\t\tstate.moving = Math.hypot(moveX, moveY) > 0.001;\n\n\t\t\t\tconst aim = resolveAim2D(\n\t\t\t\t\tinput.faceX ?? 0,\n\t\t\t\t\tinput.faceY ?? 0,\n\t\t\t\t\tstate.facingAngle,\n\t\t\t\t);\n\t\t\t\tif (aim.hasAimInput) {\n\t\t\t\t\tstate.facingAngle = aim.angle;\n\t\t\t\t\tentity.setRotationZ?.(aim.angle);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate ensureWasmAttached(handle: number, options: TopDownMovementBehaviorOptions): void {\n\t\tif (!this.wasmStage || this.attachedRuntimeSlots.has(handle)) return;\n\t\tthis.wasmStage.attachTopDown(handle, {\n\t\t\tplane: StageTopDownPlane.Xy,\n\t\t\tspeed: options.moveSpeed ?? defaultOptions.moveSpeed!,\n\t\t\tfaceMovement: options.faceMovement ?? defaultOptions.faceMovement!,\n\t\t});\n\t\tthis.attachedRuntimeSlots.add(handle);\n\t}\n\n\tdestroy(_ecs: unknown): void {\n\t\tthis.attachedRuntimeSlots.clear();\n\t}\n}\n\nexport const TopDownMovementBehavior = defineBehavior<\n\tTopDownMovementBehaviorOptions,\n\tTopDownMovementHandle,\n\tTopDownMovementEntity\n>({\n\tname: 'top-down-movement',\n\tdefaultOptions,\n\tsystemFactory: (ctx) =>\n\t\tnew TopDownMovementBehaviorSystem(ctx.wasmStage ?? null, ctx.getBehaviorLinks),\n\tcreateHandle: createTopDownMovementHandle,\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,IAAM,iBAAiD;AAAA,EACtD,WAAW;AAAA,EACX,cAAc;AACf;AAEA,IAAM,iCAAiC,uBAAO;AAAA,EAC7C;AACD;AAEA,SAAS,4BACR,KACwB;AACxB,SAAO;AAAA,IACN,gBAAgB,MACd,IAAY,UAAU,sBAAsB,eAAe;AAAA,EAC9D;AACD;AAEA,IAAM,gCAAN,MAA8D;AAAA,EAG7D,YACS,WACA,kBACP;AAFO;AACA;AAAA,EACN;AAAA,EAFM;AAAA,EACA;AAAA,EAJD,uBAAuB,oBAAI,IAAY;AAAA,EAO/C,OAAO,MAAe,QAAsB;AAC3C,UAAM,QAAQ,KAAK,mBAAmB,8BAA8B;AACpE,QAAI,C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AAC5B,SAAK,qBAAqB,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,0BAA0B,eAIrC;AAAA,EACD,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAC,QACf,IAAI,8BAA8B,IAAI,aAAa,MAAM,IAAI,gBAAgB;AAAA,EAC9E,cAAc;AACf,CAAC;","names":[]}
@@ -0,0 +1,30 @@
1
+ import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-CldqNUgr.js';
2
+ import { Vector3, Quaternion } from 'three';
3
+
4
+ /**
5
+ * Type-safe helper to apply a behavior to an entity and return the entity cast to the behavior's interface.
6
+ *
7
+ * @param entity The entity to apply the behavior to
8
+ * @param descriptor The behavior descriptor
9
+ * @param options Behavior options
10
+ * @returns The entity, cast to E & I (where I is the behavior's interface)
11
+ */
12
+ declare function useBehavior<E extends GameEntity<any>, O extends Record<string, any>, H extends Record<string, any>, I>(entity: E, descriptor: BehaviorDescriptor<O, H, I>, options?: Partial<O>): E & I;
13
+
14
+ /**
15
+ * Core behavior helper types
16
+ *
17
+ * Plain data interfaces shared by movement behaviors and coordinators.
18
+ */
19
+
20
+ interface TransformComponent {
21
+ position: Vector3;
22
+ rotation: Quaternion;
23
+ }
24
+ declare function createTransformComponent(): TransformComponent;
25
+ interface PhysicsBodyComponent {
26
+ body: unknown;
27
+ }
28
+ declare function createPhysicsBodyComponent(body: unknown): PhysicsBodyComponent;
29
+
30
+ export { type PhysicsBodyComponent as P, type TransformComponent as T, createTransformComponent as a, createPhysicsBodyComponent as c, useBehavior as u };
@@ -1,5 +1,5 @@
1
- import { a as BehaviorDescriptor } from './behavior-system-y8SGrGWy.js';
2
- import '@dimforge/rapier3d-compat';
1
+ import { a as BehaviorDescriptor } from './behavior-system-CldqNUgr.js';
2
+ import '@zylem/runtime';
3
3
 
4
4
  /**
5
5
  * CooldownBehavior
package/dist/cooldown.js CHANGED
@@ -6,8 +6,9 @@ import {
6
6
  registerCooldown,
7
7
  resetCooldown,
8
8
  tickCooldowns
9
- } from "./chunk-ZRQWSURL.js";
9
+ } from "./chunk-5XPPLTC7.js";
10
10
  import "./chunk-EZNCCO4L.js";
11
+ import "./chunk-5WRI5ZAA.js";
11
12
  export {
12
13
  CooldownBehavior,
13
14
  fireCooldown,
@@ -1,10 +1,10 @@
1
- import { M as MoveableEntity } from '../moveable-Cl9h-_w7.js';
2
- import { B as BaseEntityInterface } from '../entity-types-CmtQ-IBp.js';
1
+ import { a as MoveableEntity } from '../moveable-rdIvWiak.js';
2
+ import { B as BaseEntityInterface } from '../entity-types-DhfsZbSK.js';
3
3
  import { Ricochet3DHandle } from '../ricochet-3d.js';
4
4
  import { WorldBoundary3DHandle } from '../world-boundary-3d.js';
5
5
  import 'three';
6
- import '@dimforge/rapier3d-compat';
7
- import '../behavior-system-y8SGrGWy.js';
6
+ import '../behavior-system-CldqNUgr.js';
7
+ import '@zylem/runtime';
8
8
  import '../sync-state-machine-CZyspBpj.js';
9
9
  import 'typescript-fsm';
10
10
 
@@ -3,6 +3,7 @@ import {
3
3
  } from "../chunk-KFFETUAL.js";
4
4
  import "../chunk-OHCPV2NT.js";
5
5
  import "../chunk-LL4FLHIY.js";
6
+ import "../chunk-5WRI5ZAA.js";
6
7
  export {
7
8
  BoundaryRicochet3DCoordinator
8
9
  };
@@ -1,11 +1,11 @@
1
1
  import { Ricochet2DHandle } from '../ricochet-2d.js';
2
2
  import { WorldBoundary2DHandle } from '../world-boundary-2d.js';
3
- import { M as MoveableEntity } from '../moveable-Cl9h-_w7.js';
4
- import { B as BaseEntityInterface } from '../entity-types-CmtQ-IBp.js';
3
+ import { a as MoveableEntity } from '../moveable-rdIvWiak.js';
4
+ import { B as BaseEntityInterface } from '../entity-types-DhfsZbSK.js';
5
5
  import '../sync-state-machine-CZyspBpj.js';
6
6
  import 'typescript-fsm';
7
- import '../behavior-system-y8SGrGWy.js';
8
- import '@dimforge/rapier3d-compat';
7
+ import '../behavior-system-CldqNUgr.js';
8
+ import '@zylem/runtime';
9
9
  import 'three';
10
10
 
11
11
  /** Entity shape required by the 2D boundary-ricochet coordinator. */
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  BoundaryRicochetCoordinator
3
- } from "../chunk-XP3ASVGJ.js";
4
- import "../chunk-KDY5N6J4.js";
3
+ } from "../chunk-NW4SE5XW.js";
4
+ import "../chunk-OPZ2LVS2.js";
5
5
  import "../chunk-LL4FLHIY.js";
6
+ import "../chunk-5WRI5ZAA.js";
6
7
  export {
7
8
  BoundaryRicochetCoordinator
8
9
  };
@@ -3,6 +3,7 @@ import {
3
3
  } from "../chunk-H4TJ7X4O.js";
4
4
  import "../chunk-QVCMJ4Q2.js";
5
5
  import "../chunk-4WH2ZN7P.js";
6
+ import "../chunk-5WRI5ZAA.js";
6
7
  export {
7
8
  FirstPersonShooterCoordinator
8
9
  };
@@ -1,9 +1,9 @@
1
1
  import { T as ThrusterInputComponent } from '../components-B29WHGQN.js';
2
2
  import { Shooter2DSourceEntity, Shooter2DHandle, Shooter2DStageLike } from '../shooter-2d.js';
3
3
  import { S as Shooter2DAimFireInput } from '../shooter-fire-DGripl0z.js';
4
- import '../behavior-system-y8SGrGWy.js';
5
- import '@dimforge/rapier3d-compat';
6
- import '../vector-Bm65-FOG.js';
4
+ import '../behavior-system-CldqNUgr.js';
5
+ import '@zylem/runtime';
6
+ import '../vector-DjhLUrak.js';
7
7
  import 'three';
8
8
 
9
9
  interface MultidirectionalSpaceShooterInput extends Shooter2DAimFireInput {
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  MultidirectionalSpaceShooterCoordinator
3
- } from "../chunk-FTDZAKZW.js";
4
- import "../chunk-UL6Q5HDP.js";
3
+ } from "../chunk-NQPYMUDF.js";
4
+ import "../chunk-52FJIDGL.js";
5
5
  import "../chunk-IZJFUAXB.js";
6
- import "../chunk-Y7YIAWPW.js";
6
+ import "../chunk-TBUKJKY6.js";
7
+ import "../chunk-SGHIGTVZ.js";
8
+ import "../chunk-5WRI5ZAA.js";
7
9
  export {
8
10
  MultidirectionalSpaceShooterCoordinator
9
11
  };
@@ -1,9 +1,9 @@
1
1
  import { a as TopDownMovementInputComponent } from '../components-XCpL6IYt.js';
2
2
  import { Shooter2DSourceEntity, Shooter2DHandle, Shooter2DStageLike } from '../shooter-2d.js';
3
3
  import { S as Shooter2DAimFireInput } from '../shooter-fire-DGripl0z.js';
4
- import '../behavior-system-y8SGrGWy.js';
5
- import '@dimforge/rapier3d-compat';
6
- import '../vector-Bm65-FOG.js';
4
+ import '../behavior-system-CldqNUgr.js';
5
+ import '@zylem/runtime';
6
+ import '../vector-DjhLUrak.js';
7
7
  import 'three';
8
8
 
9
9
  interface TopDownShooterInput extends Shooter2DAimFireInput {
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  TopDownShooterCoordinator
3
- } from "../chunk-ZA43LPRM.js";
4
- import "../chunk-UL6Q5HDP.js";
3
+ } from "../chunk-KIYUUSPK.js";
4
+ import "../chunk-52FJIDGL.js";
5
5
  import "../chunk-EIWQM6U3.js";
6
- import "../chunk-Y7YIAWPW.js";
6
+ import "../chunk-TBUKJKY6.js";
7
+ import "../chunk-SGHIGTVZ.js";
8
+ import "../chunk-5WRI5ZAA.js";
7
9
  export {
8
10
  TopDownShooterCoordinator
9
11
  };