@zylem/game-lib 0.6.2 → 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/LICENSE +21 -0
- 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-Cq3Ko6_G.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 +900 -211
- package/dist/camera.js.map +1 -1
- package/dist/composition-DrzFrbqI.d.ts +218 -0
- package/dist/{core-bO8TzV7u.d.ts → core-DAkskq6Y.d.ts} +60 -62
- package/dist/core.d.ts +10 -6
- package/dist/core.js +6896 -5020
- package/dist/core.js.map +1 -1
- package/dist/{entities-DvByhMGU.d.ts → entities-DC9ce_vx.d.ts} +113 -3
- package/dist/entities.d.ts +5 -3
- package/dist/entities.js +3727 -3167
- package/dist/entities.js.map +1 -1
- package/dist/entity-BpbZqg19.d.ts +1100 -0
- package/dist/global-change-Dc8uCKi2.d.ts +25 -0
- package/dist/main.d.ts +418 -15
- package/dist/main.js +11384 -8515
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-Bd-KtcYT.d.ts → stage-types-BFsm3qsZ.d.ts} +205 -13
- package/dist/stage.d.ts +10 -7
- package/dist/stage.js +5311 -3880
- 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 +29 -13
- package/dist/behaviors.d.ts +0 -854
- package/dist/behaviors.js +0 -1209
- package/dist/behaviors.js.map +0 -1
- package/dist/camera-CeJPAgGg.d.ts +0 -116
- package/dist/moveable-B_vyA6cw.d.ts +0 -67
- package/dist/transformable-CUhvyuYO.d.ts +0 -67
- package/dist/world-C8tQ7Plj.d.ts +0 -774
|
@@ -1,50 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Z as
|
|
3
|
-
import {
|
|
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
4
|
import { Vector3 } from 'three';
|
|
5
5
|
import { Vector3 as Vector3$1 } from '@dimforge/rapier3d-compat';
|
|
6
|
-
|
|
7
|
-
interface InputProvider {
|
|
8
|
-
getInput(delta: number): Partial<InputGamepad>;
|
|
9
|
-
isConnected(): boolean;
|
|
10
|
-
getName(): string;
|
|
11
|
-
}
|
|
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
|
-
}
|
|
21
|
-
interface GameInputConfig {
|
|
22
|
-
p1?: GameInputPlayerConfig;
|
|
23
|
-
p2?: GameInputPlayerConfig;
|
|
24
|
-
p3?: GameInputPlayerConfig;
|
|
25
|
-
p4?: GameInputPlayerConfig;
|
|
26
|
-
p5?: GameInputPlayerConfig;
|
|
27
|
-
p6?: GameInputPlayerConfig;
|
|
28
|
-
p7?: GameInputPlayerConfig;
|
|
29
|
-
p8?: GameInputPlayerConfig;
|
|
30
|
-
}
|
|
31
|
-
interface ZylemGameConfig<StageInterface, GameInterface, TGlobals extends BaseGlobals> {
|
|
32
|
-
id: string;
|
|
33
|
-
globals?: TGlobals;
|
|
34
|
-
stages?: StageInterface[];
|
|
35
|
-
update?: UpdateFunction<GameInterface>;
|
|
36
|
-
debug?: boolean;
|
|
37
|
-
time?: number;
|
|
38
|
-
input?: GameInputConfig;
|
|
39
|
-
}
|
|
6
|
+
import './global-change-Dc8uCKi2.js';
|
|
40
7
|
|
|
41
8
|
declare class InputManager {
|
|
42
9
|
private inputMap;
|
|
43
10
|
private currentInputs;
|
|
44
11
|
private previousInputs;
|
|
45
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;
|
|
46
18
|
addInputProvider(playerNumber: InputPlayerNumber, provider: InputProvider): void;
|
|
47
19
|
getInputs(delta: number): Inputs;
|
|
20
|
+
private buildPlayerEntries;
|
|
48
21
|
private mergeInputs;
|
|
49
22
|
}
|
|
50
23
|
|
|
@@ -311,7 +284,10 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
311
284
|
timer: Timer;
|
|
312
285
|
inputManager: InputManager;
|
|
313
286
|
wrapperRef: Game<TGlobals>;
|
|
287
|
+
globalInputConfig: GameInputConfig | undefined;
|
|
314
288
|
defaultCamera: ZylemCamera | null;
|
|
289
|
+
/** Shared renderer manager for all stages */
|
|
290
|
+
rendererManager: RendererManager | null;
|
|
315
291
|
container: HTMLElement | null;
|
|
316
292
|
canvas: HTMLCanvasElement | null;
|
|
317
293
|
aspectRatioDelegate: AspectRatioDelegate | null;
|
|
@@ -330,6 +306,15 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
330
306
|
loadGameCanvas(config: GameConfig): void;
|
|
331
307
|
loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
|
|
332
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;
|
|
333
318
|
unloadCurrentStage(): void;
|
|
334
319
|
setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
|
|
335
320
|
params(): UpdateContext<ZylemGame<TGlobals>, TGlobals>;
|
|
@@ -365,6 +350,12 @@ declare class ZylemGame<TGlobals extends BaseGlobals> {
|
|
|
365
350
|
* Called after stage load and on global state changes.
|
|
366
351
|
*/
|
|
367
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;
|
|
368
359
|
/**
|
|
369
360
|
* Subscribe to the game event bus for stage loading and state events.
|
|
370
361
|
* Emits events to zylemEventBus for cross-package communication.
|
|
@@ -385,11 +376,21 @@ declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
|
385
376
|
private globalChangesCallbacks;
|
|
386
377
|
private activeGlobalSubscriptions;
|
|
387
378
|
private eventDelegate;
|
|
379
|
+
/** Pending global input config set before the game starts. */
|
|
380
|
+
private pendingInputConfig;
|
|
388
381
|
refErrorMessage: string;
|
|
389
382
|
constructor(options: GameOptions<TGlobals>);
|
|
390
383
|
onSetup(...callbacks: Array<SetupFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
391
384
|
onUpdate(...callbacks: Array<UpdateFunction<ZylemGame<TGlobals>, TGlobals>>): this;
|
|
392
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;
|
|
393
394
|
start(): Promise<this>;
|
|
394
395
|
private load;
|
|
395
396
|
private setOverrides;
|
|
@@ -459,42 +460,39 @@ declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
|
|
|
459
460
|
*/
|
|
460
461
|
declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
|
|
461
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
|
+
*/
|
|
462
471
|
declare class Vessel extends BaseNode<{}, Vessel> {
|
|
463
472
|
static type: symbol;
|
|
464
473
|
protected _setup(_params: SetupContext<this>): void;
|
|
465
474
|
protected _loaded(_params: LoadedContext<this>): Promise<void>;
|
|
466
475
|
protected _update(_params: UpdateContext<this>): void;
|
|
467
476
|
protected _destroy(_params: DestroyContext<this>): void;
|
|
468
|
-
protected _cleanup(_params: CleanupContext<this>):
|
|
477
|
+
protected _cleanup(_params: CleanupContext<this>): void;
|
|
469
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;
|
|
470
485
|
}
|
|
471
|
-
declare function vessel(...args: Array<BaseNode>): BaseNode<{}, Vessel>;
|
|
472
|
-
|
|
473
486
|
/**
|
|
474
|
-
*
|
|
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
|
|
475
490
|
*/
|
|
476
|
-
|
|
491
|
+
declare function vessel(...args: Array<BaseNode>): Vessel;
|
|
477
492
|
|
|
478
493
|
/**
|
|
479
|
-
*
|
|
480
|
-
* Usage: onUpdate(globalChange('p1Score', (value) => { ... }))
|
|
481
|
-
*/
|
|
482
|
-
declare function globalChange<T = any>(key: string, callback: (value: T, ctx: UpdateContext<any>) => void): (ctx: UpdateContext<any>) => void;
|
|
483
|
-
/**
|
|
484
|
-
* Listen for multiple global key changes inside an onUpdate pipeline.
|
|
485
|
-
* Calls back when any of the provided keys changes.
|
|
486
|
-
* Usage: onUpdate(globalChanges(['p1Score','p2Score'], ([p1,p2]) => { ... }))
|
|
487
|
-
*/
|
|
488
|
-
declare function globalChanges<T = any>(keys: string[], callback: (values: T[], ctx: UpdateContext<any>) => void): (ctx: UpdateContext<any>) => void;
|
|
489
|
-
/**
|
|
490
|
-
* Listen for a single stage variable change inside an onUpdate pipeline.
|
|
491
|
-
* Usage: onUpdate(variableChange('score', (value, ctx) => { ... }))
|
|
492
|
-
*/
|
|
493
|
-
declare function variableChange<T = any>(key: string, callback: (value: T, ctx: UpdateContext<any>) => void): (ctx: UpdateContext<any>) => void;
|
|
494
|
-
/**
|
|
495
|
-
* Listen for multiple stage variable changes; fires when any changes.
|
|
496
|
-
* Usage: onUpdate(variableChanges(['a','b'], ([a,b], ctx) => { ... }))
|
|
494
|
+
* @deprecated This type is deprecated.
|
|
497
495
|
*/
|
|
498
|
-
|
|
496
|
+
type Vect3 = Vector3 | Vector3$1;
|
|
499
497
|
|
|
500
|
-
export { Game as G, type Vect3 as V,
|
|
498
|
+
export { Game as G, type Vect3 as V, createGame as c, gameConfig as g, vessel as v };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export { V as Vect3,
|
|
2
|
-
|
|
1
|
+
export { V as Vect3, c as createGame, v as vessel } from './core-DAkskq6Y.js';
|
|
2
|
+
export { Z as ZylemGameConfig } from './stage-types-BFsm3qsZ.js';
|
|
3
|
+
export { g as globalChange, a as globalChanges, v as variableChange, b as variableChanges } from './global-change-Dc8uCKi2.js';
|
|
4
|
+
import './entity-BpbZqg19.js';
|
|
3
5
|
import 'three';
|
|
4
6
|
import '@dimforge/rapier3d-compat';
|
|
5
|
-
import './entity-Bq_eNEDI.js';
|
|
6
7
|
import 'bitecs';
|
|
7
8
|
import 'mitt';
|
|
8
|
-
import './
|
|
9
|
+
import './behavior-descriptor-BWNWmIjv.js';
|
|
10
|
+
import './camera-B5e4c78l.js';
|
|
11
|
+
import './entity-Bq_eNEDI.js';
|
|
12
|
+
import 'three/webgpu';
|
|
9
13
|
import 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
10
|
-
import './
|
|
14
|
+
import './world-Be5m1XC1.js';
|
|
11
15
|
import './entity-types-DAu8sGJH.js';
|
|
12
|
-
import './entities-
|
|
16
|
+
import './entities-DC9ce_vx.js';
|