@zylem/game-lib 0.6.0 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -16
- package/dist/actions.d.ts +30 -21
- package/dist/actions.js +628 -145
- package/dist/actions.js.map +1 -1
- package/dist/behavior/platformer-3d.d.ts +296 -0
- package/dist/behavior/platformer-3d.js +518 -0
- package/dist/behavior/platformer-3d.js.map +1 -0
- package/dist/behavior/ricochet-2d.d.ts +274 -0
- package/dist/behavior/ricochet-2d.js +394 -0
- package/dist/behavior/ricochet-2d.js.map +1 -0
- package/dist/behavior/screen-wrap.d.ts +86 -0
- package/dist/behavior/screen-wrap.js +195 -0
- package/dist/behavior/screen-wrap.js.map +1 -0
- package/dist/behavior/thruster.d.ts +10 -0
- package/dist/behavior/thruster.js +234 -0
- package/dist/behavior/thruster.js.map +1 -0
- package/dist/behavior/world-boundary-2d.d.ts +141 -0
- package/dist/behavior/world-boundary-2d.js +181 -0
- package/dist/behavior/world-boundary-2d.js.map +1 -0
- package/dist/behavior-descriptor-BWNWmIjv.d.ts +142 -0
- package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-BWGz8fII.d.ts} +2 -2
- package/dist/camera-B5e4c78l.d.ts +468 -0
- package/dist/camera.d.ts +3 -2
- package/dist/camera.js +962 -166
- package/dist/camera.js.map +1 -1
- package/dist/composition-DrzFrbqI.d.ts +218 -0
- package/dist/{core-CZhozNRH.d.ts → core-DAkskq6Y.d.ts} +97 -65
- package/dist/core.d.ts +12 -6
- package/dist/core.js +4449 -1052
- package/dist/core.js.map +1 -1
- package/dist/{entities-BAxfJOkk.d.ts → entities-DC9ce_vx.d.ts} +154 -45
- package/dist/entities.d.ts +5 -2
- package/dist/entities.js +2505 -722
- package/dist/entities.js.map +1 -1
- package/dist/entity-BpbZqg19.d.ts +1100 -0
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/global-change-Dc8uCKi2.d.ts +25 -0
- package/dist/main.d.ts +472 -29
- package/dist/main.js +11877 -6124
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-CD21XoIU.d.ts → stage-types-BFsm3qsZ.d.ts} +255 -26
- package/dist/stage.d.ts +11 -6
- package/dist/stage.js +3462 -491
- package/dist/stage.js.map +1 -1
- package/dist/thruster-DhRaJnoL.d.ts +172 -0
- package/dist/world-Be5m1XC1.d.ts +31 -0
- package/package.json +21 -4
- package/dist/behaviors.d.ts +0 -106
- package/dist/behaviors.js +0 -398
- package/dist/behaviors.js.map +0 -1
- package/dist/camera-CpbDr4-V.d.ts +0 -116
- package/dist/entity-COvRtFNG.d.ts +0 -395
- package/dist/moveable-B_vyA6cw.d.ts +0 -67
- package/dist/transformable-CUhvyuYO.d.ts +0 -67
|
@@ -1,40 +1,90 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as UpdateFunction, S as SetupFunction, Z as ZylemShader, I as GameEntity, K as DestroyFunction, L as SetupContext, U as UpdateContext, M as DestroyContext, N as BaseNode, O as LoadingEvent, P as GameEntityOptions, Q as StageEvents } from './entity-BpbZqg19.js';
|
|
2
2
|
import * as bitecs from 'bitecs';
|
|
3
3
|
import { defineSystem, IWorld } from 'bitecs';
|
|
4
|
-
import { Scene, Color, Object3D, Vector3,
|
|
5
|
-
import {
|
|
4
|
+
import { Scene, Color, Object3D, Vector3, BufferGeometry, Material } from 'three';
|
|
5
|
+
import { Z as ZylemWorld } from './world-Be5m1XC1.js';
|
|
6
6
|
import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-Bq_eNEDI.js';
|
|
7
|
-
import { Z as ZylemCamera, C as CameraDebugDelegate, b as CameraDebugState,
|
|
8
|
-
import
|
|
7
|
+
import { Z as ZylemCamera, C as CameraManager, R as RendererManager, a as CameraDebugDelegate, b as CameraDebugState, c as CameraWrapper } from './camera-B5e4c78l.js';
|
|
8
|
+
import { G as GameEntityInterface, B as BaseEntityInterface } from './entity-types-DAu8sGJH.js';
|
|
9
|
+
import RAPIER__default from '@dimforge/rapier3d-compat';
|
|
10
|
+
import { S as SPRITE_TYPE, Z as ZylemSprite, a as SPHERE_TYPE, b as ZylemSphere, R as RECT_TYPE, c as ZylemRect, T as TEXT_TYPE, d as ZylemText, B as BOX_TYPE, e as ZylemBox, P as PLANE_TYPE, f as ZylemPlane, g as ZONE_TYPE, h as ZylemZone, A as ACTOR_TYPE, i as ZylemActor, C as CONE_TYPE, j as ZylemCone, k as PYRAMID_TYPE, l as ZylemPyramid, m as CYLINDER_TYPE, n as ZylemCylinder, o as PILL_TYPE, p as ZylemPill } from './entities-DC9ce_vx.js';
|
|
11
|
+
import { B as BehaviorSystem, a as BehaviorSystemFactory } from './behavior-descriptor-BWNWmIjv.js';
|
|
12
|
+
|
|
13
|
+
type BasicTypes = number | string | boolean;
|
|
14
|
+
type BaseGlobals = Record<string, BasicTypes>;
|
|
15
|
+
type KeyboardMapping = Record<string, string[]>;
|
|
16
|
+
type MouseMapping = Record<string, string[]>;
|
|
17
|
+
interface GameInputPlayerConfig {
|
|
18
|
+
key?: KeyboardMapping;
|
|
19
|
+
mouse?: MouseMapping;
|
|
20
|
+
includeDefaults?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface GameInputConfig {
|
|
23
|
+
p1?: GameInputPlayerConfig;
|
|
24
|
+
p2?: GameInputPlayerConfig;
|
|
25
|
+
p3?: GameInputPlayerConfig;
|
|
26
|
+
p4?: GameInputPlayerConfig;
|
|
27
|
+
p5?: GameInputPlayerConfig;
|
|
28
|
+
p6?: GameInputPlayerConfig;
|
|
29
|
+
p7?: GameInputPlayerConfig;
|
|
30
|
+
p8?: GameInputPlayerConfig;
|
|
31
|
+
}
|
|
32
|
+
interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends BaseGlobals> {
|
|
33
|
+
id: string;
|
|
34
|
+
globals?: TGlobals;
|
|
35
|
+
stages?: StageInterface[];
|
|
36
|
+
update?: UpdateFunction<GameInterface>;
|
|
37
|
+
debug?: boolean;
|
|
38
|
+
time?: number;
|
|
39
|
+
input?: GameInputConfig;
|
|
40
|
+
}
|
|
9
41
|
|
|
10
42
|
interface SceneState {
|
|
11
43
|
backgroundColor: Color | string;
|
|
12
44
|
backgroundImage: string | null;
|
|
45
|
+
backgroundShader?: ZylemShader | null;
|
|
13
46
|
}
|
|
14
47
|
declare class ZylemScene implements Entity<ZylemScene> {
|
|
15
48
|
type: string;
|
|
16
49
|
_setup?: SetupFunction<ZylemScene>;
|
|
17
50
|
scene: Scene;
|
|
51
|
+
/** @deprecated Use cameraManager instead */
|
|
18
52
|
zylemCamera: ZylemCamera;
|
|
53
|
+
cameraManager: CameraManager | null;
|
|
19
54
|
containerElement: HTMLElement | null;
|
|
20
55
|
update: LifecycleFunction<ZylemScene>;
|
|
21
56
|
_collision?: ((entity: any, other: any, globals?: any) => void) | undefined;
|
|
22
57
|
_destroy?: ((globals?: any) => void) | undefined;
|
|
23
58
|
name?: string | undefined;
|
|
24
59
|
tag?: Set<string> | undefined;
|
|
60
|
+
private skyboxMaterial;
|
|
25
61
|
constructor(id: string, camera: ZylemCamera, state: SceneState);
|
|
62
|
+
/**
|
|
63
|
+
* Create a large inverted box with the shader for skybox effect
|
|
64
|
+
* Supports both GLSL (ShaderMaterial) and TSL (MeshBasicNodeMaterial) shaders
|
|
65
|
+
*/
|
|
66
|
+
private setupBackgroundShader;
|
|
26
67
|
setup(): void;
|
|
27
68
|
destroy(): void;
|
|
28
69
|
/**
|
|
29
|
-
* Setup camera with the scene
|
|
70
|
+
* Setup camera with the scene.
|
|
71
|
+
* Supports both legacy single camera and CameraManager modes.
|
|
72
|
+
*/
|
|
73
|
+
setupCamera(scene: Scene, camera: ZylemCamera, rendererManager?: RendererManager): void;
|
|
74
|
+
/**
|
|
75
|
+
* Setup with a CameraManager (multi-camera support).
|
|
76
|
+
*/
|
|
77
|
+
setupCameraManager(scene: Scene, cameraManager: CameraManager, rendererManager: RendererManager): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Add a camera (rig or direct) to the scene graph.
|
|
30
80
|
*/
|
|
31
|
-
|
|
81
|
+
private addCameraToScene;
|
|
32
82
|
/**
|
|
33
83
|
* Setup scene lighting
|
|
34
84
|
*/
|
|
35
85
|
setupLighting(scene: Scene): void;
|
|
36
86
|
/**
|
|
37
|
-
* Update renderer size - delegates to camera
|
|
87
|
+
* Update renderer size - delegates to camera manager or camera
|
|
38
88
|
*/
|
|
39
89
|
updateRenderer(width: number, height: number): void;
|
|
40
90
|
/**
|
|
@@ -45,32 +95,105 @@ declare class ZylemScene implements Entity<ZylemScene> {
|
|
|
45
95
|
* Add game entity to scene
|
|
46
96
|
*/
|
|
47
97
|
addEntity(entity: GameEntity<any>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Add an entity's group or mesh to the scene (for late-loaded models).
|
|
100
|
+
* Uses entity's current body position if physics is active.
|
|
101
|
+
*/
|
|
102
|
+
addEntityGroup(entity: GameEntity<any>): void;
|
|
48
103
|
/**
|
|
49
104
|
* Add debug helpers to scene
|
|
50
105
|
*/
|
|
51
106
|
debugScene(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Update skybox shader uniforms (only applies to GLSL ShaderMaterial)
|
|
109
|
+
* TSL shaders use the time node which auto-updates
|
|
110
|
+
*/
|
|
111
|
+
updateSkybox(delta: number): void;
|
|
52
112
|
}
|
|
53
113
|
|
|
54
114
|
/**
|
|
55
|
-
*
|
|
115
|
+
* Configuration for batch key generation
|
|
56
116
|
*/
|
|
57
|
-
interface
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
collider: Collider | null;
|
|
117
|
+
interface BatchKeyConfig {
|
|
118
|
+
geometryType: string;
|
|
119
|
+
dimensions: Record<string, number>;
|
|
120
|
+
materialPath?: string | null;
|
|
121
|
+
shaderType?: 'standard' | 'custom';
|
|
122
|
+
colorHex?: number;
|
|
64
123
|
}
|
|
65
124
|
/**
|
|
66
|
-
*
|
|
125
|
+
* Manages instanced mesh batching for entities
|
|
67
126
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
127
|
+
declare class InstanceManager {
|
|
128
|
+
private batches;
|
|
129
|
+
private entityToBatch;
|
|
130
|
+
private scene;
|
|
131
|
+
/** Default initial capacity for new batches */
|
|
132
|
+
static DEFAULT_CAPACITY: number;
|
|
133
|
+
/** Factor to grow batch when full */
|
|
134
|
+
static GROWTH_FACTOR: number;
|
|
135
|
+
/**
|
|
136
|
+
* Set the scene to add instanced meshes to
|
|
137
|
+
*/
|
|
138
|
+
setScene(scene: Object3D): void;
|
|
139
|
+
/**
|
|
140
|
+
* Generate a batch key from configuration
|
|
141
|
+
*/
|
|
142
|
+
static generateBatchKey(config: BatchKeyConfig): string;
|
|
143
|
+
/**
|
|
144
|
+
* Register an entity with the instance manager
|
|
145
|
+
* @returns The instance index, or -1 if registration failed
|
|
146
|
+
*/
|
|
147
|
+
register(entity: GameEntity<any>, geometry: BufferGeometry, material: Material, batchKey: string): number;
|
|
148
|
+
/**
|
|
149
|
+
* Unregister an entity from the instance manager
|
|
150
|
+
*/
|
|
151
|
+
unregister(entity: GameEntity<any>): void;
|
|
152
|
+
/**
|
|
153
|
+
* Mark an entity's transform as dirty (needs syncing)
|
|
154
|
+
*/
|
|
155
|
+
markDirty(entity: GameEntity<any>): void;
|
|
156
|
+
/**
|
|
157
|
+
* Update all dirty instance transforms
|
|
158
|
+
* Call this once per frame
|
|
159
|
+
*/
|
|
160
|
+
/**
|
|
161
|
+
* Update all active instance transforms
|
|
162
|
+
* Call this once per frame
|
|
163
|
+
*/
|
|
164
|
+
update(): void;
|
|
165
|
+
private updateInstanceMatrix;
|
|
166
|
+
/**
|
|
167
|
+
* Get batch info for an entity
|
|
168
|
+
*/
|
|
169
|
+
getBatchInfo(entity: GameEntity<any>): {
|
|
170
|
+
batchKey: string;
|
|
171
|
+
instanceId: number;
|
|
172
|
+
} | null;
|
|
173
|
+
/**
|
|
174
|
+
* Get statistics about current batching
|
|
175
|
+
*/
|
|
176
|
+
getStats(): {
|
|
177
|
+
batchCount: number;
|
|
178
|
+
totalInstances: number;
|
|
179
|
+
batches: {
|
|
180
|
+
key: string;
|
|
181
|
+
count: number;
|
|
182
|
+
capacity: number;
|
|
183
|
+
}[];
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Dispose all batches and release resources
|
|
187
|
+
*/
|
|
188
|
+
dispose(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Create a new batch group
|
|
191
|
+
*/
|
|
192
|
+
private createBatch;
|
|
193
|
+
/**
|
|
194
|
+
* Grow a batch's capacity
|
|
195
|
+
*/
|
|
196
|
+
private growBatch;
|
|
74
197
|
}
|
|
75
198
|
|
|
76
199
|
/**
|
|
@@ -118,6 +241,8 @@ declare class StageDebugDelegate {
|
|
|
118
241
|
private debugCursor;
|
|
119
242
|
private debugLines;
|
|
120
243
|
constructor(stage: ZylemStage, options?: StageDebugDelegateOptions);
|
|
244
|
+
private initDebugVisuals;
|
|
245
|
+
private disposeDebugVisuals;
|
|
121
246
|
update(): void;
|
|
122
247
|
dispose(): void;
|
|
123
248
|
private handleActionOnHit;
|
|
@@ -139,6 +264,7 @@ interface ZylemStageConfig {
|
|
|
139
264
|
inputs: Record<string, string[]>;
|
|
140
265
|
backgroundColor: Color | string;
|
|
141
266
|
backgroundImage: string | null;
|
|
267
|
+
backgroundShader: any | null;
|
|
142
268
|
gravity: Vector3;
|
|
143
269
|
variables: Record<string, any>;
|
|
144
270
|
stageRef?: Stage;
|
|
@@ -167,6 +293,7 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
167
293
|
gravity: Vector3;
|
|
168
294
|
world: ZylemWorld | null;
|
|
169
295
|
scene: ZylemScene | null;
|
|
296
|
+
instanceManager: InstanceManager | null;
|
|
170
297
|
children: Array<BaseNode>;
|
|
171
298
|
_childrenMap: Map<number, BaseNode>;
|
|
172
299
|
_removalMap: Map<number, BaseNode>;
|
|
@@ -178,15 +305,23 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
178
305
|
ecs: bitecs.IWorld;
|
|
179
306
|
testSystem: any;
|
|
180
307
|
transformSystem: ReturnType<typeof createTransformSystem> | null;
|
|
308
|
+
private behaviorSystems;
|
|
309
|
+
private registeredSystemKeys;
|
|
181
310
|
debugDelegate: StageDebugDelegate | null;
|
|
182
311
|
cameraDebugDelegate: StageCameraDebugDelegate | null;
|
|
183
312
|
private debugStateUnsubscribe;
|
|
184
313
|
uuid: string;
|
|
185
314
|
wrapperRef: Stage | null;
|
|
186
315
|
camera?: CameraWrapper;
|
|
316
|
+
cameras: CameraWrapper[];
|
|
187
317
|
cameraRef?: ZylemCamera | null;
|
|
318
|
+
/** Camera manager for multi-camera support */
|
|
319
|
+
cameraManagerRef: CameraManager | null;
|
|
320
|
+
/** Shared renderer manager (injected by the game) */
|
|
321
|
+
rendererManager: RendererManager | null;
|
|
188
322
|
private cameraDelegate;
|
|
189
323
|
private loadingDelegate;
|
|
324
|
+
private entityModelDelegate;
|
|
190
325
|
/**
|
|
191
326
|
* Create a new stage.
|
|
192
327
|
* @param options Stage options: partial config, camera, and initial entities or factories
|
|
@@ -202,7 +337,7 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
202
337
|
* @param id DOM element id for the renderer container
|
|
203
338
|
* @param camera Optional camera override
|
|
204
339
|
*/
|
|
205
|
-
load(id: string, camera?: ZylemCamera | null): Promise<void>;
|
|
340
|
+
load(id: string, camera?: ZylemCamera | null, rendererManager?: RendererManager | null): Promise<void>;
|
|
206
341
|
/**
|
|
207
342
|
* Generator that yields between entity loads for real-time progress updates.
|
|
208
343
|
*/
|
|
@@ -225,6 +360,11 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
225
360
|
* Safe to call only after `load` when scene/world exist.
|
|
226
361
|
*/
|
|
227
362
|
spawnEntity(child: BaseNode): Promise<void>;
|
|
363
|
+
/**
|
|
364
|
+
* Try to register an entity for instanced rendering.
|
|
365
|
+
* Batching is enabled by default unless explicitly disabled with batched: false.
|
|
366
|
+
*/
|
|
367
|
+
private tryRegisterInstance;
|
|
228
368
|
buildEntityState(child: BaseNode): Partial<BaseEntityInterface>;
|
|
229
369
|
/** Add the entity to internal maps and notify listeners. */
|
|
230
370
|
addEntityToStage(entity: BaseNode): void;
|
|
@@ -238,6 +378,12 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
238
378
|
replayExisting?: boolean;
|
|
239
379
|
}): () => void;
|
|
240
380
|
onLoading(callback: (event: LoadingEvent) => void): () => void;
|
|
381
|
+
/**
|
|
382
|
+
* Register an ECS behavior system to run each frame.
|
|
383
|
+
* @param systemOrFactory A BehaviorSystem instance or factory function
|
|
384
|
+
* @returns this for chaining
|
|
385
|
+
*/
|
|
386
|
+
registerSystem(systemOrFactory: BehaviorSystem | BehaviorSystemFactory): this;
|
|
241
387
|
/**
|
|
242
388
|
* Remove an entity and its resources by its UUID.
|
|
243
389
|
* @returns true if removed, false if not found or stage not ready
|
|
@@ -246,6 +392,22 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
246
392
|
/** Get an entity by its name; returns null if not found. */
|
|
247
393
|
getEntityByName(name: string): BaseNode<any, any> | null;
|
|
248
394
|
logMissingEntities(): void;
|
|
395
|
+
/**
|
|
396
|
+
* Add a camera to this stage's camera manager.
|
|
397
|
+
*/
|
|
398
|
+
addCamera(camera: ZylemCamera, name?: string): string | null;
|
|
399
|
+
/**
|
|
400
|
+
* Remove a camera from this stage's camera manager.
|
|
401
|
+
*/
|
|
402
|
+
removeCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
403
|
+
/**
|
|
404
|
+
* Set the active camera by name or reference.
|
|
405
|
+
*/
|
|
406
|
+
setActiveCamera(nameOrRef: string | ZylemCamera): boolean;
|
|
407
|
+
/**
|
|
408
|
+
* Get a camera by name from the camera manager.
|
|
409
|
+
*/
|
|
410
|
+
getCamera(name: string): ZylemCamera | null;
|
|
249
411
|
/** Resize renderer viewport. */
|
|
250
412
|
resize(width: number, height: number): void;
|
|
251
413
|
/**
|
|
@@ -257,6 +419,20 @@ declare class ZylemStage extends LifeCycleBase<ZylemStage> {
|
|
|
257
419
|
enqueue(...items: StageEntityInput[]): void;
|
|
258
420
|
}
|
|
259
421
|
|
|
422
|
+
type ZylemDiskOptions = GameEntityOptions & {
|
|
423
|
+
innerRadius?: number;
|
|
424
|
+
outerRadius?: number;
|
|
425
|
+
thetaSegments?: number;
|
|
426
|
+
};
|
|
427
|
+
declare const DISK_TYPE: unique symbol;
|
|
428
|
+
declare class ZylemDisk extends GameEntity<ZylemDiskOptions> {
|
|
429
|
+
static type: symbol;
|
|
430
|
+
constructor(options?: ZylemDiskOptions);
|
|
431
|
+
buildInfo(): Record<string, any>;
|
|
432
|
+
}
|
|
433
|
+
type DiskOptions = BaseNode | Partial<ZylemDiskOptions>;
|
|
434
|
+
declare function createDisk(...args: Array<DiskOptions>): ZylemDisk;
|
|
435
|
+
|
|
260
436
|
/**
|
|
261
437
|
* Maps entity type symbols to their class types.
|
|
262
438
|
* Used by getEntityByName to infer return types.
|
|
@@ -270,6 +446,11 @@ interface EntityTypeMap {
|
|
|
270
446
|
[PLANE_TYPE]: ZylemPlane;
|
|
271
447
|
[ZONE_TYPE]: ZylemZone;
|
|
272
448
|
[ACTOR_TYPE]: ZylemActor;
|
|
449
|
+
[DISK_TYPE]: ZylemDisk;
|
|
450
|
+
[CONE_TYPE]: ZylemCone;
|
|
451
|
+
[PYRAMID_TYPE]: ZylemPyramid;
|
|
452
|
+
[CYLINDER_TYPE]: ZylemCylinder;
|
|
453
|
+
[PILL_TYPE]: ZylemPill;
|
|
273
454
|
}
|
|
274
455
|
|
|
275
456
|
type NodeLike = {
|
|
@@ -285,8 +466,24 @@ declare class Stage {
|
|
|
285
466
|
private updateCallbacks;
|
|
286
467
|
private destroyCallbacks;
|
|
287
468
|
private pendingLoadingCallbacks;
|
|
469
|
+
private eventDelegate;
|
|
470
|
+
/** Per-stage input configuration overrides. Merged with game-level defaults on stage load. */
|
|
471
|
+
inputConfig: GameInputConfig | null;
|
|
472
|
+
/**
|
|
473
|
+
* Callback set by the game to trigger input reconfiguration
|
|
474
|
+
* when this stage's input config changes at runtime.
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
onInputConfigChanged: (() => void) | null;
|
|
288
478
|
constructor(options: StageOptions);
|
|
289
|
-
|
|
479
|
+
/**
|
|
480
|
+
* Set composable input configuration for this stage.
|
|
481
|
+
* Multiple configs are deep-merged (later configs win on key conflicts).
|
|
482
|
+
* If this stage is currently active, the change takes effect immediately.
|
|
483
|
+
* @example stage.setInputConfiguration(useArrowsForAxes('p1'), useWASDForDirections('p2'));
|
|
484
|
+
*/
|
|
485
|
+
setInputConfiguration(...configs: GameInputConfig[]): this;
|
|
486
|
+
load(id: string, camera?: ZylemCamera | CameraWrapper | null, rendererManager?: RendererManager | null): Promise<void>;
|
|
290
487
|
private applyLifecycleCallbacks;
|
|
291
488
|
addEntities(entities: BaseNode[]): Promise<void>;
|
|
292
489
|
add(...inputs: Array<EntityInput>): void;
|
|
@@ -305,6 +502,38 @@ declare class Stage {
|
|
|
305
502
|
* @example stage.getEntityByName('scoreText', TEXT_TYPE)
|
|
306
503
|
*/
|
|
307
504
|
getEntityByName<T extends symbol | void = void>(name: string, type?: T): T extends keyof EntityTypeMap ? EntityTypeMap[T] | undefined : BaseNode | undefined;
|
|
505
|
+
/**
|
|
506
|
+
* Add a camera to this stage.
|
|
507
|
+
* @param camera The ZylemCamera or CameraWrapper to add
|
|
508
|
+
* @param name Optional name for lookup
|
|
509
|
+
*/
|
|
510
|
+
addCamera(camera: ZylemCamera | CameraWrapper, name?: string): string | null;
|
|
511
|
+
/**
|
|
512
|
+
* Remove a camera from this stage by name or reference.
|
|
513
|
+
*/
|
|
514
|
+
removeCamera(nameOrRef: string | ZylemCamera | CameraWrapper): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* Set the active camera by name or reference.
|
|
517
|
+
*/
|
|
518
|
+
setActiveCamera(nameOrRef: string | ZylemCamera | CameraWrapper): boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Get a camera by name from the camera manager.
|
|
521
|
+
*/
|
|
522
|
+
getCamera(name: string): ZylemCamera | null;
|
|
523
|
+
/**
|
|
524
|
+
* Dispatch an event from the stage.
|
|
525
|
+
* Events are emitted both locally and to the global event bus.
|
|
526
|
+
*/
|
|
527
|
+
dispatch<K extends keyof StageEvents>(event: K, payload: StageEvents[K]): void;
|
|
528
|
+
/**
|
|
529
|
+
* Listen for events on this stage instance.
|
|
530
|
+
* @returns Unsubscribe function
|
|
531
|
+
*/
|
|
532
|
+
listen<K extends keyof StageEvents>(event: K, handler: (payload: StageEvents[K]) => void): () => void;
|
|
533
|
+
/**
|
|
534
|
+
* Clean up stage resources including event subscriptions.
|
|
535
|
+
*/
|
|
536
|
+
dispose(): void;
|
|
308
537
|
}
|
|
309
538
|
/**
|
|
310
539
|
* Create a stage with optional camera
|
|
@@ -335,4 +564,4 @@ interface StageInterface {
|
|
|
335
564
|
state: StageStateInterface;
|
|
336
565
|
}
|
|
337
566
|
|
|
338
|
-
export { type StageStateInterface as S, type StageOptions as a, Stage as b, createStage as c, type StageInterface as
|
|
567
|
+
export { type BaseGlobals as B, type GameInputConfig as G, type StageStateInterface as S, type ZylemGameConfig as Z, type StageOptions as a, Stage as b, createStage as c, createDisk as d, type StageInterface as e };
|
package/dist/stage.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { S as StageStateInterface } from './stage-types-
|
|
2
|
-
export { a as StageOptions, c as createStage } from './stage-types-
|
|
3
|
-
export { S as StageBlueprint, e as entitySpawner } from './blueprints-
|
|
4
|
-
import './entity-
|
|
1
|
+
import { S as StageStateInterface } from './stage-types-BFsm3qsZ.js';
|
|
2
|
+
export { a as StageOptions, c as createStage } from './stage-types-BFsm3qsZ.js';
|
|
3
|
+
export { S as StageBlueprint, e as entitySpawner } from './blueprints-BWGz8fII.js';
|
|
4
|
+
import './entity-BpbZqg19.js';
|
|
5
5
|
import 'three';
|
|
6
6
|
import '@dimforge/rapier3d-compat';
|
|
7
7
|
import 'bitecs';
|
|
8
|
-
import '
|
|
8
|
+
import 'mitt';
|
|
9
|
+
import './behavior-descriptor-BWNWmIjv.js';
|
|
10
|
+
import './world-Be5m1XC1.js';
|
|
9
11
|
import './entity-Bq_eNEDI.js';
|
|
10
|
-
import './camera-
|
|
12
|
+
import './camera-B5e4c78l.js';
|
|
13
|
+
import 'three/webgpu';
|
|
11
14
|
import 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
15
|
+
import './entity-types-DAu8sGJH.js';
|
|
16
|
+
import './entities-DC9ce_vx.js';
|
|
12
17
|
import '@sinclair/typebox';
|
|
13
18
|
|
|
14
19
|
/**
|