@zylem/behaviors 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{behavior-system-DYbx-x_-.d.ts → behavior-system-DSNek0W9.d.ts} +205 -29
  3. package/dist/{chunk-RER2IDPW.js → chunk-4URF65BR.js} +1 -0
  4. package/dist/chunk-4URF65BR.js.map +1 -0
  5. package/dist/{chunk-YYJP62QD.js → chunk-4V7TIRO2.js} +1 -0
  6. package/dist/chunk-4V7TIRO2.js.map +1 -0
  7. package/dist/{chunk-F7E23E26.js → chunk-4WH2ZN7P.js} +1 -0
  8. package/dist/chunk-4WH2ZN7P.js.map +1 -0
  9. package/dist/{chunk-VPZ32CCD.js → chunk-5SM5SH5O.js} +29 -28
  10. package/dist/chunk-5SM5SH5O.js.map +1 -0
  11. package/dist/{chunk-L76JG73P.js → chunk-5XZWTFGF.js} +7 -4
  12. package/dist/chunk-5XZWTFGF.js.map +1 -0
  13. package/dist/{chunk-HIBJDA5Z.js → chunk-64HKCSXD.js} +21 -17
  14. package/dist/chunk-64HKCSXD.js.map +1 -0
  15. package/dist/{chunk-WSKD7GY3.js → chunk-7JJEIADR.js} +1 -0
  16. package/dist/chunk-7JJEIADR.js.map +1 -0
  17. package/dist/{chunk-F6LFX4V3.js → chunk-BXP4K7RF.js} +3 -2
  18. package/dist/chunk-BXP4K7RF.js.map +1 -0
  19. package/dist/{chunk-2HKY6WF7.js → chunk-EIWQM6U3.js} +1 -0
  20. package/dist/chunk-EIWQM6U3.js.map +1 -0
  21. package/dist/{chunk-YDLO5M7S.js → chunk-EZNCCO4L.js} +1 -0
  22. package/dist/chunk-EZNCCO4L.js.map +1 -0
  23. package/dist/{chunk-T2P4JTQN.js → chunk-FRJDQM23.js} +110 -155
  24. package/dist/chunk-FRJDQM23.js.map +1 -0
  25. package/dist/{chunk-FHDYJ5WP.js → chunk-FTDZAKZW.js} +5 -17
  26. package/dist/chunk-FTDZAKZW.js.map +1 -0
  27. package/dist/{chunk-D53GNZXP.js → chunk-GFARAJV2.js} +6 -7
  28. package/dist/chunk-GFARAJV2.js.map +1 -0
  29. package/dist/{chunk-IQRG5BAZ.js → chunk-GTLA6LOJ.js} +18 -23
  30. package/dist/chunk-GTLA6LOJ.js.map +1 -0
  31. package/dist/{chunk-VO5J64DG.js → chunk-H4TJ7X4O.js} +4 -6
  32. package/dist/chunk-H4TJ7X4O.js.map +1 -0
  33. package/dist/{chunk-6UMC6BB5.js → chunk-HNESASBB.js} +7 -8
  34. package/dist/chunk-HNESASBB.js.map +1 -0
  35. package/dist/{chunk-4DVDFCVY.js → chunk-HZMY3TT4.js} +1 -0
  36. package/dist/chunk-HZMY3TT4.js.map +1 -0
  37. package/dist/{chunk-2HLZBWGD.js → chunk-IZJFUAXB.js} +1 -0
  38. package/dist/chunk-IZJFUAXB.js.map +1 -0
  39. package/dist/{chunk-UFHYR2LV.js → chunk-JXMF4NUI.js} +51 -2
  40. package/dist/chunk-JXMF4NUI.js.map +1 -0
  41. package/dist/{chunk-ZHBD65AZ.js → chunk-KDY5N6J4.js} +1 -0
  42. package/dist/chunk-KDY5N6J4.js.map +1 -0
  43. package/dist/chunk-KFFETUAL.js +40 -0
  44. package/dist/chunk-KFFETUAL.js.map +1 -0
  45. package/dist/chunk-LL4FLHIY.js +12 -0
  46. package/dist/chunk-LL4FLHIY.js.map +1 -0
  47. package/dist/{chunk-BC3IJYS7.js → chunk-MJFMNRMZ.js} +15 -15
  48. package/dist/chunk-MJFMNRMZ.js.map +1 -0
  49. package/dist/{chunk-WHKPWIQO.js → chunk-OHCPV2NT.js} +1 -0
  50. package/dist/chunk-OHCPV2NT.js.map +1 -0
  51. package/dist/{chunk-RQWWUML4.js → chunk-OTLSUYQQ.js} +2 -1
  52. package/dist/chunk-OTLSUYQQ.js.map +1 -0
  53. package/dist/{chunk-E4HTCQPK.js → chunk-PWF757B6.js} +7 -8
  54. package/dist/chunk-PWF757B6.js.map +1 -0
  55. package/dist/{chunk-4EWASZHB.js → chunk-QVCMJ4Q2.js} +1 -0
  56. package/dist/chunk-QVCMJ4Q2.js.map +1 -0
  57. package/dist/{chunk-FOOM42MK.js → chunk-RONH2KDI.js} +12 -13
  58. package/dist/chunk-RONH2KDI.js.map +1 -0
  59. package/dist/chunk-RTRFJVCZ.js +454 -0
  60. package/dist/chunk-RTRFJVCZ.js.map +1 -0
  61. package/dist/{chunk-IEA7F73P.js → chunk-UL6Q5HDP.js} +25 -2
  62. package/dist/chunk-UL6Q5HDP.js.map +1 -0
  63. package/dist/{chunk-K6CWKFHL.js → chunk-UYFOLI2X.js} +1 -0
  64. package/dist/chunk-UYFOLI2X.js.map +1 -0
  65. package/dist/{chunk-RD2YTTXY.js → chunk-V74N7D6Q.js} +9 -8
  66. package/dist/chunk-V74N7D6Q.js.map +1 -0
  67. package/dist/{chunk-ERS6SNA5.js → chunk-WOMHL23C.js} +2 -1
  68. package/dist/chunk-WOMHL23C.js.map +1 -0
  69. package/dist/{chunk-RHW3IDQX.js → chunk-WWVD5DR5.js} +1 -0
  70. package/dist/chunk-WWVD5DR5.js.map +1 -0
  71. package/dist/{chunk-SBACY5SU.js → chunk-WXXXJ22R.js} +14 -15
  72. package/dist/chunk-WXXXJ22R.js.map +1 -0
  73. package/dist/{chunk-6Y3GB76J.js → chunk-XLUJDKCT.js} +9 -8
  74. package/dist/chunk-XLUJDKCT.js.map +1 -0
  75. package/dist/{chunk-7Y6JVZ5H.js → chunk-XP3ASVGJ.js} +14 -10
  76. package/dist/chunk-XP3ASVGJ.js.map +1 -0
  77. package/dist/{chunk-7U4WFBWM.js → chunk-Y7YIAWPW.js} +11 -0
  78. package/dist/chunk-Y7YIAWPW.js.map +1 -0
  79. package/dist/{chunk-7IZ36Y5G.js → chunk-ZA43LPRM.js} +5 -24
  80. package/dist/chunk-ZA43LPRM.js.map +1 -0
  81. package/dist/{chunk-J5XLB24H.js → chunk-ZRQWSURL.js} +3 -2
  82. package/dist/chunk-ZRQWSURL.js.map +1 -0
  83. package/dist/cooldown.d.ts +2 -1
  84. package/dist/cooldown.js +3 -2
  85. package/dist/cooldown.js.map +1 -0
  86. package/dist/coordinators/boundary-ricochet-3d.d.ts +12 -5
  87. package/dist/coordinators/boundary-ricochet-3d.js +4 -2
  88. package/dist/coordinators/boundary-ricochet-3d.js.map +1 -0
  89. package/dist/coordinators/boundary-ricochet.d.ts +9 -7
  90. package/dist/coordinators/boundary-ricochet.js +4 -2
  91. package/dist/coordinators/boundary-ricochet.js.map +1 -0
  92. package/dist/coordinators/first-person-shooter.d.ts +9 -8
  93. package/dist/coordinators/first-person-shooter.js +4 -3
  94. package/dist/coordinators/first-person-shooter.js.map +1 -0
  95. package/dist/coordinators/multidirectional-space-shooter.d.ts +12 -9
  96. package/dist/coordinators/multidirectional-space-shooter.js +5 -4
  97. package/dist/coordinators/multidirectional-space-shooter.js.map +1 -0
  98. package/dist/coordinators/top-down-shooter.d.ts +9 -8
  99. package/dist/coordinators/top-down-shooter.js +5 -4
  100. package/dist/coordinators/top-down-shooter.js.map +1 -0
  101. package/dist/core.d.ts +4 -4
  102. package/dist/core.js +9 -36
  103. package/dist/core.js.map +1 -0
  104. package/dist/destructible-3d.d.ts +2 -1
  105. package/dist/destructible-3d.js +4 -3
  106. package/dist/destructible-3d.js.map +1 -0
  107. package/dist/destructible-prebake.js +2 -1
  108. package/dist/destructible-prebake.js.map +1 -0
  109. package/dist/first-person.d.ts +12 -12
  110. package/dist/first-person.js +12 -11
  111. package/dist/first-person.js.map +1 -0
  112. package/dist/index.d.ts +37 -14
  113. package/dist/index.js +85 -55
  114. package/dist/index.js.map +1 -0
  115. package/dist/jumper-2d.d.ts +7 -6
  116. package/dist/jumper-2d.js +8 -7
  117. package/dist/jumper-2d.js.map +1 -0
  118. package/dist/jumper-3d.d.ts +12 -11
  119. package/dist/jumper-3d.js +9 -8
  120. package/dist/jumper-3d.js.map +1 -0
  121. package/dist/{moveable-BCRpjAQb.d.ts → moveable-BLTHO7Jq.d.ts} +2 -78
  122. package/dist/particle-emitter/presets.js +2 -1
  123. package/dist/particle-emitter/presets.js.map +1 -0
  124. package/dist/particle-emitter.d.ts +1 -1
  125. package/dist/particle-emitter.js +5 -4
  126. package/dist/particle-emitter.js.map +1 -0
  127. package/dist/platformer-2d.d.ts +306 -0
  128. package/dist/platformer-2d.js +23 -0
  129. package/dist/platformer-2d.js.map +1 -0
  130. package/dist/platformer-3d.d.ts +74 -87
  131. package/dist/platformer-3d.js +7 -6
  132. package/dist/platformer-3d.js.map +1 -0
  133. package/dist/ricochet-2d.d.ts +1 -1
  134. package/dist/ricochet-2d.js +5 -4
  135. package/dist/ricochet-2d.js.map +1 -0
  136. package/dist/ricochet-3d.d.ts +1 -1
  137. package/dist/ricochet-3d.js +5 -4
  138. package/dist/ricochet-3d.js.map +1 -0
  139. package/dist/runtime-2d.d.ts +93 -2
  140. package/dist/runtime-2d.js +146 -22
  141. package/dist/runtime-2d.js.map +1 -0
  142. package/dist/screen-visibility.d.ts +2 -1
  143. package/dist/screen-visibility.js +3 -2
  144. package/dist/screen-visibility.js.map +1 -0
  145. package/dist/screen-wrap.d.ts +2 -1
  146. package/dist/screen-wrap.js +5 -4
  147. package/dist/screen-wrap.js.map +1 -0
  148. package/dist/shooter-2d.d.ts +5 -3
  149. package/dist/shooter-2d.js +5 -4
  150. package/dist/shooter-2d.js.map +1 -0
  151. package/dist/shooter-fire-DGripl0z.d.ts +55 -0
  152. package/dist/thruster.d.ts +8 -18
  153. package/dist/thruster.js +9 -8
  154. package/dist/thruster.js.map +1 -0
  155. package/dist/top-down-movement.d.ts +7 -4
  156. package/dist/top-down-movement.js +8 -7
  157. package/dist/top-down-movement.js.map +1 -0
  158. package/dist/{use-behavior-D_82jAL3.d.ts → use-behavior-h9-T5FSv.d.ts} +1 -1
  159. package/dist/world-boundary-2d.d.ts +2 -1
  160. package/dist/world-boundary-2d.js +6 -5
  161. package/dist/world-boundary-2d.js.map +1 -0
  162. package/dist/world-boundary-3d.d.ts +2 -1
  163. package/dist/world-boundary-3d.js +6 -5
  164. package/dist/world-boundary-3d.js.map +1 -0
  165. package/package.json +8 -7
  166. package/dist/chunk-23HQH3GJ.js +0 -34
  167. package/dist/chunk-K4UBXSZL.js +0 -175
  168. package/dist/runtime-pong.d.ts +0 -92
  169. package/dist/runtime-pong.js +0 -37
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  ScreenVisibilityBehavior,
3
3
  ScreenVisibilityFSM
