@skewedaspect/sage 0.9.0-beta.1 → 0.9.0-beta.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/abstractAudioBus-C4O1vkCH.js +15 -0
- package/dist/abstractAudioBus-C4O1vkCH.js.map +1 -0
- package/dist/abstractSoundInstance-Ojv9HUsA.js +156 -0
- package/dist/abstractSoundInstance-Ojv9HUsA.js.map +1 -0
- package/dist/abstractSoundSource-B4K-9snf.js +49 -0
- package/dist/abstractSoundSource-B4K-9snf.js.map +1 -0
- package/dist/behaviors/sound.d.ts +18 -21
- package/dist/classes/entity.d.ts +6 -2
- package/dist/classes/gameEngine.d.ts +6 -2
- package/dist/classes/level.d.ts +3 -10
- package/dist/engines/audio.d.ts +19 -0
- package/dist/engines/scene.d.ts +1 -14
- package/dist/handlers/sound.d.ts +1 -0
- package/dist/interfaces/game.d.ts +2 -0
- package/dist/interfaces/level.d.ts +4 -16
- package/dist/managers/audio.d.ts +31 -0
- package/dist/managers/entity.d.ts +9 -0
- package/dist/managers/level.d.ts +8 -7
- package/dist/sage-xiX6P4Dl.js +11925 -0
- package/dist/sage-xiX6P4Dl.js.map +1 -0
- package/dist/sage.d.ts +4 -1
- package/dist/sage.es.js +38 -4866
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +4 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/spatialWebAudio-CUPyGUDC.js +475 -0
- package/dist/spatialWebAudio-CUPyGUDC.js.map +1 -0
- package/dist/webAudioBaseSubGraph-KtziJf_K.js +465 -0
- package/dist/webAudioBaseSubGraph-KtziJf_K.js.map +1 -0
- package/dist/webAudioBus-BO_GcV0u.js +89 -0
- package/dist/webAudioBus-BO_GcV0u.js.map +1 -0
- package/dist/webAudioMainBus-DR3wyocY.js +50 -0
- package/dist/webAudioMainBus-DR3wyocY.js.map +1 -0
- package/dist/webAudioSoundSource-DBhSP5-M.js +56 -0
- package/dist/webAudioSoundSource-DBhSP5-M.js.map +1 -0
- package/dist/webAudioStaticSound-CEj-2W9T.js +346 -0
- package/dist/webAudioStaticSound-CEj-2W9T.js.map +1 -0
- package/dist/webAudioStreamingSound-DaKxJI43.js +1900 -0
- package/dist/webAudioStreamingSound-DaKxJI43.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { A as o } from "./webAudioBaseSubGraph-KtziJf_K.js";
|
|
2
|
+
class A extends o {
|
|
3
|
+
constructor(s, t) {
|
|
4
|
+
super(
|
|
5
|
+
s,
|
|
6
|
+
t,
|
|
7
|
+
3
|
|
8
|
+
/* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
A
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=abstractAudioBus-C4O1vkCH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractAudioBus-C4O1vkCH.js","sources":["../node_modules/@babylonjs/core/AudioV2/abstractAudio/abstractAudioBus.js"],"sourcesContent":["import { AbstractAudioOutNode } from \"./abstractAudioOutNode.js\";\n/**\n * Abstract class representing an audio bus with volume control.\n *\n * An audio bus is a node in the audio graph that can have multiple inputs and outputs. It is typically used to group\n * sounds together and apply effects to them.\n */\nexport class AbstractAudioBus extends AbstractAudioOutNode {\n constructor(name, engine) {\n super(name, engine, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */);\n }\n}\n//# sourceMappingURL=abstractAudioBus.js.map"],"names":["AbstractAudioBus","AbstractAudioOutNode","name","engine"],"mappings":";AAOO,MAAMA,UAAyBC,EAAqB;AAAA,EACvD,YAAYC,GAAMC,GAAQ;AACtB;AAAA,MAAMD;AAAA,MAAMC;AAAA,MAAQ;AAAA;AAAA,IAAC;AAAA,EACzB;AACJ;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { O as i, A as r } from "./sage-xiX6P4Dl.js";
|
|
2
|
+
import { A as o } from "./abstractSoundSource-B4K-9snf.js";
|
|
3
|
+
class _ extends o {
|
|
4
|
+
constructor(t, s, e) {
|
|
5
|
+
super(
|
|
6
|
+
t,
|
|
7
|
+
s,
|
|
8
|
+
e,
|
|
9
|
+
3
|
|
10
|
+
/* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */
|
|
11
|
+
), this._newestInstance = null, this._privateInstances = /* @__PURE__ */ new Set(), this._state = 1, this._instances = this._privateInstances, this.onEndedObservable = new i(), this._onInstanceEnded = (n) => {
|
|
12
|
+
this._newestInstance === n && (this._newestInstance = null), this._privateInstances.delete(n), this._instances.size === 0 && (this._state = 1, this.onEndedObservable.notifyObservers(this)), n.dispose();
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The number of active instances of the sound that are currently playing.
|
|
17
|
+
*/
|
|
18
|
+
get activeInstancesCount() {
|
|
19
|
+
return this._instances.size;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Whether the sound should start playing automatically. Defaults to `false`.
|
|
23
|
+
*/
|
|
24
|
+
get autoplay() {
|
|
25
|
+
return this._options.autoplay;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The current playback time of the sound, in seconds.
|
|
29
|
+
*/
|
|
30
|
+
get currentTime() {
|
|
31
|
+
const t = this._getNewestInstance();
|
|
32
|
+
return t ? t.currentTime : 0;
|
|
33
|
+
}
|
|
34
|
+
set currentTime(t) {
|
|
35
|
+
this.startOffset = t;
|
|
36
|
+
const s = this._getNewestInstance();
|
|
37
|
+
s && (s.currentTime = t);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Whether the sound should loop. Defaults to `false`.
|
|
41
|
+
*/
|
|
42
|
+
get loop() {
|
|
43
|
+
return this._options.loop;
|
|
44
|
+
}
|
|
45
|
+
set loop(t) {
|
|
46
|
+
this._options.loop = t;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The maximum number of instances that can play at the same time. Defaults to `Infinity`.
|
|
50
|
+
*/
|
|
51
|
+
get maxInstances() {
|
|
52
|
+
return this._options.maxInstances;
|
|
53
|
+
}
|
|
54
|
+
set maxInstances(t) {
|
|
55
|
+
this._options.maxInstances = t;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The time within the sound buffer to start playing at, in seconds. Defaults to `0`.
|
|
59
|
+
*/
|
|
60
|
+
get startOffset() {
|
|
61
|
+
return this._options.startOffset;
|
|
62
|
+
}
|
|
63
|
+
set startOffset(t) {
|
|
64
|
+
this._options.startOffset = t;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The state of the sound.
|
|
68
|
+
*/
|
|
69
|
+
get state() {
|
|
70
|
+
return this._state;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Releases associated resources.
|
|
74
|
+
*/
|
|
75
|
+
dispose() {
|
|
76
|
+
super.dispose(), this.stop(), this._newestInstance = null, this._privateInstances.clear(), this.onEndedObservable.clear();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Pauses the sound.
|
|
80
|
+
*/
|
|
81
|
+
pause() {
|
|
82
|
+
const t = this._instances.values();
|
|
83
|
+
for (let s = t.next(); !s.done; s = t.next())
|
|
84
|
+
s.value.pause();
|
|
85
|
+
this._state = 5;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Resumes the sound.
|
|
89
|
+
*/
|
|
90
|
+
resume() {
|
|
91
|
+
if (this._state !== 5)
|
|
92
|
+
return;
|
|
93
|
+
const t = this._instances.values();
|
|
94
|
+
for (let s = t.next(); !s.done; s = t.next())
|
|
95
|
+
s.value.resume();
|
|
96
|
+
this._state = 3;
|
|
97
|
+
}
|
|
98
|
+
_beforePlay(t) {
|
|
99
|
+
if (this.state === 5 && this._instances.size > 0) {
|
|
100
|
+
this.resume();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
t.onEndedObservable.addOnce(this._onInstanceEnded), this._privateInstances.add(t), this._newestInstance = t;
|
|
104
|
+
}
|
|
105
|
+
_afterPlay(t) {
|
|
106
|
+
this._state = t.state;
|
|
107
|
+
}
|
|
108
|
+
_getNewestInstance() {
|
|
109
|
+
if (this._instances.size === 0)
|
|
110
|
+
return null;
|
|
111
|
+
if (!this._newestInstance) {
|
|
112
|
+
const t = this._instances.values();
|
|
113
|
+
for (let s = t.next(); !s.done; s = t.next())
|
|
114
|
+
this._newestInstance = s.value;
|
|
115
|
+
}
|
|
116
|
+
return this._newestInstance;
|
|
117
|
+
}
|
|
118
|
+
_setState(t) {
|
|
119
|
+
this._state = t;
|
|
120
|
+
}
|
|
121
|
+
_stopExcessInstances() {
|
|
122
|
+
if (this.maxInstances < 1 / 0) {
|
|
123
|
+
const t = Array.from(this._instances).filter(
|
|
124
|
+
(e) => e.state === 3
|
|
125
|
+
/* SoundState.Started */
|
|
126
|
+
).length - this.maxInstances, s = this._instances.values();
|
|
127
|
+
for (let e = 0; e < t; e++)
|
|
128
|
+
s.next().value.stop();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
class l extends r {
|
|
133
|
+
constructor(t) {
|
|
134
|
+
super(
|
|
135
|
+
t.engine,
|
|
136
|
+
2
|
|
137
|
+
/* AudioNodeType.HAS_OUTPUTS */
|
|
138
|
+
), this._state = 1, this.onEndedObservable = new i(), this.onErrorObservable = new i(), this.onStateChangedObservable = new i(), this._sound = t;
|
|
139
|
+
}
|
|
140
|
+
/** The playback state of the sound instance */
|
|
141
|
+
get state() {
|
|
142
|
+
return this._state;
|
|
143
|
+
}
|
|
144
|
+
/** @internal */
|
|
145
|
+
dispose() {
|
|
146
|
+
super.dispose(), this.stop(), this.onEndedObservable.clear(), this.onStateChangedObservable.clear();
|
|
147
|
+
}
|
|
148
|
+
_setState(t) {
|
|
149
|
+
this._state !== t && (this._state = t, this.onStateChangedObservable.notifyObservers(this), this._state === 1 && this.onEndedObservable.notifyObservers(this));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
_ as A,
|
|
154
|
+
l as _
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=abstractSoundInstance-Ojv9HUsA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractSoundInstance-Ojv9HUsA.js","sources":["../node_modules/@babylonjs/core/AudioV2/abstractAudio/abstractSound.js","../node_modules/@babylonjs/core/AudioV2/abstractAudio/abstractSoundInstance.js"],"sourcesContent":["import { Observable } from \"../../Misc/observable.js\";\nimport { AbstractSoundSource } from \"./abstractSoundSource.js\";\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport class AbstractSound extends AbstractSoundSource {\n constructor(name, engine, options) {\n super(name, engine, options, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */); // Inputs are for instances.\n this._newestInstance = null;\n this._privateInstances = new Set();\n this._state = 1 /* SoundState.Stopped */;\n this._instances = this._privateInstances;\n /**\n * Observable for when the sound stops playing.\n */\n this.onEndedObservable = new Observable();\n this._onInstanceEnded = (instance) => {\n if (this._newestInstance === instance) {\n this._newestInstance = null;\n }\n this._privateInstances.delete(instance);\n if (this._instances.size === 0) {\n this._state = 1 /* SoundState.Stopped */;\n this.onEndedObservable.notifyObservers(this);\n }\n instance.dispose();\n };\n }\n /**\n * The number of active instances of the sound that are currently playing.\n */\n get activeInstancesCount() {\n return this._instances.size;\n }\n /**\n * Whether the sound should start playing automatically. Defaults to `false`.\n */\n get autoplay() {\n return this._options.autoplay;\n }\n /**\n * The current playback time of the sound, in seconds.\n */\n get currentTime() {\n const instance = this._getNewestInstance();\n return instance ? instance.currentTime : 0;\n }\n set currentTime(value) {\n this.startOffset = value;\n const instance = this._getNewestInstance();\n if (instance) {\n instance.currentTime = value;\n }\n }\n /**\n * Whether the sound should loop. Defaults to `false`.\n */\n get loop() {\n return this._options.loop;\n }\n set loop(value) {\n this._options.loop = value;\n }\n /**\n * The maximum number of instances that can play at the same time. Defaults to `Infinity`.\n */\n get maxInstances() {\n return this._options.maxInstances;\n }\n set maxInstances(value) {\n this._options.maxInstances = value;\n }\n /**\n * The time within the sound buffer to start playing at, in seconds. Defaults to `0`.\n */\n get startOffset() {\n return this._options.startOffset;\n }\n set startOffset(value) {\n this._options.startOffset = value;\n }\n /**\n * The state of the sound.\n */\n get state() {\n return this._state;\n }\n /**\n * Releases associated resources.\n */\n dispose() {\n super.dispose();\n this.stop();\n this._newestInstance = null;\n this._privateInstances.clear();\n this.onEndedObservable.clear();\n }\n /**\n * Pauses the sound.\n */\n pause() {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.pause();\n }\n this._state = 5 /* SoundState.Paused */;\n }\n /**\n * Resumes the sound.\n */\n resume() {\n if (this._state !== 5 /* SoundState.Paused */) {\n return;\n }\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n next.value.resume();\n }\n this._state = 3 /* SoundState.Started */;\n }\n _beforePlay(instance) {\n if (this.state === 5 /* SoundState.Paused */ && this._instances.size > 0) {\n this.resume();\n return;\n }\n instance.onEndedObservable.addOnce(this._onInstanceEnded);\n this._privateInstances.add(instance);\n this._newestInstance = instance;\n }\n _afterPlay(instance) {\n this._state = instance.state;\n }\n _getNewestInstance() {\n if (this._instances.size === 0) {\n return null;\n }\n if (!this._newestInstance) {\n const it = this._instances.values();\n for (let next = it.next(); !next.done; next = it.next()) {\n this._newestInstance = next.value;\n }\n }\n return this._newestInstance;\n }\n _setState(state) {\n this._state = state;\n }\n _stopExcessInstances() {\n if (this.maxInstances < Infinity) {\n const numberOfInstancesToStop = Array.from(this._instances).filter((instance) => instance.state === 3 /* SoundState.Started */).length - this.maxInstances;\n const it = this._instances.values();\n for (let i = 0; i < numberOfInstancesToStop; i++) {\n const instance = it.next().value;\n instance.stop();\n }\n }\n }\n}\n//# sourceMappingURL=abstractSound.js.map","import { Observable } from \"../../Misc/observable.js\";\nimport { AbstractAudioNode } from \"./abstractAudioNode.js\";\n/** @internal */\nexport class _AbstractSoundInstance extends AbstractAudioNode {\n constructor(sound) {\n super(sound.engine, 2 /* AudioNodeType.HAS_OUTPUTS */);\n this._state = 1 /* SoundState.Stopped */;\n /** Observable triggered when the sound instance's playback ends */\n this.onEndedObservable = new Observable();\n /** Observable triggered if the sound instance encounters an error and can not be played */\n this.onErrorObservable = new Observable();\n /** Observable triggered when the sound instance's state changes */\n this.onStateChangedObservable = new Observable();\n this._sound = sound;\n }\n /** The playback state of the sound instance */\n get state() {\n return this._state;\n }\n /** @internal */\n dispose() {\n super.dispose();\n this.stop();\n this.onEndedObservable.clear();\n this.onStateChangedObservable.clear();\n }\n _setState(value) {\n if (this._state === value) {\n return;\n }\n this._state = value;\n this.onStateChangedObservable.notifyObservers(this);\n if (this._state === 1 /* SoundState.Stopped */) {\n this.onEndedObservable.notifyObservers(this);\n }\n }\n}\n//# sourceMappingURL=abstractSoundInstance.js.map"],"names":["AbstractSound","AbstractSoundSource","name","engine","options","Observable","instance","value","it","next","state","numberOfInstancesToStop","i","_AbstractSoundInstance","AbstractAudioNode","sound"],"mappings":"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","x_google_ignoreList":[0,1]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { A as e } from "./webAudioBaseSubGraph-KtziJf_K.js";
|
|
2
|
+
class p extends e {
|
|
3
|
+
constructor(t, i, s, a = 2) {
|
|
4
|
+
super(t, i, a), this._spatialAutoUpdate = !0, this._spatialMinUpdateTime = 0, this._outBus = null, this._spatial = null, this._onOutBusDisposed = null, typeof s.spatialAutoUpdate == "boolean" && (this._spatialAutoUpdate = s.spatialAutoUpdate), typeof s.spatialMinUpdateTime == "number" && (this._spatialMinUpdateTime = s.spatialMinUpdateTime);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The output bus for the sound.
|
|
8
|
+
* @see {@link AudioEngineV2.defaultMainBus}
|
|
9
|
+
*/
|
|
10
|
+
get outBus() {
|
|
11
|
+
return this._outBus;
|
|
12
|
+
}
|
|
13
|
+
set outBus(t) {
|
|
14
|
+
if (this._outBus !== t) {
|
|
15
|
+
if (this._outBus && (this._onOutBusDisposed && (this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed), this._onOutBusDisposed = null), !this._disconnect(this._outBus)))
|
|
16
|
+
throw new Error("Disconnect failed");
|
|
17
|
+
if (this._outBus = t, this._outBus && (this._onOutBusDisposed = () => {
|
|
18
|
+
this._outBus = null;
|
|
19
|
+
}, this._outBus.onDisposeObservable.add(this._onOutBusDisposed), !this._connect(this._outBus)))
|
|
20
|
+
throw new Error("Connect failed");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The spatial audio features.
|
|
25
|
+
*/
|
|
26
|
+
get spatial() {
|
|
27
|
+
return this._spatial ? this._spatial : this._initSpatialProperty();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Releases associated resources.
|
|
31
|
+
*/
|
|
32
|
+
dispose() {
|
|
33
|
+
super.dispose(), this._spatial?.dispose(), this._spatial = null, this._outBus && this._onOutBusDisposed && (this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed), this._onOutBusDisposed = null), this._outBus = null;
|
|
34
|
+
}
|
|
35
|
+
_initSpatialProperty() {
|
|
36
|
+
return this._spatial = this._createSpatialProperty(this._spatialAutoUpdate, this._spatialMinUpdateTime);
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
get _isSpatial() {
|
|
40
|
+
return this._spatial !== null;
|
|
41
|
+
}
|
|
42
|
+
set _isSpatial(t) {
|
|
43
|
+
t && !this._spatial ? this._initSpatialProperty() : !t && this._spatial && (this._spatial.dispose(), this._spatial = null);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
p as A
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=abstractSoundSource-B4K-9snf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstractSoundSource-B4K-9snf.js","sources":["../node_modules/@babylonjs/core/AudioV2/abstractAudio/abstractSoundSource.js"],"sourcesContent":["import { AbstractAudioOutNode } from \"./abstractAudioOutNode.js\";\n/**\n * Abstract class representing a sound in the audio engine.\n */\nexport class AbstractSoundSource extends AbstractAudioOutNode {\n constructor(name, engine, options, nodeType = 2 /* AudioNodeType.HAS_OUTPUTS */) {\n super(name, engine, nodeType);\n this._spatialAutoUpdate = true;\n this._spatialMinUpdateTime = 0;\n this._outBus = null;\n this._spatial = null;\n this._onOutBusDisposed = null;\n if (typeof options.spatialAutoUpdate === \"boolean\") {\n this._spatialAutoUpdate = options.spatialAutoUpdate;\n }\n if (typeof options.spatialMinUpdateTime === \"number\") {\n this._spatialMinUpdateTime = options.spatialMinUpdateTime;\n }\n }\n /**\n * The output bus for the sound.\n * @see {@link AudioEngineV2.defaultMainBus}\n */\n get outBus() {\n return this._outBus;\n }\n set outBus(outBus) {\n if (this._outBus === outBus) {\n return;\n }\n if (this._outBus) {\n if (this._onOutBusDisposed) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n this._onOutBusDisposed = null;\n }\n if (!this._disconnect(this._outBus)) {\n throw new Error(\"Disconnect failed\");\n }\n }\n this._outBus = outBus;\n if (this._outBus) {\n this._onOutBusDisposed = () => {\n this._outBus = null;\n };\n this._outBus.onDisposeObservable.add(this._onOutBusDisposed);\n if (!this._connect(this._outBus)) {\n throw new Error(\"Connect failed\");\n }\n }\n }\n /**\n * The spatial audio features.\n */\n get spatial() {\n if (this._spatial) {\n return this._spatial;\n }\n return this._initSpatialProperty();\n }\n /**\n * Releases associated resources.\n */\n dispose() {\n super.dispose();\n this._spatial?.dispose();\n this._spatial = null;\n if (this._outBus && this._onOutBusDisposed) {\n this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed);\n this._onOutBusDisposed = null;\n }\n this._outBus = null;\n }\n _initSpatialProperty() {\n return (this._spatial = this._createSpatialProperty(this._spatialAutoUpdate, this._spatialMinUpdateTime));\n }\n /** @internal */\n get _isSpatial() {\n return this._spatial !== null;\n }\n set _isSpatial(value) {\n if (value && !this._spatial) {\n this._initSpatialProperty();\n }\n else if (!value && this._spatial) {\n this._spatial.dispose();\n this._spatial = null;\n }\n }\n}\n//# sourceMappingURL=abstractSoundSource.js.map"],"names":["AbstractSoundSource","AbstractAudioOutNode","name","engine","options","nodeType","outBus","value"],"mappings":";AAIO,MAAMA,UAA4BC,EAAqB;AAAA,EAC1D,YAAYC,GAAMC,GAAQC,GAASC,IAAW,GAAmC;AAC7E,UAAMH,GAAMC,GAAQE,CAAQ,GAC5B,KAAK,qBAAqB,IAC1B,KAAK,wBAAwB,GAC7B,KAAK,UAAU,MACf,KAAK,WAAW,MAChB,KAAK,oBAAoB,MACrB,OAAOD,EAAQ,qBAAsB,cACrC,KAAK,qBAAqBA,EAAQ,oBAElC,OAAOA,EAAQ,wBAAyB,aACxC,KAAK,wBAAwBA,EAAQ;AAAA,EAE7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,SAAS;AACT,WAAO,KAAK;AAAA,EAChB;AAAA,EACA,IAAI,OAAOE,GAAQ;AACf,QAAI,KAAK,YAAYA,GAGrB;AAAA,UAAI,KAAK,YACD,KAAK,sBACL,KAAK,QAAQ,oBAAoB,eAAe,KAAK,iBAAiB,GACtE,KAAK,oBAAoB,OAEzB,CAAC,KAAK,YAAY,KAAK,OAAO;AAC9B,cAAM,IAAI,MAAM,mBAAmB;AAI3C,UADA,KAAK,UAAUA,GACX,KAAK,YACL,KAAK,oBAAoB,MAAM;AAC3B,aAAK,UAAU;AAAA,MACnB,GACA,KAAK,QAAQ,oBAAoB,IAAI,KAAK,iBAAiB,GACvD,CAAC,KAAK,SAAS,KAAK,OAAO;AAC3B,cAAM,IAAI,MAAM,gBAAgB;AAAA;AAAA,EAG5C;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAAU;AACV,WAAI,KAAK,WACE,KAAK,WAET,KAAK,qBAAoB;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAIA,UAAU;AACN,UAAM,QAAO,GACb,KAAK,UAAU,QAAO,GACtB,KAAK,WAAW,MACZ,KAAK,WAAW,KAAK,sBACrB,KAAK,QAAQ,oBAAoB,eAAe,KAAK,iBAAiB,GACtE,KAAK,oBAAoB,OAE7B,KAAK,UAAU;AAAA,EACnB;AAAA,EACA,uBAAuB;AACnB,WAAQ,KAAK,WAAW,KAAK,uBAAuB,KAAK,oBAAoB,KAAK,qBAAqB;AAAA,EAC3G;AAAA;AAAA,EAEA,IAAI,aAAa;AACb,WAAO,KAAK,aAAa;AAAA,EAC7B;AAAA,EACA,IAAI,WAAWC,GAAO;AAClB,IAAIA,KAAS,CAAC,KAAK,WACf,KAAK,qBAAoB,IAEpB,CAACA,KAAS,KAAK,aACpB,KAAK,SAAS,QAAO,GACrB,KAAK,WAAW;AAAA,EAExB;AACJ;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformNode } from '@babylonjs/core';
|
|
2
2
|
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
3
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
3
4
|
import { GameEvent } from "../classes/eventBus.d.ts";
|
|
4
5
|
/**
|
|
5
6
|
* Configuration for a single sound.
|
|
@@ -17,6 +18,8 @@ export interface SoundConfig {
|
|
|
17
18
|
maxDistance?: number;
|
|
18
19
|
/** Whether to autoplay when registered, default false */
|
|
19
20
|
autoplay?: boolean;
|
|
21
|
+
/** Audio channel name (e.g., 'sfx', 'music'). Used with AudioManager. */
|
|
22
|
+
channel?: string;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* State interface for entities using SoundBehavior.
|
|
@@ -30,8 +33,10 @@ export interface SoundEntityState {
|
|
|
30
33
|
* Behavior for managing sounds on an entity.
|
|
31
34
|
*
|
|
32
35
|
* Sounds are configured in the entity's state under the `sounds` property.
|
|
33
|
-
* The behavior creates
|
|
34
|
-
*
|
|
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.
|
|
35
40
|
*
|
|
36
41
|
* @example
|
|
37
42
|
* ```typescript
|
|
@@ -41,8 +46,8 @@ export interface SoundEntityState {
|
|
|
41
46
|
* behaviors: [SoundBehavior, ...],
|
|
42
47
|
* defaultState: {
|
|
43
48
|
* sounds: {
|
|
44
|
-
* jump: { url: 'sounds/jump.mp3', volume: 0.8 },
|
|
45
|
-
* footstep: { url: 'sounds/footstep.mp3', loop: true }
|
|
49
|
+
* jump: { url: 'sounds/jump.mp3', volume: 0.8, channel: 'sfx' },
|
|
50
|
+
* footstep: { url: 'sounds/footstep.mp3', loop: true, channel: 'sfx' }
|
|
46
51
|
* }
|
|
47
52
|
* }
|
|
48
53
|
* }
|
|
@@ -55,26 +60,18 @@ export interface SoundEntityState {
|
|
|
55
60
|
export declare class SoundBehavior extends GameEntityBehavior<SoundEntityState> {
|
|
56
61
|
name: string;
|
|
57
62
|
eventSubscriptions: string[];
|
|
58
|
-
/** Map of sound name to
|
|
63
|
+
/** Map of sound name to StaticSound instance */
|
|
59
64
|
private _sounds;
|
|
60
|
-
/** Reference to the scene for creating sounds */
|
|
61
|
-
private _scene;
|
|
62
65
|
/** Whether sounds have been initialized */
|
|
63
66
|
private _initialized;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
initialize(scene: Scene): void;
|
|
71
|
-
/**
|
|
72
|
-
* Process events. Override to handle action events that should trigger sounds.
|
|
73
|
-
*/
|
|
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;
|
|
74
73
|
processEvent(_event: GameEvent, _state: SoundEntityState): boolean;
|
|
75
|
-
|
|
76
|
-
* Called when the entity is destroyed.
|
|
77
|
-
*/
|
|
74
|
+
onReset(_state: SoundEntityState): void;
|
|
78
75
|
destroy(): Promise<void>;
|
|
79
76
|
private _createSound;
|
|
80
77
|
private _disposeSounds;
|
package/dist/classes/entity.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { TransformNode } from '@babylonjs/core';
|
|
|
2
2
|
import { GameEntityBehaviorConstructor } from "../interfaces/entity.d.ts";
|
|
3
3
|
import { Destroyable } from "../interfaces/lifecycle.d.ts";
|
|
4
4
|
import { GameEvent, GameEventBus } from "./eventBus.d.ts";
|
|
5
|
+
import { GameEngine } from "./gameEngine.d.ts";
|
|
5
6
|
/**
|
|
6
7
|
* Options for attaching a behavior at a specific position.
|
|
7
8
|
* Only one positioning option should be specified.
|
|
@@ -60,8 +61,9 @@ export declare abstract class GameEntityBehavior<RequiredState extends object =
|
|
|
60
61
|
* The scene is accessible via `node.getScene()`.
|
|
61
62
|
*
|
|
62
63
|
* @param node - The TransformNode (typically a Mesh) the entity is attached to.
|
|
64
|
+
* @param gameEngine - The game engine instance for accessing managers and engines.
|
|
63
65
|
*/
|
|
64
|
-
onNodeAttached?(node: TransformNode): void;
|
|
66
|
+
onNodeAttached?(node: TransformNode, gameEngine: GameEngine): void;
|
|
65
67
|
/**
|
|
66
68
|
* Called when the entity is detached from its scene node.
|
|
67
69
|
* Override to clean up node-dependent resources.
|
|
@@ -100,6 +102,7 @@ export declare class GameEntity<EntityState extends object = object> implements
|
|
|
100
102
|
/** Array of behaviors attached to the entity. Order determines event processing priority. */
|
|
101
103
|
behaviors: GameEntityBehavior[];
|
|
102
104
|
eventBus: GameEventBus;
|
|
105
|
+
private _gameEngine;
|
|
103
106
|
private _tags;
|
|
104
107
|
private subscriptions;
|
|
105
108
|
/**
|
|
@@ -144,9 +147,10 @@ export declare class GameEntity<EntityState extends object = object> implements
|
|
|
144
147
|
* Internal method for EntityManager to attach entity to a node.
|
|
145
148
|
* Do not call directly - use EntityManager.attachToNode() instead.
|
|
146
149
|
* @param node
|
|
150
|
+
* @param gameEngine
|
|
147
151
|
* @internal
|
|
148
152
|
*/
|
|
149
|
-
$attachToNode(node: TransformNode): void;
|
|
153
|
+
$attachToNode(node: TransformNode, gameEngine: GameEngine): void;
|
|
150
154
|
/**
|
|
151
155
|
* Internal method for EntityManager to detach entity from its node.
|
|
152
156
|
* Do not call directly - use EntityManager.detachFromNode() instead.
|
|
@@ -2,6 +2,7 @@ import { AbstractEngine, HavokPlugin } from '@babylonjs/core';
|
|
|
2
2
|
import { GameCanvas } from "../interfaces/game.d.ts";
|
|
3
3
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
4
4
|
import { SceneEngine } from "../engines/scene.d.ts";
|
|
5
|
+
import { AudioEngine } from "../engines/audio.d.ts";
|
|
5
6
|
import { AssetManager } from "../managers/asset.d.ts";
|
|
6
7
|
import { BindingManager } from "../managers/binding.d.ts";
|
|
7
8
|
import { GameManager } from "../managers/game.d.ts";
|
|
@@ -9,6 +10,7 @@ import { GameEntityManager } from "../managers/entity.d.ts";
|
|
|
9
10
|
import { LevelManager } from "../managers/level.d.ts";
|
|
10
11
|
import { SaveManager } from "../managers/save.d.ts";
|
|
11
12
|
import { UserInputManager } from "../managers/input.d.ts";
|
|
13
|
+
import { AudioManager } from "../managers/audio.d.ts";
|
|
12
14
|
import { GameEvent, GameEventBus, GameEventCallback, Unsubscribe } from "./eventBus.d.ts";
|
|
13
15
|
import { ActionPayload, LibraryEventPayloadMap } from "../events/payloads.d.ts";
|
|
14
16
|
import { WildcardPattern } from "../events/types.d.ts";
|
|
@@ -23,14 +25,15 @@ export type GameHook = (gameEngine: GameEngine) => Promise<void>;
|
|
|
23
25
|
* Interface representing the engines used in the game.
|
|
24
26
|
* All engines must implement Disposable for proper cleanup.
|
|
25
27
|
*/
|
|
26
|
-
interface Engines extends Record<string, Disposable> {
|
|
28
|
+
interface Engines extends Record<string, Disposable | undefined> {
|
|
27
29
|
sceneEngine: SceneEngine;
|
|
30
|
+
audioEngine?: AudioEngine;
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* Interface representing the managers used in the game.
|
|
31
34
|
* All managers must implement Disposable for proper cleanup.
|
|
32
35
|
*/
|
|
33
|
-
interface Managers extends Record<string, Disposable> {
|
|
36
|
+
interface Managers extends Record<string, Disposable | undefined> {
|
|
34
37
|
assetManager: AssetManager;
|
|
35
38
|
bindingManager: BindingManager;
|
|
36
39
|
gameManager: GameManager;
|
|
@@ -38,6 +41,7 @@ interface Managers extends Record<string, Disposable> {
|
|
|
38
41
|
inputManager: UserInputManager;
|
|
39
42
|
levelManager: LevelManager;
|
|
40
43
|
saveManager: SaveManager;
|
|
44
|
+
audioManager?: AudioManager;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
47
|
* Central hub that owns the render loop, physics, event bus, and all managers.
|
package/dist/classes/level.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Scene } from '@babylonjs/core';
|
|
2
2
|
import { LoggerInterface } from "../interfaces/logger.d.ts";
|
|
3
3
|
import { LevelConfig, LevelContext, LevelInstance, PropertyHandler } from "../interfaces/level.d.ts";
|
|
4
|
-
import {
|
|
5
|
-
import { SceneEngine } from "../engines/scene.d.ts";
|
|
6
|
-
import { GameEventBus } from "./eventBus.d.ts";
|
|
7
|
-
import { GameEntityManager } from "../managers/entity.d.ts";
|
|
4
|
+
import { GameEngine } from "./gameEngine.d.ts";
|
|
8
5
|
/**
|
|
9
6
|
* Abstract base class for game levels.
|
|
10
7
|
*
|
|
@@ -37,10 +34,7 @@ export declare abstract class Level implements LevelInstance {
|
|
|
37
34
|
constructor(config: LevelConfig, context: LevelContext);
|
|
38
35
|
get scene(): Scene | null;
|
|
39
36
|
get isLoaded(): boolean;
|
|
40
|
-
get
|
|
41
|
-
get assetManager(): AssetManager;
|
|
42
|
-
get entityManager(): GameEntityManager;
|
|
43
|
-
get sceneEngine(): SceneEngine;
|
|
37
|
+
get gameEngine(): GameEngine;
|
|
44
38
|
get propertyHandlers(): Map<string, PropertyHandler>;
|
|
45
39
|
/**
|
|
46
40
|
* Emit a progress event during loading
|
|
@@ -58,8 +52,7 @@ export declare abstract class Level implements LevelInstance {
|
|
|
58
52
|
* Abstract method for building the scene content.
|
|
59
53
|
* Concrete levels must implement this to create their specific content.
|
|
60
54
|
*
|
|
61
|
-
* All dependencies
|
|
62
|
-
* `this.sceneEngine`, `this.entityManager`, etc.
|
|
55
|
+
* All dependencies are available via `this.gameEngine`.
|
|
63
56
|
*
|
|
64
57
|
*/
|
|
65
58
|
protected abstract buildScene(): Promise<Scene>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AudioBus } from '@babylonjs/core/AudioV2/abstractAudio/audioBus';
|
|
2
|
+
import { IStaticSoundOptions, StaticSound } from '@babylonjs/core/AudioV2/abstractAudio/staticSound';
|
|
3
|
+
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
4
|
+
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
5
|
+
export declare class AudioEngine implements Disposable {
|
|
6
|
+
private _engine;
|
|
7
|
+
private _mainBus;
|
|
8
|
+
private _buses;
|
|
9
|
+
private _log;
|
|
10
|
+
constructor(logger: LoggingUtility);
|
|
11
|
+
initialize(): Promise<void>;
|
|
12
|
+
$teardown(): Promise<void>;
|
|
13
|
+
createBus(name: string): Promise<AudioBus>;
|
|
14
|
+
getBus(name: string): AudioBus | undefined;
|
|
15
|
+
createSound(name: string, url: string, bus?: AudioBus, options?: Partial<IStaticSoundOptions>): Promise<StaticSound>;
|
|
16
|
+
setMasterVolume(volume: number): void;
|
|
17
|
+
getMasterVolume(): number;
|
|
18
|
+
setBusVolume(bus: AudioBus, volume: number): void;
|
|
19
|
+
}
|
package/dist/engines/scene.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractEngine, AbstractMesh, AssetContainer, DirectionalLight, FreeCamera, HemisphericLight, Light, Mesh, PhysicsAggregate, PhysicsShapeType, PointLight, Scene,
|
|
1
|
+
import { AbstractEngine, AbstractMesh, AssetContainer, DirectionalLight, FreeCamera, HemisphericLight, Light, Mesh, PhysicsAggregate, PhysicsShapeType, PointLight, Scene, SpotLight, Vector3 } from '@babylonjs/core';
|
|
2
2
|
import { HavokPhysicsWithBindings } from '@babylonjs/havok';
|
|
3
3
|
import { GameCanvas } from "../interfaces/game.d.ts";
|
|
4
4
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
@@ -114,19 +114,6 @@ export declare class SceneEngine implements Disposable {
|
|
|
114
114
|
restitution?: number;
|
|
115
115
|
friction?: number;
|
|
116
116
|
} | undefined, scene: Scene): PhysicsAggregate;
|
|
117
|
-
/**
|
|
118
|
-
* Creates and loads a sound. Defaults: no loop, no autoplay, volume 1.0, playbackRate 1.0.
|
|
119
|
-
* @param name
|
|
120
|
-
* @param url
|
|
121
|
-
* @param scene
|
|
122
|
-
* @param options
|
|
123
|
-
*/
|
|
124
|
-
createSound(name: string, url: string, scene: Scene, options?: {
|
|
125
|
-
loop?: boolean;
|
|
126
|
-
autoplay?: boolean;
|
|
127
|
-
volume?: number;
|
|
128
|
-
playbackRate?: number;
|
|
129
|
-
}): Sound;
|
|
130
117
|
/**
|
|
131
118
|
* Loads a 3D model/asset into an AssetContainer without adding it to the scene automatically.
|
|
132
119
|
* @param sceneFilename
|
package/dist/handlers/sound.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { LevelManager } from "../managers/level.d.ts";
|
|
|
9
9
|
* - `sound_spatial` (boolean): Whether to use 3D spatial audio, default true
|
|
10
10
|
* - `sound_distance` (number): Maximum distance for spatial audio, default 100
|
|
11
11
|
* - `sound_autoplay` (boolean): Whether to autoplay, default true
|
|
12
|
+
* - `sound_channel` (string): Audio channel name, default 'ambient'
|
|
12
13
|
*
|
|
13
14
|
* @param levelManager
|
|
14
15
|
*/
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Scene, TransformNode } from '@babylonjs/core';
|
|
2
|
-
import {
|
|
3
|
-
import { SceneEngine } from "../engines/scene.d.ts";
|
|
4
|
-
import { AssetManager } from "../managers/asset.d.ts";
|
|
5
|
-
import { GameEntityManager } from "../managers/entity.d.ts";
|
|
2
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
6
3
|
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
7
4
|
/**
|
|
8
5
|
* Minimal interface for Level that property handlers receive.
|
|
@@ -10,9 +7,6 @@ import { LoggingUtility } from "../utils/logger.d.ts";
|
|
|
10
7
|
*/
|
|
11
8
|
export interface LevelInstance {
|
|
12
9
|
readonly name: string;
|
|
13
|
-
readonly eventBus: GameEventBus;
|
|
14
|
-
readonly sceneEngine: SceneEngine;
|
|
15
|
-
readonly entityManager: GameEntityManager;
|
|
16
10
|
/** The current scene for this level (null if not loaded) */
|
|
17
11
|
readonly scene: Scene | null;
|
|
18
12
|
/**
|
|
@@ -23,20 +17,14 @@ export interface LevelInstance {
|
|
|
23
17
|
/**
|
|
24
18
|
* Handler function for processing custom properties on scene nodes.
|
|
25
19
|
*/
|
|
26
|
-
export type PropertyHandler = (node: TransformNode, value: unknown, level: LevelInstance) => void | Promise<void>;
|
|
20
|
+
export type PropertyHandler = (node: TransformNode, value: unknown, level: LevelInstance, gameEngine: GameEngine) => void | Promise<void>;
|
|
27
21
|
/**
|
|
28
22
|
* Runtime context containing all dependencies needed by a Level.
|
|
29
23
|
* Passed to Level constructor by LevelManager during instantiation.
|
|
30
24
|
*/
|
|
31
25
|
export interface LevelContext {
|
|
32
|
-
/** The game
|
|
33
|
-
|
|
34
|
-
/** The scene engine for creating and managing scenes */
|
|
35
|
-
sceneEngine: SceneEngine;
|
|
36
|
-
/** The entity manager for spawning entities */
|
|
37
|
-
entityManager: GameEntityManager;
|
|
38
|
-
/** The asset manager for loading and caching assets */
|
|
39
|
-
assetManager: AssetManager;
|
|
26
|
+
/** The game engine instance providing access to all subsystems */
|
|
27
|
+
gameEngine: GameEngine;
|
|
40
28
|
/** Map of property handlers for processing scene node metadata */
|
|
41
29
|
propertyHandlers: Map<string, PropertyHandler>;
|
|
42
30
|
/** Optional logging utility for creating level-specific loggers */
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IStaticSoundOptions, StaticSound } from '@babylonjs/core/AudioV2/abstractAudio/staticSound';
|
|
2
|
+
import { AudioEngine } from "../engines/audio.d.ts";
|
|
3
|
+
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
4
|
+
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Public channel info exposed to consumers (no BabylonJS internals).
|
|
7
|
+
*/
|
|
8
|
+
export interface ChannelInfo {
|
|
9
|
+
volume: number;
|
|
10
|
+
muted: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare class AudioManager implements Disposable {
|
|
13
|
+
private _audioEngine;
|
|
14
|
+
private _channels;
|
|
15
|
+
private _masterMuted;
|
|
16
|
+
private _masterVolumeBeforeMute;
|
|
17
|
+
private _log;
|
|
18
|
+
constructor(audioEngine: AudioEngine, logger: LoggingUtility);
|
|
19
|
+
initialize(channels: string[]): Promise<void>;
|
|
20
|
+
$teardown(): Promise<void>;
|
|
21
|
+
createSound(name: string, url: string, channel?: string, options?: Partial<IStaticSoundOptions>): Promise<StaticSound>;
|
|
22
|
+
setMasterVolume(volume: number): void;
|
|
23
|
+
getMasterVolume(): number;
|
|
24
|
+
setMasterMuted(muted: boolean): void;
|
|
25
|
+
isMasterMuted(): boolean;
|
|
26
|
+
setChannelVolume(channel: string, volume: number): void;
|
|
27
|
+
getChannelVolume(channel: string): number;
|
|
28
|
+
setChannelMuted(channel: string, muted: boolean): void;
|
|
29
|
+
isChannelMuted(channel: string): boolean;
|
|
30
|
+
getChannels(): string[];
|
|
31
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TransformNode } from '@babylonjs/core';
|
|
2
2
|
import { GameEntity } from "../classes/entity.d.ts";
|
|
3
3
|
import { GameEventBus } from "../classes/eventBus.d.ts";
|
|
4
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
4
5
|
import { GameEntityDefinition } from "../interfaces/entity.d.ts";
|
|
5
6
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
6
7
|
import { BindingManager } from "../managers/binding.d.ts";
|
|
@@ -25,6 +26,8 @@ export declare class GameEntityManager implements Disposable {
|
|
|
25
26
|
private entities;
|
|
26
27
|
/** A map of entity definitions registered with the entity manager. */
|
|
27
28
|
private entityDefinitions;
|
|
29
|
+
/** Late-bound GameEngine reference */
|
|
30
|
+
private _gameEngine;
|
|
28
31
|
/** Reference to the binding manager for registering actions */
|
|
29
32
|
private bindingManager;
|
|
30
33
|
/** Logger instance */
|
|
@@ -46,6 +49,12 @@ export declare class GameEntityManager implements Disposable {
|
|
|
46
49
|
* @param bindingManager
|
|
47
50
|
*/
|
|
48
51
|
constructor(eventBus: GameEventBus, logger: LoggingUtility | undefined, bindingManager: BindingManager);
|
|
52
|
+
/**
|
|
53
|
+
* Late-bind the GameEngine after construction.
|
|
54
|
+
* Called by createGameEngine() after the GameEngine instance is created.
|
|
55
|
+
*/
|
|
56
|
+
$setGameEngine(gameEngine: GameEngine): void;
|
|
57
|
+
private get _engine();
|
|
49
58
|
/**
|
|
50
59
|
* Gets or creates a Set in a Map, returning the Set.
|
|
51
60
|
*/
|
package/dist/managers/level.d.ts
CHANGED
|
@@ -2,9 +2,7 @@ import { LevelConfig, LevelConstructor, PropertyHandler } from "../interfaces/le
|
|
|
2
2
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
3
3
|
import { Level } from "../classes/level.d.ts";
|
|
4
4
|
import { GameEventBus } from "../classes/eventBus.d.ts";
|
|
5
|
-
import {
|
|
6
|
-
import { AssetManager } from "./asset.d.ts";
|
|
7
|
-
import { GameEntityManager } from "./entity.d.ts";
|
|
5
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
8
6
|
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
9
7
|
/**
|
|
10
8
|
* Options for level transitions.
|
|
@@ -38,9 +36,7 @@ export interface TransitionOptions {
|
|
|
38
36
|
*/
|
|
39
37
|
export declare class LevelManager implements Disposable {
|
|
40
38
|
private _eventBus;
|
|
41
|
-
private
|
|
42
|
-
private _assetManager;
|
|
43
|
-
private _entityManager;
|
|
39
|
+
private _gameEngine;
|
|
44
40
|
private _log;
|
|
45
41
|
private _logger?;
|
|
46
42
|
/** Map of registered level configurations by name */
|
|
@@ -63,7 +59,12 @@ export declare class LevelManager implements Disposable {
|
|
|
63
59
|
* Gets the registered property handlers
|
|
64
60
|
*/
|
|
65
61
|
get propertyHandlers(): Map<string, PropertyHandler>;
|
|
66
|
-
constructor(eventBus: GameEventBus,
|
|
62
|
+
constructor(eventBus: GameEventBus, logger?: LoggingUtility);
|
|
63
|
+
/**
|
|
64
|
+
* Late-bind the GameEngine after construction.
|
|
65
|
+
* Called by createGameEngine() after the GameEngine instance is created.
|
|
66
|
+
*/
|
|
67
|
+
$setGameEngine(gameEngine: GameEngine): void;
|
|
67
68
|
private _handleProgress;
|
|
68
69
|
private _handleComplete;
|
|
69
70
|
private _handleError;
|