@zylem/game-lib 0.6.0 → 0.6.2
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/dist/behaviors.d.ts +834 -86
- package/dist/behaviors.js +1166 -355
- package/dist/behaviors.js.map +1 -1
- package/dist/{blueprints-BOCc3Wve.d.ts → blueprints-Cq3Ko6_G.d.ts} +2 -2
- package/dist/{camera-CpbDr4-V.d.ts → camera-CeJPAgGg.d.ts} +2 -2
- package/dist/camera.d.ts +1 -1
- package/dist/camera.js +126 -19
- package/dist/camera.js.map +1 -1
- package/dist/{core-CZhozNRH.d.ts → core-bO8TzV7u.d.ts} +40 -6
- package/dist/core.d.ts +8 -6
- package/dist/core.js +6554 -5033
- package/dist/core.js.map +1 -1
- package/dist/{entities-BAxfJOkk.d.ts → entities-DvByhMGU.d.ts} +43 -44
- package/dist/entities.d.ts +4 -3
- package/dist/entities.js +3236 -2013
- package/dist/entities.js.map +1 -1
- package/dist/entity-types-DAu8sGJH.d.ts +26 -0
- package/dist/main.d.ts +71 -31
- package/dist/main.js +9197 -6313
- package/dist/main.js.map +1 -1
- package/dist/{stage-types-CD21XoIU.d.ts → stage-types-Bd-KtcYT.d.ts} +65 -28
- package/dist/stage.d.ts +9 -7
- package/dist/stage.js +3993 -2453
- package/dist/stage.js.map +1 -1
- package/dist/world-C8tQ7Plj.d.ts +774 -0
- package/package.json +11 -10
- package/LICENSE +0 -21
- package/dist/entity-COvRtFNG.d.ts +0 -395
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Group } from 'three';
|
|
2
|
+
import { RigidBody, Collider } from '@dimforge/rapier3d-compat';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base entity interface - shared across modules to prevent circular dependencies
|
|
6
|
+
*/
|
|
7
|
+
interface BaseEntityInterface {
|
|
8
|
+
uuid: string;
|
|
9
|
+
name: string;
|
|
10
|
+
eid: number;
|
|
11
|
+
group: Group | null | undefined;
|
|
12
|
+
body: RigidBody | null | undefined;
|
|
13
|
+
collider: Collider | null | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Game entity interface - minimal interface to break circular dependencies
|
|
17
|
+
*/
|
|
18
|
+
interface GameEntityInterface extends BaseEntityInterface {
|
|
19
|
+
type: string;
|
|
20
|
+
isStatic: boolean;
|
|
21
|
+
setPosition(x: number, y: number, z: number): void;
|
|
22
|
+
setRotation(x: number, y: number, z: number): void;
|
|
23
|
+
setScale(x: number, y: number, z: number): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type { BaseEntityInterface as B, GameEntityInterface as G };
|
package/dist/main.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { G as Game } from './core-
|
|
2
|
-
export { V as Vect3, Z as ZylemGameConfig, c as createGame, g as gameConfig, a as globalChange, b as globalChanges, d as variableChange, e as variableChanges, v as vessel } from './core-
|
|
3
|
-
export { a as StageOptions, c as createStage } from './stage-types-
|
|
4
|
-
import { S as StageBlueprint } from './blueprints-
|
|
5
|
-
export { e as entitySpawner } from './blueprints-
|
|
6
|
-
export { P as PerspectiveType,
|
|
7
|
-
export { A as ACTOR_TYPE, B as BOX_TYPE, P as PLANE_TYPE, R as RECT_TYPE,
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
import { M as MoveableEntity } from './moveable-B_vyA6cw.js';
|
|
1
|
+
import { G as Game } from './core-bO8TzV7u.js';
|
|
2
|
+
export { V as Vect3, Z as ZylemGameConfig, c as createGame, g as gameConfig, a as globalChange, b as globalChanges, d as variableChange, e as variableChanges, v as vessel } from './core-bO8TzV7u.js';
|
|
3
|
+
export { a as StageOptions, d as createDisk, c as createStage } from './stage-types-Bd-KtcYT.js';
|
|
4
|
+
import { S as StageBlueprint } from './blueprints-Cq3Ko6_G.js';
|
|
5
|
+
export { e as entitySpawner } from './blueprints-Cq3Ko6_G.js';
|
|
6
|
+
export { P as PerspectiveType, d as Perspectives, c as createCamera } from './camera-CeJPAgGg.js';
|
|
7
|
+
export { A as ACTOR_TYPE, B as BOX_TYPE, P as PLANE_TYPE, R as RECT_TYPE, a as SPHERE_TYPE, S as SPRITE_TYPE, T as TEXT_TYPE, g as ZONE_TYPE, e as ZylemBox, o as createActor, j as createBox, m as createPlane, q as createRect, k as createSphere, l as createSprite, p as createText, n as createZone } from './entities-DvByhMGU.js';
|
|
8
|
+
import { G as GameEntity, g as GameEntityOptions } from './world-C8tQ7Plj.js';
|
|
9
|
+
export { q as BehaviorDescriptor, s as BehaviorHandle, r as BehaviorRef, e as BehaviorSystem, f as BehaviorSystemFactory, t as DefineBehaviorConfig, o as EntityConfigPayload, k as EntityEvents, E as EventEmitterDelegate, j as GameEvents, l as GameLoadingPayload, L as LoadingEvent, a as SetupContext, n as StageConfigPayload, h as StageEvents, m as StateDispatchPayload, b as UpdateContext, i as ZylemEvents, Z as ZylemShaderObject, p as defineBehavior, z as zylemEventBus } from './world-C8tQ7Plj.js';
|
|
10
|
+
export { Behavior, BoundaryRicochetCoordinator, MovementSequence2DBehavior, MovementSequence2DCurrentStep, MovementSequence2DEvent, MovementSequence2DFSM, MovementSequence2DHandle, MovementSequence2DMovement, MovementSequence2DOptions, MovementSequence2DProgress, MovementSequence2DState, MovementSequence2DStep, PhysicsBodyComponent, PhysicsStepBehavior, PhysicsSyncBehavior, PlayerInput, Ricochet2DBehavior, Ricochet2DCollisionContext, Ricochet2DEvent, Ricochet2DFSM, Ricochet2DHandle, Ricochet2DOptions, Ricochet2DResult, Ricochet2DState, ScreenWrapBehavior, ScreenWrapEvent, ScreenWrapFSM, ScreenWrapOptions, ScreenWrapState, ThrusterBehavior, ThrusterBehaviorOptions, ThrusterEntity, ThrusterEvent, ThrusterFSM, ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementBehavior, ThrusterMovementComponent, ThrusterState, ThrusterStateComponent, TransformComponent, WorldBoundary2DBehavior, WorldBoundary2DBounds, WorldBoundary2DEvent, WorldBoundary2DFSM, WorldBoundary2DHandle, WorldBoundary2DHit, WorldBoundary2DHits, WorldBoundary2DOptions, WorldBoundary2DPosition, WorldBoundary2DState, computeWorldBoundary2DHits, createPhysicsBodyComponent, createThrusterInputComponent, createThrusterMovementComponent, createThrusterStateComponent, createTransformComponent, hasAnyWorldBoundary2DHit, useBehavior } from './behaviors.js';
|
|
12
11
|
export { m as makeMoveable, b as move, a as moveable, r as resetVelocity } from './moveable-B_vyA6cw.js';
|
|
13
12
|
export { m as makeRotatable, a as makeTransformable, r as rotatable, b as rotateInDirection } from './transformable-CUhvyuYO.js';
|
|
14
13
|
export { Howl } from 'howler';
|
|
@@ -18,8 +17,11 @@ import * as RAPIER from '@dimforge/rapier3d-compat';
|
|
|
18
17
|
export { RAPIER };
|
|
19
18
|
export { S as StageEntity } from './entity-Bq_eNEDI.js';
|
|
20
19
|
import 'bitecs';
|
|
20
|
+
import './entity-types-DAu8sGJH.js';
|
|
21
21
|
import '@sinclair/typebox';
|
|
22
22
|
import 'three/examples/jsm/postprocessing/EffectComposer.js';
|
|
23
|
+
import 'mitt';
|
|
24
|
+
import 'typescript-fsm';
|
|
23
25
|
|
|
24
26
|
declare const stageState: {
|
|
25
27
|
previous: StageBlueprint | null;
|
|
@@ -37,8 +39,8 @@ declare const StageManager: {
|
|
|
37
39
|
data?: {
|
|
38
40
|
[x: string]: any;
|
|
39
41
|
} | undefined;
|
|
40
|
-
id: string;
|
|
41
42
|
type: string;
|
|
43
|
+
id: string;
|
|
42
44
|
}[];
|
|
43
45
|
}>;
|
|
44
46
|
registerStaticStage(id: string, blueprint: StageBlueprint): void;
|
|
@@ -50,26 +52,38 @@ declare const StageManager: {
|
|
|
50
52
|
preloadNext(stageId: string, loadStaticStage?: (id: string) => Promise<StageBlueprint>): Promise<void>;
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
interface MovementSequence2DStep {
|
|
54
|
-
name: string;
|
|
55
|
-
moveX?: number;
|
|
56
|
-
moveY?: number;
|
|
57
|
-
timeInSeconds: number;
|
|
58
|
-
}
|
|
59
|
-
interface MovementSequence2DOptions {
|
|
60
|
-
sequence: MovementSequence2DStep[];
|
|
61
|
-
loop?: boolean;
|
|
62
|
-
}
|
|
63
|
-
type MovementSequence2DCallback = (current: MovementSequence2DStep, index: number, ctx: UpdateContext<MoveableEntity>) => void;
|
|
64
55
|
/**
|
|
65
|
-
*
|
|
66
|
-
* Each step sets linear velocity via `moveXY` for a duration, then advances.
|
|
67
|
-
* Defaults to looping when the end is reached.
|
|
56
|
+
* Factory interface for generating entity copies
|
|
68
57
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
interface TemplateFactory<E extends GameEntity<O>, O extends GameEntityOptions = GameEntityOptions> {
|
|
59
|
+
/** The template entity used for cloning */
|
|
60
|
+
readonly template: E;
|
|
61
|
+
/**
|
|
62
|
+
* Generate multiple copies of the template entity
|
|
63
|
+
* @param count Number of copies to generate
|
|
64
|
+
* @returns Array of new entity instances
|
|
65
|
+
*/
|
|
66
|
+
generate(count: number): E[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Create an entity factory from a template entity.
|
|
70
|
+
*
|
|
71
|
+
* @param template The entity to use as a template for cloning
|
|
72
|
+
* @returns Factory object with generate() method
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const asteroidTemplate = createSprite({ images: [{ name: 'asteroid', file: asteroidImg }] });
|
|
77
|
+
* const asteroidFactory = createEntityFactory(asteroidTemplate);
|
|
78
|
+
* const asteroids = asteroidFactory.generate(10);
|
|
79
|
+
*
|
|
80
|
+
* asteroids.forEach((asteroid, i) => {
|
|
81
|
+
* asteroid.setPosition(Math.random() * 20 - 10, Math.random() * 15 - 7.5, 0);
|
|
82
|
+
* stage.add(asteroid);
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
declare function createEntityFactory<E extends GameEntity<O>, O extends GameEntityOptions = GameEntityOptions>(template: E): TemplateFactory<E, O>;
|
|
73
87
|
|
|
74
88
|
declare function destroy(entity: any, globals?: any): void;
|
|
75
89
|
|
|
@@ -193,6 +207,10 @@ declare class ZylemGameElement extends HTMLElement {
|
|
|
193
207
|
private _state;
|
|
194
208
|
private container;
|
|
195
209
|
constructor();
|
|
210
|
+
/**
|
|
211
|
+
* Focus the game container for keyboard input
|
|
212
|
+
*/
|
|
213
|
+
focus(): void;
|
|
196
214
|
set game(game: Game<any>);
|
|
197
215
|
get game(): Game<any> | null;
|
|
198
216
|
set state(value: ZylemGameState);
|
|
@@ -208,4 +226,26 @@ declare class ZylemGameElement extends HTMLElement {
|
|
|
208
226
|
disconnectedCallback(): void;
|
|
209
227
|
}
|
|
210
228
|
|
|
211
|
-
|
|
229
|
+
declare const fireShader: {
|
|
230
|
+
vertex: string;
|
|
231
|
+
fragment: string;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
declare const starShader: {
|
|
235
|
+
vertex: string;
|
|
236
|
+
fragment: string;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
declare const standardShader: {
|
|
240
|
+
vertex: string;
|
|
241
|
+
fragment: string;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
declare const debugShader: {
|
|
245
|
+
vertex: string;
|
|
246
|
+
fragment: string;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
declare const objectVertexShader = "\nuniform vec2 uvScale;\nvarying vec2 vUv;\n\nvoid main() {\n\tvUv = uv;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n}\n";
|
|
250
|
+
|
|
251
|
+
export { type DebugTools, Game, StageBlueprint, StageManager, type TemplateFactory, ZylemGameElement, type ZylemGameState, clearGlobalSubscriptions, createEntityFactory, createGlobal, createVariable, debugShader, debugState, destroy, fireShader, getGlobal, getGlobals, getVariable, objectVertexShader, onGlobalChange, onGlobalChanges, onVariableChange, onVariableChanges, pingPongBeep, ricochetSound, setDebugTool, setGlobal, setPaused, setVariable, stageState, standardShader, starShader };
|