@zylem/game-lib 0.6.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +18 -2
  2. package/dist/actions.d.ts +321 -11
  3. package/dist/actions.js +1 -936
  4. package/dist/api/game-lib.api.json +54074 -0
  5. package/dist/api/game-lib.api.md +4544 -0
  6. package/dist/api/game-lib.d.ts +8258 -0
  7. package/dist/api/game-lib.typedoc.json +345421 -0
  8. package/dist/audio.d.ts +13 -0
  9. package/dist/audio.js +1 -0
  10. package/dist/base-node-life-cycle-D2NuN1VB.d.ts +151 -0
  11. package/dist/behavior.d.ts +2 -0
  12. package/dist/behavior.js +1 -0
  13. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  14. package/dist/chunk-4QLJUQSJ.js +1 -0
  15. package/dist/chunk-7FR5JSQ2.js +1 -0
  16. package/dist/chunk-7GYFZKK7.js +1 -0
  17. package/dist/chunk-7WRQ2UAN.js +1 -0
  18. package/dist/chunk-BH53MBAZ.js +1 -0
  19. package/dist/chunk-BIGH6D34.js +0 -0
  20. package/dist/chunk-CM5YRNBJ.js +19 -0
  21. package/dist/chunk-COM6HJ2L.js +1 -0
  22. package/dist/chunk-D2PATZCC.js +1 -0
  23. package/dist/chunk-DFLI7ICU.js +0 -0
  24. package/dist/chunk-E3UBSUPX.js +1 -0
  25. package/dist/chunk-FKIKN7RP.js +24 -0
  26. package/dist/chunk-G4HONLWC.js +1 -0
  27. package/dist/chunk-IKWE2W6L.js +1 -0
  28. package/dist/chunk-IPWUDOV5.js +1 -0
  29. package/dist/chunk-JEHFHUH4.js +0 -0
  30. package/dist/chunk-JNKPTL77.js +1 -0
  31. package/dist/chunk-JQKS42G4.js +1 -0
  32. package/dist/chunk-M3XNO56P.js +1 -0
  33. package/dist/chunk-MSC2BEO5.js +1 -0
  34. package/dist/chunk-ORIDWL3T.js +0 -0
  35. package/dist/chunk-QB3NL7VQ.js +1 -0
  36. package/dist/chunk-QXVH6POE.js +1 -0
  37. package/dist/chunk-RXDTAWI2.js +29 -0
  38. package/dist/chunk-TAUWDQZF.js +9 -0
  39. package/dist/chunk-VS2D4B3W.js +1 -0
  40. package/dist/chunk-WQ3WMMZD.js +1 -0
  41. package/dist/chunk-XK63E4SX.js +1 -0
  42. package/dist/chunk-XNDS4YFR.js +1 -0
  43. package/dist/chunk-XNHVRFAK.js +1 -0
  44. package/dist/chunk-XRP4JJXL.js +1 -0
  45. package/dist/chunk-YHEWKN7N.js +1 -0
  46. package/dist/chunk-ZRT3ZQVH.js +1 -0
  47. package/dist/collision-builder-jF-toPIl.d.ts +38 -0
  48. package/dist/core.d.ts +223 -16
  49. package/dist/core.js +1 -12424
  50. package/dist/debug-state-BPT6jEog.d.ts +17 -0
  51. package/dist/debug.d.ts +76 -0
  52. package/dist/debug.js +1 -0
  53. package/dist/default-controls-0-vCnli7.d.ts +111 -0
  54. package/dist/{entity-vj-HTjzU.d.ts → entity-BdSI8CL3.d.ts} +119 -626
  55. package/dist/{entity-Bq_eNEDI.d.ts → entity-DZbFQ1Wg.d.ts} +4 -4
  56. package/dist/entity-type-map-Bd69SpAS.d.ts +928 -0
  57. package/dist/entity.d.ts +268 -0
  58. package/dist/entity.js +1 -0
  59. package/dist/events.d.ts +181 -0
  60. package/dist/events.js +1 -0
  61. package/dist/game-C1FHVqXl.d.ts +1886 -0
  62. package/dist/game-default-QHROHW2O.js +1 -0
  63. package/dist/game-interfaces-mchNYSZE.d.ts +90 -0
  64. package/dist/globals.d.ts +115 -0
  65. package/dist/globals.js +1 -0
  66. package/dist/graphics.d.ts +53 -0
  67. package/dist/graphics.js +1 -0
  68. package/dist/input-ui.d.ts +35 -0
  69. package/dist/input-ui.js +1 -0
  70. package/dist/input.d.ts +73 -0
  71. package/dist/input.js +1 -0
  72. package/dist/material-9vJ6SZaI.d.ts +126 -0
  73. package/dist/public.d.ts +38 -0
  74. package/dist/public.js +1 -0
  75. package/dist/runtime.d.ts +59 -0
  76. package/dist/runtime.js +1 -0
  77. package/dist/schema/entity.schema.json +244 -0
  78. package/dist/schema/game-config.schema.json +625 -0
  79. package/dist/schema/input-config.schema.json +499 -0
  80. package/dist/schema/stage-config.schema.json +93 -0
  81. package/dist/schema/stage.schema.json +271 -0
  82. package/dist/schema.d.ts +538 -0
  83. package/dist/schema.js +1 -0
  84. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  85. package/dist/vector-CiSHbivc.d.ts +133 -0
  86. package/dist/web-components.d.ts +70 -0
  87. package/dist/web-components.js +1 -0
  88. package/dist/zylem-camera-C3bn6BTI.d.ts +575 -0
  89. package/package.json +70 -73
  90. package/dist/actions.js.map +0 -1
  91. package/dist/behavior/jumper-2d.d.ts +0 -114
  92. package/dist/behavior/jumper-2d.js +0 -711
  93. package/dist/behavior/jumper-2d.js.map +0 -1
  94. package/dist/behavior/platformer-3d.d.ts +0 -296
  95. package/dist/behavior/platformer-3d.js +0 -761
  96. package/dist/behavior/platformer-3d.js.map +0 -1
  97. package/dist/behavior/ricochet-2d.d.ts +0 -275
  98. package/dist/behavior/ricochet-2d.js +0 -425
  99. package/dist/behavior/ricochet-2d.js.map +0 -1
  100. package/dist/behavior/ricochet-3d.d.ts +0 -117
  101. package/dist/behavior/ricochet-3d.js +0 -443
  102. package/dist/behavior/ricochet-3d.js.map +0 -1
  103. package/dist/behavior/screen-visibility.d.ts +0 -79
  104. package/dist/behavior/screen-visibility.js +0 -358
  105. package/dist/behavior/screen-visibility.js.map +0 -1
  106. package/dist/behavior/screen-wrap.d.ts +0 -87
  107. package/dist/behavior/screen-wrap.js +0 -246
  108. package/dist/behavior/screen-wrap.js.map +0 -1
  109. package/dist/behavior/shooter-2d.d.ts +0 -79
  110. package/dist/behavior/shooter-2d.js +0 -180
  111. package/dist/behavior/shooter-2d.js.map +0 -1
  112. package/dist/behavior/thruster.d.ts +0 -11
  113. package/dist/behavior/thruster.js +0 -292
  114. package/dist/behavior/thruster.js.map +0 -1
  115. package/dist/behavior/top-down-movement.d.ts +0 -56
  116. package/dist/behavior/top-down-movement.js +0 -125
  117. package/dist/behavior/top-down-movement.js.map +0 -1
  118. package/dist/behavior/world-boundary-2d.d.ts +0 -142
  119. package/dist/behavior/world-boundary-2d.js +0 -235
  120. package/dist/behavior/world-boundary-2d.js.map +0 -1
  121. package/dist/behavior/world-boundary-3d.d.ts +0 -76
  122. package/dist/behavior/world-boundary-3d.js +0 -274
  123. package/dist/behavior/world-boundary-3d.js.map +0 -1
  124. package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
  125. package/dist/blueprints-DmbK2dki.d.ts +0 -26
  126. package/dist/camera-4XO5gbQH.d.ts +0 -905
  127. package/dist/camera.d.ts +0 -6
  128. package/dist/camera.js +0 -1993
  129. package/dist/camera.js.map +0 -1
  130. package/dist/composition-BASvMKrW.d.ts +0 -218
  131. package/dist/core-CARRaS55.d.ts +0 -541
  132. package/dist/core.js.map +0 -1
  133. package/dist/entities-ChFirVL9.d.ts +0 -410
  134. package/dist/entities.d.ts +0 -9
  135. package/dist/entities.js +0 -4986
  136. package/dist/entities.js.map +0 -1
  137. package/dist/entity-types-DAu8sGJH.d.ts +0 -26
  138. package/dist/global-change-2JvMaz44.d.ts +0 -25
  139. package/dist/main.d.ts +0 -1353
  140. package/dist/main.js +0 -19525
  141. package/dist/main.js.map +0 -1
  142. package/dist/physics-pose-DCc4oE44.d.ts +0 -25
  143. package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
  144. package/dist/physics-worker.d.ts +0 -21
  145. package/dist/physics-worker.js +0 -306
  146. package/dist/physics-worker.js.map +0 -1
  147. package/dist/physics.d.ts +0 -205
  148. package/dist/physics.js +0 -577
  149. package/dist/physics.js.map +0 -1
  150. package/dist/stage-types-C19IhuzA.d.ts +0 -731
  151. package/dist/stage.d.ts +0 -52
  152. package/dist/stage.js +0 -8479
  153. package/dist/stage.js.map +0 -1
  154. package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
  155. package/dist/thruster-23lzoPZd.d.ts +0 -180
  156. package/dist/world-DfgxoNMt.d.ts +0 -105
