@energy8platform/game-engine 0.20.0 → 0.22.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.
Files changed (93) hide show
  1. package/README.md +121 -0
  2. package/dist/animation.cjs.js +18 -3
  3. package/dist/animation.cjs.js.map +1 -1
  4. package/dist/animation.esm.js +18 -3
  5. package/dist/animation.esm.js.map +1 -1
  6. package/dist/core.cjs.js +18 -3
  7. package/dist/core.cjs.js.map +1 -1
  8. package/dist/core.esm.js +18 -3
  9. package/dist/core.esm.js.map +1 -1
  10. package/dist/host.cjs.js +18 -3
  11. package/dist/host.cjs.js.map +1 -1
  12. package/dist/host.d.ts +3 -5
  13. package/dist/host.esm.js +18 -3
  14. package/dist/host.esm.js.map +1 -1
  15. package/dist/index.cjs.js +18 -2535
  16. package/dist/index.cjs.js.map +1 -1
  17. package/dist/index.d.ts +3 -1020
  18. package/dist/index.esm.js +20 -2525
  19. package/dist/index.esm.js.map +1 -1
  20. package/dist/slot.cjs.js +1872 -61
  21. package/dist/slot.cjs.js.map +1 -1
  22. package/dist/slot.d.ts +555 -28
  23. package/dist/slot.esm.js +1857 -62
  24. package/dist/slot.esm.js.map +1 -1
  25. package/dist/vite.cjs.js +0 -5
  26. package/dist/vite.cjs.js.map +1 -1
  27. package/dist/vite.esm.js +0 -5
  28. package/dist/vite.esm.js.map +1 -1
  29. package/package.json +2 -35
  30. package/src/animation/Tween.ts +14 -3
  31. package/src/host/index.ts +0 -1
  32. package/src/host/types.ts +0 -3
  33. package/src/index.ts +0 -28
  34. package/src/slot/anim/easing-map.ts +16 -2
  35. package/src/slot/cascade/TumbleController.ts +230 -0
  36. package/src/slot/config/ReelSystemConfig.ts +559 -0
  37. package/src/slot/config/presets.ts +222 -0
  38. package/src/slot/features/extra.ts +189 -0
  39. package/src/slot/features/index.ts +44 -0
  40. package/src/slot/features/symbols.ts +183 -0
  41. package/src/slot/features/types.ts +136 -0
  42. package/src/slot/features/wilds.ts +151 -0
  43. package/src/slot/grid/ReelGrid.ts +93 -24
  44. package/src/slot/grid/SymbolCell.ts +45 -11
  45. package/src/slot/index.ts +61 -2
  46. package/src/slot/motion/AnticipationController.ts +96 -0
  47. package/src/slot/motion/SpinEngine.ts +384 -0
  48. package/src/slot/system/ReelSystem.ts +295 -0
  49. package/src/vite/index.ts +0 -5
  50. package/dist/react-jsx.cjs.js +0 -3
  51. package/dist/react-jsx.cjs.js.map +0 -1
  52. package/dist/react-jsx.d.ts +0 -602
  53. package/dist/react-jsx.esm.js +0 -2
  54. package/dist/react-jsx.esm.js.map +0 -1
  55. package/dist/react.cjs.js +0 -3787
  56. package/dist/react.cjs.js.map +0 -1
  57. package/dist/react.d.ts +0 -1467
  58. package/dist/react.esm.js +0 -3771
  59. package/dist/react.esm.js.map +0 -1
  60. package/dist/ui.cjs.js +0 -2999
  61. package/dist/ui.cjs.js.map +0 -1
  62. package/dist/ui.d.ts +0 -1116
  63. package/dist/ui.esm.js +0 -2983
  64. package/dist/ui.esm.js.map +0 -1
  65. package/src/react/EngineContext.ts +0 -26
  66. package/src/react/ReactScene.ts +0 -88
  67. package/src/react/applyProps.ts +0 -271
  68. package/src/react/catalogue.ts +0 -17
  69. package/src/react/createPixiRoot.ts +0 -31
  70. package/src/react/extendAll.ts +0 -74
  71. package/src/react/hooks.ts +0 -46
  72. package/src/react/index.ts +0 -29
  73. package/src/react/jsx-runtime.ts +0 -346
  74. package/src/react/reconciler.ts +0 -338
  75. package/src/slot/freeSpins/FreeSpinsSession.ts +0 -40
  76. package/src/state/StateMachine.ts +0 -231
  77. package/src/state/index.ts +0 -1
  78. package/src/ui/BalanceDisplay.ts +0 -159
  79. package/src/ui/Button.ts +0 -304
  80. package/src/ui/FlexContainer.ts +0 -775
  81. package/src/ui/Label.ts +0 -124
  82. package/src/ui/LabelValue.ts +0 -122
  83. package/src/ui/Layout.ts +0 -291
  84. package/src/ui/Modal.ts +0 -170
  85. package/src/ui/Panel.ts +0 -204
  86. package/src/ui/ProgressBar.ts +0 -170
  87. package/src/ui/ScrollContainer.ts +0 -478
  88. package/src/ui/Slider.ts +0 -241
  89. package/src/ui/Toast.ts +0 -150
  90. package/src/ui/Toggle.ts +0 -201
  91. package/src/ui/WinDisplay.ts +0 -145
  92. package/src/ui/index.ts +0 -33
  93. package/src/ui/view.ts +0 -28
