@skewedaspect/sage 0.9.5 → 0.10.0-beta.1
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/classes/debugConsole.d.ts +1 -0
- package/dist/classes/gameEngine.d.ts +24 -46
- package/dist/classes/gameLevel.d.ts +15 -12
- package/dist/classes/level.d.ts +5 -29
- package/dist/debug/builtins.d.ts +4 -0
- package/dist/entities/constants.d.ts +1 -0
- package/dist/entities/defineEntity.d.ts +17 -0
- package/dist/entities/entityPicking.d.ts +14 -0
- package/dist/entities/meshConfig.d.ts +14 -0
- package/dist/entities/nodeEntity.d.ts +33 -0
- package/dist/entities/nodePool.d.ts +8 -0
- package/dist/entities/nodeSimulation.d.ts +22 -0
- package/dist/entities/nodeSimulationContext.d.ts +13 -0
- package/dist/entities/standardMeshSource.d.ts +8 -0
- package/dist/events/payloads.d.ts +0 -30
- package/dist/events/types.d.ts +2 -23
- package/dist/input/actionContext.d.ts +11 -0
- package/dist/input/actionRegistry.d.ts +7 -0
- package/dist/input/binding.d.ts +31 -0
- package/dist/input/bindings/toggle.d.ts +21 -0
- package/dist/input/bindings/trigger.d.ts +19 -0
- package/dist/input/bindings/value.d.ts +23 -0
- package/dist/input/configuration.d.ts +15 -0
- package/dist/input/deliverAction.d.ts +3 -0
- package/dist/input/deviceReader.d.ts +5 -0
- package/dist/input/deviceReaders/gamepad.d.ts +9 -0
- package/dist/input/deviceReaders/keyboard.d.ts +8 -0
- package/dist/input/deviceReaders/mouse.d.ts +9 -0
- package/dist/input/deviceState.d.ts +19 -0
- package/dist/input/inputCapture.d.ts +21 -0
- package/dist/input/resolveBinding.d.ts +4 -0
- package/dist/interfaces/game.d.ts +20 -4
- package/dist/interfaces/level.d.ts +19 -1
- package/dist/managers/game.d.ts +8 -5
- package/dist/managers/level.d.ts +16 -4
- package/dist/managers/outline.d.ts +4 -4
- package/dist/managers/simulationSave.d.ts +30 -0
- package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-rr2DbgPi.js} +1 -1
- package/dist/{postProcessingFrameGraph-CaMgQzR-.js.map → postProcessingFrameGraph-rr2DbgPi.js.map} +1 -1
- package/dist/sage.d.ts +46 -16
- package/dist/sage.es.js +1441 -2470
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/utils/physics.d.ts +4 -1
- package/package.json +29 -66
- package/LICENSE +0 -21
- package/Readme.md +0 -73
- package/dist/behaviors/index.d.ts +0 -2
- package/dist/behaviors/sound.d.ts +0 -137
- package/dist/behaviors/stateMachine.d.ts +0 -76
- package/dist/classes/bindings/toggle.d.ts +0 -116
- package/dist/classes/bindings/trigger.d.ts +0 -81
- package/dist/classes/bindings/value.d.ts +0 -104
- package/dist/classes/entity.d.ts +0 -332
- package/dist/classes/input/gamepad.d.ts +0 -94
- package/dist/classes/input/keyboard.d.ts +0 -66
- package/dist/classes/input/mouse.d.ts +0 -91
- package/dist/classes/input/readers/gamepad.d.ts +0 -73
- package/dist/classes/input/readers/keyboard.d.ts +0 -56
- package/dist/classes/input/readers/mouse.d.ts +0 -41
- package/dist/interfaces/action.d.ts +0 -22
- package/dist/interfaces/binding.d.ts +0 -123
- package/dist/interfaces/entity.d.ts +0 -97
- package/dist/interfaces/input.d.ts +0 -180
- package/dist/managers/binding.d.ts +0 -233
- package/dist/managers/entity.d.ts +0 -256
- package/dist/managers/input.d.ts +0 -54
- package/dist/managers/save.d.ts +0 -75
- package/dist/utils/entityProxy.d.ts +0 -2
- package/dist/utils/raycast.d.ts +0 -26
package/dist/utils/physics.d.ts
CHANGED
|
@@ -5,8 +5,11 @@ import { HavokPlugin } from '@babylonjs/core';
|
|
|
5
5
|
*
|
|
6
6
|
* Each BabylonJS scene needs its own HavokPlugin instance (because scene.dispose() disposes the
|
|
7
7
|
* plugin attached to it). The raw WASM module can be shared across plugins safely.
|
|
8
|
+
*
|
|
9
|
+
* @param wasmBinary - Pre-loaded Havok WASM. Left unset, Havok fetches its own over HTTP, which
|
|
10
|
+
* only works in a browser.
|
|
8
11
|
*/
|
|
9
|
-
export declare function initHavok(): Promise<HavokPhysicsWithBindings>;
|
|
12
|
+
export declare function initHavok(wasmBinary?: BufferSource): Promise<HavokPhysicsWithBindings>;
|
|
10
13
|
/**
|
|
11
14
|
* Creates a new HavokPlugin from an existing WASM instance.
|
|
12
15
|
*/
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skewedaspect/sage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": true,
|
|
4
6
|
"main": "dist/sage.umd.js",
|
|
5
7
|
"module": "dist/sage.es.js",
|
|
6
8
|
"types": "dist/sage.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"sideEffects": true,
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/sage.d.ts",
|
|
@@ -14,87 +14,50 @@
|
|
|
14
14
|
"default": "./dist/sage.es.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://gitlab.com/skewed-aspect/sage/sage",
|
|
20
|
+
"directory": "packages/sage"
|
|
21
|
+
},
|
|
22
|
+
"author": "Christopher S. Case<chris.case@g33xnexus.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"description": "A modern JavaScript/TypeScript game engine built on top of BabylonJS that provides simplified abstractions for 3D game development.",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"engine",
|
|
27
|
+
"babylonjs",
|
|
28
|
+
"babylon.js",
|
|
29
|
+
"game"
|
|
21
30
|
],
|
|
22
31
|
"scripts": {
|
|
23
32
|
"build": "vite build",
|
|
24
33
|
"dev": "vite",
|
|
25
|
-
"
|
|
26
|
-
"examples:build": "vite build --config examples/vite.config.ts",
|
|
27
|
-
"docs": "npm run examples:build -- --base /examples/ && rm -rf site/docs/public/examples && cp -r examples/dist site/docs/public/examples && cd site && npx vitepress dev docs",
|
|
28
|
-
"docs:build": "npm run examples:build -- --base /examples/ && node scripts/examples-spa-fallback.mjs && rm -rf site/docs/public/examples && cp -r examples/dist site/docs/public/examples && cd site && npx vitepress build docs",
|
|
29
|
-
"test": "vitest run",
|
|
30
|
-
"test:watch": "vitest",
|
|
34
|
+
"test": "vitest run --config vitest.config.ts",
|
|
31
35
|
"test:e2e": "playwright test",
|
|
32
36
|
"test:e2e:ui": "playwright test --ui",
|
|
33
|
-
"
|
|
34
|
-
"test:bench:id": "node ./benchmark/id-generation.bench.ts",
|
|
35
|
-
"lint": "eslint \"{src,tests,benchmark}/**/*.{ts,js,vue}\" --max-warnings=0 --no-warn-ignored",
|
|
36
|
-
"lint:staged": "lint-staged",
|
|
37
|
-
"prepare": "if-env NODE_ENV=production && exit 0 || husky",
|
|
38
|
-
"release": "bash scripts/release.sh"
|
|
37
|
+
"lint:types": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tests/tsconfig.json"
|
|
39
38
|
},
|
|
40
39
|
"files": [
|
|
41
40
|
"dist"
|
|
42
41
|
],
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@skewedaspect/sage-core": "*",
|
|
44
|
+
"hexoid": "^2.0.0",
|
|
45
|
+
"js-yaml": "^4.1.1"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@babylonjs/core": "^9.0.0",
|
|
49
|
+
"@babylonjs/havok": "^1.3.10",
|
|
50
|
+
"@babylonjs/loaders": "^9.0.0"
|
|
52
51
|
},
|
|
53
|
-
"author": "Christopher S. Case<chris.case@g33xnexus.com>",
|
|
54
|
-
"license": "MIT",
|
|
55
|
-
"description": "A modern JavaScript/TypeScript game engine built on top of BabylonJS that provides simplified abstractions for 3D game development.",
|
|
56
52
|
"devDependencies": {
|
|
57
53
|
"@babylonjs/core": "^9.0.0",
|
|
58
54
|
"@babylonjs/havok": "^1.3.12",
|
|
59
55
|
"@babylonjs/loaders": "^9.0.0",
|
|
60
|
-
"@eslint/js": "^10.0.1",
|
|
61
56
|
"@playwright/test": "^1.58.0",
|
|
62
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
63
|
-
"@types/eslint__js": "^8.42.3",
|
|
64
57
|
"@types/js-yaml": "^4.0.9",
|
|
65
|
-
"@types/node": "^25.5.0",
|
|
66
|
-
"@types/sinon": "^21.0.0",
|
|
67
|
-
"eslint": "^10.1.0",
|
|
68
|
-
"eslint-formatter-junit": "^9.0.1",
|
|
69
|
-
"husky": "^9.1.7",
|
|
70
|
-
"if-env": "^1.0.4",
|
|
71
|
-
"jsdom": "^29.0.1",
|
|
72
|
-
"lint-staged": "^16.4.0",
|
|
73
|
-
"sinon": "^21.0.3",
|
|
74
|
-
"tinybench": "^6.0.0",
|
|
75
|
-
"tslib": "^2.8.1",
|
|
76
58
|
"typescript": "^6.0.2",
|
|
77
|
-
"typescript-eslint": "^8.29.0",
|
|
78
|
-
"uid": "^2.0.2",
|
|
79
59
|
"vite": "^8.0.3",
|
|
80
|
-
"vite-plugin-
|
|
81
|
-
"
|
|
82
|
-
},
|
|
83
|
-
"lint-staged": {
|
|
84
|
-
"*.{ts,js}": "npm run lint"
|
|
85
|
-
},
|
|
86
|
-
"peerDependencies": {
|
|
87
|
-
"@babylonjs/core": "^9.0.0",
|
|
88
|
-
"@babylonjs/havok": "^1.3.10",
|
|
89
|
-
"@babylonjs/loaders": "^9.0.0"
|
|
90
|
-
},
|
|
91
|
-
"overrides": {
|
|
92
|
-
"typescript-eslint": {
|
|
93
|
-
"typescript": "$typescript"
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
"dependencies": {
|
|
97
|
-
"hexoid": "^2.0.0",
|
|
98
|
-
"js-yaml": "^4.1.1"
|
|
60
|
+
"vite-plugin-checker": "^0.12.0",
|
|
61
|
+
"vite-plugin-dts": "^4.5.4"
|
|
99
62
|
}
|
|
100
63
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Christopher Case
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/Readme.md
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# SkewedAspect Game Engine (SAGE)
|
|
3
|
-
|
|
4
|
-
<div align="center">
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
The SkewedAspect Game Engine (SAGE) is a powerful and flexible game engine designed for creating 2D and 3D games. It leverages BabylonJS for rendering and Havok for physics simulation.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
To install the SAGE library, use npm:
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
npm install @skewedaspect/sage
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Usage
|
|
20
|
-
|
|
21
|
-
### Creating a Game Engine Instance
|
|
22
|
-
|
|
23
|
-
To create an instance of the SkewedAspect Game Engine, you need to provide a game canvas and rendering options.
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { createGameEngine, GameCanvas, RenderEngineOptions } from '@skewedaspect/sage';
|
|
27
|
-
|
|
28
|
-
const canvas: GameCanvas = document.getElementById('gameCanvas') as HTMLCanvasElement;
|
|
29
|
-
const renderOptions: RenderEngineOptions = {
|
|
30
|
-
// ...your rendering options...
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const gameEngine = await createGameEngine(canvas, renderOptions);
|
|
34
|
-
|
|
35
|
-
// Start the game engine
|
|
36
|
-
gameEngine.start();
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Stopping the Game Engine
|
|
40
|
-
|
|
41
|
-
To stop the game engine, simply call the `stop` method on the game engine instance.
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
gameEngine.stop();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Releasing
|
|
48
|
-
|
|
49
|
-
Releases are done locally via the release script, which bumps the version, stamps the changelog, commits, tags,
|
|
50
|
-
and pushes. CI then auto-publishes to npm when it sees the version tag.
|
|
51
|
-
|
|
52
|
-
```sh
|
|
53
|
-
npm run release -- patch # 0.8.0 -> 0.8.1
|
|
54
|
-
npm run release -- minor # 0.8.0 -> 0.9.0
|
|
55
|
-
npm run release -- major # 0.8.0 -> 1.0.0
|
|
56
|
-
npm run release -- prerelease --preid=beta # 0.9.0 -> 0.9.1-beta.0
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Requirements:
|
|
60
|
-
- Clean working tree (commit or stash first)
|
|
61
|
-
- On the `main` branch
|
|
62
|
-
- GitLab CI needs `NPM_ID_TOKEN` OIDC configured for npm provenance publishing
|
|
63
|
-
|
|
64
|
-
The script publishes both `@skewedaspect/sage` and `@skewedaspect/sage-vue` at the same version. Prereleases are
|
|
65
|
-
tagged as `next` on npm.
|
|
66
|
-
|
|
67
|
-
## Contributing
|
|
68
|
-
|
|
69
|
-
Contributions are welcome! Please open an issue or submit a merge request on GitLab.
|
|
70
|
-
|
|
71
|
-
## License
|
|
72
|
-
|
|
73
|
-
This project is licensed under the MIT License.
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { TransformNode } from '@babylonjs/core';
|
|
2
|
-
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
3
|
-
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
4
|
-
import { GameEvent } from "../classes/eventBus.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for a single sound.
|
|
7
|
-
*/
|
|
8
|
-
export interface SoundConfig {
|
|
9
|
-
/** Path to the sound file */
|
|
10
|
-
url: string;
|
|
11
|
-
/** Volume level (0-1), default 1 */
|
|
12
|
-
volume?: number;
|
|
13
|
-
/** Whether to loop the sound, default false */
|
|
14
|
-
loop?: boolean;
|
|
15
|
-
/** Whether to use spatial 3D audio, default false */
|
|
16
|
-
spatial?: boolean;
|
|
17
|
-
/** Maximum distance for spatial audio, default 100 */
|
|
18
|
-
maxDistance?: number;
|
|
19
|
-
/** Whether to autoplay when registered, default false */
|
|
20
|
-
autoplay?: boolean;
|
|
21
|
-
/** Audio channel name (e.g., 'sfx', 'music'). Used with AudioManager. */
|
|
22
|
-
channel?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* State interface for entities using SoundBehavior.
|
|
26
|
-
* Entity state should include a `sounds` property with sound configurations.
|
|
27
|
-
*/
|
|
28
|
-
export interface SoundEntityState {
|
|
29
|
-
/** Map of sound name to configuration */
|
|
30
|
-
sounds?: Record<string, SoundConfig>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Behavior for managing sounds on an entity.
|
|
34
|
-
*
|
|
35
|
-
* Sounds are configured in the entity's state under the `sounds` property.
|
|
36
|
-
* The behavior creates sounds via AudioManager (BabylonJS AudioV2).
|
|
37
|
-
*
|
|
38
|
-
* Requires AudioManager to be configured on the GameEngine. If no AudioManager is found,
|
|
39
|
-
* a warning is logged and no sounds are created.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* // Entity definition
|
|
44
|
-
* {
|
|
45
|
-
* type: 'player',
|
|
46
|
-
* behaviors: [SoundBehavior, ...],
|
|
47
|
-
* defaultState: {
|
|
48
|
-
* sounds: {
|
|
49
|
-
* jump: { url: 'sounds/jump.mp3', volume: 0.8, channel: 'sfx' },
|
|
50
|
-
* footstep: { url: 'sounds/footstep.mp3', loop: true, channel: 'sfx' }
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* // In another behavior, get the sound behavior and control sounds
|
|
56
|
-
* const soundBehavior = entity.getBehavior(SoundBehavior);
|
|
57
|
-
* soundBehavior?.play('jump');
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare class SoundBehavior extends GameEntityBehavior<SoundEntityState> {
|
|
61
|
-
name: string;
|
|
62
|
-
eventSubscriptions: string[];
|
|
63
|
-
/** Map of sound name to StaticSound instance */
|
|
64
|
-
private _sounds;
|
|
65
|
-
/** Whether sounds have been initialized */
|
|
66
|
-
private _initialized;
|
|
67
|
-
/** AudioManager reference */
|
|
68
|
-
private _audioManager;
|
|
69
|
-
/** Node reference for spatial detach on cleanup */
|
|
70
|
-
private _node;
|
|
71
|
-
private _log;
|
|
72
|
-
onNodeAttached(node: TransformNode, gameEngine: GameEngine): void;
|
|
73
|
-
processEvent(_event: GameEvent, _state: SoundEntityState): boolean;
|
|
74
|
-
onReset(_state: SoundEntityState): void;
|
|
75
|
-
destroy(): Promise<void>;
|
|
76
|
-
private _createSound;
|
|
77
|
-
private _disposeSounds;
|
|
78
|
-
/**
|
|
79
|
-
* Play a sound by name.
|
|
80
|
-
*
|
|
81
|
-
* @param name - The name of the sound to play. If omitted and only one sound exists, plays that sound.
|
|
82
|
-
* @param time - Optional time offset in seconds to start playing from
|
|
83
|
-
*/
|
|
84
|
-
play(name?: string, time?: number): void;
|
|
85
|
-
/**
|
|
86
|
-
* Stop a sound by name.
|
|
87
|
-
*
|
|
88
|
-
* @param name - The name of the sound to stop. If omitted, stops all sounds.
|
|
89
|
-
*/
|
|
90
|
-
stop(name?: string): void;
|
|
91
|
-
/**
|
|
92
|
-
* Pause a sound by name.
|
|
93
|
-
*
|
|
94
|
-
* @param name - The name of the sound to pause. If omitted and only one sound exists, pauses that sound.
|
|
95
|
-
*/
|
|
96
|
-
pause(name?: string): void;
|
|
97
|
-
/**
|
|
98
|
-
* Set the volume of a sound.
|
|
99
|
-
*
|
|
100
|
-
* @param volume - Volume level (0-1)
|
|
101
|
-
* @param name - The name of the sound. If omitted, sets volume for all sounds.
|
|
102
|
-
*/
|
|
103
|
-
setVolume(volume: number, name?: string): void;
|
|
104
|
-
/**
|
|
105
|
-
* Check if a sound is currently playing.
|
|
106
|
-
*
|
|
107
|
-
* @param name - The name of the sound. If omitted and only one sound exists, checks that sound.
|
|
108
|
-
*/
|
|
109
|
-
isPlaying(name?: string): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Get all registered sound names.
|
|
112
|
-
*/
|
|
113
|
-
getSoundNames(): string[];
|
|
114
|
-
/**
|
|
115
|
-
* Check if a sound with the given name exists.
|
|
116
|
-
*
|
|
117
|
-
* @param name
|
|
118
|
-
*/
|
|
119
|
-
hasSound(name: string): boolean;
|
|
120
|
-
/**
|
|
121
|
-
* Register a new sound at runtime. Replaces any existing sound with the same name.
|
|
122
|
-
*
|
|
123
|
-
* @param name
|
|
124
|
-
* @param config
|
|
125
|
-
*/
|
|
126
|
-
registerSound(name: string, config: SoundConfig): void;
|
|
127
|
-
/**
|
|
128
|
-
* Unregister and dispose a sound.
|
|
129
|
-
*
|
|
130
|
-
* @param name
|
|
131
|
-
*/
|
|
132
|
-
unregisterSound(name: string): void;
|
|
133
|
-
/**
|
|
134
|
-
* Get a sound by name. If name is omitted and only one sound exists, returns that sound.
|
|
135
|
-
*/
|
|
136
|
-
private _getSound;
|
|
137
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
2
|
-
import { GameEvent } from "../classes/eventBus.d.ts";
|
|
3
|
-
import { StateMachine } from "../utils/stateMachine.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* A single transition definition for the state machine behavior configuration.
|
|
6
|
-
*/
|
|
7
|
-
export interface TransitionConfig<States extends string> {
|
|
8
|
-
from: States;
|
|
9
|
-
to: States;
|
|
10
|
-
guard?: () => boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A wildcard transition definition (from any state).
|
|
14
|
-
*/
|
|
15
|
-
export interface WildcardTransitionConfig<States extends string> {
|
|
16
|
-
to: States;
|
|
17
|
-
guard?: () => boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Configuration for creating a StateMachineBehavior subclass.
|
|
21
|
-
*/
|
|
22
|
-
export interface StateMachineBehaviorConfig<States extends string, EntityState extends object> {
|
|
23
|
-
/** The initial state of the state machine. */
|
|
24
|
-
initialState: States;
|
|
25
|
-
/** The key in the entity's state object to update when state changes. */
|
|
26
|
-
stateKey: keyof EntityState & string;
|
|
27
|
-
/** Valid transitions between states. */
|
|
28
|
-
transitions: TransitionConfig<States>[];
|
|
29
|
-
/** Wildcard transitions (from any state). */
|
|
30
|
-
wildcardTransitions?: WildcardTransitionConfig<States>[];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* A behavior that wraps a {@link StateMachine} and ties it to entity state.
|
|
34
|
-
*
|
|
35
|
-
* Since behaviors are instantiated with `new BehaviorClass()` (no constructor args),
|
|
36
|
-
* use the static factory `StateMachineBehavior.create(config)` to produce a configured subclass.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const EnemyAI = StateMachineBehavior.create<EnemyStates, EnemyState>({
|
|
41
|
-
* initialState: 'idle',
|
|
42
|
-
* stateKey: 'aiState',
|
|
43
|
-
* transitions: [
|
|
44
|
-
* { from: 'idle', to: 'patrol' },
|
|
45
|
-
* { from: 'patrol', to: 'chase' },
|
|
46
|
-
* { from: 'chase', to: 'attack' },
|
|
47
|
-
* ],
|
|
48
|
-
* wildcardTransitions: [
|
|
49
|
-
* { to: 'dead' },
|
|
50
|
-
* ],
|
|
51
|
-
* });
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare class StateMachineBehavior<States extends string = string, EntityState extends object = object> extends GameEntityBehavior<EntityState> {
|
|
55
|
-
name: string;
|
|
56
|
-
eventSubscriptions: string[];
|
|
57
|
-
protected stateMachine: StateMachine<States>;
|
|
58
|
-
protected stateKey: keyof EntityState & string;
|
|
59
|
-
protected constructor();
|
|
60
|
-
/**
|
|
61
|
-
* The current state of the state machine.
|
|
62
|
-
*/
|
|
63
|
-
get currentState(): States;
|
|
64
|
-
/**
|
|
65
|
-
* Transition to a new state. Updates the entity's state and emits a state changed event.
|
|
66
|
-
*
|
|
67
|
-
* @throws If the transition is not defined or a guard rejects it.
|
|
68
|
-
*/
|
|
69
|
-
transition(to: States): void;
|
|
70
|
-
processEvent(_event: GameEvent, _state: EntityState): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a configured StateMachineBehavior subclass with the given state machine configuration baked in.
|
|
73
|
-
* The returned class can be used directly as a behavior constructor.
|
|
74
|
-
*/
|
|
75
|
-
static create<States extends string, EntityState extends object>(config: StateMachineBehaviorConfig<States, EntityState>): new () => StateMachineBehavior<States, EntityState>;
|
|
76
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../eventBus.d.ts";
|
|
2
|
-
import { Action } from "../../interfaces/action.d.ts";
|
|
3
|
-
import { Binding, ToggleBindingDefinition } from "../../interfaces/binding.d.ts";
|
|
4
|
-
import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Options for configuring a toggle binding
|
|
7
|
-
*/
|
|
8
|
-
export interface ToggleBindingOptions {
|
|
9
|
-
/**
|
|
10
|
-
* If true, toggle on falling edge (true -> false) instead of rising edge (false -> true)
|
|
11
|
-
*/
|
|
12
|
-
invert?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Initial toggle state (defaults to false - off)
|
|
15
|
-
*/
|
|
16
|
-
initialState?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Threshold for analog inputs (0.0 to 1.0)
|
|
19
|
-
* When input value is >= threshold, it's considered "active" (true)
|
|
20
|
-
* When input value is < threshold, it's considered "inactive" (false)
|
|
21
|
-
* Defaults to 0.5 for analog inputs
|
|
22
|
-
*/
|
|
23
|
-
threshold?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Value to emit when the toggle is in the "on" state for digital actions
|
|
26
|
-
* If undefined, will emit boolean true
|
|
27
|
-
* Ignored for analog actions
|
|
28
|
-
*/
|
|
29
|
-
onValue?: boolean | number;
|
|
30
|
-
/**
|
|
31
|
-
* Value to emit when the toggle is in the "off" state for digital actions
|
|
32
|
-
* If undefined, will emit boolean false
|
|
33
|
-
* Ignored for analog actions
|
|
34
|
-
*/
|
|
35
|
-
offValue?: boolean | number;
|
|
36
|
-
/**
|
|
37
|
-
* Optional context name this binding belongs to
|
|
38
|
-
*/
|
|
39
|
-
context?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Implementation of a toggle binding, which maintains and toggles state between true/false
|
|
43
|
-
* when a button/key is pressed or released, remaining in that state until toggled again.
|
|
44
|
-
* Can handle both digital and analog inputs with configurable threshold.
|
|
45
|
-
* Can output either digital or analog values based on the action type.
|
|
46
|
-
*/
|
|
47
|
-
export declare class ToggleBinding implements Binding {
|
|
48
|
-
readonly type: "toggle";
|
|
49
|
-
readonly action: Action;
|
|
50
|
-
readonly context?: string;
|
|
51
|
-
readonly deviceID: string;
|
|
52
|
-
readonly deviceType: DeviceType;
|
|
53
|
-
readonly reader: DeviceValueReader;
|
|
54
|
-
private readonly _invert;
|
|
55
|
-
private readonly _threshold;
|
|
56
|
-
private readonly _initialState;
|
|
57
|
-
private readonly _onValue;
|
|
58
|
-
private readonly _offValue;
|
|
59
|
-
private _lastDigitalState;
|
|
60
|
-
private _toggleState;
|
|
61
|
-
/**
|
|
62
|
-
* Get the current toggle state (true = on, false = off)
|
|
63
|
-
*/
|
|
64
|
-
get state(): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Set the toggle state directly (useful for programmatic control)
|
|
67
|
-
*/
|
|
68
|
-
set state(value: boolean);
|
|
69
|
-
/**
|
|
70
|
-
* Get the value emitted when toggle is in the "on" state
|
|
71
|
-
*/
|
|
72
|
-
get onValue(): boolean | number;
|
|
73
|
-
/**
|
|
74
|
-
* Get the value emitted when toggle is in the "off" state
|
|
75
|
-
*/
|
|
76
|
-
get offValue(): boolean | number;
|
|
77
|
-
/**
|
|
78
|
-
* Get the current value based on toggle state.
|
|
79
|
-
* For analog actions, returns min/max value. For digital, returns on/off value.
|
|
80
|
-
*/
|
|
81
|
-
get value(): boolean | number;
|
|
82
|
-
/**
|
|
83
|
-
* Get the current options for this toggle binding.
|
|
84
|
-
*/
|
|
85
|
-
get options(): ToggleBindingOptions;
|
|
86
|
-
/**
|
|
87
|
-
* Create a new toggle binding
|
|
88
|
-
*
|
|
89
|
-
* @param action
|
|
90
|
-
* @param deviceID
|
|
91
|
-
* @param deviceType
|
|
92
|
-
* @param reader
|
|
93
|
-
* @param options
|
|
94
|
-
*/
|
|
95
|
-
constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: ToggleBindingOptions);
|
|
96
|
-
/**
|
|
97
|
-
* Process input state and emit an action event if the toggle flipped.
|
|
98
|
-
*
|
|
99
|
-
* @param state
|
|
100
|
-
* @param eventBus
|
|
101
|
-
*/
|
|
102
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
103
|
-
/**
|
|
104
|
-
* Reset edge-detection state for a context activation. When a state is provided, primes from the current physical
|
|
105
|
-
* input so that already-held inputs don't produce phantom edges in the newly activated context.
|
|
106
|
-
*/
|
|
107
|
-
resetEdgeState(state?: InputState): void;
|
|
108
|
-
/**
|
|
109
|
-
* Reset toggle to its initial state
|
|
110
|
-
*/
|
|
111
|
-
reset(): void;
|
|
112
|
-
/**
|
|
113
|
-
* Returns a JSON-serializable representation of this toggle binding.
|
|
114
|
-
*/
|
|
115
|
-
toJSON(): ToggleBindingDefinition;
|
|
116
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { GameEventBus } from "../eventBus.d.ts";
|
|
2
|
-
import { Action } from "../../interfaces/action.d.ts";
|
|
3
|
-
import { Binding, TriggerBindingDefinition } from "../../interfaces/binding.d.ts";
|
|
4
|
-
import { DeviceType, DeviceValueReader, InputState } from "../../interfaces/input.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* All supported edge modes for validation
|
|
7
|
-
*/
|
|
8
|
-
export declare const edgeModes: readonly ["rising", "falling", "both"];
|
|
9
|
-
/**
|
|
10
|
-
* Defines when a trigger binding will fire based on input state changes
|
|
11
|
-
*/
|
|
12
|
-
export type EdgeMode = typeof edgeModes[number];
|
|
13
|
-
/**
|
|
14
|
-
* Options for configuring a trigger binding
|
|
15
|
-
*/
|
|
16
|
-
export interface TriggerBindingOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Which edge(s) should cause the trigger to fire
|
|
19
|
-
* - 'rising': Only trigger on false -> true transitions
|
|
20
|
-
* - 'falling': Only trigger on true -> false transitions
|
|
21
|
-
* - 'both': Trigger on any state change
|
|
22
|
-
*/
|
|
23
|
-
edgeMode?: EdgeMode;
|
|
24
|
-
/**
|
|
25
|
-
* Threshold for analog inputs (0.0 to 1.0)
|
|
26
|
-
* When input value is >= threshold, it's considered "active" (true)
|
|
27
|
-
* When input value is < threshold, it's considered "inactive" (false)
|
|
28
|
-
* Defaults to 0.5 for analog inputs
|
|
29
|
-
*/
|
|
30
|
-
threshold?: number;
|
|
31
|
-
/**
|
|
32
|
-
* Optional context name this binding belongs to
|
|
33
|
-
*/
|
|
34
|
-
context?: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Implementation of a trigger binding, which emits an action when a button/key is pressed or released.
|
|
38
|
-
* Can handle both digital and analog inputs with configurable threshold.
|
|
39
|
-
* Can output either digital or analog values based on the action type.
|
|
40
|
-
*/
|
|
41
|
-
export declare class TriggerBinding implements Binding {
|
|
42
|
-
readonly type: "trigger";
|
|
43
|
-
readonly action: Action;
|
|
44
|
-
readonly context?: string;
|
|
45
|
-
readonly deviceID: string;
|
|
46
|
-
readonly deviceType: DeviceType;
|
|
47
|
-
readonly reader: DeviceValueReader;
|
|
48
|
-
private readonly _edgeMode;
|
|
49
|
-
private readonly _threshold;
|
|
50
|
-
private _lastDigitalState;
|
|
51
|
-
/**
|
|
52
|
-
* Get the current options for this trigger binding.
|
|
53
|
-
*/
|
|
54
|
-
get options(): TriggerBindingOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new trigger binding
|
|
57
|
-
*
|
|
58
|
-
* @param action
|
|
59
|
-
* @param deviceID
|
|
60
|
-
* @param deviceType
|
|
61
|
-
* @param reader
|
|
62
|
-
* @param options
|
|
63
|
-
*/
|
|
64
|
-
constructor(action: Action, deviceID: string, deviceType: DeviceType, reader: DeviceValueReader, options?: TriggerBindingOptions);
|
|
65
|
-
/**
|
|
66
|
-
* Process input state and emit an action event on the configured edge transition(s).
|
|
67
|
-
*
|
|
68
|
-
* @param state
|
|
69
|
-
* @param eventBus
|
|
70
|
-
*/
|
|
71
|
-
process(state: InputState, eventBus: GameEventBus): void;
|
|
72
|
-
/**
|
|
73
|
-
* Reset edge-detection state for a context activation. When a state is provided, primes from the current physical
|
|
74
|
-
* input so that already-held inputs don't produce phantom rising edges in the newly activated context.
|
|
75
|
-
*/
|
|
76
|
-
resetEdgeState(state?: InputState): void;
|
|
77
|
-
/**
|
|
78
|
-
* Returns a JSON-serializable representation of this trigger binding.
|
|
79
|
-
*/
|
|
80
|
-
toJSON(): TriggerBindingDefinition;
|
|
81
|
-
}
|