@@ -0,0 +1,268 @@
1
+ export { A as ACTOR_TYPE, $ as AmbientLightOptions, B as BOX_TYPE, z as CONE_TYPE, J as CYLINDER_TYPE, C as CollisionShapeType, D as DISK_TYPE, a1 as DirectionalLightOptions, aj as EntityForType, ai as EntityTypeMap, a7 as FOG_TYPE, a0 as HemisphereLightOptions, Y as LIGHT_TYPE, aa as LINE_TYPE, a4 as LightShadowOptions, ad as LinePickResult, n as OnEnterParams, o as OnExitParams, O as OnHeldParams, U as PARTICLE_SYSTEM_TYPE, M as PILL_TYPE, P as PLANE_TYPE, G as PYRAMID_TYPE, a2 as PointLightOptions, R as RECT_TYPE, S as SPHERE_TYPE, f as SPRITE_TYPE, a3 as SpotLightOptions, h as SpriteAnimation, g as SpriteImage, T as TEXT_TYPE, m as ZONE_TYPE, q as ZylemActor, Z as ZylemBox, y as ZylemCone, I as ZylemCylinder, w as ZylemDisk, a6 as ZylemFog, ag as ZylemFogHeightOptions, ah as ZylemFogNoiseOptions, ae as ZylemFogOptions, af as ZylemFogType, X as ZylemLight, _ as ZylemLightOptions, a9 as ZylemLine, ac as ZylemLineOptions, Q as ZylemParticleSystem, V as ZylemParticleSystemOptions, L as ZylemPill, j as ZylemPlane, F as ZylemPyramid, u as ZylemRect, b as ZylemSphere, e as ZylemSprite, s as ZylemText, l as ZylemZone, p as createActor, c as createBox, x as createCone, H as createCylinder, v as createDisk, a5 as createFog, W as createLight, a8 as createLine, N as createParticleSystem, K as createPill, i as createPlane, E as createPyramid, t as createRect, a as createSphere, d as createSprite, r as createText, k as createZone, ab as pickZylemLine } from './entity-type-map-Bd69SpAS.js';
2
+ import { G as GameEntity, a as GameEntityOptions, E as EntityBuilder, D as EntityMeshBuilder, F as EntityCollisionBuilder, B as BaseNode } from './entity-BdSI8CL3.js';
3
+ export { C as CollisionComponent, b as boxCollision, d as coneCollision, c as create, e as cylinderCollision, f as pillCollision, g as planeCollision, p as pyramidCollision, s as sphereCollision, z as zoneCollision } from './entity-BdSI8CL3.js';
4
+ import { Color, Mesh } from 'three';
5
+ import { b as Vec2Input, e as Vec3Input } from './vector-CiSHbivc.js';
6
+ import { e as MaterialOptions } from './material-9vJ6SZaI.js';
7
+ import './base-node-life-cycle-D2NuN1VB.js';
8
+ import './stage-transition-CmGpV4tc.js';
9
+ import '@zylem/behaviors/core';
10
+ import './entity-DZbFQ1Wg.js';
11
+ import '@zylem/behaviors/particle-emitter';
12
+ import 'three/addons/lines/webgpu/Line2.js';
13
+ import './collision-builder-jF-toPIl.js';
14
+ import './events.js';
15
+ import 'mitt';
16
+ import 'three/webgpu';
17
+
18
+ interface CreateGameEntityOptions<T extends GameEntity<any>, CreateOptions extends GameEntityOptions> {
19
+ args: Array<any>;
20
+ defaultConfig: GameEntityOptions;
21
+ EntityClass: new (options: any) => T;
22
+ BuilderClass: new (options: any, entity: T, meshBuilder: any, collisionBuilder: any) => EntityBuilder<T, CreateOptions>;
23
+ MeshBuilderClass?: new (data: any) => EntityMeshBuilder;
24
+ CollisionBuilderClass?: new (data: any) => EntityCollisionBuilder;
25
+ entityType: symbol;
26
+ cloneFactory: (options?: Partial<CreateOptions>) => T;
27
+ }
28
+ declare function createEntity<T extends GameEntity<any>, CreateOptions extends GameEntityOptions>(params: CreateGameEntityOptions<T, CreateOptions>): T;
29
+
30
+ /**
31
+ * Factory interface for generating entity copies
32
+ */
33
+ interface TemplateFactory<E extends GameEntity<O>, O extends GameEntityOptions = GameEntityOptions> {
34
+ /** The template entity used for cloning */
35
+ readonly template: E;
36
+ /**
37
+ * Generate multiple copies of the template entity
38
+ * @param count Number of copies to generate
39
+ * @returns Array of new entity instances
40
+ */
41
+ generate(count: number): E[];
42
+ }
43
+ /**
44
+ * Create an entity factory from a template entity.
45
+ *
46
+ * @param template The entity to use as a template for cloning
47
+ * @returns Factory object with generate() method
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const asteroidTemplate = createSprite({ images: [{ name: 'asteroid', file: asteroidImg }] });
52
+ * const asteroidFactory = createEntityFactory(asteroidTemplate);
53
+ * const asteroids = asteroidFactory.generate(10);
54
+ *
55
+ * asteroids.forEach((asteroid, i) => {
56
+ * asteroid.setPosition(Math.random() * 20 - 10, Math.random() * 15 - 7.5, 0);
57
+ * stage.add(asteroid);
58
+ * });
59
+ * ```
60
+ */
61
+ declare function createEntityFactory<E extends GameEntity<O>, O extends GameEntityOptions = GameEntityOptions>(template: E): TemplateFactory<E, O>;
62
+
63
+ /**
64
+ * CooldownIcon -- a WoW-style cooldown icon UI entity.
65
+ *
66
+ * Renders a square icon with a semi-transparent clockwise sweep overlay
67
+ * that reflects cooldown progress from the CooldownStore. Optionally shows
68
+ * remaining time text in the center.
69
+ *
70
+ * Modeled after ZylemRect's canvas-based viewport-attached sprite pattern.
71
+ */
72
+
73
+ /**
74
+ * Reference point on the viewport for positioning UI elements.
75
+ * The offset in `screenPosition` is applied relative to this anchor.
76
+ */
77
+ type ScreenAnchor = 'top-left' | 'top-center' | 'top-right' | 'center-left' | 'center' | 'center-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
78
+ /** Preset icon sizes in view units. */
79
+ declare const ICON_SIZE_PRESETS: {
80
+ readonly xs: 8;
81
+ readonly sm: 16;
82
+ readonly md: 32;
83
+ readonly lg: 48;
84
+ readonly xl: 64;
85
+ };
86
+ /** Named size preset. */
87
+ type IconSizePreset = keyof typeof ICON_SIZE_PRESETS;
88
+ /**
89
+ * Icon size expressed as a named preset, a square unit value, or
90
+ * a `{ width, height }` object for non-square icons.
91
+ *
92
+ * All numeric values are in **view units** (viewport height = 192 units).
93
+ */
94
+ type IconSize = IconSizePreset | number | {
95
+ width: number;
96
+ height: number;
97
+ };
98
+ type ZylemCooldownIconOptions = GameEntityOptions & {
99
+ /** Name of the cooldown in the CooldownStore */
100
+ cooldown: string;
101
+ /** Texture path for the icon background (optional) */
102
+ icon?: string;
103
+ /** Solid fill color when no icon texture is provided */
104
+ fillColor?: Color | string;
105
+ /**
106
+ * Size of the icon in view units, a named preset, or a `{ width, height }` object.
107
+ *
108
+ * Presets: `'xs'` (8), `'sm'` (16), `'md'` (32), `'lg'` (48), `'xl'` (64).
109
+ * A bare number creates a square icon of that many units.
110
+ * The viewport height equals 192 units; width scales with aspect ratio.
111
+ *
112
+ * @default 'md'
113
+ */
114
+ iconSize?: IconSize;
115
+ /** Whether to show remaining time text */
116
+ showTimer?: boolean;
117
+ /** Whether to attach to the camera viewport (default: true) */
118
+ stickToViewport?: boolean;
119
+ /**
120
+ * Viewport anchor the icon is positioned relative to.
121
+ * @default 'top-left'
122
+ */
123
+ screenAnchor?: ScreenAnchor;
124
+ /**
125
+ * Offset from the {@link screenAnchor} in **view units**.
126
+ * Positive x = right, positive y = down.
127
+ * Accepts a `Vector2`, plain `{ x, y }` object, or tuple.
128
+ * @default { x: 0, y: 0 }
129
+ */
130
+ screenPosition?: Vec2Input;
131
+ /** Distance from camera (default: 1) */
132
+ zDistance?: number;
133
+ /** Color of the sweep overlay (default: semi-transparent black) */
134
+ overlayColor?: string;
135
+ };
136
+ declare class ZylemCooldownIcon extends GameEntity<ZylemCooldownIconOptions> {
137
+ static type: symbol;
138
+ private _sprite;
139
+ private _texture;
140
+ private _canvas;
141
+ private _ctx;
142
+ private _cameraRef;
143
+ private _iconTexture;
144
+ private _iconImage;
145
+ private _lastRenderedProgress;
146
+ constructor(options?: ZylemCooldownIconOptions);
147
+ private createSprite;
148
+ private redraw;
149
+ private toCssColor;
150
+ private getResolution;
151
+ private iconSetup;
152
+ private iconUpdate;
153
+ /**
154
+ * Resolve screen position to pixels.
155
+ * Computes the anchor point in pixels, then adds the view-unit offset.
156
+ */
157
+ private resolveScreenPosition;
158
+ /**
159
+ * Resolve `iconSize` to screen pixels using the view-unit grid.
160
+ * Viewport height = {@link VIEW_UNITS_HEIGHT} units; width scales with aspect ratio.
161
+ */
162
+ private resolveIconSize;
163
+ /** Compute the world-space half-extents at a given distance from the camera. */
164
+ private computeWorldExtents;
165
+ private updateStickyTransform;
166
+ /**
167
+ * Dispose Three.js / DOM resources when the entity is destroyed.
168
+ */
169
+ private iconDestroy;
170
+ }
171
+ type CooldownIconOptions = BaseNode | Partial<ZylemCooldownIconOptions>;
172
+ /**
173
+ * Create a WoW-style cooldown icon UI entity.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const attackIcon = createCooldownIcon({
178
+ * cooldown: 'attack',
179
+ * icon: swordIconPath,
180
+ * screenAnchor: 'top-center', // reference point on the viewport
181
+ * screenPosition: { x: 0, y: 10 }, // offset in view units from anchor
182
+ * iconSize: 'sm', // preset (16 × 16 view units)
183
+ * // iconSize: 24, // square (24 × 24 view units)
184
+ * // iconSize: { width: 16, height: 24 }, // custom rectangle
185
+ * });
186
+ * ```
187
+ */
188
+ declare function createCooldownIcon(...args: Array<CooldownIconOptions>): ZylemCooldownIcon;
189
+
190
+ declare function destroy(entity: any, globals?: any): void;
191
+
192
+ /** Shared options that every mesh factory accepts. */
193
+ interface BaseMeshOptions {
194
+ /** Offset position relative to the entity origin */
195
+ position?: Vec3Input;
196
+ /** Material options (texture, shader, etc.) */
197
+ material?: Partial<MaterialOptions>;
198
+ /** Convenience color override */
199
+ color?: Color;
200
+ }
201
+ interface BoxMeshOptions extends BaseMeshOptions {
202
+ /** Box dimensions (default: 1x1x1) */
203
+ size?: Vec3Input;
204
+ }
205
+ /**
206
+ * Create a box mesh.
207
+ */
208
+ declare function boxMesh(opts?: BoxMeshOptions): Mesh;
209
+ interface SphereMeshOptions extends BaseMeshOptions {
210
+ /** Sphere radius (default: 1) */
211
+ radius?: number;
212
+ }
213
+ /**
214
+ * Create a sphere mesh.
215
+ */
216
+ declare function sphereMesh(opts?: SphereMeshOptions): Mesh;
217
+ interface ConeMeshOptions extends BaseMeshOptions {
218
+ /** Base radius (default: 1) */
219
+ radius?: number;
220
+ /** Height (default: 2) */
221
+ height?: number;
222
+ /** Radial segments (default: 32) */
223
+ radialSegments?: number;
224
+ }
225
+ /**
226
+ * Create a cone mesh.
227
+ */
228
+ declare function coneMesh(opts?: ConeMeshOptions): Mesh;
229
+ interface PyramidMeshOptions extends BaseMeshOptions {
230
+ /** Base radius (default: 1) */
231
+ radius?: number;
232
+ /** Height (default: 2) */
233
+ height?: number;
234
+ }
235
+ /**
236
+ * Create a pyramid mesh (4-sided cone).
237
+ */
238
+ declare function pyramidMesh(opts?: PyramidMeshOptions): Mesh;
239
+ interface CylinderMeshOptions extends BaseMeshOptions {
240
+ /** Top radius (default: 1) */
241
+ radiusTop?: number;
242
+ /** Bottom radius (default: 1) */
243
+ radiusBottom?: number;
244
+ /** Height (default: 2) */
245
+ height?: number;
246
+ /** Radial segments (default: 32) */
247
+ radialSegments?: number;
248
+ }
249
+ /**
250
+ * Create a cylinder mesh.
251
+ */
252
+ declare function cylinderMesh(opts?: CylinderMeshOptions): Mesh;
253
+ interface PillMeshOptions extends BaseMeshOptions {
254
+ /** Capsule hemisphere radius (default: 0.5) */
255
+ radius?: number;
256
+ /** Cylindrical section length (default: 1) */
257
+ length?: number;
258
+ /** Cap segments (default: 10) */
259
+ capSegments?: number;
260
+ /** Radial segments (default: 20) */
261
+ radialSegments?: number;
262
+ }
263
+ /**
264
+ * Create a pill (capsule) mesh.
265
+ */
266
+ declare function pillMesh(opts?: PillMeshOptions): Mesh;
267
+
268
+ export { GameEntity, GameEntityOptions, type IconSize, type IconSizePreset, type ScreenAnchor, type TemplateFactory, boxMesh, coneMesh, createCooldownIcon, createEntity, createEntityFactory, cylinderMesh, destroy, pillMesh, pyramidMesh, sphereMesh };
package/dist/entity.js ADDED
@@ -0,0 +1 @@
1
+ import{A as $,B as aa,C as ba,D as ca,E as da,F as ea,G as fa,H as ga,I as ha,J as ia,K as ja,L as ka,M as la,N as ma,O as na,P as oa,Q as pa,R as qa,a as B,b as C,c as D,d as E,e as F,f as G,g as H,h as I,i as J,j as K,k as L,l as M,m as N,n as O,o as P,p as Q,q as R,r as S,s as T,t as U,u as V,v as W,w as X,x as Y,y as Z,z as _}from"./chunk-7FR5JSQ2.js";import{b as q,c as r,d as s,e as t,f as u,g as v,h as w,i as x,j as y,k as z,m as A}from"./chunk-XNDS4YFR.js";import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,n as i,p as j,t as k,u as l,v as m,w as n,x as o,y as p}from"./chunk-XNHVRFAK.js";import"./chunk-CM5YRNBJ.js";import"./chunk-YHEWKN7N.js";import"./chunk-QXVH6POE.js";import"./chunk-E3UBSUPX.js";import"./chunk-4QLJUQSJ.js";import"./chunk-7WRQ2UAN.js";import"./chunk-XRP4JJXL.js";export{k as ACTOR_TYPE,H as BOX_TYPE,Z as CONE_TYPE,da as CYLINDER_TYPE,W as DISK_TYPE,n as FOG_TYPE,ma as LIGHT_TYPE,w as LINE_TYPE,ja as PARTICLE_SYSTEM_TYPE,ga as PILL_TYPE,N as PLANE_TYPE,aa as PYRAMID_TYPE,T as RECT_TYPE,K as SPHERE_TYPE,t as SPRITE_TYPE,q as TEXT_TYPE,Q as ZONE_TYPE,l as ZylemActor,I as ZylemBox,_ as ZylemCone,ea as ZylemCylinder,X as ZylemDisk,o as ZylemFog,na as ZylemLight,y as ZylemLine,ka as ZylemParticleSystem,ha as ZylemPill,O as ZylemPlane,ba as ZylemPyramid,U as ZylemRect,L as ZylemSphere,u as ZylemSprite,r as ZylemText,R as ZylemZone,a as boxCollision,B as boxMesh,c as coneCollision,D as coneMesh,i as create,m as createActor,J as createBox,$ as createCone,pa as createCooldownIcon,fa as createCylinder,Y as createDisk,j as createEntity,A as createEntityFactory,p as createFog,oa as createLight,z as createLine,la as createParticleSystem,ia as createPill,P as createPlane,ca as createPyramid,V as createRect,M as createSphere,v as createSprite,s as createText,S as createZone,e as cylinderCollision,F as cylinderMesh,qa as destroy,x as pickZylemLine,f as pillCollision,G as pillMesh,g as planeCollision,d as pyramidCollision,E as pyramidMesh,b as sphereCollision,C as sphereMesh,h as zoneCollision};
@@ -0,0 +1,181 @@
1
+ import * as mitt from 'mitt';
2
+ import { L as LoadingEvent } from './base-node-life-cycle-D2NuN1VB.js';
3
+ import 'three';
4
+ import './stage-transition-CmGpV4tc.js';
5
+
6
+ /**
7
+ * Reusable delegate for event emission and subscription.
8
+ * Use via composition in Game, Stage, and Entity classes.
9
+ *
10
+ * @example
11
+ * class Game {
12
+ * private eventDelegate = new EventEmitterDelegate<GameEvents>();
13
+ *
14
+ * dispatch<K extends keyof GameEvents>(event: K, payload: GameEvents[K]) {
15
+ * this.eventDelegate.dispatch(event, payload);
16
+ * }
17
+ * }
18
+ */
19
+ declare class EventEmitterDelegate<TEvents extends Record<string, unknown>> {
20
+ private emitter;
21
+ private unsubscribes;
22
+ constructor();
23
+ /**
24
+ * Dispatch an event to all listeners.
25
+ */
26
+ dispatch<K extends keyof TEvents>(event: K, payload: TEvents[K]): void;
27
+ /**
28
+ * Subscribe to an event. Returns an unsubscribe function.
29
+ */
30
+ listen<K extends keyof TEvents>(event: K, handler: (payload: TEvents[K]) => void): () => void;
31
+ /**
32
+ * Subscribe to all events.
33
+ */
34
+ listenAll(handler: (type: keyof TEvents, payload: TEvents[keyof TEvents]) => void): () => void;
35
+ /**
36
+ * Clean up all subscriptions.
37
+ */
38
+ dispose(): void;
39
+ }
40
+
41
+ /**
42
+ * Payload for game loading events with stage context.
43
+ */
44
+ interface GameLoadingPayload extends LoadingEvent {
45
+ stageName?: string;
46
+ stageIndex?: number;
47
+ }
48
+ /** Payload for stage configuration sent to editor. */
49
+ interface StageConfigPayload {
50
+ id: string;
51
+ backgroundColor: string;
52
+ backgroundImage: string | null;
53
+ gravity: {
54
+ x: number;
55
+ y: number;
56
+ z: number;
57
+ };
58
+ inputs: Record<string, string[]>;
59
+ variables: Record<string, unknown>;
60
+ }
61
+ /** Payload for entity configuration sent to editor. */
62
+ interface EntityConfigPayload {
63
+ uuid: string;
64
+ name: string;
65
+ type: string;
66
+ position: {
67
+ x: number;
68
+ y: number;
69
+ z: number;
70
+ };
71
+ rotation: {
72
+ x: number;
73
+ y: number;
74
+ z: number;
75
+ };
76
+ scale: {
77
+ x: number;
78
+ y: number;
79
+ z: number;
80
+ };
81
+ /** PNG data URL of a framed entity preview, when available. */
82
+ thumbnail?: string | null;
83
+ /** World-space AABB size used for thumbnail rulers. */
84
+ bounds?: {
85
+ width: number;
86
+ height: number;
87
+ depth: number;
88
+ };
89
+ }
90
+ /** Payload for state dispatch events from game to editor. */
91
+ interface StateDispatchPayload {
92
+ scope: 'game' | 'stage' | 'entity';
93
+ path: string;
94
+ value: unknown;
95
+ previousValue?: unknown;
96
+ config?: {
97
+ id: string;
98
+ aspectRatio: number;
99
+ fullscreen: boolean;
100
+ bodyBackground: string | undefined;
101
+ internalResolution: {
102
+ width: number;
103
+ height: number;
104
+ } | undefined;
105
+ debug: boolean;
106
+ } | null;
107
+ stageConfig?: StageConfigPayload | null;
108
+ entities?: EntityConfigPayload[] | null;
109
+ }
110
+ type GameEvents = {
111
+ 'loading:start': GameLoadingPayload;
112
+ 'loading:progress': GameLoadingPayload;
113
+ 'loading:complete': GameLoadingPayload;
114
+ 'paused': {
115
+ paused: boolean;
116
+ };
117
+ 'debug': {
118
+ enabled: boolean;
119
+ };
120
+ 'state:dispatch': StateDispatchPayload;
121
+ };
122
+ type StageEvents = {
123
+ 'stage:loaded': {
124
+ stageId: string;
125
+ };
126
+ 'stage:unloaded': {
127
+ stageId: string;
128
+ };
129
+ 'stage:variable:changed': {
130
+ key: string;
131
+ value: unknown;
132
+ };
133
+ };
134
+ type EntityEvents = {
135
+ 'entity:spawned': {
136
+ entityId: string;
137
+ name: string;
138
+ };
139
+ 'entity:destroyed': {
140
+ entityId: string;
141
+ };
142
+ 'entity:collision': {
143
+ entityId: string;
144
+ otherId: string;
145
+ };
146
+ 'entity:model:loading': {
147
+ entityId: string;
148
+ files: string[];
149
+ };
150
+ 'entity:model:loaded': {
151
+ entityId: string;
152
+ success: boolean;
153
+ meshCount?: number;
154
+ errorMessage?: string;
155
+ };
156
+ 'entity:animation:loaded': {
157
+ entityId: string;
158
+ animationCount: number;
159
+ };
160
+ };
161
+ type ZylemEvents = GameEvents & StageEvents & EntityEvents;
162
+ /**
163
+ * Global event bus for cross-package communication.
164
+ *
165
+ * Usage:
166
+ * ```ts
167
+ * import { zylemEventBus } from '@zylem/game-lib/events';
168
+ *
169
+ * // Subscribe
170
+ * const unsub = zylemEventBus.on('loading:progress', (e) => console.log(e));
171
+ *
172
+ * // Emit
173
+ * zylemEventBus.emit('loading:progress', { type: 'progress', progress: 0.5 });
174
+ *
175
+ * // Cleanup
176
+ * unsub();
177
+ * ```
178
+ */
179
+ declare const zylemEventBus: mitt.Emitter<ZylemEvents>;
180
+
181
+ export { type EntityConfigPayload, type EntityEvents, EventEmitterDelegate, type GameEvents, type GameLoadingPayload, type StageConfigPayload, type StageEvents, type StateDispatchPayload, type ZylemEvents, zylemEventBus };
package/dist/events.js ADDED
@@ -0,0 +1 @@
1
+ import"./chunk-BIGH6D34.js";import{a,b}from"./chunk-YHEWKN7N.js";import"./chunk-QXVH6POE.js";export{a as EventEmitterDelegate,b as zylemEventBus};