4
- } from "./chunk-ERS6SNA5.js";
5
- import "./chunk-YDLO5M7S.js";
4
+ } from "./chunk-WOMHL23C.js";
5
+ import "./chunk-EZNCCO4L.js";
6
6
  export {
7
7
  ScreenVisibilityBehavior,
8
8
  ScreenVisibilityFSM
9
9
  };
10
+ //# sourceMappingURL=screen-visibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,5 +1,6 @@
1
- import { a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
1
+ import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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
  /**
@@ -3,13 +3,14 @@ import {
3
3
  ScreenWrapEvent,
4
4
  ScreenWrapFSM,
5
5
  ScreenWrapState
6
- } from "./chunk-D53GNZXP.js";
7
- import "./chunk-ZHBD65AZ.js";
8
- import "./chunk-RER2IDPW.js";
9
- import "./chunk-YDLO5M7S.js";
6
+ } from "./chunk-GFARAJV2.js";
7
+ import "./chunk-KDY5N6J4.js";
8
+ import "./chunk-4URF65BR.js";
9
+ import "./chunk-EZNCCO4L.js";
10
10
  export {
11
11
  ScreenWrapBehavior,
12
12
  ScreenWrapEvent,
13
13
  ScreenWrapFSM,
14
14
  ScreenWrapState
15
15
  };
16
+ //# sourceMappingURL=screen-wrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +1,7 @@
1
- import { a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
1
+ import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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
- velocity: boolean;
26
+ velocityX: boolean;
27
+ velocityY: boolean;
28
+ velocityZ: boolean;
27
29
  };
28
30
  };
29
31
  prependSetup(callback: (params: {
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  Shooter2DBehavior,
3
3
  createShooter2DStateComponent
4
- } from "./chunk-L76JG73P.js";
5
- import "./chunk-7U4WFBWM.js";
6
- import "./chunk-RHW3IDQX.js";
7
- import "./chunk-YDLO5M7S.js";
4
+ } from "./chunk-5XZWTFGF.js";
5
+ import "./chunk-Y7YIAWPW.js";
6
+ import "./chunk-WWVD5DR5.js";
7
+ import "./chunk-EZNCCO4L.js";
8
8
  export {
9
9
  Shooter2DBehavior,
10
10
  createShooter2DStateComponent
11
11
  };
12
+ //# sourceMappingURL=shooter-2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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 };
@@ -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 { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
4
+ import { Z as ZylemWorld, a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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 ThrusterMovementBehavior - it only writes ThrusterInputComponent.
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
- * ThrusterMovementBehavior
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
- * ThrusterMovementBehavior - Force generator for thruster-equipped entities
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 ThrusterMovementBehavior implements Behavior {
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 ThrusterMovementBehavior under the hood.
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 Behavior, type PlayerInput, ThrusterBehavior, type ThrusterBehaviorOptions, type ThrusterEntity, ThrusterEvent, ThrusterFSM, type ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementBehavior, ThrusterMovementComponent, ThrusterState };
122
+ export { type PlayerInput, ThrusterBehavior, type ThrusterBehaviorOptions, type ThrusterEntity, ThrusterEvent, ThrusterFSM, type ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementComponent, ThrusterState, ThrusterSystem };
package/dist/thruster.js CHANGED
@@ -2,24 +2,25 @@ import {
2
2
  ThrusterBehavior,
3
3
  ThrusterEvent,
4
4
  ThrusterFSM,
5
- ThrusterMovementBehavior,
6
- ThrusterState
7
- } from "./chunk-BC3IJYS7.js";
5
+ ThrusterState,
6
+ ThrusterSystem
7
+ } from "./chunk-MJFMNRMZ.js";
8
8
  import {
9
9
  createThrusterInputComponent,
10
10
  createThrusterMovementComponent,
11
11
  createThrusterStateComponent
12
- } from "./chunk-2HLZBWGD.js";
13
- import "./chunk-7U4WFBWM.js";
14
- import "./chunk-RER2IDPW.js";
15
- import "./chunk-YDLO5M7S.js";
12
+ } from "./chunk-IZJFUAXB.js";
13
+ import "./chunk-Y7YIAWPW.js";
14
+ import "./chunk-4URF65BR.js";
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
25
25
  };
26
+ //# sourceMappingURL=thruster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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-DYbx-x_-.js';
3
+ import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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
- velocity: boolean;
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 TopDownMovementRuntimeBehavior {
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, TopDownMovementRuntimeBehavior, TopDownMovementStateComponent };
43
+ export { TopDownMovementBehavior, type TopDownMovementBehaviorOptions, TopDownMovementComponent, type TopDownMovementEntity, type TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementStateComponent, TopDownMovementSystem };
@@ -1,19 +1,20 @@
1
1
  import {
2
2
  TopDownMovementBehavior,
3
- TopDownMovementRuntimeBehavior
4
- } from "./chunk-HIBJDA5Z.js";
3
+ TopDownMovementSystem
4
+ } from "./chunk-64HKCSXD.js";
5
5
  import {
6
6
  createTopDownMovementComponent,
7
7
  createTopDownMovementInputComponent,
8
8
  createTopDownMovementStateComponent
9
- } from "./chunk-2HKY6WF7.js";
10
- import "./chunk-7U4WFBWM.js";
11
- import "./chunk-YYJP62QD.js";
12
- import "./chunk-YDLO5M7S.js";
9
+ } from "./chunk-EIWQM6U3.js";
10
+ import "./chunk-Y7YIAWPW.js";
11
+ import "./chunk-4V7TIRO2.js";
12
+ import "./chunk-EZNCCO4L.js";
13
13
  export {
14
14
  TopDownMovementBehavior,
15
- TopDownMovementRuntimeBehavior,
15
+ TopDownMovementSystem,
16
16
  createTopDownMovementComponent,
17
17
  createTopDownMovementInputComponent,
18
18
  createTopDownMovementStateComponent
19
19
  };
20
+ //# sourceMappingURL=top-down-movement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,4 @@
1
- import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
1
+ import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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-DYbx-x_-.js';
1
+ import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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,11 +5,11 @@ import {
5
5
  WorldBoundary2DState,
6
6
  computeWorldBoundary2DHits,
7
7
  hasAnyWorldBoundary2DHit
8
- } from "./chunk-E4HTCQPK.js";
9
- import "./chunk-ZHBD65AZ.js";
10
- import "./chunk-YYJP62QD.js";
11
- import "./chunk-RER2IDPW.js";
12
- import "./chunk-YDLO5M7S.js";
8
+ } from "./chunk-PWF757B6.js";
9
+ import "./chunk-KDY5N6J4.js";
10
+ import "./chunk-4V7TIRO2.js";
11
+ import "./chunk-4URF65BR.js";
12
+ import "./chunk-EZNCCO4L.js";
13
13
  export {
14
14
  WorldBoundary2DBehavior,
15
15
  WorldBoundary2DEvent,
@@ -18,3 +18,4 @@ export {
18
18
  computeWorldBoundary2DHits,
19
19
  hasAnyWorldBoundary2DHit
20
20
  };
21
+ //# sourceMappingURL=world-boundary-2d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,5 +1,6 @@
1
- import { a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
1
+ import { a as BehaviorDescriptor } from './behavior-system-DSNek0W9.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,11 +5,11 @@ import {
5
5
  WorldBoundary3DState,
6
6
  computeWorldBoundary3DHits,
7
7
  hasAnyWorldBoundary3DHit
8
- } from "./chunk-6UMC6BB5.js";
9
- import "./chunk-WHKPWIQO.js";
10
- import "./chunk-YYJP62QD.js";
11
- import "./chunk-RER2IDPW.js";
12
- import "./chunk-YDLO5M7S.js";
8
+ } from "./chunk-HNESASBB.js";
9
+ import "./chunk-OHCPV2NT.js";
10
+ import "./chunk-4V7TIRO2.js";
11
+ import "./chunk-4URF65BR.js";
12
+ import "./chunk-EZNCCO4L.js";
13
13
  export {
14
14
  WorldBoundary3DBehavior,
15
15
  WorldBoundary3DEvent,
@@ -18,3 +18,4 @@ export {
18
18
  computeWorldBoundary3DHits,
19
19
  hasAnyWorldBoundary3DHit
20
20
  };
21
+ //# sourceMappingURL=world-boundary-3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zylem/behaviors",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Tree-shakable Zylem behavior descriptors, systems, coordinators, and runtime-agnostic behavior helpers.",
6
6
  "license": "MIT",
@@ -57,6 +57,10 @@
57
57
  "types": "./dist/particle-emitter/presets.d.ts",
58
58
  "import": "./dist/particle-emitter/presets.js"
59
59
  },
60
+ "./platformer-2d": {
61
+ "types": "./dist/platformer-2d.d.ts",
62
+ "import": "./dist/platformer-2d.js"
63
+ },
60
64
  "./platformer-3d": {
61
65
  "types": "./dist/platformer-3d.d.ts",
62
66
  "import": "./dist/platformer-3d.js"
@@ -73,10 +77,6 @@
73
77
  "types": "./dist/runtime-2d.d.ts",
74
78
  "import": "./dist/runtime-2d.js"
75
79
  },
76
- "./runtime-pong": {
77
- "types": "./dist/runtime-pong.d.ts",
78
- "import": "./dist/runtime-pong.js"
79
- },
80
80
  "./screen-visibility": {
81
81
  "types": "./dist/screen-visibility.d.ts",
82
82
  "import": "./dist/screen-visibility.js"
@@ -131,7 +131,8 @@
131
131
  "build": "tsup",
132
132
  "dev": "tsup --watch",
133
133
  "typecheck": "tsc --noEmit",
134
- "test": "vitest --reporter=verbose"
134
+ "test": "vitest --reporter=verbose",
135
+ "prepublishOnly": "pnpm run build && vitest run"
135
136
  },
136
137
  "dependencies": {
137
138
  "@dgreenheck/three-pinata": "^2.0.1",
@@ -154,7 +155,7 @@
154
155
  },
155
156
  "packageManager": "pnpm@10.33.0",
156
157
  "publishConfig": {
157
- "access": "restricted",
158
+ "access": "public",
158
159
  "registry": "https://registry.npmjs.org/"
159
160
  }
160
161
  }
@@ -1,34 +0,0 @@
1
- import {
2
- getBounds3DNormalFromHits
3
- } from "./chunk-WHKPWIQO.js";
4
-
5
- // src/lib/coordinators/boundary-ricochet-3d.coordinator.ts
6
- var BoundaryRicochet3DCoordinator = class {
7
- constructor(entity, boundary, ricochet) {
8
- this.entity = entity;
9
- this.boundary = boundary;
10
- this.ricochet = ricochet;
11
- }
12
- entity;
13
- boundary;
14
- ricochet;
15
- update() {
16
- const hits = this.boundary.getLastHits();
17
- if (!hits) return false;
18
- const anyHit = hits.left || hits.right || hits.top || hits.bottom || hits.back || hits.front;
19
- if (!anyHit) return false;
20
- const clamped = this.boundary.getLastClampedPosition();
21
- if (clamped && this.entity.body) {
22
- this.entity.body.setTranslation(clamped, true);
23
- }
24
- const normal = getBounds3DNormalFromHits(hits);
25
- return this.ricochet.applyRicochet({
26
- entity: this.entity,
27
- contact: { normal }
28
- });
29
- }
30
- };
31
-
32
- export {
33
- BoundaryRicochet3DCoordinator
34
- };
@@ -1,175 +0,0 @@
1
- import {
2
- defineBehavior
3
- } from "./chunk-YDLO5M7S.js";
4
-
5
- // src/lib/behaviors/runtime-pong/runtime-pong.descriptors.ts
6
- var runtimeNoopSystemFactory = () => ({
7
- update(_ecs, _delta) {
8
- }
9
- });
10
- var RUNTIME_PONG_BALL_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-pong-ball");
11
- var RUNTIME_PADDLE_INPUT_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-paddle-input-2d");
12
- var RUNTIME_WORLD_BOUNDARY_2D_BEHAVIOR_KEY = /* @__PURE__ */ Symbol.for("zylem:behavior:runtime-world-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 RUNTIME_BALL_SET_POSITION = /* @__PURE__ */ Symbol("runtime-ball-set-position");
20
- var RUNTIME_BALL_SET_VELOCITY = /* @__PURE__ */ Symbol("runtime-ball-set-velocity");
21
- var RUNTIME_BALL_GET_POSITION = /* @__PURE__ */ Symbol("runtime-ball-get-position");
22
- var RuntimePongBallBehavior = defineBehavior({
23
- name: "runtime-pong-ball",
24
- defaultOptions: {
25
- initialVelocity: [0, 0]
26
- },
27
- systemFactory: runtimeNoopSystemFactory,
28
- createHandle: (ref) => ({
29
- setRuntimePosition(x, y, z = 0) {
30
- const callback = ref[RUNTIME_BALL_SET_POSITION];
31
- callback?.(x, y, z);
32
- },
33
- setRuntimeVelocity(x, y) {
34
- const callback = ref[RUNTIME_BALL_SET_VELOCITY];
35
- callback?.(x, y);
36
- },
37
- getRuntimePosition() {
38
- const callback = ref[RUNTIME_BALL_GET_POSITION];
39
- return callback?.() ?? null;
40
- }
41
- })
42
- });
43
- var RuntimePaddleInput2DBehavior = defineBehavior({
44
- name: "runtime-paddle-input-2d",
45
- defaultOptions: {
46
- player: "p1",
47
- speed: 5
48
- },
49
- systemFactory: runtimeNoopSystemFactory
50
- });
51
- var RuntimeWorldBoundary2DBehavior = defineBehavior({
52
- name: "runtime-world-boundary-2d",
53
- defaultOptions: {
54
- boundaries: {
55
- left: 0,
56
- right: 0,
57
- bottom: 0,
58
- top: 0
59
- }
60
- },
61
- systemFactory: runtimeNoopSystemFactory
62
- });
63
- var RuntimeRicochet2DBehavior = defineBehavior({
64
- name: "runtime-ricochet-2d",
65
- defaultOptions: {
66
- minSpeed: 2,
67
- maxSpeed: 20,
68
- speedMultiplier: 1.05,
69
- reflectionMode: "angled",
70
- maxAngleDeg: 60
71
- },
72
- systemFactory: runtimeNoopSystemFactory,
73
- createHandle: (ref) => ({
74
- onRicochet(callback) {
75
- const listeners = ref[RICOCHET_LISTENERS] ?? [];
76
- if (!ref[RICOCHET_LISTENERS]) {
77
- ref[RICOCHET_LISTENERS] = listeners;
78
- }
79
- listeners.push(callback);
80
- return () => {
81
- const index = listeners.indexOf(callback);
82
- if (index >= 0) {
83
- listeners.splice(index, 1);
84
- }
85
- };
86
- }
87
- })
88
- });
89
- var RuntimeTriggerRegion2DBehavior = defineBehavior({
90
- name: "runtime-trigger-region-2d",
91
- defaultOptions: {
92
- triggerId: 0,
93
- halfExtents: [0.5, 2.5]
94
- },
95
- systemFactory: runtimeNoopSystemFactory,
96
- createHandle: (ref) => ({
97
- onRegionEnter(callback) {
98
- const listeners = ref[TRIGGER_REGION_LISTENERS] ?? [];
99
- if (!ref[TRIGGER_REGION_LISTENERS]) {
100
- ref[TRIGGER_REGION_LISTENERS] = listeners;
101
- }
102
- listeners.push(callback);
103
- return () => {
104
- const index = listeners.indexOf(callback);
105
- if (index >= 0) {
106
- listeners.splice(index, 1);
107
- }
108
- };
109
- }
110
- })
111
- });
112
- var RuntimeGoalZone2DBehavior = defineBehavior({
113
- name: "runtime-goal-zone-2d",
114
- defaultOptions: {
115
- scorer: "p1"
116
- },
117
- systemFactory: runtimeNoopSystemFactory,
118
- createHandle: (ref) => ({
119
- onGoal(callback) {
120
- const listeners = ref[GOAL_LISTENERS] ?? [];
121
- if (!ref[GOAL_LISTENERS]) {
122
- ref[GOAL_LISTENERS] = listeners;
123
- }
124
- listeners.push(callback);
125
- return () => {
126
- const index = listeners.indexOf(callback);
127
- if (index >= 0) {
128
- listeners.splice(index, 1);
129
- }
130
- };
131
- }
132
- })
133
- });
134
- function emitRuntimeRicochet(ref, event) {
135
- const listeners = ref[RICOCHET_LISTENERS];
136
- for (const listener of listeners ?? []) {
137
- listener(event);
138
- }
139
- }
140
- function emitRuntimeTriggerRegionEnter(ref, event) {
141
- const listeners = ref[TRIGGER_REGION_LISTENERS];
142
- for (const listener of listeners ?? []) {
143
- listener(event);
144
- }
145
- }
146
- function emitRuntimeGoal(ref, event) {
147
- const listeners = ref[GOAL_LISTENERS];
148
- for (const listener of listeners ?? []) {
149
- listener(event);
150
- }
151
- }
152
- function bindRuntimePongBallHandle(ref, controls) {
153
- ref[RUNTIME_BALL_SET_POSITION] = controls.setPosition;
154
- ref[RUNTIME_BALL_SET_VELOCITY] = controls.setVelocity;
155
- ref[RUNTIME_BALL_GET_POSITION] = controls.getPosition;
156
- }
157
-
158
- export {
159
- RUNTIME_PONG_BALL_BEHAVIOR_KEY,
160
- RUNTIME_PADDLE_INPUT_2D_BEHAVIOR_KEY,
161
- RUNTIME_WORLD_BOUNDARY_2D_BEHAVIOR_KEY,
162
- RUNTIME_RICOCHET_2D_BEHAVIOR_KEY,
163
- RUNTIME_TRIGGER_REGION_2D_BEHAVIOR_KEY,
164
- RUNTIME_GOAL_ZONE_2D_BEHAVIOR_KEY,
165
- RuntimePongBallBehavior,
166
- RuntimePaddleInput2DBehavior,
167
- RuntimeWorldBoundary2DBehavior,
168
- RuntimeRicochet2DBehavior,
169
- RuntimeTriggerRegion2DBehavior,
170
- RuntimeGoalZone2DBehavior,
171
- emitRuntimeRicochet,
172
- emitRuntimeTriggerRegionEnter,
173
- emitRuntimeGoal,
174
- bindRuntimePongBallHandle
175
- };