@zylem/game-lib 0.8.8 → 0.9.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 +7 -1
- package/dist/actions.d.ts +2 -2
- package/dist/actions.js +1 -1
- package/dist/api/game-lib.api.json +35786 -18973
- package/dist/api/game-lib.api.md +1209 -13
- package/dist/api/game-lib.d.ts +1609 -7
- package/dist/api/game-lib.typedoc.json +220861 -97409
- package/dist/audio.d.ts +193 -1
- package/dist/audio.js +1 -1
- package/dist/behavior.js +1 -1
- package/dist/bridge.d.ts +46 -6
- package/dist/bridge.js +1 -1
- package/dist/catalog.d.ts +91 -3
- package/dist/catalog.js +1 -1
- package/dist/chunk-2HSR5XDQ.js +1 -0
- package/dist/chunk-2MHB4X6B.js +24 -0
- package/dist/chunk-2PFNNGTV.js +1 -0
- package/dist/chunk-2XMG3NJS.js +1 -0
- package/dist/chunk-4CZZZCFB.js +9 -0
- package/dist/{chunk-7NYP4YAG.js → chunk-6FGXC4T6.js} +1 -1
- package/dist/chunk-6XFXPIVB.js +1 -0
- package/dist/{chunk-CBUQBP2U.js → chunk-BQRMYLYD.js} +1 -1
- package/dist/chunk-FZNEWOC5.js +1 -0
- package/dist/chunk-GPCSX3M6.js +1 -0
- package/dist/chunk-HISTSRAL.js +1 -0
- package/dist/chunk-K3NNXZIJ.js +1 -0
- package/dist/chunk-KP6DLLJO.js +1 -0
- package/dist/{chunk-JNFFTNMH.js → chunk-KSEP7AUF.js} +1 -1
- package/dist/{chunk-YOVE25NW.js → chunk-LI43BZQN.js} +1 -1
- package/dist/chunk-LSFWI46T.js +1 -0
- package/dist/chunk-NVVLLWIM.js +1 -0
- package/dist/chunk-QGIYILYI.js +1 -0
- package/dist/chunk-STVEILJJ.js +1 -0
- package/dist/chunk-UUOPT2N4.js +1 -0
- package/dist/chunk-VMXSE3EC.js +0 -0
- package/dist/chunk-VSFULLND.js +1 -0
- package/dist/chunk-VUJXR5K5.js +1 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/chunk-YNX3Q3CL.js +1 -0
- package/dist/chunk-YQS7CGXE.js +1 -0
- package/dist/chunk-ZZO4CKRU.js +1 -0
- package/dist/cinematics.d.ts +279 -0
- package/dist/cinematics.js +1 -0
- package/dist/core.d.ts +13 -10
- package/dist/core.js +1 -1
- package/dist/cutscene-definition-C479fkei.d.ts +509 -0
- package/dist/{debug-state-CpnNRUFh.d.ts → debug-state-Cg3f5FB6.d.ts} +1 -1
- package/dist/debug.d.ts +3 -2
- package/dist/debug.js +1 -1
- package/dist/{entity-XZNGBeca.d.ts → entity-XqvuWgPm.d.ts} +54 -0
- package/dist/{entity-type-map-CkkFMSrL.d.ts → entity-type-map-CrsrKT8c.d.ts} +13 -4
- package/dist/entity.d.ts +4 -3
- package/dist/entity.js +1 -1
- package/dist/events.js +1 -1
- package/dist/game-9PjI5z2p.d.ts +652 -0
- package/dist/game-default-WBKQCEDJ.js +1 -0
- package/dist/globals.js +1 -1
- package/dist/graphics.d.ts +1 -1
- package/dist/graphics.js +1 -1
- package/dist/input-ui.js +1 -1
- package/dist/input.js +1 -1
- package/dist/public.d.ts +14 -8
- package/dist/public.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/schema/cutscene.schema.json +782 -0
- package/dist/schema/entity.schema.json +24 -24
- package/dist/schema/game-config.schema.json +10 -10
- package/dist/schema/song.schema.json +430 -0
- package/dist/schema/stage.schema.json +29 -29
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +1 -1
- package/dist/selection-bounds-BKmSo9aG.d.ts +50 -0
- package/dist/song-definition-rEKksP0B.d.ts +263 -0
- package/dist/song-player-7QPLFLAS.js +1 -0
- package/dist/{game-BPOr7zTB.d.ts → stage-BuGkjZnr.d.ts} +90 -644
- package/dist/web-components.d.ts +7 -5
- package/dist/web-components.js +1 -1
- package/dist/{zylem-camera-DZTpPOiD.d.ts → zylem-camera-Baf5vH8Z.d.ts} +8 -0
- package/package.json +25 -16
- package/dist/chunk-34MYRTRP.js +0 -9
- package/dist/chunk-AE3CTVHY.js +0 -1
- package/dist/chunk-BMRFDDMR.js +0 -1
- package/dist/chunk-EVMLNMGU.js +0 -1
- package/dist/chunk-F5LROYZL.js +0 -24
- package/dist/chunk-GHJQ2HKI.js +0 -1
- package/dist/chunk-HNCTOJP7.js +0 -1
- package/dist/chunk-IBJLPJLE.js +0 -1
- package/dist/chunk-MXO4VGDB.js +0 -1
- package/dist/chunk-QDQ4QMAI.js +0 -1
- package/dist/chunk-SAQA4SXW.js +0 -1
- package/dist/chunk-XK63E4SX.js +0 -1
- package/dist/chunk-ZRT3ZQVH.js +0 -1
- package/dist/chunk-ZTYNZ2N2.js +0 -1
- package/dist/game-default-7HCJJF5S.js +0 -1
- /package/dist/{chunk-MSCVL5OK.js → chunk-ELQN62PQ.js} +0 -0
|
@@ -1,134 +1,17 @@
|
|
|
1
|
-
import { e as InputPlayerNumber, f as InputProvider, I as Inputs, h as SetupFunction, g as UpdateFunction, j as DestroyFunction, a as SetupContext, U as UpdateContext, D as DestroyContext, L as LoadingEvent, m as IGame, S as StageNavigationOptions } from './base-node-life-cycle-BK9xebT9.js';
|
|
2
|
-
import { G as GameInputConfig, B as BaseGlobals, Z as ZylemGameConfig } from './game-interfaces-vF5sRi1n.js';
|
|
3
1
|
import { B as BaseNode } from './base-node-idopiSw5.js';
|
|
2
|
+
import { h as SetupFunction, g as UpdateFunction, j as DestroyFunction, a as SetupContext, U as UpdateContext, D as DestroyContext, L as LoadingEvent } from './base-node-life-cycle-BK9xebT9.js';
|
|
4
3
|
import { Scene, Color, Object3D, Vector3, BufferGeometry, Material, Group, Texture } from 'three';
|
|
5
|
-
import { al as ZylemWorld, aj as EntityTypeMap } from './entity-type-map-
|
|
4
|
+
import { al as ZylemWorld, aj as EntityTypeMap } from './entity-type-map-CrsrKT8c.js';
|
|
6
5
|
import { E as Entity, L as LifecycleFunction, S as StageEntity } from './entity-BIf_a4dl.js';
|
|
7
|
-
import { G as GameEntity, a as GameEntityOptions
|
|
8
|
-
import { k as ZylemCamera, R as RendererManager, e as CameraPerspective, d as CameraContext, C as CameraPose, P as PerspectiveType, f as CameraBehavior, g as CameraAction, h as CameraPipelineState, V as Viewport, Z as ZylemPostEffect } from './zylem-camera-
|
|
6
|
+
import { G as GameEntity, a as GameEntityOptions } from './entity-XqvuWgPm.js';
|
|
7
|
+
import { k as ZylemCamera, R as RendererManager, e as CameraPerspective, d as CameraContext, C as CameraPose, P as PerspectiveType, f as CameraBehavior, g as CameraAction, h as CameraPipelineState, V as Viewport, Z as ZylemPostEffect } from './zylem-camera-Baf5vH8Z.js';
|
|
9
8
|
import { d as ZylemShader } from './material-CxxAyJYp.js';
|
|
10
9
|
import { a as SimulationBody } from './simulation-body-zQw-emOr.js';
|
|
11
10
|
import { e as Vec3Input, b as Vec2Input, d as Vec3Components } from './vector-D3eDzvcA.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { S as StageTransitionConfig } from './stage-transition-CmGpV4tc.js';
|
|
17
|
-
|
|
18
|
-
declare class InputManager {
|
|
19
|
-
private inputMap;
|
|
20
|
-
private currentInputs;
|
|
21
|
-
private previousInputs;
|
|
22
|
-
private readonly targetElement?;
|
|
23
|
-
private readonly mouseTargetElement?;
|
|
24
|
-
constructor(config?: GameInputConfig, options?: {
|
|
25
|
-
targetElement?: HTMLElement;
|
|
26
|
-
mouseTargetElement?: HTMLElement;
|
|
27
|
-
});
|
|
28
|
-
/**
|
|
29
|
-
* Reconfigure keyboard and mouse providers at runtime without affecting gamepad providers.
|
|
30
|
-
* Disposes existing keyboard/mouse providers and creates new ones from the given config.
|
|
31
|
-
*/
|
|
32
|
-
configure(config: GameInputConfig): void;
|
|
33
|
-
addInputProvider(playerNumber: InputPlayerNumber, provider: InputProvider): void;
|
|
34
|
-
dispose(): void;
|
|
35
|
-
getInputs(delta: number): Inputs;
|
|
36
|
-
private buildPlayerEntries;
|
|
37
|
-
private addConfigurableProviders;
|
|
38
|
-
private createConfigurableProviders;
|
|
39
|
-
private mergeInputs;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* This class is an alternative to {@link Clock} with a different API design and behavior.
|
|
44
|
-
* The goal is to avoid the conceptual flaws that became apparent in `Clock` over time.
|
|
45
|
-
*
|
|
46
|
-
* - `Timer` has an `update()` method that updates its internal state. That makes it possible to
|
|
47
|
-
* call `getDelta()` and `getElapsed()` multiple times per simulation step without getting different values.
|
|
48
|
-
* - The class can make use of the Page Visibility API to avoid large time delta values when the app
|
|
49
|
-
* is inactive (e.g. tab switched or browser hidden).
|
|
50
|
-
*
|
|
51
|
-
* ```js
|
|
52
|
-
* const timer = new Timer();
|
|
53
|
-
* timer.connect( document ); // use Page Visibility API
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @three_import import { Timer } from 'three/addons/misc/Timer.js';
|
|
57
|
-
*/
|
|
58
|
-
declare class Timer {
|
|
59
|
-
protected _previousTime: number;
|
|
60
|
-
protected _currentTime: number;
|
|
61
|
-
protected _startTime: number;
|
|
62
|
-
protected _delta: number;
|
|
63
|
-
protected _elapsed: number;
|
|
64
|
-
protected _timescale: number;
|
|
65
|
-
protected _document: Document | null;
|
|
66
|
-
protected _pageVisibilityHandler: (() => void) | null;
|
|
67
|
-
/**
|
|
68
|
-
* Constructs a new timer.
|
|
69
|
-
*/
|
|
70
|
-
constructor();
|
|
71
|
-
/**
|
|
72
|
-
* Connect the timer to the given document.Calling this method is not mandatory to
|
|
73
|
-
* use the timer but enables the usage of the Page Visibility API to avoid large time
|
|
74
|
-
* delta values.
|
|
75
|
-
*
|
|
76
|
-
* @param {Document} document - The document.
|
|
77
|
-
*/
|
|
78
|
-
connect(document: Document): void;
|
|
79
|
-
/**
|
|
80
|
-
* Disconnects the timer from the DOM and also disables the usage of the Page Visibility API.
|
|
81
|
-
*/
|
|
82
|
-
disconnect(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Returns the time delta in seconds.
|
|
85
|
-
*
|
|
86
|
-
* @return {number} The time delta in second.
|
|
87
|
-
*/
|
|
88
|
-
getDelta(): number;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the elapsed time in seconds.
|
|
91
|
-
*
|
|
92
|
-
* @return {number} The elapsed time in second.
|
|
93
|
-
*/
|
|
94
|
-
getElapsed(): number;
|
|
95
|
-
/**
|
|
96
|
-
* Returns the timescale.
|
|
97
|
-
*
|
|
98
|
-
* @return {number} The timescale.
|
|
99
|
-
*/
|
|
100
|
-
getTimescale(): number;
|
|
101
|
-
/**
|
|
102
|
-
* Sets the given timescale which scale the time delta computation
|
|
103
|
-
* in `update()`.
|
|
104
|
-
*
|
|
105
|
-
* @param {number} timescale - The timescale to set.
|
|
106
|
-
* @return {Timer} A reference to this timer.
|
|
107
|
-
*/
|
|
108
|
-
setTimescale(timescale: number): Timer;
|
|
109
|
-
/**
|
|
110
|
-
* Resets the time computation for the current simulation step.
|
|
111
|
-
*
|
|
112
|
-
* @return {Timer} A reference to this timer.
|
|
113
|
-
*/
|
|
114
|
-
reset(): Timer;
|
|
115
|
-
/**
|
|
116
|
-
* Can be used to free all internal resources. Usually called when
|
|
117
|
-
* the timer instance isn't required anymore.
|
|
118
|
-
*/
|
|
119
|
-
dispose(): void;
|
|
120
|
-
/**
|
|
121
|
-
* Updates the internal state of the timer. This method should be called
|
|
122
|
-
* once per simulation step and before you perform queries against the timer
|
|
123
|
-
* (e.g. via `getDelta()`).
|
|
124
|
-
*
|
|
125
|
-
* @param {number} timestamp - The current time in milliseconds. Can be obtained
|
|
126
|
-
* from the `requestAnimationFrame` callback argument. If not provided, the current
|
|
127
|
-
* time will be determined with `performance.now`.
|
|
128
|
-
* @return {Timer} A reference to this timer.
|
|
129
|
-
*/
|
|
130
|
-
update(timestamp?: number): Timer;
|
|
131
|
-
}
|
|
11
|
+
import { StageEvents } from './events.js';
|
|
12
|
+
import { G as GameInputConfig } from './game-interfaces-vF5sRi1n.js';
|
|
13
|
+
import { SwatchApplyResult, SceneOperationEntry, EntityApplySwatchPayload, SceneOperationPayload } from '@zylem/bridge';
|
|
14
|
+
import { BehaviorSystem, BehaviorEntityLink, BehaviorRuntime, BehaviorSystemFactory, BehaviorRef } from '@zylem/behaviors/core';
|
|
132
15
|
|
|
133
16
|
/**
|
|
134
17
|
* CameraManager orchestrates multiple cameras per stage.
|
|
@@ -846,6 +729,28 @@ declare class CameraWrapper {
|
|
|
846
729
|
*/
|
|
847
730
|
declare function createCamera(options: CameraOptions): CameraWrapper;
|
|
848
731
|
|
|
732
|
+
/**
|
|
733
|
+
* Applies swatches (configured shaders / behaviors) to live entities and
|
|
734
|
+
* inverts those applications for undo.
|
|
735
|
+
*
|
|
736
|
+
* One `entity:apply-swatch` message is a batch: every swatch is applied to
|
|
737
|
+
* every uuid, in order, under a single operation id. Each pair reports its own
|
|
738
|
+
* result so a multi-select apply can partially succeed (a light in the
|
|
739
|
+
* selection has no material) while the rest still land.
|
|
740
|
+
*
|
|
741
|
+
* Undo follows the stage's "editor holds the history, game holds the
|
|
742
|
+
* instances" rule. The original material and any displaced behavior refs are
|
|
743
|
+
* kept here per operation, so undo puts back the exact objects rather than a
|
|
744
|
+
* reconstruction — the pre-swatch material (texture, tint, standard shader) is
|
|
745
|
+
* usually not describable as a swatch at all.
|
|
746
|
+
*/
|
|
747
|
+
|
|
748
|
+
interface SwatchApplyOutcome {
|
|
749
|
+
results: SwatchApplyResult[];
|
|
750
|
+
/** One entry per successful pair, ready for a `scene:operation`. */
|
|
751
|
+
entries: SceneOperationEntry[];
|
|
752
|
+
}
|
|
753
|
+
|
|
849
754
|
/**
|
|
850
755
|
* Owns the stage's in-world debug/editor interaction layer.
|
|
851
756
|
*
|
|
@@ -893,6 +798,11 @@ declare class StageDebugDelegate {
|
|
|
893
798
|
private lastDebugEnabled;
|
|
894
799
|
private warnedMissingAddFactory;
|
|
895
800
|
private transformTool;
|
|
801
|
+
private swatchApplier;
|
|
802
|
+
private marquee;
|
|
803
|
+
private selectionHighlight;
|
|
804
|
+
private selectionBoundsPool;
|
|
805
|
+
private hoverBounds;
|
|
896
806
|
private grid;
|
|
897
807
|
private lastTool;
|
|
898
808
|
/** Element the current gizmo drag captured, so pointerup is never missed. */
|
|
@@ -906,6 +816,13 @@ declare class StageDebugDelegate {
|
|
|
906
816
|
/** Camera used for debug orbit / raycasts (active primary, usually `__debug__`). */
|
|
907
817
|
private getDebugViewCamera;
|
|
908
818
|
private resolveEntity;
|
|
819
|
+
/**
|
|
820
|
+
* Every entity a marquee may catch. `childrenMap` is the live stage;
|
|
821
|
+
* `debugMap` is consulted too so anything only registered there (the same
|
|
822
|
+
* set the single pick resolves through) is not skipped. Whether an entity
|
|
823
|
+
* has a selectable volume is the marquee's call, via its selection bounds.
|
|
824
|
+
*/
|
|
825
|
+
private forEachSelectableEntity;
|
|
909
826
|
/** Copy all stage children into debugMap so raycast/select tools work after enabling debug mid-session. */
|
|
910
827
|
private populateDebugMap;
|
|
911
828
|
private ensureCameraDebugDelegate;
|
|
@@ -938,6 +855,12 @@ declare class StageDebugDelegate {
|
|
|
938
855
|
* available when a tool is armed with debug off.
|
|
939
856
|
*/
|
|
940
857
|
private ensureToolVisuals;
|
|
858
|
+
/**
|
|
859
|
+
* Outline every selected entity. Re-fitted each frame so the boxes follow
|
|
860
|
+
* entities that move, and so a uuid whose entity has gone (deleted, or
|
|
861
|
+
* undone) simply drops out instead of leaving a stale box behind.
|
|
862
|
+
*/
|
|
863
|
+
private updateSelectionHighlight;
|
|
941
864
|
/**
|
|
942
865
|
* Hide the overlays whose tool has just gone away.
|
|
943
866
|
*
|
|
@@ -951,13 +874,27 @@ declare class StageDebugDelegate {
|
|
|
951
874
|
update(): void;
|
|
952
875
|
/**
|
|
953
876
|
* Raycast at NDC coordinates (from a host that cannot send DOM pointer
|
|
954
|
-
* events, e.g. an overlay sitting on a preview iframe
|
|
955
|
-
*
|
|
877
|
+
* events, e.g. an overlay sitting on a preview iframe, or the bridge's
|
|
878
|
+
* `entity:pick`).
|
|
879
|
+
*
|
|
880
|
+
* Hover follows the pick only while pick mode is armed (a drag in flight),
|
|
881
|
+
* so a one-shot pick from an inspector does not disturb the user's hover.
|
|
882
|
+
* While armed, the next `update()` paints the highlight.
|
|
956
883
|
*/
|
|
957
|
-
pickAtNdc(ndcX: number, ndcY: number
|
|
884
|
+
pickAtNdc(ndcX: number, ndcY: number, options?: {
|
|
885
|
+
updateHover?: boolean;
|
|
886
|
+
}): {
|
|
958
887
|
uuid: string;
|
|
959
888
|
name: string;
|
|
960
889
|
} | null;
|
|
890
|
+
/**
|
|
891
|
+
* Apply swatches to live entities (`entity:apply-swatch`). Every uuid ×
|
|
892
|
+
* swatch pair is attempted and reported; successful pairs are recorded so
|
|
893
|
+
* the operation can be undone exactly via {@link applySceneOperation}.
|
|
894
|
+
*/
|
|
895
|
+
applySwatches(payload: EntityApplySwatchPayload & {
|
|
896
|
+
opId: string;
|
|
897
|
+
}): SwatchApplyOutcome;
|
|
961
898
|
/** Collider wireframes, straight from the wasm simulation. */
|
|
962
899
|
private updateColliderWireframes;
|
|
963
900
|
/**
|
|
@@ -1355,11 +1292,35 @@ declare class StageEntityDelegate {
|
|
|
1355
1292
|
*/
|
|
1356
1293
|
destroyAll(): void;
|
|
1357
1294
|
private registerBehaviorLinks;
|
|
1295
|
+
/**
|
|
1296
|
+
* Index one ref, lazily create its system, and attach. Shared by spawn-time
|
|
1297
|
+
* registration and late per-ref attaches.
|
|
1298
|
+
*/
|
|
1299
|
+
private linkBehaviorRef;
|
|
1300
|
+
private unlinkBehaviorLink;
|
|
1358
1301
|
/**
|
|
1359
1302
|
* Re-index an entity's behavior refs after a late `entity.use(...)`.
|
|
1360
1303
|
* Spawn-time registration only sees refs that existed at attach.
|
|
1304
|
+
*
|
|
1305
|
+
* Detaches and re-attaches every behavior on the entity, which resets their
|
|
1306
|
+
* per-link state. Prefer {@link attachBehaviorLink} /
|
|
1307
|
+
* {@link detachBehaviorLink} when only one ref changed.
|
|
1361
1308
|
*/
|
|
1362
1309
|
syncBehaviorLinks(entity: any): void;
|
|
1310
|
+
/**
|
|
1311
|
+
* Attach a single ref that was added to a live entity (`entity.use(...)`
|
|
1312
|
+
* after spawn) without disturbing the entity's other behaviors.
|
|
1313
|
+
*
|
|
1314
|
+
* @returns `false` when the stage is not loaded or the ref is already linked.
|
|
1315
|
+
*/
|
|
1316
|
+
attachBehaviorLink(entity: any, ref: BehaviorRef): boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* Detach a single ref's system link from a live entity, leaving its other
|
|
1319
|
+
* behaviors attached.
|
|
1320
|
+
*
|
|
1321
|
+
* @returns `false` when no link for that ref exists.
|
|
1322
|
+
*/
|
|
1323
|
+
detachBehaviorLink(entity: any, ref: BehaviorRef): boolean;
|
|
1363
1324
|
private unregisterBehaviorLinks;
|
|
1364
1325
|
}
|
|
1365
1326
|
|
|
@@ -1603,519 +1564,4 @@ declare class Stage {
|
|
|
1603
1564
|
*/
|
|
1604
1565
|
declare function createStage(...options: StageOptions): Stage;
|
|
1605
1566
|
|
|
1606
|
-
|
|
1607
|
-
* Stage state interface - minimal to prevent circular dependencies
|
|
1608
|
-
*/
|
|
1609
|
-
interface StageStateInterface {
|
|
1610
|
-
backgroundColor: Color;
|
|
1611
|
-
backgroundImage: string | null;
|
|
1612
|
-
inputs: {
|
|
1613
|
-
p1: string[];
|
|
1614
|
-
p2: string[];
|
|
1615
|
-
};
|
|
1616
|
-
variables: Record<string, any>;
|
|
1617
|
-
gravity: Vector3 | Vec3Components;
|
|
1618
|
-
entities: Partial<BaseEntityInterface>[];
|
|
1619
|
-
stageRef?: any;
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* Minimal stage interface to break circular dependencies
|
|
1623
|
-
*/
|
|
1624
|
-
interface StageInterface {
|
|
1625
|
-
uuid: string;
|
|
1626
|
-
children: any[];
|
|
1627
|
-
state: StageStateInterface;
|
|
1628
|
-
}
|
|
1629
|
-
|
|
1630
|
-
declare const AspectRatio: {
|
|
1631
|
-
readonly FourByThree: number;
|
|
1632
|
-
readonly SixteenByNine: number;
|
|
1633
|
-
readonly NineBySixteen: number;
|
|
1634
|
-
readonly TwentyOneByNine: number;
|
|
1635
|
-
readonly OneByOne: number;
|
|
1636
|
-
};
|
|
1637
|
-
type AspectRatioValue = (typeof AspectRatio)[keyof typeof AspectRatio] | number;
|
|
1638
|
-
/**
|
|
1639
|
-
* AspectRatioDelegate manages sizing a canvas to fit within a container
|
|
1640
|
-
* while preserving a target aspect ratio. It notifies a consumer via
|
|
1641
|
-
* onResize when the final width/height are applied so renderers/cameras
|
|
1642
|
-
* can update their viewports.
|
|
1643
|
-
*/
|
|
1644
|
-
declare class AspectRatioDelegate {
|
|
1645
|
-
container: HTMLElement;
|
|
1646
|
-
canvas: HTMLCanvasElement;
|
|
1647
|
-
aspectRatio: number;
|
|
1648
|
-
onResize?: (width: number, height: number) => void;
|
|
1649
|
-
private handleResizeBound;
|
|
1650
|
-
private resizeObserver;
|
|
1651
|
-
constructor(params: {
|
|
1652
|
-
container: HTMLElement;
|
|
1653
|
-
canvas: HTMLCanvasElement;
|
|
1654
|
-
aspectRatio: AspectRatioValue;
|
|
1655
|
-
onResize?: (width: number, height: number) => void;
|
|
1656
|
-
});
|
|
1657
|
-
/** Attach window resize listener and apply once. */
|
|
1658
|
-
attach(): void;
|
|
1659
|
-
/** Detach window resize listener. */
|
|
1660
|
-
detach(): void;
|
|
1661
|
-
/** Compute the largest size that fits container while preserving aspect. */
|
|
1662
|
-
measure(): {
|
|
1663
|
-
width: number;
|
|
1664
|
-
height: number;
|
|
1665
|
-
};
|
|
1666
|
-
/** Apply measured size to canvas and notify. */
|
|
1667
|
-
apply(): void;
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
interface ViewportSize {
|
|
1671
|
-
width: number;
|
|
1672
|
-
height: number;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
type RetroResolution = {
|
|
1676
|
-
key: string;
|
|
1677
|
-
width: number;
|
|
1678
|
-
height: number;
|
|
1679
|
-
notes?: string;
|
|
1680
|
-
};
|
|
1681
|
-
type RetroPreset = {
|
|
1682
|
-
displayAspect: number;
|
|
1683
|
-
resolutions: RetroResolution[];
|
|
1684
|
-
};
|
|
1685
|
-
/**
|
|
1686
|
-
* Retro, console, and device display presets.
|
|
1687
|
-
* displayAspect represents the intended display aspect (letterboxing target),
|
|
1688
|
-
* not necessarily the raw pixel aspect of internal buffers.
|
|
1689
|
-
*/
|
|
1690
|
-
declare const RetroPresets: Record<string, RetroPreset>;
|
|
1691
|
-
type RetroPresetKey = keyof typeof RetroPresets;
|
|
1692
|
-
declare function getDisplayAspect(preset: RetroPresetKey): number;
|
|
1693
|
-
declare function getPresetResolution(preset: RetroPresetKey, key?: string): RetroResolution | undefined;
|
|
1694
|
-
declare function parseResolution(text: string): {
|
|
1695
|
-
width: number;
|
|
1696
|
-
height: number;
|
|
1697
|
-
} | null;
|
|
1698
|
-
|
|
1699
|
-
/**
|
|
1700
|
-
* Resolution descriptor for the game's internal render buffer.
|
|
1701
|
-
* - `string` : a "WxH" literal or a known retro preset (e.g. `'NES'`).
|
|
1702
|
-
* - `{ width, height }` : explicit pixel dimensions.
|
|
1703
|
-
* - `'native'` : skip internal-resolution scaling — render at the
|
|
1704
|
-
* canvas' CSS size × DPR (i.e. 1:1 with the device viewport).
|
|
1705
|
-
*/
|
|
1706
|
-
type ResolutionInput = string | {
|
|
1707
|
-
width: number;
|
|
1708
|
-
height: number;
|
|
1709
|
-
} | 'native';
|
|
1710
|
-
type DeviceProfile = 'auto' | 'desktop' | 'mobile';
|
|
1711
|
-
interface ResolveGameConfigRuntime {
|
|
1712
|
-
deviceProfile?: DeviceProfile;
|
|
1713
|
-
viewportSize?: ViewportSize;
|
|
1714
|
-
}
|
|
1715
|
-
type GameDeviceConfig = Partial<{
|
|
1716
|
-
/** numeric value or key in AspectRatio */
|
|
1717
|
-
aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
|
|
1718
|
-
/** console/display preset to derive aspect ratio */
|
|
1719
|
-
preset: RetroPresetKey;
|
|
1720
|
-
/** lock internal render buffer for this device profile */
|
|
1721
|
-
resolution: ResolutionInput;
|
|
1722
|
-
/**
|
|
1723
|
-
* Auto-merge built-in virtual touch controls into the resolved input
|
|
1724
|
-
* config. The provider auto-enables on mobile devices via
|
|
1725
|
-
* `enabled: 'auto'`, so on desktop runtimes the UI stays dormant.
|
|
1726
|
-
* - `true` : default joystick + A/B layout, default theme.
|
|
1727
|
-
* - options object : forwarded to `defaultTouchControls('p1', ...)`.
|
|
1728
|
-
* - `false` / unset: no auto-injection (caller wires controls manually).
|
|
1729
|
-
*/
|
|
1730
|
-
controls: boolean | DefaultTouchControlsOptions;
|
|
1731
|
-
}>;
|
|
1732
|
-
type GameConfigLike = Partial<{
|
|
1733
|
-
id: string;
|
|
1734
|
-
globals: Record<string, any>;
|
|
1735
|
-
stages: StageInterface[];
|
|
1736
|
-
debug: boolean;
|
|
1737
|
-
time: number;
|
|
1738
|
-
input: GameInputConfig;
|
|
1739
|
-
/** numeric value or key in AspectRatio */
|
|
1740
|
-
aspectRatio: AspectRatioValue | keyof typeof AspectRatio;
|
|
1741
|
-
/** console/display preset to derive aspect ratio */
|
|
1742
|
-
preset: RetroPresetKey;
|
|
1743
|
-
/** lock internal render buffer to this desktop/default resolution */
|
|
1744
|
-
resolution: ResolutionInput;
|
|
1745
|
-
/** mobile-specific aspect/preset/resolution overrides */
|
|
1746
|
-
mobile: GameDeviceConfig;
|
|
1747
|
-
fullscreen: boolean;
|
|
1748
|
-
/** CSS background value for document body */
|
|
1749
|
-
bodyBackground: string;
|
|
1750
|
-
/** existing container by reference */
|
|
1751
|
-
container: HTMLElement;
|
|
1752
|
-
/** create/find container by id */
|
|
1753
|
-
containerId: string;
|
|
1754
|
-
/** optional canvas if caller wants to manage it */
|
|
1755
|
-
canvas: HTMLCanvasElement;
|
|
1756
|
-
}>;
|
|
1757
|
-
declare class GameConfig {
|
|
1758
|
-
id: string;
|
|
1759
|
-
globals: Record<string, any>;
|
|
1760
|
-
stages: StageInterface[];
|
|
1761
|
-
debug: boolean;
|
|
1762
|
-
time: number;
|
|
1763
|
-
input: GameInputConfig | undefined;
|
|
1764
|
-
aspectRatio: number;
|
|
1765
|
-
internalResolution: {
|
|
1766
|
-
width: number;
|
|
1767
|
-
height: number;
|
|
1768
|
-
} | undefined;
|
|
1769
|
-
fullscreen: boolean;
|
|
1770
|
-
bodyBackground: string | undefined;
|
|
1771
|
-
container: HTMLElement;
|
|
1772
|
-
containerId?: string | undefined;
|
|
1773
|
-
canvas?: HTMLCanvasElement | undefined;
|
|
1774
|
-
constructor(id: string, globals: Record<string, any>, stages: StageInterface[], debug: boolean, time: number, input: GameInputConfig | undefined, aspectRatio: number, internalResolution: {
|
|
1775
|
-
width: number;
|
|
1776
|
-
height: number;
|
|
1777
|
-
} | undefined, fullscreen: boolean, bodyBackground: string | undefined, container: HTMLElement, containerId?: string | undefined, canvas?: HTMLCanvasElement | undefined);
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* Factory for authoring configuration objects in user code.
|
|
1781
|
-
* Returns a plain object that can be passed to `game(...)`.
|
|
1782
|
-
*/
|
|
1783
|
-
declare function gameConfig(config: GameConfigLike): GameConfigLike;
|
|
1784
|
-
|
|
1785
|
-
interface GameCanvasOptions {
|
|
1786
|
-
id: string;
|
|
1787
|
-
container?: HTMLElement;
|
|
1788
|
-
containerId?: string;
|
|
1789
|
-
canvas?: HTMLCanvasElement;
|
|
1790
|
-
bodyBackground?: string;
|
|
1791
|
-
fullscreen?: boolean;
|
|
1792
|
-
aspectRatio: AspectRatioValue | number;
|
|
1793
|
-
}
|
|
1794
|
-
/**
|
|
1795
|
-
* GameCanvas is a DOM delegate that owns:
|
|
1796
|
-
* - container lookup/creation and styling (including fullscreen centering)
|
|
1797
|
-
* - body background application
|
|
1798
|
-
* - canvas mounting into container
|
|
1799
|
-
* - aspect ratio sizing via AspectRatioDelegate
|
|
1800
|
-
*/
|
|
1801
|
-
declare class GameCanvas {
|
|
1802
|
-
id: string;
|
|
1803
|
-
container: HTMLElement;
|
|
1804
|
-
canvas: HTMLCanvasElement;
|
|
1805
|
-
bodyBackground?: string;
|
|
1806
|
-
fullscreen: boolean;
|
|
1807
|
-
aspectRatio: number;
|
|
1808
|
-
private ratioDelegate;
|
|
1809
|
-
private overlayContainer;
|
|
1810
|
-
constructor(options: GameCanvasOptions);
|
|
1811
|
-
applyBodyBackground(): void;
|
|
1812
|
-
mountCanvas(): void;
|
|
1813
|
-
mountRenderer(rendererDom: HTMLCanvasElement, onResize: (width: number, height: number) => void): void;
|
|
1814
|
-
getOverlayContainer(): HTMLElement;
|
|
1815
|
-
centerIfFullscreen(): void;
|
|
1816
|
-
attachAspectRatio(onResize: (width: number, height: number) => void): void;
|
|
1817
|
-
setAspectRatio(aspectRatio: number): void;
|
|
1818
|
-
reapplyLayout(): void;
|
|
1819
|
-
destroy(): void;
|
|
1820
|
-
private mountChildren;
|
|
1821
|
-
private ensureOverlayContainer;
|
|
1822
|
-
private ensureContainer;
|
|
1823
|
-
}
|
|
1824
|
-
|
|
1825
|
-
/**
|
|
1826
|
-
* Game-level loading event that includes stage context.
|
|
1827
|
-
*/
|
|
1828
|
-
interface GameLoadingEvent {
|
|
1829
|
-
type: 'start' | 'progress' | 'complete';
|
|
1830
|
-
stageName?: string;
|
|
1831
|
-
stageIndex?: number;
|
|
1832
|
-
message: string;
|
|
1833
|
-
progress: number;
|
|
1834
|
-
current?: number;
|
|
1835
|
-
total?: number;
|
|
1836
|
-
}
|
|
1837
|
-
|
|
1838
|
-
type ZylemGameOptions<TGlobals extends BaseGlobals> = ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals> & Partial<GameConfig>;
|
|
1839
|
-
declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
1840
|
-
id: string;
|
|
1841
|
-
initialGlobals: TGlobals;
|
|
1842
|
-
customSetup: ((params: SetupContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
1843
|
-
customUpdate: ((params: UpdateContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
1844
|
-
customDestroy: ((params: DestroyContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
|
|
1845
|
-
stages: Stage[];
|
|
1846
|
-
stageMap: Map<string, Stage>;
|
|
1847
|
-
currentStageId: string;
|
|
1848
|
-
previousTimeStamp: number;
|
|
1849
|
-
totalTime: number;
|
|
1850
|
-
timer: Timer;
|
|
1851
|
-
inputManager: InputManager;
|
|
1852
|
-
wrapperRef: Game<TGlobals>;
|
|
1853
|
-
globalInputConfig: GameInputConfig | undefined;
|
|
1854
|
-
defaultCamera: ZylemCamera | null;
|
|
1855
|
-
/** Shared renderer manager for all stages */
|
|
1856
|
-
rendererManager: RendererManager | null;
|
|
1857
|
-
container: HTMLElement | null;
|
|
1858
|
-
canvas: HTMLCanvasElement | null;
|
|
1859
|
-
aspectRatioDelegate: AspectRatioDelegate | null;
|
|
1860
|
-
resolvedConfig: GameConfig | null;
|
|
1861
|
-
gameCanvas: GameCanvas | null;
|
|
1862
|
-
private animationFrameId;
|
|
1863
|
-
private isDisposed;
|
|
1864
|
-
/**
|
|
1865
|
-
* True while a `loadStage` is in progress. Used to reject re-entrant stage
|
|
1866
|
-
* navigation (e.g. a button press during a transition), which would race
|
|
1867
|
-
* two loads on `stageMap`/the render loop and, because `currentStageId` is
|
|
1868
|
-
* transiently `''`, misresolve the target stage.
|
|
1869
|
-
*/
|
|
1870
|
-
private loadInFlight;
|
|
1871
|
-
/**
|
|
1872
|
-
* True once `start()` has been invoked for this game's initial stage.
|
|
1873
|
-
* Used by `loadStage` to decide whether to drive the stage's `_setup`
|
|
1874
|
-
* lifecycle directly (for subsequent stages loaded via `nextStage`
|
|
1875
|
-
* / `loadStage`) or defer to `start()` (for the very first stage).
|
|
1876
|
-
*/
|
|
1877
|
-
private hasStarted;
|
|
1878
|
-
private debugDelegate;
|
|
1879
|
-
private loadingDelegate;
|
|
1880
|
-
private rendererObserver;
|
|
1881
|
-
private eventBusUnsubscribes;
|
|
1882
|
-
private thumbnailUnsubscribes;
|
|
1883
|
-
/** Serialized last-published game config, for dirty-checking resize churn. */
|
|
1884
|
-
private lastPublishedGameConfig;
|
|
1885
|
-
/** Editor ↔ game bridge adapter (RAF-coalesced publishes, command intake). */
|
|
1886
|
-
private gameBridge;
|
|
1887
|
-
/** Stops republishing the entity catalog on registry changes. */
|
|
1888
|
-
private catalogUnsubscribe;
|
|
1889
|
-
private readonly gameUpdateParams;
|
|
1890
|
-
private readonly stageSetupParams;
|
|
1891
|
-
private readonly stageUpdateParams;
|
|
1892
|
-
private readonly frameCallback;
|
|
1893
|
-
private readonly sourceOptions;
|
|
1894
|
-
private displayRuntime;
|
|
1895
|
-
static FRAME_LIMIT: number;
|
|
1896
|
-
static FRAME_DURATION: number;
|
|
1897
|
-
static MAX_DELTA_SECONDS: number;
|
|
1898
|
-
constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>, displayRuntime?: ResolveGameConfigRuntime);
|
|
1899
|
-
/** Publish the placeable entity types the editor's Add palette lists. */
|
|
1900
|
-
private publishEntityCatalog;
|
|
1901
|
-
/** Spawn a catalog type programmatically (editor `entity:create`). */
|
|
1902
|
-
private createCatalogEntity;
|
|
1903
|
-
setDisplayRuntime(runtime: ResolveGameConfigRuntime): void;
|
|
1904
|
-
loadGameCanvas(config: GameConfig): void;
|
|
1905
|
-
loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
|
|
1906
|
-
/** Whether a stage load is currently in progress. */
|
|
1907
|
-
isLoading(): boolean;
|
|
1908
|
-
loadStage(stage: Stage, stageIndex?: number, transition?: StageTransitionConfig): Promise<void>;
|
|
1909
|
-
private performLoadStage;
|
|
1910
|
-
/**
|
|
1911
|
-
* Merges game-level global input config with the stage's per-stage overrides
|
|
1912
|
-
* and reconfigures the InputManager.
|
|
1913
|
-
*/
|
|
1914
|
-
applyInputConfig(stage: Stage): void;
|
|
1915
|
-
/**
|
|
1916
|
-
* Update the game-level global input config and re-apply to the current stage.
|
|
1917
|
-
*/
|
|
1918
|
-
setGlobalInputConfig(config: GameInputConfig): void;
|
|
1919
|
-
unloadCurrentStage(): void;
|
|
1920
|
-
setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
|
|
1921
|
-
params(): UpdateContext<ZylemGame<TGlobals>, TGlobals>;
|
|
1922
|
-
start(): void;
|
|
1923
|
-
/**
|
|
1924
|
-
* Execute a single frame update.
|
|
1925
|
-
* This method can be called directly for testing or from the game loop.
|
|
1926
|
-
* @param deltaTime Optional delta time in seconds. If not provided, uses timer delta.
|
|
1927
|
-
*/
|
|
1928
|
-
step(deltaTime?: number): void;
|
|
1929
|
-
loop(timestamp: number): void;
|
|
1930
|
-
dispose(): void;
|
|
1931
|
-
outOfLoop(): void;
|
|
1932
|
-
getStage(id: string): Stage | undefined;
|
|
1933
|
-
currentStage(): Stage | undefined;
|
|
1934
|
-
/**
|
|
1935
|
-
* Subscribe to loading events from the game.
|
|
1936
|
-
* Events include stage context (stageName, stageIndex).
|
|
1937
|
-
* @param callback Invoked for each loading event
|
|
1938
|
-
* @returns Unsubscribe function
|
|
1939
|
-
*/
|
|
1940
|
-
onLoading(callback: (event: GameLoadingEvent) => void): () => void;
|
|
1941
|
-
/**
|
|
1942
|
-
* Build the stage config payload for the current stage.
|
|
1943
|
-
*/
|
|
1944
|
-
private buildStageConfigPayload;
|
|
1945
|
-
/**
|
|
1946
|
-
* Build a bridge entity summary for one entity, or null for entities on
|
|
1947
|
-
* the managed render path (instanced packs/bundles), which can number in
|
|
1948
|
-
* the thousands and are not useful in the editor panel.
|
|
1949
|
-
*/
|
|
1950
|
-
private buildEntitySummary;
|
|
1951
|
-
/**
|
|
1952
|
-
* Build the full entities payload for the current stage.
|
|
1953
|
-
*/
|
|
1954
|
-
private buildEntitiesPayload;
|
|
1955
|
-
/**
|
|
1956
|
-
* Generate entity thumbnails as entities become available, streaming
|
|
1957
|
-
* upserts/thumbnails/removals to the editor through the bridge
|
|
1958
|
-
* (RAF-coalesced, merged by uuid).
|
|
1959
|
-
*
|
|
1960
|
-
* All of this work exists only to feed the editor, and thumbnails in
|
|
1961
|
-
* particular cost an offscreen render plus a pixel readback on the shared
|
|
1962
|
-
* renderer. Each publisher therefore checks the bridge for a live listener
|
|
1963
|
-
* first, and a late-connecting editor is backfilled from
|
|
1964
|
-
* {@link wireEditorBackfill}.
|
|
1965
|
-
*/
|
|
1966
|
-
private wireEntityThumbnails;
|
|
1967
|
-
/**
|
|
1968
|
-
* Republish the current stage when an editor subscribes after the game
|
|
1969
|
-
* started. Without this, entities added while nothing was listening would
|
|
1970
|
-
* never appear, since the per-entity publishers were skipped.
|
|
1971
|
-
*/
|
|
1972
|
-
private wireEditorBackfill;
|
|
1973
|
-
private clearEntityThumbnailWiring;
|
|
1974
|
-
private buildGameConfigPayload;
|
|
1975
|
-
/** Publish the resolved display config over the bridge. */
|
|
1976
|
-
/**
|
|
1977
|
-
* Publish the display config, skipping unchanged payloads. The
|
|
1978
|
-
* `ResizeObserver` on `<zylem-game>` funnels into `setDisplayRuntime`, which
|
|
1979
|
-
* fires on every layout tick even when nothing about the config moved.
|
|
1980
|
-
*/
|
|
1981
|
-
private publishGameConfig;
|
|
1982
|
-
/** Publish a full stage snapshot (config + entity list) over the bridge. */
|
|
1983
|
-
private publishStageSnapshot;
|
|
1984
|
-
/**
|
|
1985
|
-
* Subscribe to the game event bus for stage loading and state events,
|
|
1986
|
-
* mirroring global-variable updates to the editor over the bridge.
|
|
1987
|
-
*/
|
|
1988
|
-
private subscribeToEventBus;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
type GameOptions<TGlobals extends BaseGlobals> = Array<ZylemGameConfig<Stage, any, TGlobals> | GameConfigLike | Stage | GameEntityLifeCycle | BaseNode>;
|
|
1992
|
-
|
|
1993
|
-
declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
1994
|
-
private wrappedGame;
|
|
1995
|
-
options: GameOptions<TGlobals>;
|
|
1996
|
-
private setupCallbacks;
|
|
1997
|
-
private updateCallbacks;
|
|
1998
|
-
private destroyCallbacks;
|
|
1999
|
-
private pendingLoadingCallbacks;
|
|
2000
|
-
private globalChangeCallbacks;
|
|
2001
|
-
private globalChangesCallbacks;
|
|
2002
|
-
private activeGlobalSubscriptions;
|
|
2003
|
-
private eventDelegate;
|
|
2004
|
-
/** Pending global input config set before the game starts. */
|
|
2005
|
-
private pendingInputConfig;
|
|
2006
|
-
private displayRuntime;
|
|
2007
|
-
refErrorMessage: string;
|
|
2008
|
-
constructor(options: GameOptions<TGlobals>);
|
|
2009
|
-
onSetup(...callbacks: Array<SetupFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
2010
|
-
onUpdate(...callbacks: Array<UpdateFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
2011
|
-
onDestroy(...callbacks: Array<DestroyFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
2012
|
-
/**
|
|
2013
|
-
* Set composable input configuration as global defaults for the entire game.
|
|
2014
|
-
* Multiple configs are deep-merged (later configs win on key conflicts).
|
|
2015
|
-
* Per-stage overrides (via stage.setInputConfiguration) are merged on top.
|
|
2016
|
-
* Can be called before or after start().
|
|
2017
|
-
* @example game.setInputConfiguration(useArrowsForAxes('p1'), useWASDForDirections('p2'));
|
|
2018
|
-
*/
|
|
2019
|
-
setInputConfiguration(...configs: GameInputConfig[]): this;
|
|
2020
|
-
start(): Promise<this>;
|
|
2021
|
-
setDisplayRuntime(runtime: Partial<ResolveGameConfigRuntime>): this;
|
|
2022
|
-
setDeviceProfile(profile: DeviceProfile): this;
|
|
2023
|
-
setViewportSize(width: number, height: number): this;
|
|
2024
|
-
private load;
|
|
2025
|
-
private setOverrides;
|
|
2026
|
-
/**
|
|
2027
|
-
* Subscribe to changes on a global value. Subscriptions are registered
|
|
2028
|
-
* when the game starts and cleaned up when disposed.
|
|
2029
|
-
* The callback receives the value and the current stage.
|
|
2030
|
-
* @example game.onGlobalChange('score', (val, stage) => console.log(val));
|
|
2031
|
-
*/
|
|
2032
|
-
onGlobalChange<T = unknown>(path: string, callback: (value: T, stage: Stage | null) => void): this;
|
|
2033
|
-
/**
|
|
2034
|
-
* Subscribe to changes on multiple global paths. Subscriptions are registered
|
|
2035
|
-
* when the game starts and cleaned up when disposed.
|
|
2036
|
-
* The callback receives the values and the current stage.
|
|
2037
|
-
* @example game.onGlobalChanges(['score', 'lives'], ([score, lives], stage) => console.log(score, lives));
|
|
2038
|
-
*/
|
|
2039
|
-
onGlobalChanges<T extends unknown[] = unknown[]>(paths: string[], callback: (values: T, stage: Stage | null) => void): this;
|
|
2040
|
-
/**
|
|
2041
|
-
* Register all stored global change callbacks.
|
|
2042
|
-
* Called internally during start().
|
|
2043
|
-
*/
|
|
2044
|
-
private registerGlobalSubscriptions;
|
|
2045
|
-
/**
|
|
2046
|
-
* Get the current stage wrapper.
|
|
2047
|
-
*/
|
|
2048
|
-
getCurrentStage(): Stage | null;
|
|
2049
|
-
/**
|
|
2050
|
-
* Experimental escape hatches. APIs here are unstable and may change or be
|
|
2051
|
-
* removed without a major version bump.
|
|
2052
|
-
*/
|
|
2053
|
-
readonly experimental: {
|
|
2054
|
-
/**
|
|
2055
|
-
* The `@zylem/behaviors` {@link Simulation} backing the current stage's
|
|
2056
|
-
* physics world, or `null` before a stage is loaded. Intended for debug
|
|
2057
|
-
* tooling and the editor; games should not need it.
|
|
2058
|
-
*/
|
|
2059
|
-
getRuntime: () => Simulation | null;
|
|
2060
|
-
};
|
|
2061
|
-
pause(): Promise<void>;
|
|
2062
|
-
resume(): Promise<void>;
|
|
2063
|
-
/**
|
|
2064
|
-
* Execute a single frame update.
|
|
2065
|
-
* Useful for testing or manual frame stepping.
|
|
2066
|
-
* @param deltaTime Optional delta time in seconds (defaults to 1/60)
|
|
2067
|
-
*/
|
|
2068
|
-
step(deltaTime?: number): void;
|
|
2069
|
-
/**
|
|
2070
|
-
* Reload the first stage. Pass `{ transition }` to blend from the current
|
|
2071
|
-
* stage instead of cutting.
|
|
2072
|
-
* @example game.reset({ transition: { duration: 1 } });
|
|
2073
|
-
*/
|
|
2074
|
-
reset(options?: StageNavigationOptions): Promise<void>;
|
|
2075
|
-
/**
|
|
2076
|
-
* Go to the previous stage in the stage array. Pass `{ transition }` to
|
|
2077
|
-
* blend from the current stage instead of cutting.
|
|
2078
|
-
*/
|
|
2079
|
-
previousStage(options?: StageNavigationOptions): void;
|
|
2080
|
-
loadStageFromId(stageId: string): Promise<void>;
|
|
2081
|
-
/**
|
|
2082
|
-
* Go to the next stage. Pass `{ transition }` to blend from the current
|
|
2083
|
-
* stage instead of cutting.
|
|
2084
|
-
* @example
|
|
2085
|
-
* game.nextStage({
|
|
2086
|
-
* transition: { duration: 1.2, shader: createStageTransition({ pattern: 'noise' }) },
|
|
2087
|
-
* });
|
|
2088
|
-
*/
|
|
2089
|
-
nextStage(options?: StageNavigationOptions): void;
|
|
2090
|
-
goToStage(): Promise<void>;
|
|
2091
|
-
end(): Promise<void>;
|
|
2092
|
-
dispose(): void;
|
|
2093
|
-
/**
|
|
2094
|
-
* Dispatch an event from the game.
|
|
2095
|
-
* Events are emitted both locally and to the global event bus.
|
|
2096
|
-
*/
|
|
2097
|
-
dispatch<K extends keyof GameEvents>(event: K, payload: GameEvents[K]): void;
|
|
2098
|
-
/**
|
|
2099
|
-
* Listen for events on this game instance.
|
|
2100
|
-
* @returns Unsubscribe function
|
|
2101
|
-
*/
|
|
2102
|
-
listen<K extends keyof GameEvents>(event: K, handler: (payload: GameEvents[K]) => void): () => void;
|
|
2103
|
-
/**
|
|
2104
|
-
* Subscribe to loading events from the game.
|
|
2105
|
-
* Events include stage context (stageName, stageIndex).
|
|
2106
|
-
* @param callback Invoked for each loading event
|
|
2107
|
-
* @returns Unsubscribe function
|
|
2108
|
-
*/
|
|
2109
|
-
onLoading(callback: (event: GameLoadingEvent) => void): () => void;
|
|
2110
|
-
}
|
|
2111
|
-
/**
|
|
2112
|
-
* create a new game
|
|
2113
|
-
* @param options GameOptions - Array of IGameOptions, Stage, GameEntity, or BaseNode objects
|
|
2114
|
-
* @param options.id Game name string (when using IGameOptions)
|
|
2115
|
-
* @param options.globals Game globals object (when using IGameOptions)
|
|
2116
|
-
* @param options.stages Array of stage objects (when using IGameOptions)
|
|
2117
|
-
* @returns Game
|
|
2118
|
-
*/
|
|
2119
|
-
declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
|
|
2120
|
-
|
|
2121
|
-
export { AspectRatio as A, Stage as B, CameraWrapper as C, type DeviceProfile as D, type StageStateInterface as E, Fixed2DPerspective as F, Game as G, type PerspectiveOptions as P, type ResolutionInput as R, type StageConfigLike as S, ThirdPersonPerspective as T, type GameLoadingEvent as a, type GameConfigLike as b, createGame as c, type GameDeviceConfig as d, type ResolveGameConfigRuntime as e, createStage as f, gameConfig as g, type StageOptions as h, createCamera as i, type CameraOptions as j, CameraManager as k, FirstPersonPerspective as l, createPerspective as m, type ThirdPersonOptions as n, type Fixed2DOptions as o, type FirstPersonOptions as p, type AspectRatioValue as q, getDisplayAspect as r, stageConfig as s, getPresetResolution as t, parseResolution as u, type RetroPreset as v, type RetroPresetKey as w, type RetroResolution as x, RenderBundleManager as y, RenderStrategyManager as z };
|
|
1567
|
+
export { type BaseEntityInterface as B, CameraWrapper as C, Fixed2DPerspective as F, type PerspectiveOptions as P, RenderBundleManager as R, type StageConfigLike as S, ThirdPersonPerspective as T, ZylemStage as Z, type StageOptions as a, createCamera as b, createStage as c, type CameraOptions as d, CameraManager as e, FirstPersonPerspective as f, createPerspective as g, type ThirdPersonOptions as h, type Fixed2DOptions as i, type FirstPersonOptions as j, RenderStrategyManager as k, Stage as l, stageConfig as s };
|