@energy8platform/game-engine 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio.cjs.js +15 -5
- package/dist/audio.cjs.js.map +1 -1
- package/dist/audio.d.ts +5 -0
- package/dist/audio.esm.js +15 -5
- package/dist/audio.esm.js.map +1 -1
- package/dist/core.cjs.js +46 -18
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.d.ts +13 -1
- package/dist/core.esm.js +46 -18
- package/dist/core.esm.js.map +1 -1
- package/dist/host.cjs.js +333 -67
- package/dist/host.cjs.js.map +1 -1
- package/dist/host.d.ts +111 -26
- package/dist/host.esm.js +333 -67
- package/dist/host.esm.js.map +1 -1
- package/dist/index.cjs.js +46 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.esm.js +46 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/react.d.ts +13 -1
- package/package.json +3 -2
- package/src/audio/AudioManager.ts +17 -5
- package/src/core/GameApplication.ts +22 -5
- package/src/host/createSlotGame.ts +143 -23
- package/src/host/index.ts +4 -1
- package/src/host/overlayController.ts +81 -0
- package/src/host/pauseController.ts +21 -0
- package/src/host/runRound.ts +35 -43
- package/src/host/sceneAudio.ts +14 -0
- package/src/host/sceneController.ts +84 -19
- package/src/host/shellConfig.ts +11 -6
- package/src/host/skipGesture.ts +24 -0
- package/src/host/types.ts +5 -2
- package/src/viewport/ViewportManager.ts +19 -9
package/dist/index.d.ts
CHANGED
|
@@ -342,6 +342,7 @@ declare class AudioManager {
|
|
|
342
342
|
private _persist;
|
|
343
343
|
private _storageKey;
|
|
344
344
|
private _categories;
|
|
345
|
+
private _masterGain;
|
|
345
346
|
private _currentMusic;
|
|
346
347
|
private _unlocked;
|
|
347
348
|
private _unlockHandler;
|
|
@@ -382,6 +383,10 @@ declare class AudioManager {
|
|
|
382
383
|
* Stop all sounds.
|
|
383
384
|
*/
|
|
384
385
|
stopAll(): void;
|
|
386
|
+
/** Global gain (0..1) folded into every category's effective volume. Driven by the shell's
|
|
387
|
+
* 'master' settingChange. Does not affect the persisted per-category volumes. */
|
|
388
|
+
setMasterVolume(volume: number): void;
|
|
389
|
+
getMasterVolume(): number;
|
|
385
390
|
/**
|
|
386
391
|
* Set volume for a category.
|
|
387
392
|
*/
|
|
@@ -584,6 +589,7 @@ declare class ViewportManager extends EventEmitter<ViewportEvents> {
|
|
|
584
589
|
private _app;
|
|
585
590
|
private _container;
|
|
586
591
|
private _config;
|
|
592
|
+
private _target;
|
|
587
593
|
private _resizeObserver;
|
|
588
594
|
private _currentOrientation;
|
|
589
595
|
private _currentWidth;
|
|
@@ -591,7 +597,7 @@ declare class ViewportManager extends EventEmitter<ViewportEvents> {
|
|
|
591
597
|
private _currentScale;
|
|
592
598
|
private _destroyed;
|
|
593
599
|
private _resizeTimeout;
|
|
594
|
-
constructor(app: Application, container: HTMLElement, config: ViewportConfig);
|
|
600
|
+
constructor(app: Application, container: HTMLElement, config: ViewportConfig, target?: Container);
|
|
595
601
|
/** Current canvas width in game units */
|
|
596
602
|
get width(): number;
|
|
597
603
|
/** Current canvas height in game units */
|
|
@@ -692,6 +698,12 @@ declare class GameApplication extends EventEmitter<GameEngineEvents> {
|
|
|
692
698
|
input: InputManager;
|
|
693
699
|
/** Viewport manager */
|
|
694
700
|
viewport: ViewportManager;
|
|
701
|
+
/** Scaled world root (holds scenes). Transformed by the ViewportManager to fit the design
|
|
702
|
+
* resolution; lives below the UI layer on app.stage. */
|
|
703
|
+
worldRoot: Container;
|
|
704
|
+
/** Unscaled, screen-space UI layer. Sits above {@link worldRoot} and is NOT touched by the
|
|
705
|
+
* viewport transform — children fill the real screen (e.g. the host's shell + overlay). */
|
|
706
|
+
uiLayer: Container;
|
|
695
707
|
/** SDK instance (null in offline mode) */
|
|
696
708
|
sdk: CasinoGameSDK | null;
|
|
697
709
|
/** FPS overlay instance (only when debug: true) */
|
package/dist/index.esm.js
CHANGED
|
@@ -734,6 +734,7 @@ class AudioManager {
|
|
|
734
734
|
_persist;
|
|
735
735
|
_storageKey;
|
|
736
736
|
_categories;
|
|
737
|
+
_masterGain = 1.0;
|
|
737
738
|
_currentMusic = null;
|
|
738
739
|
_unlocked = false;
|
|
739
740
|
_unlockHandler = null;
|
|
@@ -793,7 +794,7 @@ class AudioManager {
|
|
|
793
794
|
if (this._globalMuted || this._categories[category].muted)
|
|
794
795
|
return;
|
|
795
796
|
const { sound } = this._soundModule;
|
|
796
|
-
const vol = (options?.volume ?? 1) * this._categories[category].volume;
|
|
797
|
+
const vol = (options?.volume ?? 1) * this._categories[category].volume * this._masterGain;
|
|
797
798
|
try {
|
|
798
799
|
sound.play(alias, {
|
|
799
800
|
volume: vol,
|
|
@@ -822,7 +823,7 @@ class AudioManager {
|
|
|
822
823
|
if (this._globalMuted || this._categories.music.muted)
|
|
823
824
|
return;
|
|
824
825
|
// Fade out the previous track
|
|
825
|
-
this.fadeVolume(prevAlias, this._categories.music.volume, 0, fadeDuration, () => {
|
|
826
|
+
this.fadeVolume(prevAlias, this._categories.music.volume * this._masterGain, 0, fadeDuration, () => {
|
|
826
827
|
try {
|
|
827
828
|
sound.stop(prevAlias);
|
|
828
829
|
}
|
|
@@ -834,7 +835,7 @@ class AudioManager {
|
|
|
834
835
|
volume: 0,
|
|
835
836
|
loop: true,
|
|
836
837
|
});
|
|
837
|
-
this.fadeVolume(alias, 0, this._categories.music.volume, fadeDuration);
|
|
838
|
+
this.fadeVolume(alias, 0, this._categories.music.volume * this._masterGain, fadeDuration);
|
|
838
839
|
}
|
|
839
840
|
catch (e) {
|
|
840
841
|
console.warn(`[AudioManager] Failed to play music "${alias}":`, e);
|
|
@@ -853,7 +854,7 @@ class AudioManager {
|
|
|
853
854
|
return;
|
|
854
855
|
try {
|
|
855
856
|
sound.play(alias, {
|
|
856
|
-
volume: this._categories.music.volume,
|
|
857
|
+
volume: this._categories.music.volume * this._masterGain,
|
|
857
858
|
loop: true,
|
|
858
859
|
});
|
|
859
860
|
}
|
|
@@ -887,6 +888,15 @@ class AudioManager {
|
|
|
887
888
|
sound.stopAll();
|
|
888
889
|
this._currentMusic = null;
|
|
889
890
|
}
|
|
891
|
+
/** Global gain (0..1) folded into every category's effective volume. Driven by the shell's
|
|
892
|
+
* 'master' settingChange. Does not affect the persisted per-category volumes. */
|
|
893
|
+
setMasterVolume(volume) {
|
|
894
|
+
this._masterGain = Math.max(0, Math.min(1, volume));
|
|
895
|
+
this.applyVolumes();
|
|
896
|
+
}
|
|
897
|
+
getMasterVolume() {
|
|
898
|
+
return this._masterGain;
|
|
899
|
+
}
|
|
890
900
|
/**
|
|
891
901
|
* Set volume for a category.
|
|
892
902
|
*/
|
|
@@ -1032,7 +1042,7 @@ class AudioManager {
|
|
|
1032
1042
|
const { sound } = this._soundModule;
|
|
1033
1043
|
// Global mute is owned by sound.muteAll()/unmuteAll() (context.muted),
|
|
1034
1044
|
// not by volumeAll — mixing both leaves mute un-undoable after reload.
|
|
1035
|
-
sound.volumeAll =
|
|
1045
|
+
sound.volumeAll = this._masterGain; // master multiplies the global bus
|
|
1036
1046
|
}
|
|
1037
1047
|
setupMobileUnlock() {
|
|
1038
1048
|
if (this._unlocked)
|
|
@@ -1300,6 +1310,7 @@ class ViewportManager extends EventEmitter {
|
|
|
1300
1310
|
_app;
|
|
1301
1311
|
_container;
|
|
1302
1312
|
_config;
|
|
1313
|
+
_target;
|
|
1303
1314
|
_resizeObserver = null;
|
|
1304
1315
|
_currentOrientation = Orientation.LANDSCAPE;
|
|
1305
1316
|
_currentWidth = 0;
|
|
@@ -1307,11 +1318,15 @@ class ViewportManager extends EventEmitter {
|
|
|
1307
1318
|
_currentScale = 1;
|
|
1308
1319
|
_destroyed = false;
|
|
1309
1320
|
_resizeTimeout = null;
|
|
1310
|
-
constructor(app, container, config) {
|
|
1321
|
+
constructor(app, container, config, target) {
|
|
1311
1322
|
super();
|
|
1312
1323
|
this._app = app;
|
|
1313
1324
|
this._container = container;
|
|
1314
1325
|
this._config = config;
|
|
1326
|
+
// The container this manager scales/offsets. Defaults to app.stage for backward
|
|
1327
|
+
// compatibility; the engine passes a dedicated scaled world root so app.stage stays
|
|
1328
|
+
// identity (screen space) for unscaled UI layers.
|
|
1329
|
+
this._target = target ?? app.stage;
|
|
1315
1330
|
this.setupObserver();
|
|
1316
1331
|
}
|
|
1317
1332
|
/** Current canvas width in game units */
|
|
@@ -1400,19 +1415,19 @@ class ViewportManager extends EventEmitter {
|
|
|
1400
1415
|
const stageScale = scaleMode === ScaleMode.STRETCH
|
|
1401
1416
|
? Math.min(containerWidth / designWidth, containerHeight / designHeight)
|
|
1402
1417
|
: scale;
|
|
1403
|
-
this.
|
|
1418
|
+
this._target.scale.set(stageScale);
|
|
1404
1419
|
// Center the stage for FIT mode
|
|
1405
1420
|
if (scaleMode === ScaleMode.FIT) {
|
|
1406
|
-
this.
|
|
1407
|
-
this.
|
|
1421
|
+
this._target.x = Math.round((containerWidth - designWidth * stageScale) / 2);
|
|
1422
|
+
this._target.y = Math.round((containerHeight - designHeight * stageScale) / 2);
|
|
1408
1423
|
}
|
|
1409
1424
|
else if (scaleMode === ScaleMode.FILL) {
|
|
1410
|
-
this.
|
|
1411
|
-
this.
|
|
1425
|
+
this._target.x = Math.round((containerWidth - gameWidth * stageScale) / 2);
|
|
1426
|
+
this._target.y = Math.round((containerHeight - gameHeight * stageScale) / 2);
|
|
1412
1427
|
}
|
|
1413
1428
|
else {
|
|
1414
|
-
this.
|
|
1415
|
-
this.
|
|
1429
|
+
this._target.x = 0;
|
|
1430
|
+
this._target.y = 0;
|
|
1416
1431
|
}
|
|
1417
1432
|
this._currentWidth = gameWidth;
|
|
1418
1433
|
this._currentHeight = gameHeight;
|
|
@@ -1903,6 +1918,12 @@ class GameApplication extends EventEmitter {
|
|
|
1903
1918
|
input;
|
|
1904
1919
|
/** Viewport manager */
|
|
1905
1920
|
viewport;
|
|
1921
|
+
/** Scaled world root (holds scenes). Transformed by the ViewportManager to fit the design
|
|
1922
|
+
* resolution; lives below the UI layer on app.stage. */
|
|
1923
|
+
worldRoot;
|
|
1924
|
+
/** Unscaled, screen-space UI layer. Sits above {@link worldRoot} and is NOT touched by the
|
|
1925
|
+
* viewport transform — children fill the real screen (e.g. the host's shell + overlay). */
|
|
1926
|
+
uiLayer;
|
|
1906
1927
|
/** SDK instance (null in offline mode) */
|
|
1907
1928
|
sdk = null;
|
|
1908
1929
|
/** FPS overlay instance (only when debug: true) */
|
|
@@ -2082,20 +2103,27 @@ class GameApplication extends EventEmitter {
|
|
|
2082
2103
|
this.audio = new AudioManager(this.config.audio);
|
|
2083
2104
|
// Input Manager
|
|
2084
2105
|
this.input = new InputManager(this.app.canvas);
|
|
2085
|
-
//
|
|
2106
|
+
// Stage layers: a scaled world root (scenes, transformed to design resolution by the
|
|
2107
|
+
// viewport) below an unscaled UI layer (screen space). app.stage itself stays identity.
|
|
2108
|
+
this.worldRoot = new Container();
|
|
2109
|
+
this.worldRoot.label = 'world';
|
|
2110
|
+
this.uiLayer = new Container();
|
|
2111
|
+
this.uiLayer.label = 'ui';
|
|
2112
|
+
this.app.stage.addChild(this.worldRoot, this.uiLayer);
|
|
2113
|
+
// Viewport Manager — scales worldRoot (NOT app.stage), so the UI layer is unscaled.
|
|
2086
2114
|
this.viewport = new ViewportManager(this.app, this._container, {
|
|
2087
2115
|
designWidth: this.config.designWidth,
|
|
2088
2116
|
designHeight: this.config.designHeight,
|
|
2089
2117
|
scaleMode: this.config.scaleMode,
|
|
2090
2118
|
orientation: this.config.orientation,
|
|
2091
|
-
});
|
|
2092
|
-
// Wire SceneManager to the
|
|
2093
|
-
this.scenes.setRoot(this.
|
|
2119
|
+
}, this.worldRoot);
|
|
2120
|
+
// Wire SceneManager to the scaled world root
|
|
2121
|
+
this.scenes.setRoot(this.worldRoot);
|
|
2094
2122
|
this.scenes.setApp(this);
|
|
2095
2123
|
// Wire viewport resize → scene manager + input manager
|
|
2096
2124
|
this.viewport.on('resize', ({ width, height, scale }) => {
|
|
2097
2125
|
this.scenes.resize(width, height);
|
|
2098
|
-
this.input.setViewportTransform(scale, this.
|
|
2126
|
+
this.input.setViewportTransform(scale, this.worldRoot.x, this.worldRoot.y);
|
|
2099
2127
|
this.emit('resize', { width, height });
|
|
2100
2128
|
});
|
|
2101
2129
|
this.viewport.on('orientationChange', (orientation) => {
|