@zylem/game-lib 0.6.3 → 0.7.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.
- package/README.md +3 -1
- package/dist/actions.d.ts +255 -8
- package/dist/actions.js +1 -772
- package/dist/audio.d.ts +13 -0
- package/dist/audio.js +1 -0
- package/dist/base-node-life-cycle-CnJ-7zX-.d.ts +143 -0
- package/dist/behavior.d.ts +3 -0
- package/dist/behavior.js +1 -0
- package/dist/chunk-4QLJUQSJ.js +1 -0
- package/dist/chunk-73VZQZUL.js +1 -0
- package/dist/chunk-A34ZG3L4.js +1 -0
- package/dist/chunk-CDPY4VOQ.js +1 -0
- package/dist/chunk-DR6XXZE7.js +19 -0
- package/dist/chunk-FM5TBEPO.js +1 -0
- package/dist/chunk-G2IIMSUH.js +1 -0
- package/dist/chunk-MSC2BEO5.js +1 -0
- package/dist/chunk-NIH5CONO.js +1 -0
- package/dist/chunk-ONWXGBWB.js +1 -0
- package/dist/chunk-QEDQDR27.js +1 -0
- package/dist/chunk-QXVH6POE.js +1 -0
- package/dist/chunk-RXDTAWI2.js +29 -0
- package/dist/chunk-WKHW2QO2.js +1 -0
- package/dist/chunk-XRP4JJXL.js +1 -0
- package/dist/chunk-YHEWKN7N.js +1 -0
- package/dist/chunk-YHKXQ2ZN.js +1 -0
- package/dist/core.d.ts +206 -13
- package/dist/core.js +24 -9160
- package/dist/debug.d.ts +24 -0
- package/dist/debug.js +1 -0
- package/dist/default-controls-BGc61yYl.d.ts +111 -0
- package/dist/entity-DNkYKfdp.d.ts +1043 -0
- package/dist/entity-type-map-C94h2TDW.d.ts +781 -0
- package/dist/entity.d.ts +265 -0
- package/dist/entity.js +1 -0
- package/dist/events.d.ts +172 -0
- package/dist/events.js +1 -0
- package/dist/game-Cuj5gy7U.d.ts +1590 -0
- package/dist/game-default-PZLLHYL7.js +1 -0
- package/dist/game-interfaces-tfpM5NBk.d.ts +90 -0
- package/dist/globals.d.ts +104 -0
- package/dist/globals.js +1 -0
- package/dist/graphics.d.ts +83 -0
- package/dist/graphics.js +1 -0
- package/dist/input-ui.d.ts +34 -0
- package/dist/input-ui.js +1 -0
- package/dist/input.d.ts +72 -0
- package/dist/input.js +1 -0
- package/dist/material-Wz83vTTp.d.ts +151 -0
- package/dist/runtime.d.ts +433 -0
- package/dist/runtime.js +1 -0
- package/dist/web-components.d.ts +67 -0
- package/dist/web-components.js +9 -0
- package/dist/world-C9zdyl5d.d.ts +103 -0
- package/dist/zylem-stage-runtime-Cs-UDEVU.d.ts +777 -0
- package/package.json +54 -41
- package/dist/actions.js.map +0 -1
- package/dist/behavior/platformer-3d.d.ts +0 -296
- package/dist/behavior/platformer-3d.js +0 -518
- package/dist/behavior/platformer-3d.js.map +0 -1
- package/dist/behavior/ricochet-2d.d.ts +0 -274
- package/dist/behavior/ricochet-2d.js +0 -394
- package/dist/behavior/ricochet-2d.js.map +0 -1
- package/dist/behavior/screen-wrap.d.ts +0 -86
- package/dist/behavior/screen-wrap.js +0 -195
- package/dist/behavior/screen-wrap.js.map +0 -1
- package/dist/behavior/thruster.d.ts +0 -10
- package/dist/behavior/thruster.js +0 -234
- package/dist/behavior/thruster.js.map +0 -1
- package/dist/behavior/world-boundary-2d.d.ts +0 -141
- package/dist/behavior/world-boundary-2d.js +0 -181
- package/dist/behavior/world-boundary-2d.js.map +0 -1
- package/dist/behavior-descriptor-BWNWmIjv.d.ts +0 -142
- package/dist/blueprints-BWGz8fII.d.ts +0 -26
- package/dist/camera-B5e4c78l.d.ts +0 -468
- package/dist/camera.d.ts +0 -6
- package/dist/camera.js +0 -1406
- package/dist/camera.js.map +0 -1
- package/dist/composition-DrzFrbqI.d.ts +0 -218
- package/dist/core-DAkskq6Y.d.ts +0 -498
- package/dist/core.js.map +0 -1
- package/dist/entities-DC9ce_vx.d.ts +0 -416
- package/dist/entities.d.ts +0 -9
- package/dist/entities.js +0 -4069
- package/dist/entities.js.map +0 -1
- package/dist/entity-BpbZqg19.d.ts +0 -1100
- package/dist/entity-Bq_eNEDI.d.ts +0 -28
- package/dist/entity-types-DAu8sGJH.d.ts +0 -26
- package/dist/global-change-Dc8uCKi2.d.ts +0 -25
- package/dist/main.d.ts +0 -654
- package/dist/main.js +0 -13355
- package/dist/main.js.map +0 -1
- package/dist/stage-types-BFsm3qsZ.d.ts +0 -567
- package/dist/stage.d.ts +0 -51
- package/dist/stage.js +0 -5738
- package/dist/stage.js.map +0 -1
- package/dist/thruster-DhRaJnoL.d.ts +0 -172
- package/dist/world-Be5m1XC1.d.ts +0 -31
package/dist/core-DAkskq6Y.d.ts
DELETED
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
import { ak as InputPlayerNumber, al as InputProvider, am as Inputs, L as SetupContext, U as UpdateContext, M as DestroyContext, an as GameEntityLifeCycle, N as BaseNode, ao as IGame, S as SetupFunction, J as UpdateFunction, K as DestroyFunction, aa as GameEvents, ap as LoadedContext, aq as CleanupContext, ar as NodeInterface } from './entity-BpbZqg19.js';
|
|
2
|
-
import { G as GameInputConfig, e as StageInterface, B as BaseGlobals, b as Stage, Z as ZylemGameConfig } from './stage-types-BFsm3qsZ.js';
|
|
3
|
-
import { Z as ZylemCamera, R as RendererManager } from './camera-B5e4c78l.js';
|
|
4
|
-
import { Vector3 } from 'three';
|
|
5
|
-
import { Vector3 as Vector3$1 } from '@dimforge/rapier3d-compat';
|
|
6
|
-
import './global-change-Dc8uCKi2.js';
|
|
7
|
-
|
|
8
|
-
declare class InputManager {
|
|
9
|
-
private inputMap;
|
|
10
|
-
private currentInputs;
|
|
11
|
-
private previousInputs;
|
|
12
|
-
constructor(config?: GameInputConfig);
|
|
13
|
-
/**
|
|
14
|
-
* Reconfigure keyboard providers at runtime without affecting gamepad providers.
|
|
15
|
-
* Disposes existing keyboard providers and creates new ones from the given config.
|
|
16
|
-
*/
|
|
17
|
-
configure(config: GameInputConfig): void;
|
|
18
|
-
addInputProvider(playerNumber: InputPlayerNumber, provider: InputProvider): void;
|
|
19
|
-
getInputs(delta: number): Inputs;
|
|
20
|
-
private buildPlayerEntries;
|
|
21
|
-
private mergeInputs;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* This class is an alternative to {@link Clock} with a different API design and behavior.
|
|
26
|
-
* The goal is to avoid the conceptual flaws that became apparent in `Clock` over time.
|
|
27
|
-
*
|
|
28
|
-
* - `Timer` has an `update()` method that updates its internal state. That makes it possible to
|
|
29
|
-
* call `getDelta()` and `getElapsed()` multiple times per simulation step without getting different values.
|
|
30
|
-
* - The class can make use of the Page Visibility API to avoid large time delta values when the app
|
|
31
|
-
* is inactive (e.g. tab switched or browser hidden).
|
|
32
|
-
*
|
|
33
|
-
* ```js
|
|
34
|
-
* const timer = new Timer();
|
|
35
|
-
* timer.connect( document ); // use Page Visibility API
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @three_import import { Timer } from 'three/addons/misc/Timer.js';
|
|
39
|
-
*/
|
|
40
|
-
declare class Timer {
|
|
41
|
-
protected _previousTime: number;
|
|
42
|
-
protected _currentTime: number;
|
|
43
|
-
protected _startTime: number;
|
|
44
|
-
protected _delta: number;
|
|
45
|
-
protected _elapsed: number;
|
|
46
|
-
protected _timescale: number;
|
|
47
|
-
protected _document: Document | null;
|
|
48
|
-
protected _pageVisibilityHandler: (() => void) | null;
|
|
49
|
-
/**
|
|
50
|
-
* Constructs a new timer.
|
|
51
|
-
*/
|
|
52
|
-
constructor();
|
|
53
|
-
/**
|
|
54
|
-
* Connect the timer to the given document.Calling this method is not mandatory to
|
|
55
|
-
* use the timer but enables the usage of the Page Visibility API to avoid large time
|
|
56
|
-
* delta values.
|
|
57
|
-
*
|
|
58
|
-
* @param {Document} document - The document.
|
|
59
|
-
*/
|
|
60
|
-
connect(document: Document): void;
|
|
61
|
-
/**
|
|
62
|
-
* Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
|
|
63
|
-
*/
|
|
64
|
-
disconnect(): void;
|
|
65
|
-
/**
|
|
66
|
-
* Returns the time delta in seconds.
|
|
67
|
-
*
|
|
68
|
-
* @return {number} The time delta in second.
|
|
69
|
-
*/
|
|
70
|
-
getDelta(): number;
|
|
71
|
-
/**
|
|
72
|
-
* Returns the elapsed time in seconds.
|
|
73
|
-
*
|
|
74
|
-
* @return {number} The elapsed time in second.
|
|
75
|
-
*/
|
|
76
|
-
getElapsed(): number;
|
|
77
|
-
/**
|
|
78
|
-
* Returns the timescale.
|
|
79
|
-
*
|
|
80
|
-
* @return {number} The timescale.
|
|
81
|
-
*/
|
|
82
|
-
getTimescale(): number;
|
|
83
|
-
/**
|
|
84
|
-
* Sets the given timescale which scale the time delta computation
|
|
85
|
-
* in `update()`.
|
|
86
|
-
*
|
|
87
|
-
* @param {number} timescale - The timescale to set.
|
|
88
|
-
* @return {Timer} A reference to this timer.
|
|
89
|
-
*/
|
|
90
|
-
setTimescale(timescale: number): Timer;
|
|
91
|
-
/**
|
|
92
|
-
* Resets the time computation for the current simulation step.
|
|
93
|
-
*
|
|
94
|
-
* @return {Timer} A reference to this timer.
|
|
95
|
-
*/
|
|
96
|
-
reset(): Timer;
|
|
97
|
-
/**
|
|
98
|
-
* Can be used to free all internal resources. Usually called when
|
|
99
|
-
* the timer instance isn't required anymore.
|
|
100
|
-
*/
|
|
101
|
-
dispose(): void;
|
|
102
|
-
/**
|
|
103
|
-
* Updates the internal state of the timer. This method should be called
|
|
104
|
-
* once per simulation step and before you perform queries against the timer
|
|
105
|
-
* (e.g. via `getDelta()`).
|
|
106
|
-
*
|
|
107
|
-
* @param {number} timestamp - The current time in milliseconds. Can be obtained
|
|
108
|
-
* from the `requestAnimationFrame` callback argument. If not provided, the current
|
|
109
|
-
* time will be determined with `performance.now`.
|
|
110
|
-
* @return {Timer} A reference to this timer.
|
|
111
|
-
*/
|
|
112
|
-
update(timestamp?: number): Timer;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
declare const AspectRatio: {
|
|
116
|
-
readonly FourByThree: number;
|
|
117
|
-
readonly SixteenByNine: number;
|
|
118
|
-
readonly TwentyOneByNine: number;
|
|
119
|
-
readonly OneByOne: number;
|
|
120
|
-
};
|
|
121
|
-
type AspectRatioValue = (typeof AspectRatio)[keyof typeof AspectRatio] | number;
|
|
122
|
-
/**
|
|
123
|
-
* AspectRatioDelegate manages sizing a canvas to fit within a container
|
|
124
|
-
* while preserving a target aspect ratio. It notifies a consumer via
|
|
125
|
-
* onResize when the final width/height are applied so renderers/cameras
|
|
126
|
-
* can update their viewports.
|
|
127
|
-
*/
|
|
128
|
-
declare class AspectRatioDelegate {
|
|
129
|
-
container: HTMLElement;
|
|
130
|
-
canvas: HTMLCanvasElement;
|
|
131
|
-
aspectRatio: number;
|
|
132
|
-
onResize?: (width: number, height: number) => void;
|
|
133
|
-
private handleResizeBound;
|
|
134
|
-
constructor(params: {
|
|
135
|
-
container: HTMLElement;
|
|
136
|
-
canvas: HTMLCanvasElement;
|
|
137
|
-
aspectRatio: AspectRatioValue;
|
|
138
|
-
onResize?: (width: number, height: number) => void;
|
|
139
|
-
});
|
|
140
|
-
/** Attach window resize listener and apply once. */
|
|
141
|
-
attach(): void;
|
|
142
|
-
/** Detach window resize listener. */
|
|
143
|
-
detach(): void;
|
|
144
|
-
/** Compute the largest size that fits container while preserving aspect. */
|
|
145
|
-
measure(): {
|
|
146
|
-
width: number;
|
|
147
|
-
height: number;
|
|
148
|
-
};
|
|
149
|
-
/** Apply measured size to canvas and notify. */
|
|
150
|
-
apply(): void;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
type RetroResolution = {
|
|
154
|
-
key: string;
|
|
155
|
-
width: number;
|
|
156
|
-
height: number;
|
|
157
|
-
notes?: string;
|
|
158
|
-
};
|
|
159
|
-
type RetroPreset = {
|
|
160
|
-
displayAspect: number;
|
|
161
|
-
resolutions: RetroResolution[];
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Retro and console display presets.
|
|
165
|
-
* displayAspect represents the intended display aspect (letterboxing target),
|
|
166
|
-
* not necessarily the raw pixel aspect of internal buffers.
|
|
167
|
-
*/
|
|
168
|
-
declare const RetroPresets: Record<string, RetroPreset>;
|
|
169
|
-
type RetroPresetKey = keyof typeof RetroPresets;
|
|
170
|
-
|
|
171
|
-
type GameConfigLike = Partial<{
|
|
172
|
-
id: string;
|
|
173
|
-
globals: Record<string, any>;
|
|
174
|
-
stages: StageInterface[];
|
|
175
|
-
debug: boolean;
|
|
176
|
-
time: number;
|
|
177
|
-
input: GameInputConfig;
|
|
178
|
-
/** numeric value or key in AspectRatio */
|
|
179
|
-
aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
|
|
180
|
-
/** console/display preset to derive aspect ratio */
|
|
181
|
-
preset: RetroPresetKey;
|
|
182
|
-
/** lock internal render buffer to this resolution (e.g., '256x240' or { width, height }) */
|
|
183
|
-
resolution: string | {
|
|
184
|
-
width: number;
|
|
185
|
-
height: number;
|
|
186
|
-
};
|
|
187
|
-
fullscreen: boolean;
|
|
188
|
-
/** CSS background value for document body */
|
|
189
|
-
bodyBackground: string;
|
|
190
|
-
/** existing container by reference */
|
|
191
|
-
container: HTMLElement;
|
|
192
|
-
/** create/find container by id */
|
|
193
|
-
containerId: string;
|
|
194
|
-
/** optional canvas if caller wants to manage it */
|
|
195
|
-
canvas: HTMLCanvasElement;
|
|
196
|
-
}>;
|
|
197
|
-
declare class GameConfig {
|
|
198
|
-
id: string;
|
|
199
|
-
globals: Record<string, any>;
|
|
200
|
-
stages: StageInterface[];
|
|
201
|
-
debug: boolean;
|
|
202
|
-
time: number;
|
|
203
|
-
input: GameInputConfig | undefined;
|
|
204
|
-
aspectRatio: number;
|
|
205
|
-
internalResolution: {
|
|
206
|
-
width: number;
|
|
207
|
-
height: number;
|
|
208
|
-
} | undefined;
|
|
209
|
-
fullscreen: boolean;
|
|
210
|
-
bodyBackground: string | undefined;
|
|
211
|
-
container: HTMLElement;
|
|
212
|
-
containerId?: string | undefined;
|
|
213
|
-
canvas?: HTMLCanvasElement | undefined;
|
|
214
|
-
constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, internalResolution: {
|
|
215
|
-
width: number;
|
|
216
|
-
height: number;
|
|
217
|
-
} | undefined, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Factory for authoring configuration objects in user code.
|
|
221
|
-
* Returns a plain object that can be passed to `game(...)`.
|
|
222
|
-
*/
|
|
223
|
-
declare function gameConfig(config: GameConfigLike): GameConfigLike;
|
|
224
|
-
|
|
225
|
-
interface GameCanvasOptions {
|
|
226
|
-
id: string;
|
|
227
|
-
container?: HTMLElement;
|
|
228
|
-
containerId?: string;
|
|
229
|
-
canvas?: HTMLCanvasElement;
|
|
230
|
-
bodyBackground?: string;
|
|
231
|
-
fullscreen?: boolean;
|
|
232
|
-
aspectRatio: AspectRatioValue | number;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* GameCanvas is a DOM delegate that owns:
|
|
236
|
-
* - container lookup/creation and styling (including fullscreen centering)
|
|
237
|
-
* - body background application
|
|
238
|
-
* - canvas mounting into container
|
|
239
|
-
* - aspect ratio sizing via AspectRatioDelegate
|
|
240
|
-
*/
|
|
241
|
-
declare class GameCanvas {
|
|
242
|
-
id: string;
|
|
243
|
-
container: HTMLElement;
|
|
244
|
-
canvas: HTMLCanvasElement;
|
|
245
|
-
bodyBackground?: string;
|
|
246
|
-
fullscreen: boolean;
|
|
247
|
-
aspectRatio: number;
|
|
248
|
-
private ratioDelegate;
|
|
249
|
-
constructor(options: GameCanvasOptions);
|
|
250
|
-
applyBodyBackground(): void;
|
|
251
|
-
mountCanvas(): void;
|
|
252
|
-
mountRenderer(rendererDom: HTMLCanvasElement, onResize: (width: number, height: number) => void): void;
|
|
253
|
-
centerIfFullscreen(): void;
|
|
254
|
-
attachAspectRatio(onResize: (width: number, height: number) => void): void;
|
|
255
|
-
destroy(): void;
|
|
256
|
-
private ensureContainer;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Game-level loading event that includes stage context.
|
|
261
|
-
*/
|
|
262
|
-
interface GameLoadingEvent {
|
|
263
|
-
type: 'start' | 'progress' | 'complete';
|
|
264
|
-
stageName?: string;
|
|
265
|
-
stageIndex?: number;
|
|
266
|
-
message: string;
|
|
267
|
-
progress: number;
|
|
268
|
-
current?: number;
|
|
269
|
-
total?: number;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
type ZylemGameOptions<TGlobals extends BaseGlobals> = ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals> & Partial<GameConfig>;
|
|
273
|
-
declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
274
|
-
id: string;
|
|
275
|
-
initialGlobals: TGlobals;
|
|
276
|
-
customSetup: ((params: SetupContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
277
|
-
customUpdate: ((params: UpdateContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
278
|
-
customDestroy: ((params: DestroyContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
279
|
-
stages: Stage[];
|
|
280
|
-
stageMap: Map<string, Stage>;
|
|
281
|
-
currentStageId: string;
|
|
282
|
-
previousTimeStamp: number;
|
|
283
|
-
totalTime: number;
|
|
284
|
-
timer: Timer;
|
|
285
|
-
inputManager: InputManager;
|
|
286
|
-
wrapperRef: Game<TGlobals>;
|
|
287
|
-
globalInputConfig: GameInputConfig | undefined;
|
|
288
|
-
defaultCamera: ZylemCamera | null;
|
|
289
|
-
/** Shared renderer manager for all stages */
|
|
290
|
-
rendererManager: RendererManager | null;
|
|
291
|
-
container: HTMLElement | null;
|
|
292
|
-
canvas: HTMLCanvasElement | null;
|
|
293
|
-
aspectRatioDelegate: AspectRatioDelegate | null;
|
|
294
|
-
resolvedConfig: GameConfig | null;
|
|
295
|
-
gameCanvas: GameCanvas | null;
|
|
296
|
-
private animationFrameId;
|
|
297
|
-
private isDisposed;
|
|
298
|
-
private debugDelegate;
|
|
299
|
-
private loadingDelegate;
|
|
300
|
-
private rendererObserver;
|
|
301
|
-
private eventBusUnsubscribes;
|
|
302
|
-
static FRAME_LIMIT: number;
|
|
303
|
-
static FRAME_DURATION: number;
|
|
304
|
-
static MAX_DELTA_SECONDS: number;
|
|
305
|
-
constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>);
|
|
306
|
-
loadGameCanvas(config: GameConfig): void;
|
|
307
|
-
loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
|
|
308
|
-
loadStage(stage: Stage, stageIndex?: number): Promise<void>;
|
|
309
|
-
/**
|
|
310
|
-
* Merges game-level global input config with the stage's per-stage overrides
|
|
311
|
-
* and reconfigures the InputManager.
|
|
312
|
-
*/
|
|
313
|
-
applyInputConfig(stage: Stage): void;
|
|
314
|
-
/**
|
|
315
|
-
* Update the game-level global input config and re-apply to the current stage.
|
|
316
|
-
*/
|
|
317
|
-
setGlobalInputConfig(config: GameInputConfig): void;
|
|
318
|
-
unloadCurrentStage(): void;
|
|
319
|
-
setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
|
|
320
|
-
params(): UpdateContext<ZylemGame<TGlobals>, TGlobals>;
|
|
321
|
-
start(): void;
|
|
322
|
-
/**
|
|
323
|
-
* Execute a single frame update.
|
|
324
|
-
* This method can be called directly for testing or from the game loop.
|
|
325
|
-
* @param deltaTime Optional delta time in seconds. If not provided, uses timer delta.
|
|
326
|
-
*/
|
|
327
|
-
step(deltaTime?: number): void;
|
|
328
|
-
loop(timestamp: number): void;
|
|
329
|
-
dispose(): void;
|
|
330
|
-
outOfLoop(): void;
|
|
331
|
-
getStage(id: string): Stage | undefined;
|
|
332
|
-
currentStage(): Stage | undefined;
|
|
333
|
-
/**
|
|
334
|
-
* Subscribe to loading events from the game.
|
|
335
|
-
* Events include stage context (stageName, stageIndex).
|
|
336
|
-
* @param callback Invoked for each loading event
|
|
337
|
-
* @returns Unsubscribe function
|
|
338
|
-
*/
|
|
339
|
-
onLoading(callback: (event: GameLoadingEvent) => void): () => void;
|
|
340
|
-
/**
|
|
341
|
-
* Build the stage config payload for the current stage.
|
|
342
|
-
*/
|
|
343
|
-
private buildStageConfigPayload;
|
|
344
|
-
/**
|
|
345
|
-
* Build the entities payload for the current stage.
|
|
346
|
-
*/
|
|
347
|
-
private buildEntitiesPayload;
|
|
348
|
-
/**
|
|
349
|
-
* Emit a state:dispatch event to the zylemEventBus.
|
|
350
|
-
* Called after stage load and on global state changes.
|
|
351
|
-
*/
|
|
352
|
-
private emitStateDispatch;
|
|
353
|
-
/**
|
|
354
|
-
* Inspect a stage's options to determine the renderer type.
|
|
355
|
-
* Looks for CameraWrapper instances in the stage options and uses
|
|
356
|
-
* the first camera's rendererType. Falls back to 'webgl'.
|
|
357
|
-
*/
|
|
358
|
-
private resolveRendererType;
|
|
359
|
-
/**
|
|
360
|
-
* Subscribe to the game event bus for stage loading and state events.
|
|
361
|
-
* Emits events to zylemEventBus for cross-package communication.
|
|
362
|
-
*/
|
|
363
|
-
private subscribeToEventBus;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
type GameOptions<TGlobals extends BaseGlobals> = Array<ZylemGameConfig<Stage, any, TGlobals> | GameConfigLike | Stage | GameEntityLifeCycle | BaseNode>;
|
|
367
|
-
|
|
368
|
-
declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
369
|
-
private wrappedGame;
|
|
370
|
-
options: GameOptions<TGlobals>;
|
|
371
|
-
private setupCallbacks;
|
|
372
|
-
private updateCallbacks;
|
|
373
|
-
private destroyCallbacks;
|
|
374
|
-
private pendingLoadingCallbacks;
|
|
375
|
-
private globalChangeCallbacks;
|
|
376
|
-
private globalChangesCallbacks;
|
|
377
|
-
private activeGlobalSubscriptions;
|
|
378
|
-
private eventDelegate;
|
|
379
|
-
/** Pending global input config set before the game starts. */
|
|
380
|
-
private pendingInputConfig;
|
|
381
|
-
refErrorMessage: string;
|
|
382
|
-
constructor(options: GameOptions<TGlobals>);
|
|
383
|
-
onSetup(...callbacks: Array<SetupFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
384
|
-
onUpdate(...callbacks: Array<UpdateFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
385
|
-
onDestroy(...callbacks: Array<DestroyFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
386
|
-
/**
|
|
387
|
-
* Set composable input configuration as global defaults for the entire game.
|
|
388
|
-
* Multiple configs are deep-merged (later configs win on key conflicts).
|
|
389
|
-
* Per-stage overrides (via stage.setInputConfiguration) are merged on top.
|
|
390
|
-
* Can be called before or after start().
|
|
391
|
-
* @example game.setInputConfiguration(useArrowsForAxes('p1'), useWASDForDirections('p2'));
|
|
392
|
-
*/
|
|
393
|
-
setInputConfiguration(...configs: GameInputConfig[]): this;
|
|
394
|
-
start(): Promise<this>;
|
|
395
|
-
private load;
|
|
396
|
-
private setOverrides;
|
|
397
|
-
/**
|
|
398
|
-
* Subscribe to changes on a global value. Subscriptions are registered
|
|
399
|
-
* when the game starts and cleaned up when disposed.
|
|
400
|
-
* The callback receives the value and the current stage.
|
|
401
|
-
* @example game.onGlobalChange('score', (val, stage) => console.log(val));
|
|
402
|
-
*/
|
|
403
|
-
onGlobalChange<T = unknown>(path: string, callback: (value: T, stage: Stage | null) => void): this;
|
|
404
|
-
/**
|
|
405
|
-
* Subscribe to changes on multiple global paths. Subscriptions are registered
|
|
406
|
-
* when the game starts and cleaned up when disposed.
|
|
407
|
-
* The callback receives the values and the current stage.
|
|
408
|
-
* @example game.onGlobalChanges(['score', 'lives'], ([score, lives], stage) => console.log(score, lives));
|
|
409
|
-
*/
|
|
410
|
-
onGlobalChanges<T extends unknown[] = unknown[]>(paths: string[], callback: (values: T, stage: Stage | null) => void): this;
|
|
411
|
-
/**
|
|
412
|
-
* Register all stored global change callbacks.
|
|
413
|
-
* Called internally during start().
|
|
414
|
-
*/
|
|
415
|
-
private registerGlobalSubscriptions;
|
|
416
|
-
/**
|
|
417
|
-
* Get the current stage wrapper.
|
|
418
|
-
*/
|
|
419
|
-
getCurrentStage(): Stage | null;
|
|
420
|
-
pause(): Promise<void>;
|
|
421
|
-
resume(): Promise<void>;
|
|
422
|
-
/**
|
|
423
|
-
* Execute a single frame update.
|
|
424
|
-
* Useful for testing or manual frame stepping.
|
|
425
|
-
* @param deltaTime Optional delta time in seconds (defaults to 1/60)
|
|
426
|
-
*/
|
|
427
|
-
step(deltaTime?: number): void;
|
|
428
|
-
reset(): Promise<void>;
|
|
429
|
-
previousStage(): void;
|
|
430
|
-
loadStageFromId(stageId: string): Promise<void>;
|
|
431
|
-
nextStage(): void;
|
|
432
|
-
goToStage(): Promise<void>;
|
|
433
|
-
end(): Promise<void>;
|
|
434
|
-
dispose(): void;
|
|
435
|
-
/**
|
|
436
|
-
* Dispatch an event from the game.
|
|
437
|
-
* Events are emitted both locally and to the global event bus.
|
|
438
|
-
*/
|
|
439
|
-
dispatch<K extends keyof GameEvents>(event: K, payload: GameEvents[K]): void;
|
|
440
|
-
/**
|
|
441
|
-
* Listen for events on this game instance.
|
|
442
|
-
* @returns Unsubscribe function
|
|
443
|
-
*/
|
|
444
|
-
listen<K extends keyof GameEvents>(event: K, handler: (payload: GameEvents[K]) => void): () => void;
|
|
445
|
-
/**
|
|
446
|
-
* Subscribe to loading events from the game.
|
|
447
|
-
* Events include stage context (stageName, stageIndex).
|
|
448
|
-
* @param callback Invoked for each loading event
|
|
449
|
-
* @returns Unsubscribe function
|
|
450
|
-
*/
|
|
451
|
-
onLoading(callback: (event: GameLoadingEvent) => void): () => void;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* create a new game
|
|
455
|
-
* @param options GameOptions - Array of IGameOptions, Stage, GameEntity, or BaseNode objects
|
|
456
|
-
* @param options.id Game name string (when using IGameOptions)
|
|
457
|
-
* @param options.globals Game globals object (when using IGameOptions)
|
|
458
|
-
* @param options.stages Array of stage objects (when using IGameOptions)
|
|
459
|
-
* @returns Game
|
|
460
|
-
*/
|
|
461
|
-
declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* A Vessel is an empty container entity that holds child entities.
|
|
465
|
-
* It has no geometry, physics, or rendering of its own, but propagates
|
|
466
|
-
* lifecycle events to its children and provides a logical grouping mechanism.
|
|
467
|
-
*
|
|
468
|
-
* Child entities added to a Vessel will be individually spawned into the
|
|
469
|
-
* stage's physics world and render scene when the Vessel is spawned.
|
|
470
|
-
*/
|
|
471
|
-
declare class Vessel extends BaseNode<{}, Vessel> {
|
|
472
|
-
static type: symbol;
|
|
473
|
-
protected _setup(_params: SetupContext<this>): void;
|
|
474
|
-
protected _loaded(_params: LoadedContext<this>): Promise<void>;
|
|
475
|
-
protected _update(_params: UpdateContext<this>): void;
|
|
476
|
-
protected _destroy(_params: DestroyContext<this>): void;
|
|
477
|
-
protected _cleanup(_params: CleanupContext<this>): void;
|
|
478
|
-
create(): this;
|
|
479
|
-
/**
|
|
480
|
-
* Add one or more child entities to this vessel.
|
|
481
|
-
* Overrides parent to support multiple arguments.
|
|
482
|
-
* @returns this for chaining
|
|
483
|
-
*/
|
|
484
|
-
add(...nodes: NodeInterface[]): this;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Create a vessel containing the given child entities.
|
|
488
|
-
* @param args Child BaseNode entities to add
|
|
489
|
-
* @returns A new Vessel with the children added
|
|
490
|
-
*/
|
|
491
|
-
declare function vessel(...args: Array<BaseNode>): Vessel;
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* @deprecated This type is deprecated.
|
|
495
|
-
*/
|
|
496
|
-
type Vect3 = Vector3 | Vector3$1;
|
|
497
|
-
|
|
498
|
-
export { Game as G, type Vect3 as V, createGame as c, gameConfig as g, vessel as v };
|