@shimotsuki/core 1.0.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/LICENSE +21 -0
- package/dist/index.d.ts +1015 -0
- package/dist/index.js +1 -0
- package/package.json +45 -0
- package/temp/tsconfig.cocos.json +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 yami
|
|
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/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1015 @@
|
|
|
1
|
+
import { Component, Node, Prefab, Vec3, Quat, Layers, math, AudioSource, Label, Button, Scene, Asset, Constructor, AssetManager, SpriteFrame, Sprite, AsyncDelegate } from 'cc';
|
|
2
|
+
import { IReactionPublic, IReactionOptions } from '@shimotsuki/mobx';
|
|
3
|
+
import * as crypto_es_lib_cipher_core from 'crypto-es/lib/cipher-core';
|
|
4
|
+
import { DescMessage, MessageShape } from '@bufbuild/protobuf';
|
|
5
|
+
import { ClientOption } from 'pitayaclient';
|
|
6
|
+
import { SocialGameClient, SocialGameClientOption, AllEventResponsePairs, AudienceOptions } from 'sgc';
|
|
7
|
+
import { ReflectMessage } from '@bufbuild/protobuf/reflect';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @describe 基础管理类
|
|
11
|
+
* @author 游金宇(KM)
|
|
12
|
+
* @date 2024-09-12 11:49:30
|
|
13
|
+
*/
|
|
14
|
+
declare class BaseManager {
|
|
15
|
+
protected cat: Manager;
|
|
16
|
+
constructor(manager: Manager);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 音频管理
|
|
21
|
+
*/
|
|
22
|
+
declare class AudioManager extends BaseManager {
|
|
23
|
+
private local_data;
|
|
24
|
+
private music;
|
|
25
|
+
private effect;
|
|
26
|
+
private _volume_music;
|
|
27
|
+
private _volume_effect;
|
|
28
|
+
private _switch_music;
|
|
29
|
+
private _switch_effect;
|
|
30
|
+
constructor(cat: Manager);
|
|
31
|
+
/**
|
|
32
|
+
* 设置背景音乐播放完成回调
|
|
33
|
+
* @param callback 背景音乐播放完成回调
|
|
34
|
+
*/
|
|
35
|
+
setMusicComplete(callback?: Function | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* 播放背景音乐
|
|
38
|
+
* @param url 资源地址
|
|
39
|
+
* @param callback 音乐播放完成事件
|
|
40
|
+
*/
|
|
41
|
+
playMusic(url: string, callback?: Function): void;
|
|
42
|
+
/**
|
|
43
|
+
* 停止音乐
|
|
44
|
+
*/
|
|
45
|
+
stopMusic(): void;
|
|
46
|
+
/**暂停音乐 */
|
|
47
|
+
pauseMusic(): void;
|
|
48
|
+
/**恢复音乐 */
|
|
49
|
+
resumeMusic(): void;
|
|
50
|
+
/**
|
|
51
|
+
* 获取背景音乐播放进度
|
|
52
|
+
*/
|
|
53
|
+
get progressMusic(): number;
|
|
54
|
+
/**
|
|
55
|
+
* 设置背景乐播放进度
|
|
56
|
+
* @param value 播放进度值
|
|
57
|
+
*/
|
|
58
|
+
set progressMusic(value: number);
|
|
59
|
+
/**
|
|
60
|
+
* 获取背景音乐音量
|
|
61
|
+
*/
|
|
62
|
+
get volumeMusic(): number;
|
|
63
|
+
/**
|
|
64
|
+
* 设置背景音乐音量
|
|
65
|
+
* @param value 音乐音量值
|
|
66
|
+
*/
|
|
67
|
+
set volumeMusic(value: number);
|
|
68
|
+
/**
|
|
69
|
+
* 获取背景音乐开关值
|
|
70
|
+
*/
|
|
71
|
+
get switchMusic(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* 设置背景音乐开关值
|
|
74
|
+
* @param value 开关值
|
|
75
|
+
*/
|
|
76
|
+
set switchMusic(value: boolean);
|
|
77
|
+
/**
|
|
78
|
+
* 播放音效
|
|
79
|
+
* @param url 资源地址
|
|
80
|
+
*/
|
|
81
|
+
playEffect(url: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* 停止音效
|
|
84
|
+
*/
|
|
85
|
+
stopEffect(): void;
|
|
86
|
+
/**
|
|
87
|
+
* 获取音效音量
|
|
88
|
+
*/
|
|
89
|
+
get volumeEffect(): number;
|
|
90
|
+
/**
|
|
91
|
+
* 设置获取音效音量
|
|
92
|
+
* @param value 音效音量值
|
|
93
|
+
*/
|
|
94
|
+
set volumeEffect(value: number);
|
|
95
|
+
/**
|
|
96
|
+
* 获取音效开关值
|
|
97
|
+
*/
|
|
98
|
+
get switchEffect(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* 设置音效开关值
|
|
101
|
+
* @param value 音效开关值
|
|
102
|
+
*/
|
|
103
|
+
set switchEffect(value: boolean);
|
|
104
|
+
/** 恢复当前暂停的音乐与音效播放 */
|
|
105
|
+
resumeAll(): void;
|
|
106
|
+
/** 暂停当前音乐与音效的播放 */
|
|
107
|
+
pauseAll(): void;
|
|
108
|
+
/** 停止当前音乐与音效的播放 */
|
|
109
|
+
stopAll(): void;
|
|
110
|
+
/** 保存音乐音效的音量、开关配置数据到本地 */
|
|
111
|
+
protected save(): void;
|
|
112
|
+
/** 本地加载音乐音效的音量、开关配置数据并设置到游戏中 */
|
|
113
|
+
protected load(): void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @describe 本地存储管理
|
|
118
|
+
* @author 游金宇(KM)
|
|
119
|
+
* @date 2023-08-03 17:58:51
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
declare class StorageManager extends BaseManager {
|
|
123
|
+
private _key;
|
|
124
|
+
private _iv;
|
|
125
|
+
private _id;
|
|
126
|
+
/**
|
|
127
|
+
* 初始化密钥
|
|
128
|
+
* @param key aes加密的key
|
|
129
|
+
* @param iv aes加密的iv
|
|
130
|
+
*/
|
|
131
|
+
init(key: string, iv: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* 设置用户唯一标识
|
|
134
|
+
* @param id
|
|
135
|
+
*/
|
|
136
|
+
setUser(id: string): void;
|
|
137
|
+
/**
|
|
138
|
+
* 存储本地数据
|
|
139
|
+
* @param key 存储key
|
|
140
|
+
* @param value 存储值
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
set(key: string, value: any): void;
|
|
144
|
+
/**
|
|
145
|
+
* 获取指定关键字的数据
|
|
146
|
+
* @param key 获取的关键字
|
|
147
|
+
* @param defaultValue 获取的默认值
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
get(key: string, defaultValue?: any): string;
|
|
151
|
+
/** 获取指定关键字的数值 */
|
|
152
|
+
getNumber(key: string, defaultValue?: number): number;
|
|
153
|
+
/** 获取指定关键字的布尔值 */
|
|
154
|
+
getBoolean(key: string): boolean;
|
|
155
|
+
/** 获取指定关键字的JSON对象 */
|
|
156
|
+
getJson(key: string, defaultValue?: any): any;
|
|
157
|
+
/**
|
|
158
|
+
* 删除指定关键字的数据
|
|
159
|
+
* @param key 需要移除的关键字
|
|
160
|
+
* @returns
|
|
161
|
+
*/
|
|
162
|
+
remove(key: string): void;
|
|
163
|
+
/** 清空整个本地存储 */
|
|
164
|
+
clear(): void;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @describe 组件基类
|
|
169
|
+
* @author 游金宇(KM)
|
|
170
|
+
* @date 2023-09-19 12:32:22
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
type HOOK_NAME = 'destroyed' | 'started';
|
|
174
|
+
type HOOK = {
|
|
175
|
+
[key in HOOK_NAME]?: () => void;
|
|
176
|
+
};
|
|
177
|
+
interface IUIOption<T extends object = {}, U extends object = {}> {
|
|
178
|
+
/**组件传值间属性值 */
|
|
179
|
+
props?: T;
|
|
180
|
+
/**组件数据 */
|
|
181
|
+
data?: U;
|
|
182
|
+
/**钩子 */
|
|
183
|
+
hook?: HOOK;
|
|
184
|
+
}
|
|
185
|
+
/**参数 */
|
|
186
|
+
declare class BaseComponent<T extends object = {}, K extends object = {}> extends Component {
|
|
187
|
+
/**组件(传值)属性 */
|
|
188
|
+
props: T;
|
|
189
|
+
/**自由属性 */
|
|
190
|
+
data: K;
|
|
191
|
+
/**autorun销毁 */
|
|
192
|
+
private autorunDisposers;
|
|
193
|
+
/**reaction销毁 */
|
|
194
|
+
private reactionDisposers;
|
|
195
|
+
hook: HOOK;
|
|
196
|
+
/**初始化UI(可在本函数中进行节点赋值或注册节点事件等...) */
|
|
197
|
+
protected initUI(): void;
|
|
198
|
+
/**添加到父节点(动画结束) */
|
|
199
|
+
protected added(): void;
|
|
200
|
+
protected __preload(): void;
|
|
201
|
+
constructor();
|
|
202
|
+
/**依赖收集生命周期(可以在该生命周期中注册依赖收集回调) */
|
|
203
|
+
protected onAutoObserver(): void;
|
|
204
|
+
/**添加自动收集 */
|
|
205
|
+
protected addAutorun(cb: (() => void) | (() => void)[]): this;
|
|
206
|
+
/**添加自动收集 */
|
|
207
|
+
protected addReaction<T, FireImmediately extends boolean = false>(expression: (r: IReactionPublic) => T, effect: (arg: T, prev: FireImmediately extends true ? T | undefined : T, r: IReactionPublic) => void, opts?: IReactionOptions<T, FireImmediately>): this;
|
|
208
|
+
_onPreDestroy(): void;
|
|
209
|
+
protected onDisable(): void;
|
|
210
|
+
protected onEnable(): void;
|
|
211
|
+
/**子类继承该方法(注册在components上的事件可以不添加取消监听(自动取消监听了)) */
|
|
212
|
+
protected onEventListener(): void;
|
|
213
|
+
/**子类继承该方法 */
|
|
214
|
+
protected addListener(): void;
|
|
215
|
+
/**子类继承该方法 */
|
|
216
|
+
protected removeListener(): void;
|
|
217
|
+
/**
|
|
218
|
+
* 添加到父节点
|
|
219
|
+
* @param parent 父节点
|
|
220
|
+
* @param option 参数
|
|
221
|
+
* @returns 自身组件
|
|
222
|
+
*/
|
|
223
|
+
addToParent(parent: Node | Prefab | Component, options?: IUIOption<T, K>): this;
|
|
224
|
+
/**设置属性(覆盖原有属性) */
|
|
225
|
+
setOptions(options?: IUIOption<T, K>): void;
|
|
226
|
+
/**设置data属性(更新) */
|
|
227
|
+
setUpdateData(data: K): this;
|
|
228
|
+
/**设置props属性(更新)*/
|
|
229
|
+
setUpdateProps(props: T): this;
|
|
230
|
+
/**从父节点移除并销毁 */
|
|
231
|
+
removeAndDestroy(): void;
|
|
232
|
+
/**设置坐标 */
|
|
233
|
+
setPosition(positin: Vec3): this;
|
|
234
|
+
setScale(scale: Vec3): this;
|
|
235
|
+
setAngle(angle: number): this;
|
|
236
|
+
setRotation(rotation: Quat): this;
|
|
237
|
+
/**显示(同onEnable) */
|
|
238
|
+
protected onShow(): void;
|
|
239
|
+
/**隐藏(同onDisable) */
|
|
240
|
+
protected onHide(): void;
|
|
241
|
+
/**设置节点和子节点的层级 */
|
|
242
|
+
setNodeAndChildrenLayer(layer: string | Layers.Enum): this;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @describe UI层 所有的UI层需继承自该自组件
|
|
247
|
+
* @author 游金宇(KM)
|
|
248
|
+
* @date 2023-08-04 10:42:26
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* left 从左往右
|
|
253
|
+
* right 从右往左
|
|
254
|
+
* top 从上往下
|
|
255
|
+
* bot 从下往上
|
|
256
|
+
* center 中间
|
|
257
|
+
*/
|
|
258
|
+
type IDirection = 'left' | 'right' | 'top' | 'bot' | 'center';
|
|
259
|
+
/**开启动画参数选项 */
|
|
260
|
+
interface IOpenOptions<T extends object, U extends object> extends IUIOption<T, U> {
|
|
261
|
+
/**动画 */
|
|
262
|
+
isMotion?: boolean;
|
|
263
|
+
/**动画时间 */
|
|
264
|
+
duration?: number;
|
|
265
|
+
/**方向 */
|
|
266
|
+
direction?: IDirection;
|
|
267
|
+
/**是否回弹 */
|
|
268
|
+
isBounce?: boolean;
|
|
269
|
+
/**回弹时间 */
|
|
270
|
+
bounceDuration?: number;
|
|
271
|
+
}
|
|
272
|
+
/**关闭动画参数选项 */
|
|
273
|
+
interface ICloseOptions<T extends object, U extends object> extends IUIOption<T, U> {
|
|
274
|
+
/**动画 */
|
|
275
|
+
isMotion?: boolean;
|
|
276
|
+
/**动画时间 */
|
|
277
|
+
duration?: number;
|
|
278
|
+
/**方向 */
|
|
279
|
+
direction?: IDirection;
|
|
280
|
+
}
|
|
281
|
+
declare class UILayer<T extends object = {}, U extends object = {}> extends BaseComponent<T, U> {
|
|
282
|
+
/**上次进入的方向 */
|
|
283
|
+
lastEnterDirection: IDirection;
|
|
284
|
+
/**屏幕尺寸 */
|
|
285
|
+
screen: math.Size;
|
|
286
|
+
/**是否正在关闭 */
|
|
287
|
+
isClosing: boolean;
|
|
288
|
+
/**组件所在的UI最顶层(不包含UI) */
|
|
289
|
+
root: Node;
|
|
290
|
+
constructor();
|
|
291
|
+
private _init;
|
|
292
|
+
/**显示动画 */
|
|
293
|
+
showTween<T extends object, U extends object = {}>({ isMotion, direction, duration, isBounce, bounceDuration }: IOpenOptions<T, U>): Promise<void>;
|
|
294
|
+
/**隐藏动画 */
|
|
295
|
+
hideTween<T extends object, U extends object>({ isMotion, direction, duration }: ICloseOptions<T, U>): Promise<void>;
|
|
296
|
+
private handle;
|
|
297
|
+
private deftween;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @describe 音频组件基类
|
|
302
|
+
* @author 游金宇(KM)
|
|
303
|
+
* @date 2023-12-22 16:20:20
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* EFFECT 音效
|
|
308
|
+
* BGM 音乐
|
|
309
|
+
*/
|
|
310
|
+
declare enum AudioTypeEnum {
|
|
311
|
+
EFFECT = 0,
|
|
312
|
+
BGM = 1
|
|
313
|
+
}
|
|
314
|
+
declare class AudioSourceBaseComponent<T extends object = {}, K extends object = {}> extends BaseComponent<T, K> {
|
|
315
|
+
type: AudioTypeEnum;
|
|
316
|
+
clip: never;
|
|
317
|
+
loop: boolean;
|
|
318
|
+
volume: number;
|
|
319
|
+
playOnAwake: boolean;
|
|
320
|
+
audioSource: AudioSource;
|
|
321
|
+
onEnable(): void;
|
|
322
|
+
__preload(): void;
|
|
323
|
+
protected start(): void;
|
|
324
|
+
protected stopAudio(): void;
|
|
325
|
+
protected playAudio(): void;
|
|
326
|
+
protected onPlayEffectHandler(): void;
|
|
327
|
+
protected onStopEffectHandler(): void;
|
|
328
|
+
protected onPlayMusicHandler(): void;
|
|
329
|
+
protected onStopMusicHandler(): void;
|
|
330
|
+
_onPreDestroy(): void;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @describe TOAST弹窗组件
|
|
335
|
+
* @author 游金宇(KM)
|
|
336
|
+
* @date 2024-09-12 11:42:29
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
declare enum ToastType {
|
|
340
|
+
FIXED = 0,
|
|
341
|
+
SLIDE = 1
|
|
342
|
+
}
|
|
343
|
+
type ToastProps = {
|
|
344
|
+
title: string;
|
|
345
|
+
type?: ToastType;
|
|
346
|
+
fixed_time?: number;
|
|
347
|
+
};
|
|
348
|
+
declare class CoreToast extends BaseComponent<ToastProps> {
|
|
349
|
+
fixed_node: Node;
|
|
350
|
+
slide_node: Node;
|
|
351
|
+
fixed_label: Label;
|
|
352
|
+
slide_label: Label;
|
|
353
|
+
onLoad(): void;
|
|
354
|
+
protected start(): void;
|
|
355
|
+
show(): Promise<void>;
|
|
356
|
+
private playAnim;
|
|
357
|
+
onDestroy(): void;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @describe 根级别的UI层 所有的ROOT UI层需继承自该自组件
|
|
362
|
+
* @author 游金宇(KM)
|
|
363
|
+
* @date 2023-08-04 10:42:26
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
declare class RootUILayer<T extends object> extends UILayer<T> {
|
|
367
|
+
protected onEnable(): void;
|
|
368
|
+
protected onDisable(): void;
|
|
369
|
+
private updateMask;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
type CoreShowLoadingProps = {
|
|
373
|
+
/**标题 */
|
|
374
|
+
title?: string;
|
|
375
|
+
/**阻挡 */
|
|
376
|
+
mask?: boolean;
|
|
377
|
+
/**显示黑色(弹窗存在公共的遮罩,这里不需要重复设置) */
|
|
378
|
+
black?: boolean;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* @describe 加载框
|
|
382
|
+
* @author 游金宇(KM)
|
|
383
|
+
* @date 2024-09-12 11:49:51
|
|
384
|
+
*/
|
|
385
|
+
declare class CoreShowLoading extends RootUILayer<CoreShowLoadingProps> {
|
|
386
|
+
title: Label;
|
|
387
|
+
loadingTween: Node;
|
|
388
|
+
private loading_rotate;
|
|
389
|
+
protected onAutoObserver(): void;
|
|
390
|
+
update(deltaTime: number): void;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
declare enum ReconnectPrompt {
|
|
394
|
+
RECONNECTED = "\u91CD\u8FDE\u6210\u529F",
|
|
395
|
+
RECONNECTING = "\u6B63\u5728\u91CD\u8FDE",
|
|
396
|
+
MAX_RECONNECT = "\u91CD\u8FDE\u6B21\u6570\u8D85\u51FA\u9650\u5236,\u8BF7\u68C0\u67E5\u7F51\u7EDC",
|
|
397
|
+
RECONNECTED_ERROR = "\u91CD\u8FDE\u5931\u8D25,\u8BF7\u68C0\u67E5\u7F51\u7EDC",
|
|
398
|
+
CONNECT_PARAM_ERROR = "\u6E38\u620F\u53C2\u6570\u9519\u8BEF,\u8BF7\u91CD\u65B0\u52A0\u8F7D",
|
|
399
|
+
KICK = "\u8D26\u53F7\u5DF2\u4E0B\u7EBF",
|
|
400
|
+
OFFLINE = "\u7F51\u7EDC\u5DF2\u65AD\u5F00",
|
|
401
|
+
ONLINE = "\u7F51\u7EDC\u5DF2\u8FDE\u63A5",
|
|
402
|
+
GAME_ERROR = "\u8FDE\u63A5\u6E38\u620F\u670D\u9519\u8BEF"
|
|
403
|
+
}
|
|
404
|
+
type CoreReconnectionProps = {
|
|
405
|
+
content: ReconnectPrompt | null;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* @describe 重连框
|
|
409
|
+
* @author 游金宇(KM)
|
|
410
|
+
* @date 2024-09-12 11:49:51
|
|
411
|
+
*/
|
|
412
|
+
declare class CoreReconnection extends RootUILayer<CoreReconnectionProps> {
|
|
413
|
+
common_prompt_text: Label;
|
|
414
|
+
btn_confirm: Button;
|
|
415
|
+
private is_close;
|
|
416
|
+
props: CoreReconnectionProps;
|
|
417
|
+
protected initUI(): void;
|
|
418
|
+
protected onLoad(): void;
|
|
419
|
+
onDestroy(): void;
|
|
420
|
+
updateProps(props: ReconnectPrompt): void;
|
|
421
|
+
/**更新提示文案 */
|
|
422
|
+
protected updatePromptText(text: ReconnectPrompt, isAnim?: boolean): void;
|
|
423
|
+
private onConfirmHandler;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
type CoreNoticeProps = {
|
|
427
|
+
text: string;
|
|
428
|
+
confrim?: () => void;
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* @describe 通知框
|
|
432
|
+
* @author 游金宇(KM)
|
|
433
|
+
* @date 2024-09-12 11:49:51
|
|
434
|
+
*/
|
|
435
|
+
declare class CoreNotice<T extends CoreNoticeProps = CoreNoticeProps> extends RootUILayer<T> {
|
|
436
|
+
text: Label;
|
|
437
|
+
btn_confirm: Button;
|
|
438
|
+
protected onLoad(): void;
|
|
439
|
+
start(): void;
|
|
440
|
+
protected onConfrimHandler(): void;
|
|
441
|
+
updateProps(props: CoreNoticeProps): void;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @describe Scene层 所有的UI层需继承自该自组件
|
|
446
|
+
* @author 游金宇(KM)
|
|
447
|
+
* @date 2023-08-04 10:42:26
|
|
448
|
+
*/
|
|
449
|
+
|
|
450
|
+
type SceneType<T> = T extends SceneLayer<infer U, infer K> ? {
|
|
451
|
+
props: U;
|
|
452
|
+
data: K;
|
|
453
|
+
} : {
|
|
454
|
+
props: object;
|
|
455
|
+
data: object;
|
|
456
|
+
};
|
|
457
|
+
type ScenePropsType<T> = SceneType<T> extends {
|
|
458
|
+
props: infer U extends object;
|
|
459
|
+
data: infer K extends object;
|
|
460
|
+
} ? U : never;
|
|
461
|
+
type SceneDataType<T> = SceneType<T> extends {
|
|
462
|
+
props: infer U extends object;
|
|
463
|
+
data: infer K extends object;
|
|
464
|
+
} ? K : never;
|
|
465
|
+
declare class SceneLayer<T extends object = Object, K extends object = {}> extends BaseComponent<T, K> {
|
|
466
|
+
/**是否为重新加载场景 */
|
|
467
|
+
isReload: boolean;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* @describe GUI组件类
|
|
472
|
+
* @author 游金宇(KM)
|
|
473
|
+
* @date 2024-09-12 11:46:22
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
type UIComponentType$1<T> = T extends UILayer<infer U, infer K> ? {
|
|
477
|
+
props: U;
|
|
478
|
+
data: K;
|
|
479
|
+
} : {
|
|
480
|
+
props: object;
|
|
481
|
+
data: object;
|
|
482
|
+
};
|
|
483
|
+
type PropsType<T> = UIComponentType$1<T> extends {
|
|
484
|
+
props: infer U extends object;
|
|
485
|
+
data: infer K extends object;
|
|
486
|
+
} ? U : never;
|
|
487
|
+
type DataType<T> = UIComponentType$1<T> extends {
|
|
488
|
+
props: infer U extends object;
|
|
489
|
+
data: infer K extends object;
|
|
490
|
+
} ? K : never;
|
|
491
|
+
declare enum LayerType {
|
|
492
|
+
UI = 0,
|
|
493
|
+
/**加载 */
|
|
494
|
+
LOADING = 1,
|
|
495
|
+
/**提示 */
|
|
496
|
+
TOAST = 2,
|
|
497
|
+
/**断线重连 */
|
|
498
|
+
RECONNECTTION = 3,
|
|
499
|
+
/**系统服务通知(停机维护) */
|
|
500
|
+
NOTICE = 4
|
|
501
|
+
}
|
|
502
|
+
/**Gui层 */
|
|
503
|
+
declare class Gui extends BaseComponent {
|
|
504
|
+
reconnection_ui_prefab: Prefab;
|
|
505
|
+
toast_ui_prefab: Prefab;
|
|
506
|
+
loading_ui_prefab: Prefab;
|
|
507
|
+
notice_ui_prefab: Prefab;
|
|
508
|
+
ui_prefab: Prefab;
|
|
509
|
+
root_ui: Node;
|
|
510
|
+
root_toast: Node;
|
|
511
|
+
root_mask: Node;
|
|
512
|
+
private cat;
|
|
513
|
+
/**场景中的UI层 */
|
|
514
|
+
private ui_container_component;
|
|
515
|
+
/**断线重连UI弹窗 */
|
|
516
|
+
private reconnection_ui_component;
|
|
517
|
+
/**公告UI弹窗组件 */
|
|
518
|
+
private notice_ui_component;
|
|
519
|
+
/**加载UI弹窗 */
|
|
520
|
+
private loading_ui_component;
|
|
521
|
+
/**提示UI弹窗 */
|
|
522
|
+
private toast_ui_component;
|
|
523
|
+
/**当前场景对象名 */
|
|
524
|
+
currentScene: string;
|
|
525
|
+
protected onEventListener(): void;
|
|
526
|
+
init(cat: Manager): this;
|
|
527
|
+
protected start(): void;
|
|
528
|
+
/**显示提示 */
|
|
529
|
+
showToast({ title, type, fixed_time }: ToastProps): this;
|
|
530
|
+
/**隐藏提示 */
|
|
531
|
+
hideToast(): this;
|
|
532
|
+
/**显示Loading */
|
|
533
|
+
showLoading({ title, mask, black }?: CoreShowLoadingProps): this;
|
|
534
|
+
/**隐藏Loading */
|
|
535
|
+
hideLoading(): this;
|
|
536
|
+
/**
|
|
537
|
+
* 显示断线重连
|
|
538
|
+
* @param option 状态提示文案
|
|
539
|
+
*/
|
|
540
|
+
showReconnect(option: ReconnectPrompt): this;
|
|
541
|
+
/**隐藏断线重连 */
|
|
542
|
+
hideReconnect(): this;
|
|
543
|
+
/**
|
|
544
|
+
* 显示公告
|
|
545
|
+
* @param option 参数
|
|
546
|
+
*/
|
|
547
|
+
showNotice(option: CoreNoticeProps): this;
|
|
548
|
+
/**隐藏公告 */
|
|
549
|
+
hideNotice(): this;
|
|
550
|
+
/**加载场景 */
|
|
551
|
+
loadScene<T>(sceneName: string): this;
|
|
552
|
+
loadScene<T>(sceneName: string, options: IUIOption<ScenePropsType<T>, SceneDataType<T>>): this;
|
|
553
|
+
loadScene<T>(sceneName: string, isReload: boolean): this;
|
|
554
|
+
loadScene<T>(sceneName: string, options: IUIOption<ScenePropsType<T>, SceneDataType<T>>, isReload: boolean): this;
|
|
555
|
+
/**重置场景(清除当前默认当前场景) */
|
|
556
|
+
resetScene(sceneName?: string): this;
|
|
557
|
+
/**清除场景 */
|
|
558
|
+
cleanScene(): void;
|
|
559
|
+
/**
|
|
560
|
+
* 场景变化
|
|
561
|
+
* @param scene 场景
|
|
562
|
+
* @param options 选项
|
|
563
|
+
* @param isReload 是否重新加载
|
|
564
|
+
*/
|
|
565
|
+
changeScene<T>(scene: Scene, options?: IUIOption<ScenePropsType<T>, SceneDataType<T>>, isReload?: boolean): void;
|
|
566
|
+
private createUILayer;
|
|
567
|
+
/**重新加载当前场景 */
|
|
568
|
+
reloadScene(): void;
|
|
569
|
+
/**关闭UI */
|
|
570
|
+
closeUI<T extends UILayer<object>, U extends object>(ui: Node | T, options?: ICloseOptions<T, U>): Promise<void>;
|
|
571
|
+
/**
|
|
572
|
+
* 打开ui层
|
|
573
|
+
* @param ui 界面的节点或组件
|
|
574
|
+
* @param options 动画参数选项
|
|
575
|
+
*/
|
|
576
|
+
openUI<T extends UILayer>(ui: Node, options?: IOpenOptions<PropsType<T>, DataType<T>>): Promise<void>;
|
|
577
|
+
/**根据节点或组件 查询根UI层(继承自UILayer的)节点或组件 */
|
|
578
|
+
private findUIBaseLayer;
|
|
579
|
+
/**根层的变化 */
|
|
580
|
+
private onRootUpdate;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @describe 游戏资管理
|
|
585
|
+
* @author 游金宇(KM)
|
|
586
|
+
* @date 2023-08-03 17:40:51
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
type ProgressCallback = (completedCount: number, totalCount: number, item: any) => void;
|
|
590
|
+
type CompleteCallback<T> = ((err: Error | null, data: T) => void) | null;
|
|
591
|
+
type IRemoteOptions = {
|
|
592
|
+
[k: string]: any;
|
|
593
|
+
ext?: string;
|
|
594
|
+
};
|
|
595
|
+
type AssetType<T = Asset> = Constructor<T>;
|
|
596
|
+
declare class ResLoader {
|
|
597
|
+
/**
|
|
598
|
+
* 获取资源
|
|
599
|
+
* @param path 资源路径
|
|
600
|
+
* @param type 资源类型
|
|
601
|
+
* @param bundleName 远程资源包名
|
|
602
|
+
*/
|
|
603
|
+
get: <T extends Asset>(path: string, type?: AssetType<T> | null, bundleName?: string) => T | null;
|
|
604
|
+
/**
|
|
605
|
+
* 获取资源类型
|
|
606
|
+
*/
|
|
607
|
+
isAssetType: <T>(value: any) => value is AssetType<T>;
|
|
608
|
+
/**
|
|
609
|
+
* 获取资源
|
|
610
|
+
* @param bundleName 远程包名
|
|
611
|
+
* @param paths 资源路径
|
|
612
|
+
* @param type 资源类型-
|
|
613
|
+
* @param onProgress 加载进度回调
|
|
614
|
+
* @param onComplete 加载完成回调
|
|
615
|
+
*/
|
|
616
|
+
load<T extends Asset>(paths: string | string[]): void;
|
|
617
|
+
load<T extends Asset>(paths: string | string[], type: AssetType<T>): void;
|
|
618
|
+
load<T extends Asset>(paths: string, onComplete: CompleteCallback<T>): void;
|
|
619
|
+
load<T extends Asset>(paths: string, type: AssetType<T>, onComplete: CompleteCallback<T>): void;
|
|
620
|
+
load<T extends Asset>(paths: string, onProgress: ProgressCallback, onComplete: CompleteCallback<T>): void;
|
|
621
|
+
load<T extends Asset>(paths: string, type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T>): void;
|
|
622
|
+
load<T extends Asset>(paths: string[], onComplete: CompleteCallback<T[]>): void;
|
|
623
|
+
load<T extends Asset>(paths: string[], onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
624
|
+
load<T extends Asset>(paths: string[], type: AssetType<T>, onComplete: CompleteCallback<T[]>): void;
|
|
625
|
+
load<T extends Asset>(paths: string[], type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
626
|
+
load<T extends Asset>(bundleName: string, paths: string | string[]): void;
|
|
627
|
+
load<T extends Asset>(bundleName: string, paths: string | string[], type: AssetType<T>): void;
|
|
628
|
+
load<T extends Asset>(bundleName: string, paths: string, onComplete: CompleteCallback<T>): void;
|
|
629
|
+
load<T extends Asset>(bundleName: string, paths: string[], onComplete: CompleteCallback<T[]>): void;
|
|
630
|
+
load<T extends Asset>(bundleName: string, paths: string, type: AssetType<T>, onComplete: CompleteCallback<T>): void;
|
|
631
|
+
load<T extends Asset>(bundleName: string, paths: string[], type: AssetType<T>, onComplete: CompleteCallback<T[]>): void;
|
|
632
|
+
load<T extends Asset>(bundleName: string, paths: string, onProgress: ProgressCallback, onComplete: CompleteCallback<T>): void;
|
|
633
|
+
load<T extends Asset>(bundleName: string, paths: string[], onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
634
|
+
load<T extends Asset>(bundleName: string, paths: string, type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T>): void;
|
|
635
|
+
load<T extends Asset>(bundleName: string, paths: string[], type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
636
|
+
/**
|
|
637
|
+
* 加载文件夹
|
|
638
|
+
* @param bundleName 远程包名
|
|
639
|
+
* @param dir 文件夹名
|
|
640
|
+
* @param type 资源类型
|
|
641
|
+
* @param onProgress 加载进度回调
|
|
642
|
+
* @param onComplete 加载完成回调
|
|
643
|
+
*/
|
|
644
|
+
loadDir<T extends Asset>(dir: string): void;
|
|
645
|
+
loadDir<T extends Asset>(dir: string, type: AssetType<T>): void;
|
|
646
|
+
loadDir<T extends Asset>(dir: string, onComplete: CompleteCallback<T[]>): void;
|
|
647
|
+
loadDir<T extends Asset>(dir: string, type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
648
|
+
loadDir<T extends Asset>(bundleName: string, dir: string): void;
|
|
649
|
+
loadDir<T extends Asset>(bundleName: string, dir: string, type: AssetType<T>): void;
|
|
650
|
+
loadDir<T extends Asset>(bundleName: string, dir: string, onComplete: CompleteCallback<T[]>): void;
|
|
651
|
+
loadDir<T extends Asset>(bundleName: string, dir: string, type: AssetType<T>, onProgress: ProgressCallback, onComplete: CompleteCallback<T[]>): void;
|
|
652
|
+
/**
|
|
653
|
+
* 加载远程资源
|
|
654
|
+
* @param url 资源地址
|
|
655
|
+
* @param options 资源参数,例:{ ext: ".png" }
|
|
656
|
+
* @param onComplete 加载完成回调
|
|
657
|
+
*
|
|
658
|
+
* res.ResLoader.loadRemote(params.iconv, (err: Error, imageAsset: ImageAsset) => {
|
|
659
|
+
if (err) return error(err)
|
|
660
|
+
if (isValid(this.itemSp)) {
|
|
661
|
+
this.itemSp.spriteFrame = SpriteFrame.createWithImage(imageAsset)
|
|
662
|
+
}
|
|
663
|
+
})
|
|
664
|
+
*/
|
|
665
|
+
loadRemote<T extends Asset>(url: string, options: IRemoteOptions, onComplete?: CompleteCallback<T>): void;
|
|
666
|
+
loadRemote<T extends Asset>(url: string, onComplete?: CompleteCallback<T>): void;
|
|
667
|
+
/**
|
|
668
|
+
* 加载bundle
|
|
669
|
+
* @param url 资源地址 <远程路径或者bundleName>
|
|
670
|
+
* @param complete 完成事件
|
|
671
|
+
* @param v 资源版本号
|
|
672
|
+
* @example
|
|
673
|
+
*/
|
|
674
|
+
loadBundle: (url: string, version?: string) => Promise<AssetManager.Bundle>;
|
|
675
|
+
/** 释放预制依赖资源 */
|
|
676
|
+
releasePrefabtDepsRecursively: (uuid: string) => void;
|
|
677
|
+
/**
|
|
678
|
+
* 通过资源相对路径释放资源
|
|
679
|
+
* @param path 资源路径
|
|
680
|
+
* @param bundleName 远程资源包名
|
|
681
|
+
*/
|
|
682
|
+
release: (path: string, bundleName?: string) => void;
|
|
683
|
+
/**
|
|
684
|
+
* 通过相对文件夹路径删除所有文件夹中资源
|
|
685
|
+
* @param path 资源文件夹路径
|
|
686
|
+
* @param bundleName 远程资源包名
|
|
687
|
+
*/
|
|
688
|
+
releaseDir: (path: string, bundleName?: string) => void;
|
|
689
|
+
/** 打印缓存中所有资源信息 */
|
|
690
|
+
dump: () => void;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* @describe 事件消息管理
|
|
695
|
+
* @author 游金宇(KM)
|
|
696
|
+
* @date 2023-08-03 18:15:38
|
|
697
|
+
*/
|
|
698
|
+
|
|
699
|
+
type ListenerFunc = (data: any, event: string | number) => void;
|
|
700
|
+
type EventKeyType = string | number;
|
|
701
|
+
interface EventBase {
|
|
702
|
+
/**注册事件 */
|
|
703
|
+
on(event: string, listener: ListenerFunc, obj: object): void;
|
|
704
|
+
/**取消所有事件 */
|
|
705
|
+
offAll(): void;
|
|
706
|
+
/**注册单次触发事件 */
|
|
707
|
+
once(event: string, listener: ListenerFunc, obj: object): void;
|
|
708
|
+
/**取消单个事件 */
|
|
709
|
+
off(event: string, listener: Function, obj: object): void;
|
|
710
|
+
/**调用事件 */
|
|
711
|
+
dispatchEvent<T>(event: string, args: Record<string, T>): void;
|
|
712
|
+
}
|
|
713
|
+
declare class MessageManager implements EventBase {
|
|
714
|
+
private events;
|
|
715
|
+
/**
|
|
716
|
+
* 注册全局事件
|
|
717
|
+
* @param event 事件名
|
|
718
|
+
* @param listener 处理事件的侦听器函数
|
|
719
|
+
* @param obj 侦听函数绑定的作用域对象
|
|
720
|
+
*/
|
|
721
|
+
on<T extends EventKeyType>(event: T, listener: ListenerFunc | null, obj: object): this;
|
|
722
|
+
/**
|
|
723
|
+
* 监听一次事件,事件响应后,该监听自动移除
|
|
724
|
+
* @param event 事件名
|
|
725
|
+
* @param listener 事件触发回调方法
|
|
726
|
+
* @param obj 侦听函数绑定的作用域对象
|
|
727
|
+
*/
|
|
728
|
+
once<T extends EventKeyType>(event: T, listener: ListenerFunc, obj: object | Symbol): void;
|
|
729
|
+
/**
|
|
730
|
+
* 移除单个事件
|
|
731
|
+
* @param event 事件名
|
|
732
|
+
* @param listener 处理事件的侦听器函数
|
|
733
|
+
* @param obj 侦听函数绑定的作用域对象
|
|
734
|
+
*/
|
|
735
|
+
off<T extends EventKeyType>(event: T, listener: Function | null, obj: object): this;
|
|
736
|
+
/**
|
|
737
|
+
* 触发全局事件
|
|
738
|
+
* @param event(string) 事件名
|
|
739
|
+
* @param args(any) 事件参数
|
|
740
|
+
*/
|
|
741
|
+
dispatchEvent<T extends EventKeyType>(event: T, args?: any): this;
|
|
742
|
+
/**移除所有事件 */
|
|
743
|
+
offAll(): void;
|
|
744
|
+
/**是否存在事件 */
|
|
745
|
+
has(event: EventKeyType): boolean;
|
|
746
|
+
/**删除事件通过组件 */
|
|
747
|
+
deleteEventByComponent(component: Component): void;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* MD5加密
|
|
752
|
+
* @param msg 加密信息
|
|
753
|
+
*/
|
|
754
|
+
declare const md5: (msg: string) => string;
|
|
755
|
+
/** 初始化加密库 */
|
|
756
|
+
declare const initCrypto: (key: string, iv: string) => void;
|
|
757
|
+
/**
|
|
758
|
+
* AES 加密
|
|
759
|
+
* @param msg 加密信息
|
|
760
|
+
* @param key aes加密的key
|
|
761
|
+
* @param iv aes加密的iv
|
|
762
|
+
*/
|
|
763
|
+
declare const aesEncrypt: (msg: string, key: string, iv: string) => string;
|
|
764
|
+
/**
|
|
765
|
+
* AES 解密
|
|
766
|
+
* @param str 解密字符串
|
|
767
|
+
* @param key aes加密的key
|
|
768
|
+
* @param iv aes加密的iv
|
|
769
|
+
*/
|
|
770
|
+
declare const aesDecrypt: (str: string, key: string, iv: string) => string;
|
|
771
|
+
declare const JsonFormatter: {
|
|
772
|
+
stringify: (cipherParams: any) => string;
|
|
773
|
+
parse: (jsonStr: string) => crypto_es_lib_cipher_core.CipherParams;
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
declare const EncryptUtil_JsonFormatter: typeof JsonFormatter;
|
|
777
|
+
declare const EncryptUtil_aesDecrypt: typeof aesDecrypt;
|
|
778
|
+
declare const EncryptUtil_aesEncrypt: typeof aesEncrypt;
|
|
779
|
+
declare const EncryptUtil_initCrypto: typeof initCrypto;
|
|
780
|
+
declare const EncryptUtil_md5: typeof md5;
|
|
781
|
+
declare namespace EncryptUtil {
|
|
782
|
+
export { EncryptUtil_JsonFormatter as JsonFormatter, EncryptUtil_aesDecrypt as aesDecrypt, EncryptUtil_aesEncrypt as aesEncrypt, EncryptUtil_initCrypto as initCrypto, EncryptUtil_md5 as md5 };
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @describe 工具类
|
|
787
|
+
* @author 游金宇(KM)
|
|
788
|
+
* @date 2023-08-02 20:16:42
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
declare class CoreUtil extends BaseManager {
|
|
792
|
+
encryptUtil: typeof EncryptUtil;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
declare enum AudioEventConstant {
|
|
796
|
+
/**音乐开 */
|
|
797
|
+
MUSIC_ON = "AudioEventConstant/MUSIC_ON",
|
|
798
|
+
/**音乐关 */
|
|
799
|
+
MUSIC_OFF = "AudioEventConstant/MUSIC_OFF",
|
|
800
|
+
/**音效开 */
|
|
801
|
+
EFFECT_ON = "AudioEventConstant/EFFECT_ON",
|
|
802
|
+
/**音效关 */
|
|
803
|
+
EFFECT_OFF = "AudioEventConstant/EFFECT_OFF",
|
|
804
|
+
/**暂停音频 */
|
|
805
|
+
PAUSE_AUDIO = "AudioEventConstant/PAUSE_AUDIO",
|
|
806
|
+
/**恢复音频 */
|
|
807
|
+
RESUME_AUDIO = "AudioEventConstant/RESUME_AUDIO"
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* @describe 全局事件监听方法
|
|
812
|
+
* @author 游金宇(KM)
|
|
813
|
+
* @date 2023-08-03 18:13:36
|
|
814
|
+
*/
|
|
815
|
+
declare enum GlobalEventConstant {
|
|
816
|
+
/** 游戏从后台进入 */
|
|
817
|
+
EVENT_SHOW = "GlobalEventConstant/EVENT_SHOW",
|
|
818
|
+
/** 游戏切到后台 */
|
|
819
|
+
EVENT_HIDE = "GlobalEventConstant/EVENT_HIDE",
|
|
820
|
+
/** 游戏画笔尺寸变化事件 */
|
|
821
|
+
GAME_RESIZE = "GlobalEventConstant/GAME_RESIZE",
|
|
822
|
+
/**游戏关闭时间 */
|
|
823
|
+
EVENT_CLOSE = "GlobalEventConstant/EVENT_CLOSE",
|
|
824
|
+
/**网络连接 */
|
|
825
|
+
ONLINE = "GlobalEventConstant/ONLINE",
|
|
826
|
+
/**网络断开 */
|
|
827
|
+
OFFLINE = "GlobalEventConstant/OFFLINE",
|
|
828
|
+
/**ROOT_MASK更新 */
|
|
829
|
+
ROOT_MASK_UPDATE = "GlobalEventConstant/ROOT_MASK_UPDATE",
|
|
830
|
+
/**ROOT_MASK更新变化 */
|
|
831
|
+
ROOT_MASK_CHANGE = "GlobalEventConstant/ROOT_MASK_CHANGE"
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
type GameNotifyType = (route: string, reqReflect: ReflectMessage, options?: {
|
|
835
|
+
audOptions?: AudienceOptions;
|
|
836
|
+
show_log?: boolean;
|
|
837
|
+
}) => Promise<void>;
|
|
838
|
+
/**
|
|
839
|
+
* @describe 基于社交游戏封装的游戏基础ws类
|
|
840
|
+
* @author 游金宇(KM)
|
|
841
|
+
* @date 2024-09-12 11:47:51
|
|
842
|
+
*/
|
|
843
|
+
declare class WrapperSocialGameClient extends SocialGameClient {
|
|
844
|
+
/**需要重连(标记接下来需要重连) */
|
|
845
|
+
private isNeedReconnect;
|
|
846
|
+
/**网络在线 */
|
|
847
|
+
private isOnline;
|
|
848
|
+
/**在后台 */
|
|
849
|
+
private isInBackground;
|
|
850
|
+
/**状态机运行 */
|
|
851
|
+
private running;
|
|
852
|
+
private index;
|
|
853
|
+
/**日志黑名单 */
|
|
854
|
+
protected logBlackList: string[];
|
|
855
|
+
constructor(opts: SocialGameClientOption, eventResponsePairs: AllEventResponsePairs, clientOption?: ClientOption);
|
|
856
|
+
/**初始化 */
|
|
857
|
+
addEvent(): void;
|
|
858
|
+
removeEvent(): void;
|
|
859
|
+
private onShowHandler;
|
|
860
|
+
private onHideHandler;
|
|
861
|
+
/**网络在线处理 */
|
|
862
|
+
private onOnlineHandler;
|
|
863
|
+
/**网络断开处理 */
|
|
864
|
+
private onOfflineHandler;
|
|
865
|
+
private handleEvent;
|
|
866
|
+
destroy(): void;
|
|
867
|
+
/**
|
|
868
|
+
* 断开
|
|
869
|
+
* @param activeDisconnect 主动断开
|
|
870
|
+
*/
|
|
871
|
+
disconnect(activeDisconnect?: boolean): void;
|
|
872
|
+
private destroyStateMachine;
|
|
873
|
+
request<U extends DescMessage>(route: string, reqReflect: ReflectMessage, resSchema: U): Promise<MessageShape<U>>;
|
|
874
|
+
Request<U extends DescMessage>(route: string, reqReflect: ReflectMessage, resSchema: U, { audOptions, show_log }?: {
|
|
875
|
+
audOptions?: {
|
|
876
|
+
forwardReq: boolean;
|
|
877
|
+
forwardResp: boolean;
|
|
878
|
+
} | undefined;
|
|
879
|
+
show_log?: boolean | undefined;
|
|
880
|
+
}): Promise<MessageShape<U>>;
|
|
881
|
+
protected GameRequest<U extends DescMessage>(route: string, reqReflect: ReflectMessage, resp: U, audOptions?: AudienceOptions): Promise<MessageShape<U>>;
|
|
882
|
+
protected gameRequest<U extends DescMessage>(route: string, reqReflect: ReflectMessage, resSchema: U): Promise<MessageShape<U>>;
|
|
883
|
+
protected GameNotify: (route: string, reqReflect: ReflectMessage, audOptions?: AudienceOptions) => Promise<void>;
|
|
884
|
+
Notify: GameNotifyType;
|
|
885
|
+
subscribe<T extends DescMessage>(route: string, respType: T, fn?: (data: MessageShape<T>) => void): this;
|
|
886
|
+
onData(body: Uint8Array): void;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
type CoreUIModalProps = {
|
|
890
|
+
content: string | SpriteFrame | null;
|
|
891
|
+
confirmCB: () => void;
|
|
892
|
+
cancelCB: () => void;
|
|
893
|
+
onDestroy?: () => void;
|
|
894
|
+
title?: SpriteFrame;
|
|
895
|
+
style?: {
|
|
896
|
+
confirm?: SpriteFrame;
|
|
897
|
+
cancel?: SpriteFrame;
|
|
898
|
+
} | null;
|
|
899
|
+
};
|
|
900
|
+
/**
|
|
901
|
+
* @describe 模态框
|
|
902
|
+
* @author 游金宇(KM)
|
|
903
|
+
* @date 2024-09-12 11:49:51
|
|
904
|
+
*/
|
|
905
|
+
declare class CoreUIModal extends UILayer<CoreUIModalProps> {
|
|
906
|
+
default_title: SpriteFrame;
|
|
907
|
+
title: Sprite;
|
|
908
|
+
prompt_content_str: Label;
|
|
909
|
+
prompt_content_spriteFrame: Sprite;
|
|
910
|
+
btn_confirm: Button;
|
|
911
|
+
confirm_spriteFrame: SpriteFrame;
|
|
912
|
+
btn_cancel: Button;
|
|
913
|
+
cancel_spriteFrame: SpriteFrame;
|
|
914
|
+
btn_close: Button;
|
|
915
|
+
isConfirm: boolean;
|
|
916
|
+
props: CoreUIModalProps;
|
|
917
|
+
protected onLoad(): void;
|
|
918
|
+
private close;
|
|
919
|
+
private onCancelHandler;
|
|
920
|
+
private onConfirmHandler;
|
|
921
|
+
onDestroy(): void;
|
|
922
|
+
private onCloseHandler;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
declare class CoreBlackMask extends BaseComponent {
|
|
926
|
+
tween: Node;
|
|
927
|
+
black_mask: Node;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* @describe UI容器管理 在场景节点下 会随着场景销毁(非常驻节点)
|
|
932
|
+
* @author 游金宇(KM)
|
|
933
|
+
* @date 2024-09-12 11:45:31
|
|
934
|
+
*/
|
|
935
|
+
|
|
936
|
+
declare class CoreUIContainer extends UILayer {
|
|
937
|
+
scene_mask_node: Node;
|
|
938
|
+
ui_container: Node;
|
|
939
|
+
gui: Gui;
|
|
940
|
+
protected onLoad(): void;
|
|
941
|
+
get scene_mask(): CoreBlackMask;
|
|
942
|
+
get brother(): Node[];
|
|
943
|
+
get tweenChildren(): Node[];
|
|
944
|
+
protected onEventListener(): void;
|
|
945
|
+
/**增加层级 */
|
|
946
|
+
addMask(): void;
|
|
947
|
+
/**减少层级 */
|
|
948
|
+
subMask(): void;
|
|
949
|
+
blockMaskSiblingIndexChanged(): void;
|
|
950
|
+
/**
|
|
951
|
+
* 将UI节点挂载在tween上执行动画
|
|
952
|
+
* @param node 节点
|
|
953
|
+
*/
|
|
954
|
+
addNodeToTween(node: Node): this;
|
|
955
|
+
show(): void;
|
|
956
|
+
hide(): void;
|
|
957
|
+
setGui(gui: Gui): this;
|
|
958
|
+
/**根层的变化 */
|
|
959
|
+
uiMaskChanged(): void;
|
|
960
|
+
setSceneMaskActive(active: boolean): void;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
type UIComponentType<T> = T extends UILayer<infer U> ? U : void;
|
|
964
|
+
type SceneComponentType<T> = T extends SceneLayer<infer U> ? U : void;
|
|
965
|
+
/**预制体路径 */
|
|
966
|
+
declare enum BasePrefab {
|
|
967
|
+
Root = "core/root",
|
|
968
|
+
Toast = "core/toast",
|
|
969
|
+
BlackMask = "core/black-mask",
|
|
970
|
+
Loading = "core/loading",
|
|
971
|
+
Notice = "core/notice",
|
|
972
|
+
Reconnection = "core/reconnection"
|
|
973
|
+
}
|
|
974
|
+
declare class GuiManager extends BaseManager {
|
|
975
|
+
/**常驻顶层UI节点层级 */
|
|
976
|
+
private _gui;
|
|
977
|
+
get gui(): Gui;
|
|
978
|
+
set gui(v: Gui);
|
|
979
|
+
/**
|
|
980
|
+
* 获取预制体
|
|
981
|
+
* @param type 类型
|
|
982
|
+
* @returns
|
|
983
|
+
*/
|
|
984
|
+
private getGuiPrefabByType;
|
|
985
|
+
/**初始化 */
|
|
986
|
+
init(): Promise<this>;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @describe 管理类
|
|
991
|
+
* @author 游金宇(KM)
|
|
992
|
+
* @date 2024-09-12 11:49:44
|
|
993
|
+
*/
|
|
994
|
+
declare class Manager {
|
|
995
|
+
static ins: Manager;
|
|
996
|
+
static get instance(): Manager;
|
|
997
|
+
readonly onAppInitDelegate: AsyncDelegate<() => (Promise<void> | void)>;
|
|
998
|
+
/**音频 */
|
|
999
|
+
audio: AudioManager;
|
|
1000
|
+
/**事件 */
|
|
1001
|
+
event: MessageManager;
|
|
1002
|
+
/**gui */
|
|
1003
|
+
gui: Gui;
|
|
1004
|
+
/**本地存储 */
|
|
1005
|
+
storage: StorageManager;
|
|
1006
|
+
/**资源 */
|
|
1007
|
+
res: ResLoader;
|
|
1008
|
+
/**工具类 */
|
|
1009
|
+
util: CoreUtil;
|
|
1010
|
+
/**启动 */
|
|
1011
|
+
boot(): Promise<void>;
|
|
1012
|
+
}
|
|
1013
|
+
declare const cat: Manager;
|
|
1014
|
+
|
|
1015
|
+
export { AudioEventConstant, AudioSourceBaseComponent, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, CoreBlackMask, CoreNotice, type CoreNoticeProps, CoreReconnection, CoreShowLoading, type CoreShowLoadingProps, CoreToast, CoreUIContainer, CoreUIModal, type CoreUIModalProps, CoreUtil, GlobalEventConstant, Gui, GuiManager, type HOOK, type ICloseOptions, type IDirection, type IOpenOptions, type IUIOption, LayerType, Manager, ReconnectPrompt, type SceneComponentType, type SceneDataType, type ScenePropsType, type ToastProps, ToastType, type UIComponentType, WrapperSocialGameClient, cat };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AudioSource as t,_decorator as e,AudioClip as s,error as o,Node as i,director as n,log as r,sys as a,Component as c,Prefab as l,instantiate as h,isValid as d,Layers as p,view as u,Widget as f,v3 as _,tween as y,Enum as g,game as m,Label as v,UITransform as E,UIOpacity as b,Tween as C,BlockInputEvents as w,Button as k,Director as O,warn as S,assetManager as x,Asset as R,resources as N,SpriteFrame as A,Sprite as T,AsyncDelegate as I}from"cc";import{PREVIEW as M,DEBUG as D}from"cc/env";import{makeObservable as F,observable as U,autorun as P,reaction as H}from"@shimotsuki/mobx";import L from"crypto-es";import{clone as B,create as G}from"@bufbuild/protobuf";import{SocialGameClient as $,AudienceOptionsSchema as j}from"sgc";class q extends t{cat;initAudio(t){return this.cat=t,this}}const{ccclass:K,menu:V}=e;class J extends q{effects=new Map;load(t){return new Promise(((e,o)=>{this.cat.res.load(t,s,((s,i)=>{if(s)return o(s);this.effects.set(t,i),this.playOneShot(i,this.volume),e(i)}))}))}release(){for(let t in this.effects)this.cat.res.release(t);this.effects.clear()}}const{ccclass:W,menu:X}=e;class z extends q{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(t){this._progress=t,this.currentTime=t*this.duration}load(t,e){this.cat.res.load(t,s,((s,i)=>{s&&o(s),this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=i,this._url=t,e&&e()}))}update(t){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class Z{cat;constructor(t){this.cat=t}}var Q;!function(t){t.MUSIC_ON="AudioEventConstant/MUSIC_ON",t.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",t.EFFECT_ON="AudioEventConstant/EFFECT_ON",t.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",t.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",t.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(Q||(Q={}));const Y="game_audio";class tt extends Z{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;constructor(t){super(t);var e=new i("UIAudioManager");n.addPersistRootNode(e);var s=new i("UIMusic");s.parent=e,this.music=s.addComponent(z).initAudio(t);var o=new i("UIEffect");o.parent=e,this.effect=o.addComponent(J).initAudio(t),this.load()}setMusicComplete(t=null){this.music.onComplete=t}playMusic(t,e){this.music.loop=!0,t&&this.music.load(t,(()=>{this._switch_music&&this.music?.play(),e&&e()}))}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){[0,2].includes(this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(t){this.music.progress=t}get volumeMusic(){return this._volume_music}set volumeMusic(t){this._volume_music=t,this.music.volume=t}get switchMusic(){return this._switch_music}set switchMusic(t){if(r("设置背景音乐开关值",t,this._switch_music),t==this._switch_music)return;this._switch_music=t,t?this.resumeMusic():this.pauseMusic();const e=t?Q.MUSIC_ON:Q.MUSIC_OFF;this.cat.event.has(e)&&this.cat.event.dispatchEvent(e),this.save()}async playEffect(t){this._switch_effect&&t&&await this.effect.load(t).then((()=>{this.effect.play()}))}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(t){this._volume_effect=t,this.effect.volume=t}get switchEffect(){return this._switch_effect}set switchEffect(t){if(t==this._switch_effect)return;this._switch_effect=t,t?this.effect?.play():this.effect?.stop();const e=t?Q.EFFECT_ON:Q.EFFECT_OFF;this.cat.event.has(e)&&this.cat.event.dispatchEvent(e),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect;let t=JSON.stringify(this.local_data);this.cat.storage.set(Y,t)}load(){try{let t=this.cat.storage.get(Y);this.local_data=JSON.parse(t),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect}catch(t){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}class et extends Z{_key=null;_iv=null;_id="";init(t,e){this.cat.util.encryptUtil.initCrypto(t,e),this._key=this.cat.util.encryptUtil.md5(t),this._iv=this.cat.util.encryptUtil.md5(e)}setUser(t){this._id=t}set(t,e){if(null!=(t=`${t}_${this._id}`)){if(M||(t=this.cat.util.encryptUtil.md5(t)),null==e)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(t);if("function"!=typeof e){if("object"==typeof e)try{e=JSON.stringify(e)}catch(t){return void console.error(`解析失败,str = ${e}`)}else"number"==typeof e&&(e+="");M||null==this._key||null==this._iv||(e=this.cat.util.encryptUtil.aesEncrypt(`${e}`,this._key,this._iv)),a.localStorage.setItem(t,e)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(t,e){if(null==t)return console.error("存储的key不能为空"),null;t=`${t}_${this._id}`,M||(t=this.cat.util.encryptUtil.md5(t));let s=a.localStorage.getItem(t);return null==s||""===s||M||null==this._key||null==this._iv||(s=this.cat.util.encryptUtil.aesDecrypt(s,this._key,this._iv)),null===s?e:s}getNumber(t,e=0){var s=this.get(t);return Number(s)||e}getBoolean(t){var e=this.get(t);return Boolean(e)||!1}getJson(t,e){var s=this.get(t);return s&&JSON.parse(s)||e}remove(t){null!=t?(t=`${t}_${this._id}`,M||(t=this.cat.util.encryptUtil.md5(t)),a.localStorage.removeItem(t)):console.error("存储的key不能为空")}clear(){a.localStorage.clear()}}function st(t,e,s,o){var i,n=arguments.length,r=n<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,s):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,s,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(n<3?i(r):n>3?i(e,s,r):i(e,s))||r);return n>3&&r&&Object.defineProperty(e,s,r),r}function ot(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}"function"==typeof SuppressedError&&SuppressedError;class it extends c{props={};data={};autorunDisposers=[];reactionDisposers=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}added(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),F(this,{props:U,data:U})}onAutoObserver(){}addAutorun(t){return(Array.isArray(t)?t:[t]).forEach((t=>{const e=P(t);this.autorunDisposers.push(e)})),this}addReaction(t,e,s){const o=H(t,e,s);return this.reactionDisposers.push(o),this}_onPreDestroy(){this.autorunDisposers.forEach((t=>{t()})),this.reactionDisposers.forEach((t=>{t()})),this.autorunDisposers=[],this.reactionDisposers=[],super._onPreDestroy()}onDisable(){this.onHide(),te.event.deleteEventByComponent(this),this.removeListener()}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(t,e){let s=t instanceof l?h(t):t instanceof c?t.node:t;return this.setOptions(e),s.addChild(this.node),this.added(),this}setOptions(t){if(t)for(let e in t)switch(e){case"hook":t.hook&&(this.hook=t.hook);break;case"props":null!==t.props&&"object"==typeof t.props&&(this.props=t.props);break;case"data":null!==t.data&&"object"==typeof t.data&&(this.data=t.data)}}setUpdateData(t){return t&&Object.assign(this.data,t),this}setUpdateProps(t){return this.props,t&&Object.assign(this.props,t),this}removeAndDestroy(){d(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(t){return this.node.setPosition(t),this}setScale(t){return this.node.setScale(t),this}setAngle(t){return this.node.angle=t,this}setRotation(t){return this.node.setRotation(t),this}onShow(){}onHide(){}setNodeAndChildrenLayer(t){return nt(this.node,t),this}}const nt=(t,e)=>{t.layer="string"==typeof e?2**p.nameToLayer(e):e,t?.children.forEach((t=>{nt(t,e)}))};class rt extends it{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=u.getVisibleSize()}async showTween({isMotion:t=!0,direction:e="center",duration:s=.1,isBounce:o=!0,bounceDuration:i=.05}){if(this.lastEnterDirection=e,t){const t=this.node.getComponent(f);let i,n;t&&(t.updateAlignment(),t.enabled=!1),_(1.1,1.1,1),"center"==e?(i=_(.01,.01,.01),n=_(1,1,1)):(i="left"==e?_(-this.screen.width,0,0):"right"==e?_(this.screen.width,0,0):_(0,"top"==e?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(e,s,i,n,o),t&&(t.enabled=!0)}}async hideTween({isMotion:t=!0,direction:e,duration:s=.1}){if(e=e||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,y(this.node).removeSelf(),t){const t=this.node.getComponent(f);let o,i;t&&(t.enabled=!1),"center"==e?(o=this.node.scale,i=_(0,0,0)):(i="left"==e?_(-this.screen.width,0,0):"right"==e?_(this.screen.width,0,0):_(0,"top"==e?this.screen.height:-this.screen.height,0),o=this.node.getPosition()),await this.handle(e,s,o,i,!1)}this.removeAndDestroy()}}async handle(t,e,s,o,i){"center"==t?this.node.setScale(s):this.node.setPosition(s),await this.deftween(e,{["center"==t?"scale":"position"]:o},i)}deftween(t,e,s,o){return new Promise(((s,o)=>{y(this.node).to(t,e).call((()=>{s()})).start()}))}}const{ccclass:at,property:ct}=e;var lt;!function(t){t[t.EFFECT=0]="EFFECT",t[t.BGM=1]="BGM"}(lt||(lt={}));class ht extends it{type=lt.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new t;onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,te.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:t,volumeMusic:e}=te.audio;this.audioSource.volume=this.type===lt.BGM?e:t}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=te.audio;this.audioSource.playing||!(this.type===lt.BGM?e:t)||m._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}st([ct({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(lt)}),ot("design:type",Object)],ht.prototype,"type",void 0),st([ct({tooltip:"音源",type:s}),ot("design:type",Object)],ht.prototype,"clip",void 0),st([ct({tooltip:"循环"}),ot("design:type",Object)],ht.prototype,"loop",void 0),st([ct({tooltip:"音量"}),ot("design:type",Object)],ht.prototype,"volume",void 0),st([ct({tooltip:"是否启用自动播放"}),ot("design:type",Object)],ht.prototype,"playOnAwake",void 0);const{ccclass:dt,property:pt}=e;var ut;!function(t){t[t.FIXED=0]="FIXED",t[t.SLIDE=1]="SLIDE"}(ut||(ut={}));let ft=class extends it{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new Promise((async(t,e)=>{const{title:s,type:o,fixed_time:i}=this.props;if(o==ut.FIXED){this.fixed_node.active=!0,this.fixed_label.string=`${s}`,this.fixed_label.updateRenderData(!0);const e=this.fixed_label.node.getComponent(E).height;e-this.fixed_node.getComponent(E).height>0&&(this.fixed_node.getComponent(E).height=e+100),this.scheduleOnce((()=>{this.node.destroy(),t()}),i)}else{this.slide_node.active=!0,this.slide_label.string=`${s}`,this.slide_label.updateRenderData(!0);const e=this.slide_label.node.getComponent(E).width;this.slide_node.getComponent(E).width-e<100&&(this.slide_node.getComponent(E).width=e+100),this.playAnim(this.node).then((()=>{t()}))}}))}playAnim(t){return new Promise(((e,s)=>{const o=this.node.getComponent(b),i=y(o).delay(1.2).to(.5,{opacity:0}).call((()=>{C.stopAllByTarget(t),this.node.destroy(),e()}));y(t).by(.5,{position:_(0,400,0)}).call((()=>{i.start()})).start()}))}onDestroy(){C.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var _t;st([pt({type:i,tooltip:"固定节点"}),ot("design:type",i)],ft.prototype,"fixed_node",void 0),st([pt({type:i,tooltip:"滑动节点"}),ot("design:type",i)],ft.prototype,"slide_node",void 0),st([pt({type:v,tooltip:"固定标签节点"}),ot("design:type",v)],ft.prototype,"fixed_label",void 0),st([pt({type:v,tooltip:"滑动标签节点"}),ot("design:type",v)],ft.prototype,"slide_label",void 0),ft=st([dt("CoreToast")],ft),function(t){t.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",t.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",t.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",t.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",t.ONLINE="GlobalEventConstant/ONLINE",t.OFFLINE="GlobalEventConstant/OFFLINE",t.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",t.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(_t||(_t={}));const{ccclass:yt,property:gt}=e;let mt=class extends rt{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Bt)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){te.event.on(_t.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const t=this.brother[this.brother.length-1];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const t=this.brother[this.brother.length-2];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(t){return this.scene_mask?(this.scene_mask.tween.addChild(t),this):(console.error("scene_mask is null"),this)}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(t){return this.gui=t,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(t){this.scene_mask.black_mask.active=!this.gui.root_mask.active&&t}};st([gt({type:i}),ot("design:type",i)],mt.prototype,"scene_mask_node",void 0),st([gt({type:i}),ot("design:type",i)],mt.prototype,"ui_container",void 0),mt=st([yt("CoreUIContainer")],mt);class vt extends rt{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){te.event.dispatchEvent(_t.ROOT_MASK_UPDATE)}}const{ccclass:Et,property:bt}=e;let Ct=class extends vt{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(w).enabled=!!this.props?.mask}])}update(t){this.loading_rotate+=220*t,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};st([bt({type:v,tooltip:"标题"}),ot("design:type",v)],Ct.prototype,"title",void 0),st([bt({type:i,tooltip:"动画"}),ot("design:type",i)],Ct.prototype,"loadingTween",void 0),Ct=st([Et("CoreShowLoading")],Ct);const{ccclass:wt,property:kt}=e;var Ot;!function(t){t.RECONNECTED="重连成功",t.RECONNECTING="正在重连",t.MAX_RECONNECT="重连次数超出限制,请检查网络",t.RECONNECTED_ERROR="重连失败,请检查网络",t.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",t.KICK="账号已下线",t.OFFLINE="网络已断开",t.ONLINE="网络已连接",t.GAME_ERROR="连接游戏服错误"}(Ot||(Ot={}));let St=class extends vt{common_prompt_text;btn_confirm;is_close=!1;props={content:null};initUI(){this.btn_confirm.node.active=!1}onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(t){this.updatePromptText(t,t==Ot.RECONNECTING)}updatePromptText(t,e=!1){if(this.unscheduleAllCallbacks(),this.props.content=t,r("更新提示文案:",t),e){let e=0;const s=()=>{e=(e+1)%4,this.common_prompt_text.string=t+["","·","··","···"][e]};this.schedule(s,.5)}}onConfirmHandler(){this.is_close=!0,te.gui.hideReconnect()}};st([kt({type:v,tooltip:"通用提示文本"}),ot("design:type",v)],St.prototype,"common_prompt_text",void 0),st([kt({type:k,tooltip:"确定按钮"}),ot("design:type",k)],St.prototype,"btn_confirm",void 0),St=st([wt("CoreReconnection")],St);const{ccclass:xt,property:Rt}=e;let Nt=class extends vt{text;btn_confirm;onLoad(){this.btn_confirm.node.on(k.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),te.gui.hideNotice()}updateProps(t){this.text.string=`${t.text}`}};st([Rt({type:v,tooltip:"提示文本"}),ot("design:type",v)],Nt.prototype,"text",void 0),st([Rt({type:k,tooltip:"确定按钮"}),ot("design:type",k)],Nt.prototype,"btn_confirm",void 0),Nt=st([xt("CoreNotice")],Nt);class At extends it{isReload}const{ccclass:Tt,property:It}=e;var Mt;!function(t){t[t.UI=0]="UI",t[t.LOADING=1]="LOADING",t[t.TOAST=2]="TOAST",t[t.RECONNECTTION=3]="RECONNECTTION",t[t.NOTICE=4]="NOTICE"}(Mt||(Mt={}));let Dt=class extends it{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;cat;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(_t.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(t){this.cat=t;const e=n.getScene();return r("init scene"),e&&this.changeScene(e),this}start(){this.onRootUpdate()}showToast({title:t="",type:e=ut.SLIDE,fixed_time:s=2}){const o=h(this.toast_ui_prefab);return r("showToast",t),this.toast_ui_component=o.getComponent(ft).addToParent(this.root_toast,{props:{title:t,type:e,fixed_time:s}}),this}hideToast(){return this.toast_ui_component?.removeAndDestroy(),this}showLoading({title:t="",mask:e=!0,black:s=!0}={}){if(r("showLoading",t),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:t,mask:e,black:s}});else{const o=h(this.loading_ui_prefab);this.loading_ui_component=o.getComponent(Ct).addToParent(this.root_ui,{props:{title:t,mask:e,black:s}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(t){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:t});else{const e=h(this.reconnection_ui_prefab);this.reconnection_ui_component=e.getComponent(St).addToParent(this.root_ui,{props:{content:t}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(t){const e=h(this.notice_ui_prefab);return this.notice_ui_component=e.getComponent(Nt).addToParent(this.root_ui,{props:t}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(t,e,s){r("加载场景",t,e,s);let o={},i=s??!1;return"boolean"==typeof e?i=e:o=e??{},r("当前场景",n.getScene()?.uuid,n.getScene()?.name),n.once(O.EVENT_BEFORE_SCENE_LAUNCH,(t=>{r("Director.EVENT_BEFORE_SCENE_LAUNCH",t),this.changeScene(t,o,i)})),n.loadScene(t),this}resetScene(t=""){return t=t||this.currentScene,this.loadScene(t)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(t,e,s){this.currentScene=t.name,this.createUILayer(t);const o=t.getComponentInChildren(At);o&&(o.isReload=s??!1),o?.setOptions(e)}createUILayer(t){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const e=h(this.ui_prefab);this.ui_container_component=e.getComponent(mt).setGui(this).addToParent(t)}reloadScene(){this.loadScene(this.currentScene,!0)}async closeUI(t,e){const{component:s}=this.findUIBaseLayer(t,!1);s&&(s.setOptions({...e?.hook??{},...e?.props??{}}),await s.hideTween(e||{}),this.ui_container_component?.subMask())}async openUI(t,e){const{rootNode:s,component:o}=this.findUIBaseLayer(t,!0);s.getComponent(rt),o?.setOptions(e),s&&this.ui_container_component?.addNodeToTween(s).addMask(),o&&await o.showTween(e||{}),this.ui_container_component?.ui_container&&o?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(t,e){let s,n=null;if(t instanceof i){s=t;const e=t.components.filter((t=>t instanceof rt));if(!e.length)return o(`${t.name}节点未找到继承自BaseLayer的组件`),{rootNode:s,component:n};1==e.length?n=e[0]:S(`${t.name}节点存在多个继承自BaseLayer的组件`)}else if(s=t.node,n=t,e){for(;s.parent;)s=s.parent;n.root=s}else s=t.root;return{rootNode:s,component:n}}onRootUpdate(){const t=this.root_ui.children.length;if(this.root_mask.active=t>1,t>1){const e=this.root_ui.children[t-2];this.root_mask.setSiblingIndex(e.getSiblingIndex())}this.cat.event.dispatchEvent(_t.ROOT_MASK_CHANGE)}};st([It({type:l,tooltip:"断线重连UI预制体"}),ot("design:type",l)],Dt.prototype,"reconnection_ui_prefab",void 0),st([It({type:l,tooltip:"提示UI预制体"}),ot("design:type",l)],Dt.prototype,"toast_ui_prefab",void 0),st([It({type:l,tooltip:"加载UI预制体"}),ot("design:type",l)],Dt.prototype,"loading_ui_prefab",void 0),st([It({type:l,tooltip:"公告UI预制体"}),ot("design:type",l)],Dt.prototype,"notice_ui_prefab",void 0),st([It({type:l,tooltip:"UI层预制体"}),ot("design:type",l)],Dt.prototype,"ui_prefab",void 0),st([It({type:i,tooltip:"root-UI层"}),ot("design:type",i)],Dt.prototype,"root_ui",void 0),st([It({type:i,tooltip:"root-组件层"}),ot("design:type",i)],Dt.prototype,"root_toast",void 0),st([It({type:i,tooltip:"root-mask"}),ot("design:type",i)],Dt.prototype,"root_mask",void 0),Dt=st([Tt("Gui")],Dt);const{ccclass:Ft,property:Ut}=e;class Pt extends rt{type=lt.EFFECT;clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=new t;onEnable(){super.onEnable(),te.event.on(Q.EFFECT_ON,this.onPlayEffectHandler,this).on(Q.EFFECT_OFF,this.onStopEffectHandler,this).on(Q.MUSIC_ON,this.onPlayMusicHandler,this).on(Q.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:t,volumeMusic:e}=te.audio;this.audioSource.volume=this.type===lt.BGM?e:t}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=te.audio;this.audioSource.playing||!(this.type===lt.BGM?e:t)||m._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}st([Ut({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(lt)}),ot("design:type",Object)],Pt.prototype,"type",void 0),st([Ut({tooltip:"音源",type:s}),ot("design:type",Object)],Pt.prototype,"clip",void 0),st([Ut({tooltip:"循环"}),ot("design:type",Object)],Pt.prototype,"loop",void 0),st([Ut({tooltip:"音量"}),ot("design:type",Object)],Pt.prototype,"volume",void 0),st([Ut({tooltip:"是否启用自动播放"}),ot("design:type",Object)],Pt.prototype,"playOnAwake",void 0);const{ccclass:Ht,property:Lt}=e;let Bt=class extends it{tween;black_mask};var Gt;st([Lt({type:i,tooltip:"动画节点"}),ot("design:type",i)],Bt.prototype,"tween",void 0),st([Lt({type:i,tooltip:"遮罩节点"}),ot("design:type",i)],Bt.prototype,"black_mask",void 0),Bt=st([Ht("CoreBlackMask")],Bt),function(t){t.Root="core/root",t.Toast="core/toast",t.BlackMask="core/black-mask",t.Loading="core/loading",t.Notice="core/notice",t.Reconnection="core/reconnection"}(Gt||(Gt={}));class $t extends Z{_gui;get gui(){return this._gui}set gui(t){this._gui=t}getGuiPrefabByType=t=>new Promise(((e,s)=>{this.cat.res.load(t,((t,o)=>{t?s(t):e(o)}))}));async init(){const t=await this.getGuiPrefabByType(Gt.Root),e=h(t);return this.gui=e.getComponent(Dt).init(this.cat),n.addPersistRootNode(e),this}}class jt{get=(t,e,s="resources")=>x.getBundle(s).get(t,e);isAssetType=t=>"function"==typeof t&&t.prototype instanceof R;async load(...t){let e=null,s=null,o=null;"string"==typeof t[0]&&"string"==typeof t[1]&&(e=t.shift());let i=t.shift();this.isAssetType(t[0])&&(s=t.shift()),2==t.length&&(o=t.shift());const n=t.shift();let r=N;if(e&&"resources"!=e){x.bundles.has(e)||await this.loadBundle(e);let t=x.bundles.get(e);t&&(r=t)}o&&n?r.load(i,s,o,n):n?r.load(i,s,n):r.load(i,s)}async loadDir(...t){let e=null,s=null,o=null,i=null;"string"==typeof t[0]&&"string"==typeof t[1]&&(e=t.shift());let n=t.shift();this.isAssetType(t[0])&&(s=t.shift()),2==t.length&&(o=t.shift()),i=t.shift();let r=N;if(e&&"resources"!=e){x.bundles.has(e)||await this.loadBundle(e);let t=x.bundles.get(e);t&&(r=t)}o&&i?r.loadDir(n,s,o,i):i?r.loadDir(n,s,i):r.loadDir(n,s)}loadRemote(t,...e){var s,o=null;2==e.length&&(o=e.shift()),s=e.shift(),x.loadRemote(t,{ext:".png",...o},s)}loadBundle=(t,e)=>new Promise(((s,o)=>{const i=(t,e)=>{if(t)return o(t);s(e)};e?x.loadBundle(t,{version:e},i):x.loadBundle(t,i)}));releasePrefabtDepsRecursively=t=>{var e=x.assets.get(t);(x.releaseAsset(e),e instanceof l)&&x.dependUtil.getDepsRecursively(t).forEach((t=>{x.assets.get(t).decRef()}))};release=(t,e="resources")=>{var s=x.getBundle(e);if(s){var o=s.get(t);o&&this.releasePrefabtDepsRecursively(o._uuid)}};releaseDir=(t,e="resources")=>{var s=x.getBundle(e),o=s?.getDirWithPath(t);o?.map((t=>{this.releasePrefabtDepsRecursively(t.uuid)})),!t&&"resources"!=e&&s&&x.removeBundle(s)};dump=()=>{x.assets.forEach(((t,e)=>{r(x.assets.get(e))})),r(`当前资源总数:${x.assets.count}`)}}class qt{events=new Map;on(t,e,s){if(!t||!e)return S(`注册【${t}】事件的侦听器函数为空`),this;const o=this.events.get(t)??this.events.set(t,new Map).get(t);return o.has(s)?(S(`名为【${t}】的事件重复注册侦听器`),this):(o.set(s,e),this)}once(t,e,s){let o=(i,n)=>{this.off(t,o,s),o=null,e.call(s,i,n)};this.on(t,o,s)}off(t,e,s){if(!this.events.get(t)?.has(s))return this;const i=this.events.get(t);return i.get(s)!==e?(o(`${s}注册事件和取消事件不一致`),this):(i.delete(s),this)}dispatchEvent(t,e){if(!this.events.has(t))return this;const s=this.events.get(t);for(const[o,i]of s)i.call(o,e,t);return this}offAll(){this.events.clear()}has(t){return this.events.has(t)}deleteEventByComponent(t){for(const[e,s]of this.events){for(const[e]of s)e===t&&s.delete(e);0===s.size&&this.events.delete(e)}}}let Kt=null;const Vt={stringify:t=>{const e={ct:t.ciphertext.toString(L.enc.Base64)};return t.iv&&(e.iv=t.iv.toString()),t.salt&&(e.s=t.salt.toString()),JSON.stringify(e)},parse:t=>{const e=JSON.parse(t),s=L.lib.CipherParams.create({ciphertext:L.enc.Base64.parse(e.ct)});return e.iv&&(s.iv=L.enc.Hex.parse(e.iv)),e.s&&(s.salt=L.enc.Hex.parse(e.s)),s}};var Jt=Object.freeze({__proto__:null,JsonFormatter:Vt,aesDecrypt:(t,e,s)=>L.AES.decrypt(t,e,{iv:Kt,format:Vt}).toString(L.enc.Utf8),aesEncrypt:(t,e,s)=>L.AES.encrypt(t,e,{iv:Kt,format:Vt}).toString(),initCrypto:(t,e)=>{Kt=L.enc.Hex.parse(e)},md5:t=>L.MD5(t).toString()});class Wt extends Z{encryptUtil=Jt}class Xt extends ${isNeedReconnect=!1;isOnline=!0;isInBackground=!1;running=!1;index=0;logBlackList=[];constructor(t,e,s){super(t,e,s),this.running=!0,this.addEvent()}addEvent(){this.on("connected",(()=>this.handleEvent({type:"connected"}))).on("reconnected",(()=>this.handleEvent({type:"reconnected"}))).on("disconnect",(t=>this.handleEvent({type:"disconnect",ev:t}))).on("handshakeError",(t=>this.handleEvent({type:"handshakeError",ret:t}))).on("kick",(()=>this.handleEvent({type:"kick"}))).on("reconnecting",(()=>this.handleEvent({type:"reconnecting"}))).on("maxReconnect",(()=>this.handleEvent({type:"maxReconnect"}))).on("error",(t=>this.handleEvent({type:"error",ev:t}))),te.event.on(_t.EVENT_SHOW,this.onShowHandler,this).on(_t.EVENT_HIDE,this.onHideHandler,this).on(_t.ONLINE,this.onOnlineHandler,this).on(_t.OFFLINE,this.onOfflineHandler,this)}removeEvent(){this.removeAllListeners(),te.event.off(_t.EVENT_SHOW,this.onShowHandler,this).off(_t.EVENT_HIDE,this.onHideHandler,this).off(_t.ONLINE,this.onOnlineHandler,this).off(_t.OFFLINE,this.onOfflineHandler,this)}onShowHandler(){r("[SHOW]"),this.isInBackground=!1,this.isNeedReconnect&&this.isOnline&&this.handleEvent({type:"show"})}onHideHandler(t){r("[HIDE]"),t().finally((()=>{this.isInBackground=!0,this.handleEvent({type:"hide"})}))}onOnlineHandler(){this.isOnline=!0,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"online"})}onOfflineHandler(){this.isOnline=!1,r("正在检查网络状态:"+(this.isOnline?"在线":"断开")),this.handleEvent({type:"offline"})}async handleEvent(t){if(this.running)switch(t.type){case"init":break;case"connected":r("ws连接成功状态 connected"),this.isNeedReconnect=!1;break;case"reconnected":r("ws重连成功状态 reconnected",this.isSocketConnected),this.isNeedReconnect=!1,r("%c 重连成功状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index);try{await this.connectRequest(),r("重连成功状态 connectRequest "),te.gui.showToast({title:Ot.RECONNECTED}),te.gui.hideReconnect().hideLoading(),te.gui.reloadScene()}catch(t){console.error(t),te.gui.showReconnect(Ot.GAME_ERROR)}break;case"disconnect":r("断开连接状态 disconnect",t.ev),r("%c 断开连接状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.isNeedReconnect=!0,this.handleEvent({type:"reconnect"});break;case"handshakeError":r("参数错误状态 handshakeError",t.ret),te.gui.showReconnect(Ot.CONNECT_PARAM_ERROR),this.handleEvent({type:"destroy"});break;case"kick":r("%c 被踢出状态","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),r("被踢出状态 kick"),te.gui.showReconnect(Ot.KICK),this.handleEvent({type:"destroy"});break;case"reconnecting":r("正在重连状态 reconnecting"),this.isOnline&&this.isInBackground;break;case"maxReconnect":r("超出最大重连状态 maxReconnect"),te.gui.showReconnect(Ot.MAX_RECONNECT);break;case"error":this.isOnline&&(r("ws报错状态 error",t.ev),"string"==typeof t.ev&&te.gui.showToast({title:t.ev}),te.gui.showReconnect(Ot.RECONNECTED_ERROR));break;case"online":te.gui.showReconnect(Ot.ONLINE),r("在线状态 online"),this.handleEvent({type:"reconnect"});break;case"offline":this.disconnect(!0),r("离线状态 offline"),this.isNeedReconnect=!0,te.gui.showReconnect(Ot.OFFLINE);break;case"show":r("前台状态 show"),this.handleEvent({type:"reconnect"});break;case"hide":r("后台状态 hide"),this.disconnect(!0),this.isNeedReconnect=!0;break;case"reconnect":r("重连状态 reconnect"),this.isNeedReconnect&&!this.isInBackground&&this.isOnline&&(te.gui.showLoading({title:"正在重连"}),this.reset(),this.index+=1,r("%c ws重连次数","background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff",this.index),this.reconnectImmediately());break;case"destroy":r("销毁状态 destroy"),this.destroyStateMachine();break;default:r("Unknown event:",t.type)}}destroy(){this.handleEvent({type:"destroy"})}disconnect(t=!1){super.disconnect(t)}destroyStateMachine(){r("Destroying state machine"),this.running=!1,this.removeEvent(),this.disconnect(!0)}request(t,e,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(e.desc,e.message)),new Promise(((i,n)=>{super.request(t,e,s).then((e=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,e)),i(e)}),(t=>{o("request err",t),n(t)}))}))}async Request(t,e,s,{audOptions:o={forwardReq:!1,forwardResp:!1},show_log:i=!0}={}){if(!this.isSocketConnected)throw""+(this.isSocketConnected?"未加入战局/观战":"Socket未连接");return D&&i&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(e.desc,e.message)),this.GameRequest(t,e,s,G(j,o))}async GameRequest(t,e,s,o){return new Promise(((i,n)=>{super.GameRequest(t,e,s,o).then((e=>{D&&r(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(s,e)),i(e)}),(t=>{te.gui.showToast({title:t.msg}),n(t)}))}))}async gameRequest(t,e,s){return D&&r(`%c ws客户端消息 %c [Request][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(e.desc,e.message)),super.gameRequest(t,e,s)}GameNotify=async(t,e,s)=>{try{super.GameNotify(t,e,s)}catch(e){throw console.error(`Error in connectRequest for route ${t}: `,e),e}};Notify=async(t,e,{audOptions:s=G(j,{forwardReq:!1,forwardResp:!1}),show_log:o=!0}={})=>{this.isSocketConnected&&(D&&o&&r(`%c ws客户端消息 %c[Notify][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7d3d ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(e.desc,e.message)),this.GameNotify(t,e,s))};subscribe(t,e,s){return super.subscribe(t,e,(o=>{D&&!this.logBlackList.includes(t)&&r(`%c ws服务端消息:[${new Date}] %c ${t} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",B(e,o)),te.event.dispatchEvent(t,B(e,o)),s?.(o)})),this}onData(t){super.onData(t)}}const{ccclass:zt,property:Zt}=e;let Qt=class extends rt{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(k.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(k.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(k.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content instanceof A?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容")},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(T).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(T).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),te.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};st([Zt({type:A,tooltip:"默认标题"}),ot("design:type",A)],Qt.prototype,"default_title",void 0),st([Zt({type:T,tooltip:"标题节点"}),ot("design:type",T)],Qt.prototype,"title",void 0),st([Zt({type:v,tooltip:"字符串内容按钮"}),ot("design:type",v)],Qt.prototype,"prompt_content_str",void 0),st([Zt({type:T,tooltip:"图片精灵内容按钮"}),ot("design:type",T)],Qt.prototype,"prompt_content_spriteFrame",void 0),st([Zt({type:k,tooltip:"确认按钮"}),ot("design:type",k)],Qt.prototype,"btn_confirm",void 0),st([Zt({type:A,tooltip:"确认按钮精灵图"}),ot("design:type",A)],Qt.prototype,"confirm_spriteFrame",void 0),st([Zt({type:k,tooltip:"取消按钮"}),ot("design:type",k)],Qt.prototype,"btn_cancel",void 0),st([Zt({type:A,tooltip:"取消按钮精灵图"}),ot("design:type",A)],Qt.prototype,"cancel_spriteFrame",void 0),st([Zt({type:k,tooltip:"关闭按钮"}),ot("design:type",k)],Qt.prototype,"btn_close",void 0),Qt=st([zt("CoreUIModal")],Qt);class Yt{static ins;static get instance(){return this.ins||(this.ins=new Yt),this.ins}onAppInitDelegate=new I;audio;event;gui;storage;res;util;async boot(){this.res=new jt,this.util=new Wt(this),this.storage=new et(this),this.event=new qt,this.audio=new tt(this),this.gui=(await new $t(this).init()).gui}}const te=Yt.instance;m.onPostProjectInitDelegate.add((async()=>{console.time("[Init App]"),await te.boot(),await te.onAppInitDelegate.dispatch(),console.timeEnd("[Init App]")}));export{Q as AudioEventConstant,ht as AudioSourceBaseComponent,lt as AudioTypeEnum,it as BaseComponent,Z as BaseManager,Gt as BasePrefab,Bt as CoreBlackMask,Nt as CoreNotice,St as CoreReconnection,Ct as CoreShowLoading,ft as CoreToast,mt as CoreUIContainer,Qt as CoreUIModal,Wt as CoreUtil,_t as GlobalEventConstant,Dt as Gui,$t as GuiManager,Mt as LayerType,Yt as Manager,Ot as ReconnectPrompt,ut as ToastType,Xt as WrapperSocialGameClient,te as cat};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shimotsuki/core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"repository": "https://gitee.com/shimotsuki_yami/cat-core",
|
|
9
|
+
"author": "shimotsuki <youcunzhou2383@shengtian.com>",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npx rollup -c rollup.config.js"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@babel/core": "^7.26.8",
|
|
15
|
+
"@babel/preset-env": "^7.26.8",
|
|
16
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
17
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
18
|
+
"api": "git+ssh://git@gitlab.stnts.com:sparklab/gameapi.git",
|
|
19
|
+
"rimraf": "^6.0.1",
|
|
20
|
+
"rollup-plugin-delete": "^2.1.0",
|
|
21
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
22
|
+
"tslib": "^2.8.1",
|
|
23
|
+
"typescript": "^5.7.3"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@bufbuild/protobuf": "^2.0.0",
|
|
28
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
29
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
30
|
+
"@shimotsuki/mobx": "^1.0.1",
|
|
31
|
+
"crypto-es": "^2.1.0",
|
|
32
|
+
"ky": "^1.7.2",
|
|
33
|
+
"rollup": "^4.18.1",
|
|
34
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
35
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
36
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
37
|
+
"sgc": "git+ssh://git@gitlab.stnts.com:sparklab/social-gaming-client.git"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"package.json",
|
|
42
|
+
"./temp/tsconfig.cocos.json",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2015",
|
|
5
|
+
"module": "ES2015",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"types": ["./temp/declarations/cc.custom-macro", "./temp/declarations/cc", "./temp/declarations/jsb", "./temp/declarations/cc.env"],
|
|
8
|
+
"paths": {
|
|
9
|
+
"db://internal/*": ["C:\\ProgramData\\cocos\\editors\\Creator\\3.8.4\\resources\\resources\\3d\\engine\\editor\\assets\\*"]
|
|
10
|
+
},
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"moduleResolution": "node",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true
|
|
16
|
+
}
|
|
17
|
+
}
|