package/src/ui/Panel.ts DELETED
@@ -1,204 +0,0 @@
1
- import { Container, Graphics, NineSliceSprite, Texture } from 'pixi.js';
2
- import { FlexContainer } from './FlexContainer';
3
- import type { FlexContainerConfig } from './FlexContainer';
4
-
5
- export interface PanelConfig {
6
- /** Width */
7
- width?: number;
8
- /** Height */
9
- height?: number;
10
- /** Background color (for Graphics-based panel) */
11
- backgroundColor?: number;
12
- /** Background alpha */
13
- backgroundAlpha?: number;
14
- /** Corner radius */
15
- borderRadius?: number;
16
- /** Border color */
17
- borderColor?: number;
18
- /** Border width */
19
- borderWidth?: number;
20
- /** 9-slice texture (if provided, uses NineSliceSprite instead of Graphics) */
21
- nineSliceTexture?: string | Texture;
22
- /** 9-slice borders [left, top, right, bottom] */
23
- nineSliceBorders?: [number, number, number, number];
24
- /** Padding inside the panel */
25
- padding?: number;
26
- /** Flex layout config for content */
27
- layout?: Partial<FlexContainerConfig>;
28
- }
29
-
30
- /**
31
- * Background panel with optional flexbox content layout.
32
- *
33
- * Supports both Graphics-based (color + border) and 9-slice sprite backgrounds.
34
- * Children added via `addContent()` participate in flex layout automatically.
35
- *
36
- * @example
37
- * ```ts
38
- * // Simple colored panel
39
- * const panel = new Panel({ width: 400, height: 300, backgroundColor: 0x222222, borderRadius: 12 });
40
- *
41
- * // 9-slice panel (texture-based)
42
- * const panel = new Panel({
43
- * nineSliceTexture: 'panel-bg',
44
- * nineSliceBorders: [20, 20, 20, 20],
45
- * width: 400, height: 300,
46
- * });
47
- * ```
48
- */
49
- export class Panel extends Container {
50
- readonly __uiComponent = true as const;
51
-
52
- private _bg: Container;
53
- private _content: FlexContainer;
54
- private _internalSetup = true;
55
- private _panelConfig: Required<
56
- Pick<PanelConfig, 'width' | 'height' | 'padding' | 'backgroundAlpha'>
57
- > & PanelConfig;
58
-
59
- constructor(config: PanelConfig = {}) {
60
- super();
61
-
62
- const resolvedConfig = {
63
- width: config.width ?? 400,
64
- height: config.height ?? 300,
65
- padding: config.padding ?? 16,
66
- backgroundAlpha: config.backgroundAlpha ?? 1,
67
- ...config,
68
- };
69
-
70
- this._panelConfig = resolvedConfig;
71
-
72
- // Create background
73
- if (config.nineSliceTexture) {
74
- const texture =
75
- typeof config.nineSliceTexture === 'string'
76
- ? Texture.from(config.nineSliceTexture)
77
- : config.nineSliceTexture;
78
- const [left, top, right, bottom] = config.nineSliceBorders ?? [10, 10, 10, 10];
79
- const nineSlice = new NineSliceSprite({
80
- texture,
81
- leftWidth: left,
82
- topHeight: top,
83
- rightWidth: right,
84
- bottomHeight: bottom,
85
- });
86
- nineSlice.width = resolvedConfig.width;
87
- nineSlice.height = resolvedConfig.height;
88
- nineSlice.alpha = resolvedConfig.backgroundAlpha;
89
- this._bg = nineSlice;
90
- } else {
91
- const g = new Graphics();
92
- const bgColor = config.backgroundColor ?? 0x1a1a2e;
93
- const radius = config.borderRadius ?? 0;
94
- g.roundRect(0, 0, resolvedConfig.width, resolvedConfig.height, radius).fill(bgColor);
95
- if (config.borderColor !== undefined && config.borderWidth) {
96
- g.roundRect(0, 0, resolvedConfig.width, resolvedConfig.height, radius)
97
- .stroke({ color: config.borderColor, width: config.borderWidth });
98
- }
99
- g.alpha = resolvedConfig.backgroundAlpha;
100
- this._bg = g;
101
- }
102
- this.addChild(this._bg);
103
-
104
- // Create content flex container
105
- this._content = new FlexContainer({
106
- ...config.layout,
107
- direction: config.layout?.direction ?? 'column',
108
- justifyContent: config.layout?.justifyContent ?? 'start',
109
- alignItems: config.layout?.alignItems ?? 'start',
110
- gap: config.layout?.gap ?? 0,
111
- padding: resolvedConfig.padding,
112
- width: resolvedConfig.width,
113
- height: resolvedConfig.height,
114
- });
115
- this.addChild(this._content);
116
- this._internalSetup = false;
117
- }
118
-
119
- /** Access the content flex container — add children here for layout */
120
- get content(): FlexContainer {
121
- return this._content;
122
- }
123
-
124
- /** Suspend content layout recalculation. Call resumeLayout() to flush. */
125
- suspendLayout(): void {
126
- this._content.suspendLayout();
127
- }
128
-
129
- /** Resume content layout and flush if dirty. */
130
- resumeLayout(): void {
131
- this._content.resumeLayout();
132
- }
133
-
134
- /** Convenience: add a child to the content layout */
135
- addContent(child: Container): this {
136
- this._content.addFlexChild(child);
137
- this._content.updateLayout();
138
- return this;
139
- }
140
-
141
- /** Resize the panel */
142
- setSize(width: number, height: number): void {
143
- this._panelConfig.width = width;
144
- this._panelConfig.height = height;
145
-
146
- // Resize background
147
- if (this._bg instanceof NineSliceSprite) {
148
- this._bg.width = width;
149
- this._bg.height = height;
150
- } else if (this._bg instanceof Graphics) {
151
- const radius = this._panelConfig.borderRadius ?? 0;
152
- const bgColor = this._panelConfig.backgroundColor ?? 0x1a1a2e;
153
- this._bg.clear();
154
- (this._bg as Graphics).roundRect(0, 0, width, height, radius).fill(bgColor);
155
- if (this._panelConfig.borderColor !== undefined && this._panelConfig.borderWidth) {
156
- (this._bg as Graphics).roundRect(0, 0, width, height, radius)
157
- .stroke({ color: this._panelConfig.borderColor, width: this._panelConfig.borderWidth });
158
- }
159
- this._bg.alpha = this._panelConfig.backgroundAlpha;
160
- }
161
-
162
- this._content.resize(width, height);
163
- }
164
-
165
- /**
166
- * Override addChild so external children are routed to content FlexContainer.
167
- * Enables `<panel><label /><button /></panel>` in React JSX.
168
- */
169
- override addChild<T extends Container>(...children: T[]): T {
170
- if (this._internalSetup) {
171
- return super.addChild(...children);
172
- }
173
- for (const child of children) {
174
- this._content.addFlexChild(child as any);
175
- }
176
- this._content.updateLayout();
177
- return children[0];
178
- }
179
-
180
- override removeChild<T extends Container>(...children: T[]): T {
181
- if (this._internalSetup) {
182
- return super.removeChild(...children);
183
- }
184
- for (const child of children) {
185
- this._content.removeFlexChild(child as any);
186
- }
187
- return children[0];
188
- }
189
-
190
- /** React reconciler update hook */
191
- updateConfig(changed: Record<string, any>): void {
192
- if ('width' in changed || 'height' in changed) {
193
- this.setSize(changed.width ?? this._panelConfig.width, changed.height ?? this._panelConfig.height);
194
- }
195
- if ('backgroundAlpha' in changed) {
196
- this._panelConfig.backgroundAlpha = changed.backgroundAlpha;
197
- this._bg.alpha = changed.backgroundAlpha;
198
- }
199
- }
200
-
201
- override destroy(options?: boolean | { children?: boolean; texture?: boolean; textureSource?: boolean }): void {
202
- super.destroy(options);
203
- }
204
- }
@@ -1,170 +0,0 @@
1
- import { Container, Graphics } from 'pixi.js';
2
- import { resolveView } from './view';
3
- import type { ViewInput } from './view';
4
-
5
- export interface ProgressBarConfig {
6
- /** Width of the bar */
7
- width?: number;
8
- /** Height of the bar */
9
- height?: number;
10
- /** Corner radius (for Graphics-based bar) */
11
- borderRadius?: number;
12
- /** Fill color (for Graphics-based bar, ignored when fillView provided) */
13
- fillColor?: number;
14
- /** Track background color (for Graphics-based bar, ignored when trackView provided) */
15
- trackColor?: number;
16
- /** Border color */
17
- borderColor?: number;
18
- /** Border width */
19
- borderWidth?: number;
20
- /** Animated fill (smoothly interpolate) */
21
- animated?: boolean;
22
- /** Animation speed (0..1 per frame, default: 0.1) */
23
- animationSpeed?: number;
24
-
25
- /** Custom track background (string texture name, Texture, or Container) */
26
- trackView?: ViewInput;
27
- /** Custom fill bar (string texture name, Texture, or Container) */
28
- fillView?: ViewInput;
29
- }
30
-
31
- /**
32
- * Horizontal progress bar with optional custom track/fill views.
33
- *
34
- * Supports asset-based skinning: provide `trackView` and/or `fillView`
35
- * as texture names, Textures, or any Container (NineSliceSprite, custom artwork, etc).
36
- * Falls back to colored Graphics when no custom views are provided.
37
- *
38
- * @example
39
- * ```ts
40
- * // Graphics-based (quick prototyping)
41
- * const bar = new ProgressBar({ width: 300, height: 20, fillColor: 0x22cc22 });
42
- * bar.progress = 0.5;
43
- *
44
- * // Asset-based (production art)
45
- * const bar = new ProgressBar({
46
- * width: 300, height: 20,
47
- * trackView: 'bar-track',
48
- * fillView: new NineSliceSprite({ texture: 'bar-fill', ... }),
49
- * });
50
- * bar.progress = 0.75;
51
- * ```
52
- */
53
- export class ProgressBar extends Container {
54
- readonly __uiComponent = true as const;
55
-
56
- private _track: Container;
57
- private _fill: Container;
58
- private _fillMask: Graphics;
59
- private _borderGfx: Graphics;
60
- private _config: Required<Pick<ProgressBarConfig, 'width' | 'height' | 'borderRadius' | 'fillColor' | 'trackColor' | 'borderColor' | 'borderWidth' | 'animated' | 'animationSpeed'>>;
61
- private _progress = 0;
62
- private _displayedProgress = 0;
63
-
64
- constructor(config: ProgressBarConfig = {}) {
65
- super();
66
-
67
- this._config = {
68
- width: config.width ?? 300,
69
- height: config.height ?? 16,
70
- borderRadius: config.borderRadius ?? 8,
71
- fillColor: config.fillColor ?? 0xffd700,
72
- trackColor: config.trackColor ?? 0x333333,
73
- borderColor: config.borderColor ?? 0x555555,
74
- borderWidth: config.borderWidth ?? 1,
75
- animated: config.animated ?? true,
76
- animationSpeed: config.animationSpeed ?? 0.1,
77
- };
78
-
79
- const { width, height, borderRadius, fillColor, trackColor, borderColor, borderWidth } = this._config;
80
-
81
- // Track background — custom view or Graphics
82
- const customTrack = resolveView(config.trackView);
83
- if (customTrack) {
84
- customTrack.width = width;
85
- customTrack.height = height;
86
- this._track = customTrack;
87
- } else {
88
- const g = new Graphics();
89
- g.roundRect(0, 0, width, height, borderRadius).fill(trackColor);
90
- this._track = g;
91
- }
92
- this.addChild(this._track);
93
-
94
- // Fill bar — custom view or Graphics
95
- const customFill = resolveView(config.fillView);
96
- if (customFill) {
97
- customFill.x = borderWidth;
98
- customFill.y = borderWidth;
99
- customFill.width = width - borderWidth * 2;
100
- customFill.height = height - borderWidth * 2;
101
- this._fill = customFill;
102
- } else {
103
- const g = new Graphics();
104
- g.roundRect(
105
- borderWidth, borderWidth,
106
- width - borderWidth * 2, height - borderWidth * 2,
107
- Math.max(0, borderRadius - 1),
108
- ).fill(fillColor);
109
- this._fill = g;
110
- }
111
- this.addChild(this._fill);
112
-
113
- // Mask for the fill (controls visible width)
114
- this._fillMask = new Graphics();
115
- this._fillMask.rect(0, 0, 0, height).fill(0xffffff);
116
- this.addChild(this._fillMask);
117
- this._fill.mask = this._fillMask;
118
-
119
- // Border overlay
120
- this._borderGfx = new Graphics();
121
- if (borderColor !== undefined && borderWidth > 0) {
122
- this._borderGfx
123
- .roundRect(0, 0, width, height, borderRadius)
124
- .stroke({ color: borderColor, width: borderWidth });
125
- }
126
- this.addChild(this._borderGfx);
127
- }
128
-
129
- /** Get/set progress (0..1) */
130
- get progress(): number {
131
- return this._progress;
132
- }
133
-
134
- set progress(value: number) {
135
- this._progress = Math.max(0, Math.min(1, value));
136
- if (!this._config.animated) {
137
- this._displayedProgress = this._progress;
138
- this.updateMask();
139
- }
140
- }
141
-
142
- /**
143
- * Call each frame if animated is true.
144
- */
145
- update(_dt: number): void {
146
- if (!this._config.animated) return;
147
- if (Math.abs(this._displayedProgress - this._progress) < 0.001) {
148
- this._displayedProgress = this._progress;
149
- this.updateMask();
150
- return;
151
- }
152
-
153
- this._displayedProgress +=
154
- (this._progress - this._displayedProgress) * this._config.animationSpeed;
155
- this.updateMask();
156
- }
157
-
158
- /** React reconciler update hook */
159
- updateConfig(changed: Record<string, any>): void {
160
- if ('progress' in changed) this.progress = changed.progress;
161
- if ('animated' in changed) this._config.animated = changed.animated;
162
- if ('animationSpeed' in changed) this._config.animationSpeed = changed.animationSpeed;
163
- }
164
-
165
- private updateMask(): void {
166
- const w = this._config.width * this._displayedProgress;
167
- this._fillMask.clear();
168
- this._fillMask.rect(0, 0, w, this._config.height).fill(0xffffff);
169
- }
170
- }