@shimotsuki/core 2.0.13 → 2.0.14

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 (2) hide show
  1. package/dist/index.js +543 -608
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,44 +1,77 @@
1
1
  import { configureTextEncoding } from '@bufbuild/protobuf/wire';
2
2
  import TextEncoding from 'text-encoding';
3
- import { AudioSource, _decorator, AudioClip, error, Node, director, log, sys, Component, Prefab, instantiate, isValid, Layers, view, Widget, v3, tween, Enum, game, UITransform, UIOpacity, Tween, Label, BlockInputEvents, Button, Director, warn, assetManager, Asset, resources, Game, SpriteFrame, Sprite, AsyncDelegate } from 'cc';
4
- import { PREVIEW, DEBUG } from 'cc/env';
5
- import { makeObservable, observable, autorun, reaction } from '@shimotsuki/mobx';
6
- import CryptoES from 'crypto-es';
7
- import { clone } from '@bufbuild/protobuf';
8
- import { SocketConnectStatus } from 'pitayaclient';
9
- import { SocialGameClient } from 'sgc';
10
- import { EventEmitter } from 'eventemitter3';
11
- import 'core-js/es/array/index.js';
12
-
13
3
  console.log('===== TextEncoding Polyfil 开始加载 =====', TextEncoding);
14
4
  // 全局挂载(必须在所有页面加载前执行)
15
- // globalThis.TextEncoder = TextEncoding.TextEncoder;
16
- // globalThis.TextDecoder = TextEncoding.TextDecoder;
5
+ const te = new TextEncoding.TextEncoder();
6
+ const td = new TextEncoding.TextDecoder();
17
7
  debugger;
18
8
  configureTextEncoding({
19
9
  encodeUtf8(text) {
20
- return TextEncoding.TextEncoder.encode(text);
10
+ return te.encode(text);
21
11
  },
22
12
  decodeUtf8(bytes) {
23
- return TextEncoding.TextDecoder.decode(bytes);
13
+ return td.decode(bytes);
24
14
  },
25
15
  checkUtf8(text) {
26
16
  try {
27
17
  encodeURIComponent(text);
28
18
  return true;
29
- }
30
- catch (e) {
19
+ } catch (e) {
31
20
  return false;
32
21
  }
33
22
  },
34
23
  });
35
24
  console.log('===== TextEncoding Polyfil 已加载 =====');
25
+ import {
26
+ AudioSource,
27
+ _decorator,
28
+ AudioClip,
29
+ error,
30
+ Node,
31
+ director,
32
+ log,
33
+ sys,
34
+ Component,
35
+ Prefab,
36
+ instantiate,
37
+ isValid,
38
+ Layers,
39
+ view,
40
+ Widget,
41
+ v3,
42
+ tween,
43
+ Enum,
44
+ game,
45
+ UITransform,
46
+ UIOpacity,
47
+ Tween,
48
+ Label,
49
+ BlockInputEvents,
50
+ Button,
51
+ Director,
52
+ warn,
53
+ assetManager,
54
+ Asset,
55
+ resources,
56
+ Game,
57
+ SpriteFrame,
58
+ Sprite,
59
+ AsyncDelegate,
60
+ } from 'cc';
61
+ import { PREVIEW, DEBUG } from 'cc/env';
62
+ import { makeObservable, observable, autorun, reaction } from '@shimotsuki/mobx';
63
+ import CryptoES from 'crypto-es';
64
+ import { clone } from '@bufbuild/protobuf';
65
+ import { SocketConnectStatus } from 'pitayaclient';
66
+ import { SocialGameClient } from 'sgc';
67
+ import { EventEmitter } from 'eventemitter3';
68
+ import 'core-js/es/array/index.js';
36
69
 
37
70
  /**
38
- * @describe 音频公共类
39
- * @author 游金宇(KM)
40
- * @date 2024-09-12 11:42:58
41
- */
71
+ * @describe 音频公共类
72
+ * @author 游金宇(KM)
73
+ * @date 2024-09-12 11:42:58
74
+ */
42
75
  class CommonAudio extends AudioSource {
43
76
  cat;
44
77
  initAudio(cat) {
@@ -48,10 +81,10 @@ class CommonAudio extends AudioSource {
48
81
  }
49
82
 
50
83
  /**
51
- * @describe 音效
52
- * @author 游金宇(KM)
53
- * @date 2023-08-03 10:59:44
54
- */
84
+ * @describe 音效
85
+ * @author 游金宇(KM)
86
+ * @date 2023-08-03 10:59:44
87
+ */
55
88
  const { ccclass: ccclass$b, menu: menu$9 } = _decorator;
56
89
  /**
57
90
  * 注:用playOneShot播放的音乐效果,在播放期间暂时没办法即时关闭音乐
@@ -100,8 +133,7 @@ class AudioMusic extends CommonAudio {
100
133
  _isPlay = false;
101
134
  /** 获取音乐播放进度 */
102
135
  get progress() {
103
- if (this.duration > 0)
104
- this._progress = this.currentTime / this.duration;
136
+ if (this.duration > 0) this._progress = this.currentTime / this.duration;
105
137
  return this._progress;
106
138
  }
107
139
  /**
@@ -156,10 +188,10 @@ class AudioMusic extends CommonAudio {
156
188
  }
157
189
 
158
190
  /**
159
- * @describe 基础管理类
160
- * @author 游金宇(KM)
161
- * @date 2024-09-12 11:49:30
162
- */
191
+ * @describe 基础管理类
192
+ * @author 游金宇(KM)
193
+ * @date 2024-09-12 11:49:30
194
+ */
163
195
  class BaseManager {
164
196
  cat;
165
197
  constructor(manager) {
@@ -170,24 +202,24 @@ class BaseManager {
170
202
  var AudioEventConstant;
171
203
  (function (AudioEventConstant) {
172
204
  /**音乐开 */
173
- AudioEventConstant["MUSIC_ON"] = "AudioEventConstant/MUSIC_ON";
205
+ AudioEventConstant['MUSIC_ON'] = 'AudioEventConstant/MUSIC_ON';
174
206
  /**音乐关 */
175
- AudioEventConstant["MUSIC_OFF"] = "AudioEventConstant/MUSIC_OFF";
207
+ AudioEventConstant['MUSIC_OFF'] = 'AudioEventConstant/MUSIC_OFF';
176
208
  /**音效开 */
177
- AudioEventConstant["EFFECT_ON"] = "AudioEventConstant/EFFECT_ON";
209
+ AudioEventConstant['EFFECT_ON'] = 'AudioEventConstant/EFFECT_ON';
178
210
  /**音效关 */
179
- AudioEventConstant["EFFECT_OFF"] = "AudioEventConstant/EFFECT_OFF";
211
+ AudioEventConstant['EFFECT_OFF'] = 'AudioEventConstant/EFFECT_OFF';
180
212
  /**暂停音频 */
181
- AudioEventConstant["PAUSE_AUDIO"] = "AudioEventConstant/PAUSE_AUDIO";
213
+ AudioEventConstant['PAUSE_AUDIO'] = 'AudioEventConstant/PAUSE_AUDIO';
182
214
  /**恢复音频 */
183
- AudioEventConstant["RESUME_AUDIO"] = "AudioEventConstant/RESUME_AUDIO";
215
+ AudioEventConstant['RESUME_AUDIO'] = 'AudioEventConstant/RESUME_AUDIO';
184
216
  })(AudioEventConstant || (AudioEventConstant = {}));
185
217
 
186
218
  /**
187
- * @describe 音频管理
188
- * @author 游金宇(KM)
189
- * @date 2023-08-03 17:54:31
190
- */
219
+ * @describe 音频管理
220
+ * @author 游金宇(KM)
221
+ * @date 2023-08-03 17:54:31
222
+ */
191
223
  /**
192
224
  * 音频管理
193
225
  */
@@ -228,27 +260,25 @@ class AudioManager extends BaseManager {
228
260
  */
229
261
  playMusic(url, callback) {
230
262
  this.music.loop = true;
231
- url && this.music.load(url, () => {
232
- this._switch_music && this.music?.play();
233
- callback && callback();
234
- });
263
+ url &&
264
+ this.music.load(url, () => {
265
+ this._switch_music && this.music?.play();
266
+ callback && callback();
267
+ });
235
268
  }
236
269
  /**
237
270
  * 停止音乐
238
271
  */
239
272
  stopMusic() {
240
- if (this.music.state != 0)
241
- this.music?.stop();
273
+ if (this.music.state != 0) this.music?.stop();
242
274
  }
243
275
  /**暂停音乐 */
244
276
  pauseMusic() {
245
- if (this.music.state == 1)
246
- this.music?.pause();
277
+ if (this.music.state == 1) this.music?.pause();
247
278
  }
248
279
  /**恢复音乐 */
249
280
  resumeMusic() {
250
- if ([0, 2].includes(this.music.state))
251
- this.music?.play();
281
+ if ([0, 2].includes(this.music.state)) this.music?.play();
252
282
  }
253
283
  /**
254
284
  * 获取背景音乐播放进度
@@ -289,8 +319,7 @@ class AudioManager extends BaseManager {
289
319
  */
290
320
  set switchMusic(value) {
291
321
  log('设置背景音乐开关值', value, this._switch_music);
292
- if (value == this._switch_music)
293
- return;
322
+ if (value == this._switch_music) return;
294
323
  this._switch_music = value;
295
324
  value ? this.resumeMusic() : this.pauseMusic();
296
325
  const nonce = value ? AudioEventConstant.MUSIC_ON : AudioEventConstant.MUSIC_OFF;
@@ -302,11 +331,11 @@ class AudioManager extends BaseManager {
302
331
  * @param url 资源地址
303
332
  */
304
333
  async playEffect(url) {
305
- if (!this._switch_effect)
306
- return;
307
- url && await this.effect.load(url).then(() => {
308
- this.effect.play();
309
- });
334
+ if (!this._switch_effect) return;
335
+ url &&
336
+ (await this.effect.load(url).then(() => {
337
+ this.effect.play();
338
+ }));
310
339
  }
311
340
  /**
312
341
  * 停止音效
@@ -339,8 +368,7 @@ class AudioManager extends BaseManager {
339
368
  * @param value 音效开关值
340
369
  */
341
370
  set switchEffect(value) {
342
- if (value == this._switch_effect)
343
- return;
371
+ if (value == this._switch_effect) return;
344
372
  this._switch_effect = value;
345
373
  value ? this.effect?.play() : this.effect?.stop();
346
374
  const nonce = value ? AudioEventConstant.EFFECT_ON : AudioEventConstant.EFFECT_OFF;
@@ -383,8 +411,7 @@ class AudioManager extends BaseManager {
383
411
  this._switch_music = this.local_data.switch_music;
384
412
  this._switch_effect = this.local_data.switch_effect;
385
413
  this.extra = this.local_data.extra;
386
- }
387
- catch (e) {
414
+ } catch (e) {
388
415
  this.local_data = {};
389
416
  this._volume_music = 0.6;
390
417
  this._volume_effect = 1.0;
@@ -392,18 +419,16 @@ class AudioManager extends BaseManager {
392
419
  this._switch_effect = true;
393
420
  this.extra = {};
394
421
  }
395
- if (this.music)
396
- this.music.volume = this._volume_music;
397
- if (this.effect)
398
- this.effect.volume = this._volume_effect;
422
+ if (this.music) this.music.volume = this._volume_music;
423
+ if (this.effect) this.effect.volume = this._volume_effect;
399
424
  }
400
425
  }
401
426
 
402
427
  /**
403
- * @describe 本地存储管理
404
- * @author 游金宇(KM)
405
- * @date 2023-08-03 17:58:51
406
- */
428
+ * @describe 本地存储管理
429
+ * @author 游金宇(KM)
430
+ * @date 2023-08-03 17:58:51
431
+ */
407
432
  class StorageManager extends BaseManager {
408
433
  _key = null;
409
434
  _iv = null;
@@ -452,13 +477,11 @@ class StorageManager extends BaseManager {
452
477
  if (typeof value === 'object') {
453
478
  try {
454
479
  value = JSON.stringify(value);
455
- }
456
- catch (e) {
480
+ } catch (e) {
457
481
  console.error(`解析失败,str = ${value}`);
458
482
  return;
459
483
  }
460
- }
461
- else if (typeof value === 'number') {
484
+ } else if (typeof value === 'number') {
462
485
  value = value + '';
463
486
  }
464
487
  if (!PREVIEW && null != this._key && null != this._iv) {
@@ -527,38 +550,41 @@ class StorageManager extends BaseManager {
527
550
  }
528
551
  }
529
552
 
530
- /******************************************************************************
531
- Copyright (c) Microsoft Corporation.
532
-
533
- Permission to use, copy, modify, and/or distribute this software for any
534
- purpose with or without fee is hereby granted.
535
-
536
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
537
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
538
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
539
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
540
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
541
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
542
- PERFORMANCE OF THIS SOFTWARE.
543
- ***************************************************************************** */
544
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
545
-
546
-
547
- function __decorate(decorators, target, key, desc) {
548
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
549
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
550
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
551
- return c > 3 && r && Object.defineProperty(target, key, r), r;
552
- }
553
-
554
- function __metadata(metadataKey, metadataValue) {
555
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
556
- }
557
-
558
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
559
- var e = new Error(message);
560
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
561
- };
553
+ /******************************************************************************
554
+ Copyright (c) Microsoft Corporation.
555
+
556
+ Permission to use, copy, modify, and/or distribute this software for any
557
+ purpose with or without fee is hereby granted.
558
+
559
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
560
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
561
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
562
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
563
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
564
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
565
+ PERFORMANCE OF THIS SOFTWARE.
566
+ ***************************************************************************** */
567
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
568
+
569
+ function __decorate(decorators, target, key, desc) {
570
+ var c = arguments.length,
571
+ r = c < 3 ? target : desc === null ? (desc = Object.getOwnPropertyDescriptor(target, key)) : desc,
572
+ d;
573
+ if (typeof Reflect === 'object' && typeof Reflect.decorate === 'function') r = Reflect.decorate(decorators, target, key, desc);
574
+ else for (var i = decorators.length - 1; i >= 0; i--) if ((d = decorators[i])) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
575
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
576
+ }
577
+
578
+ function __metadata(metadataKey, metadataValue) {
579
+ if (typeof Reflect === 'object' && typeof Reflect.metadata === 'function') return Reflect.metadata(metadataKey, metadataValue);
580
+ }
581
+
582
+ typeof SuppressedError === 'function'
583
+ ? SuppressedError
584
+ : function (error, suppressed, message) {
585
+ var e = new Error(message);
586
+ return (e.name = 'SuppressedError'), (e.error = error), (e.suppressed = suppressed), e;
587
+ };
562
588
 
563
589
  /**
564
590
  * @describe 组件基类
@@ -577,12 +603,11 @@ class BaseComponent extends Component {
577
603
  reactionDisposers = [];
578
604
  eventEmitter = [];
579
605
  hook = {
580
- destroyed: () => { },
581
- started: () => { },
606
+ destroyed: () => {},
607
+ started: () => {},
582
608
  };
583
609
  /**初始化UI(可在本函数中进行节点赋值或注册节点事件等...) */
584
- initUI() {
585
- }
610
+ initUI() {}
586
611
  __preload() {
587
612
  this.initUI();
588
613
  this.onAutoObserver();
@@ -591,12 +616,11 @@ class BaseComponent extends Component {
591
616
  super();
592
617
  makeObservable(this, {
593
618
  props: observable,
594
- data: observable
619
+ data: observable,
595
620
  });
596
621
  }
597
622
  /**依赖收集生命周期(可以在该生命周期中注册依赖收集回调) */
598
- onAutoObserver() {
599
- }
623
+ onAutoObserver() {}
600
624
  /**添加自动收集 */
601
625
  addAutorun(cb) {
602
626
  const cbs = Array.isArray(cb) ? cb : [cb];
@@ -625,10 +649,10 @@ class BaseComponent extends Component {
625
649
  return eventEmitter;
626
650
  }
627
651
  _onPreDestroy() {
628
- this.autorunDisposers.forEach((item) => {
652
+ this.autorunDisposers.forEach(item => {
629
653
  item();
630
654
  });
631
- this.reactionDisposers.forEach((item) => {
655
+ this.reactionDisposers.forEach(item => {
632
656
  item();
633
657
  });
634
658
  this.autorunDisposers = [];
@@ -653,7 +677,7 @@ class BaseComponent extends Component {
653
677
  if (!Array.isArray(handlers)) {
654
678
  handlers = [handlers]; // 统一处理,单个和数组情况
655
679
  }
656
- handlers.forEach((handler) => {
680
+ handlers.forEach(handler => {
657
681
  if (handler.context === this) {
658
682
  emitter.off(key, handler.fn, this); // 移除事件
659
683
  }
@@ -666,17 +690,17 @@ class BaseComponent extends Component {
666
690
  this.onEventListener();
667
691
  }
668
692
  /**子类继承该方法(全局事件(cat.event)注册在components上的事件可以不添加取消监听(自动取消监听了)) */
669
- onEventListener() { }
693
+ onEventListener() {}
670
694
  /**子类继承该方法 */
671
- addListener() { }
695
+ addListener() {}
672
696
  /**子类继承该方法 */
673
- removeListener() { }
697
+ removeListener() {}
674
698
  /**
675
699
  * 添加到父节点
676
- * @param parent 父节点
677
- * @param option 参数
678
- * @returns 自身组件
679
- */
700
+ * @param parent 父节点
701
+ * @param option 参数
702
+ * @returns 自身组件
703
+ */
680
704
  addToParent(parent, options) {
681
705
  let _parent = parent instanceof Prefab ? instantiate(parent) : parent instanceof Component ? parent.node : parent;
682
706
  this.setOptions(options);
@@ -686,8 +710,7 @@ class BaseComponent extends Component {
686
710
  /**设置属性(覆盖原有属性) */
687
711
  setOptions(options) {
688
712
  // 使用类型断言来确保 options 的正确类型
689
- if (!options)
690
- return;
713
+ if (!options) return;
691
714
  // 如果 options 是 IUIOption<T> 类型,则可以安全地访问 props 属性
692
715
  for (let key in options) {
693
716
  switch (key) {
@@ -695,12 +718,12 @@ class BaseComponent extends Component {
695
718
  options.hook && (this.hook = options.hook);
696
719
  break;
697
720
  case 'props':
698
- if (options.props !== null && typeof options.props === "object") {
721
+ if (options.props !== null && typeof options.props === 'object') {
699
722
  this.props = options.props;
700
723
  }
701
724
  break;
702
725
  case 'data':
703
- if (options.data !== null && typeof options.data === "object") {
726
+ if (options.data !== null && typeof options.data === 'object') {
704
727
  this.data = options.data;
705
728
  }
706
729
  break;
@@ -714,8 +737,7 @@ class BaseComponent extends Component {
714
737
  }
715
738
  /**设置props属性(更新)*/
716
739
  setUpdateProps(props) {
717
- if (!this.props)
718
- debugger;
740
+ if (!this.props) debugger;
719
741
  props && Object.assign(this.props, props);
720
742
  return this;
721
743
  }
@@ -748,11 +770,9 @@ class BaseComponent extends Component {
748
770
  return this;
749
771
  }
750
772
  /**显示(同onEnable) */
751
- onShow() {
752
- }
773
+ onShow() {}
753
774
  /**隐藏(同onDisable) */
754
- onHide() {
755
- }
775
+ onHide() {}
756
776
  /**设置节点和子节点的层级 */
757
777
  setNodeAndChildrenLayer(layer) {
758
778
  setNodeAndChildrenLayer(this.node, layer);
@@ -761,7 +781,7 @@ class BaseComponent extends Component {
761
781
  }
762
782
  /**设置节点及子节点的层级 */
763
783
  const setNodeAndChildrenLayer = (node, layer) => {
764
- node.layer = (typeof layer === 'string' ? 2 ** Layers.nameToLayer(layer) : layer);
784
+ node.layer = typeof layer === 'string' ? 2 ** Layers.nameToLayer(layer) : layer;
765
785
  node?.children.forEach(item => {
766
786
  setNodeAndChildrenLayer(item, layer);
767
787
  });
@@ -812,40 +832,33 @@ class UILayer extends BaseComponent {
812
832
  // 从中间放大
813
833
  start = v3(0.01, 0.01, 0.01);
814
834
  end = v3(1, 1, 1);
815
- }
816
- else {
835
+ } else {
817
836
  if (direction == 'left') {
818
837
  start = v3(-this.screen.width, 0, 0);
819
- }
820
- else if (direction == 'right') {
838
+ } else if (direction == 'right') {
821
839
  start = v3(this.screen.width, 0, 0);
822
- }
823
- else if (direction == 'top') {
840
+ } else if (direction == 'top') {
824
841
  start = v3(0, this.screen.height, 0);
825
- }
826
- else {
842
+ } else {
827
843
  start = v3(0, -this.screen.height, 0);
828
844
  }
829
845
  end = v3(0, 0, 0);
830
846
  }
831
847
  await this.handle(direction, duration, start, end, isBounce);
832
- if (widget)
833
- widget.enabled = true;
848
+ if (widget) widget.enabled = true;
834
849
  }
835
850
  }
836
851
  /**隐藏动画 */
837
852
  async hideTween({ isMotion = true, direction, duration = 0.1 }) {
838
853
  direction = direction || this.lastEnterDirection;
839
854
  // 避免重复点击关闭
840
- if (this.isClosing)
841
- return;
855
+ if (this.isClosing) return;
842
856
  this.isClosing = true;
843
857
  // 停止当前动画
844
858
  tween(this.node).removeSelf();
845
859
  if (isMotion) {
846
860
  const widget = this.node.getComponent(Widget);
847
- if (widget)
848
- widget.enabled = false;
861
+ if (widget) widget.enabled = false;
849
862
  // 设置起始坐标
850
863
  // 起点坐标
851
864
  let start;
@@ -855,18 +868,14 @@ class UILayer extends BaseComponent {
855
868
  // 从中间缩小
856
869
  start = this.node.scale;
857
870
  end = v3(0, 0, 0);
858
- }
859
- else {
871
+ } else {
860
872
  if (direction == 'left') {
861
873
  end = v3(-this.screen.width, 0, 0);
862
- }
863
- else if (direction == 'right') {
874
+ } else if (direction == 'right') {
864
875
  end = v3(this.screen.width, 0, 0);
865
- }
866
- else if (direction == 'top') {
876
+ } else if (direction == 'top') {
867
877
  end = v3(0, this.screen.height, 0);
868
- }
869
- else {
878
+ } else {
870
879
  end = v3(0, -this.screen.height, 0);
871
880
  }
872
881
  start = this.node.getPosition();
@@ -879,8 +888,7 @@ class UILayer extends BaseComponent {
879
888
  if (direction == 'center') {
880
889
  // 从中间放大
881
890
  this.node.setScale(start);
882
- }
883
- else {
891
+ } else {
884
892
  this.node.setPosition(start);
885
893
  }
886
894
  await this.deftween(duration, { [direction == 'center' ? 'scale' : 'position']: end }, isBounce);
@@ -890,9 +898,9 @@ class UILayer extends BaseComponent {
890
898
  tween(this.node)
891
899
  .to(duration, props)
892
900
  .call(() => {
893
- // tween_node.removeSelf();
894
- resolve();
895
- })
901
+ // tween_node.removeSelf();
902
+ resolve();
903
+ })
896
904
  .start();
897
905
  // if (options.isBounce) {
898
906
  // this.node.scale = start;
@@ -909,10 +917,10 @@ class UILayer extends BaseComponent {
909
917
  }
910
918
 
911
919
  /**
912
- * @describe 音频组件基类
913
- * @author 游金宇(KM)
914
- * @date 2023-12-22 16:20:20
915
- */
920
+ * @describe 音频组件基类
921
+ * @author 游金宇(KM)
922
+ * @date 2023-12-22 16:20:20
923
+ */
916
924
  const { ccclass: ccclass$9, property: property$9 } = _decorator;
917
925
  /**
918
926
  * EFFECT 音效
@@ -920,8 +928,8 @@ const { ccclass: ccclass$9, property: property$9 } = _decorator;
920
928
  */
921
929
  var AudioTypeEnum;
922
930
  (function (AudioTypeEnum) {
923
- AudioTypeEnum[AudioTypeEnum["EFFECT"] = 0] = "EFFECT";
924
- AudioTypeEnum[AudioTypeEnum["BGM"] = 1] = "BGM";
931
+ AudioTypeEnum[(AudioTypeEnum['EFFECT'] = 0)] = 'EFFECT';
932
+ AudioTypeEnum[(AudioTypeEnum['BGM'] = 1)] = 'BGM';
925
933
  })(AudioTypeEnum || (AudioTypeEnum = {}));
926
934
  class AudioSourceBaseComponent extends BaseComponent {
927
935
  type = AudioTypeEnum.EFFECT;
@@ -936,7 +944,8 @@ class AudioSourceBaseComponent extends BaseComponent {
936
944
  this.audioSource.loop = this.loop;
937
945
  this.audioSource.volume = this.volume;
938
946
  this.audioSource.playOnAwake = this.playOnAwake;
939
- cat.event.on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
947
+ cat.event
948
+ .on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
940
949
  .on(AudioEventConstant.EFFECT_OFF, this.onStopEffectHandler, this)
941
950
  .on(AudioEventConstant.MUSIC_ON, this.onPlayMusicHandler, this)
942
951
  .on(AudioEventConstant.MUSIC_OFF, this.onStopMusicHandler, this);
@@ -946,23 +955,20 @@ class AudioSourceBaseComponent extends BaseComponent {
946
955
  const { volumeEffect, volumeMusic } = cat.audio;
947
956
  this.audioSource.volume = this.type === AudioTypeEnum.BGM ? volumeMusic : volumeEffect;
948
957
  }
949
- start() { }
958
+ start() {}
950
959
  stopAudio() {
951
960
  this.audioSource.stop();
952
961
  }
953
962
  playAudio() {
954
963
  const { switchEffect, switchMusic } = cat.audio;
955
964
  // @ts-ignore 保证在游戏运行的时候才播放
956
- if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused)
957
- this.audioSource.play();
958
- }
959
- onPlayEffectHandler() {
965
+ if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused) this.audioSource.play();
960
966
  }
967
+ onPlayEffectHandler() {}
961
968
  onStopEffectHandler() {
962
969
  this.stopAudio();
963
970
  }
964
- onPlayMusicHandler() {
965
- }
971
+ onPlayMusicHandler() {}
966
972
  onStopMusicHandler() {
967
973
  this.stopAudio();
968
974
  }
@@ -971,31 +977,24 @@ class AudioSourceBaseComponent extends BaseComponent {
971
977
  super._onPreDestroy();
972
978
  }
973
979
  }
974
- __decorate([
975
- property$9({
976
- tooltip: `类型:
977
- EFFECT 音效
980
+ __decorate(
981
+ [
982
+ property$9({
983
+ tooltip: `类型:
984
+ EFFECT 音效
978
985
  BGM 音乐`,
979
- type: Enum(AudioTypeEnum)
980
- }),
981
- __metadata("design:type", Object)
982
- ], AudioSourceBaseComponent.prototype, "type", void 0);
983
- __decorate([
984
- property$9({ tooltip: '音源', type: AudioClip }),
985
- __metadata("design:type", Object)
986
- ], AudioSourceBaseComponent.prototype, "clip", void 0);
987
- __decorate([
988
- property$9({ tooltip: '循环' }),
989
- __metadata("design:type", Object)
990
- ], AudioSourceBaseComponent.prototype, "loop", void 0);
991
- __decorate([
992
- property$9({ tooltip: '音量' }),
993
- __metadata("design:type", Object)
994
- ], AudioSourceBaseComponent.prototype, "volume", void 0);
995
- __decorate([
996
- property$9({ tooltip: '是否启用自动播放' }),
997
- __metadata("design:type", Object)
998
- ], AudioSourceBaseComponent.prototype, "playOnAwake", void 0);
986
+ type: Enum(AudioTypeEnum),
987
+ }),
988
+ __metadata('design:type', Object),
989
+ ],
990
+ AudioSourceBaseComponent.prototype,
991
+ 'type',
992
+ void 0
993
+ );
994
+ __decorate([property$9({ tooltip: '音源', type: AudioClip }), __metadata('design:type', Object)], AudioSourceBaseComponent.prototype, 'clip', void 0);
995
+ __decorate([property$9({ tooltip: '循环' }), __metadata('design:type', Object)], AudioSourceBaseComponent.prototype, 'loop', void 0);
996
+ __decorate([property$9({ tooltip: '音量' }), __metadata('design:type', Object)], AudioSourceBaseComponent.prototype, 'volume', void 0);
997
+ __decorate([property$9({ tooltip: '是否启用自动播放' }), __metadata('design:type', Object)], AudioSourceBaseComponent.prototype, 'playOnAwake', void 0);
999
998
 
1000
999
  const { ccclass: ccclass$8, property: property$8 } = _decorator;
1001
1000
  /**带有音频通道的UIlayer组件 */
@@ -1008,7 +1007,8 @@ class AudioSourceUILayer extends UILayer {
1008
1007
  audioSource = new AudioSource();
1009
1008
  onEnable() {
1010
1009
  super.onEnable();
1011
- cat.event.on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
1010
+ cat.event
1011
+ .on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
1012
1012
  .on(AudioEventConstant.EFFECT_OFF, this.onStopEffectHandler, this)
1013
1013
  .on(AudioEventConstant.MUSIC_ON, this.onPlayMusicHandler, this)
1014
1014
  .on(AudioEventConstant.MUSIC_OFF, this.onStopMusicHandler, this);
@@ -1028,16 +1028,13 @@ class AudioSourceUILayer extends UILayer {
1028
1028
  playAudio() {
1029
1029
  const { switchEffect, switchMusic } = cat.audio;
1030
1030
  // @ts-ignore 保证在游戏运行的时候才播放
1031
- if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused)
1032
- this.audioSource.play();
1033
- }
1034
- onPlayEffectHandler() {
1031
+ if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused) this.audioSource.play();
1035
1032
  }
1033
+ onPlayEffectHandler() {}
1036
1034
  onStopEffectHandler() {
1037
1035
  this.stopAudio();
1038
1036
  }
1039
- onPlayMusicHandler() {
1040
- }
1037
+ onPlayMusicHandler() {}
1041
1038
  onStopMusicHandler() {
1042
1039
  this.stopAudio();
1043
1040
  }
@@ -1046,42 +1043,35 @@ class AudioSourceUILayer extends UILayer {
1046
1043
  super._onPreDestroy();
1047
1044
  }
1048
1045
  }
1049
- __decorate([
1050
- property$8({
1051
- tooltip: `类型:
1052
- EFFECT 音效
1046
+ __decorate(
1047
+ [
1048
+ property$8({
1049
+ tooltip: `类型:
1050
+ EFFECT 音效
1053
1051
  BGM 音乐`,
1054
- type: Enum(AudioTypeEnum)
1055
- }),
1056
- __metadata("design:type", Object)
1057
- ], AudioSourceUILayer.prototype, "type", void 0);
1058
- __decorate([
1059
- property$8({ tooltip: '音源', type: AudioClip }),
1060
- __metadata("design:type", Object)
1061
- ], AudioSourceUILayer.prototype, "clip", void 0);
1062
- __decorate([
1063
- property$8({ tooltip: '循环' }),
1064
- __metadata("design:type", Object)
1065
- ], AudioSourceUILayer.prototype, "loop", void 0);
1066
- __decorate([
1067
- property$8({ tooltip: '音量' }),
1068
- __metadata("design:type", Object)
1069
- ], AudioSourceUILayer.prototype, "volume", void 0);
1070
- __decorate([
1071
- property$8({ tooltip: '是否启用自动播放' }),
1072
- __metadata("design:type", Object)
1073
- ], AudioSourceUILayer.prototype, "playOnAwake", void 0);
1052
+ type: Enum(AudioTypeEnum),
1053
+ }),
1054
+ __metadata('design:type', Object),
1055
+ ],
1056
+ AudioSourceUILayer.prototype,
1057
+ 'type',
1058
+ void 0
1059
+ );
1060
+ __decorate([property$8({ tooltip: '音源', type: AudioClip }), __metadata('design:type', Object)], AudioSourceUILayer.prototype, 'clip', void 0);
1061
+ __decorate([property$8({ tooltip: '循环' }), __metadata('design:type', Object)], AudioSourceUILayer.prototype, 'loop', void 0);
1062
+ __decorate([property$8({ tooltip: '音量' }), __metadata('design:type', Object)], AudioSourceUILayer.prototype, 'volume', void 0);
1063
+ __decorate([property$8({ tooltip: '是否启用自动播放' }), __metadata('design:type', Object)], AudioSourceUILayer.prototype, 'playOnAwake', void 0);
1074
1064
 
1075
1065
  /**
1076
- * @describe TOAST弹窗组件
1077
- * @author 游金宇(KM)
1078
- * @date 2024-09-12 11:42:29
1079
- */
1066
+ * @describe TOAST弹窗组件
1067
+ * @author 游金宇(KM)
1068
+ * @date 2024-09-12 11:42:29
1069
+ */
1080
1070
  const { ccclass: ccclass$7, property: property$7, menu: menu$7 } = _decorator;
1081
1071
  var ToastType;
1082
1072
  (function (ToastType) {
1083
- ToastType[ToastType["FIXED"] = 0] = "FIXED";
1084
- ToastType[ToastType["SLIDE"] = 1] = "SLIDE";
1073
+ ToastType[(ToastType['FIXED'] = 0)] = 'FIXED';
1074
+ ToastType[(ToastType['SLIDE'] = 1)] = 'SLIDE';
1085
1075
  })(ToastType || (ToastType = {}));
1086
1076
  let CoreToast = class CoreToast extends BaseComponent {
1087
1077
  fixed_node;
@@ -1113,8 +1103,7 @@ let CoreToast = class CoreToast extends BaseComponent {
1113
1103
  this.node.destroy();
1114
1104
  resolve();
1115
1105
  }, fixed_time);
1116
- }
1117
- else {
1106
+ } else {
1118
1107
  this.slide_node.active = true;
1119
1108
  this.slide_label.string = `${title}`;
1120
1109
  // v2.4
@@ -1141,15 +1130,15 @@ let CoreToast = class CoreToast extends BaseComponent {
1141
1130
  .delay(delay)
1142
1131
  .to(duration, { opacity: 0 })
1143
1132
  .call(() => {
1144
- Tween.stopAllByTarget(node);
1145
- this.node.destroy();
1146
- resolve();
1147
- });
1133
+ Tween.stopAllByTarget(node);
1134
+ this.node.destroy();
1135
+ resolve();
1136
+ });
1148
1137
  tween(node)
1149
1138
  .by(duration, { position: v3(0, 400, 0) })
1150
1139
  .call(() => {
1151
- uiOpacityTween.start();
1152
- })
1140
+ uiOpacityTween.start();
1141
+ })
1153
1142
  .start();
1154
1143
  });
1155
1144
  }
@@ -1158,57 +1147,42 @@ let CoreToast = class CoreToast extends BaseComponent {
1158
1147
  this.unscheduleAllCallbacks();
1159
1148
  }
1160
1149
  };
1161
- __decorate([
1162
- property$7({ type: Node, tooltip: '固定节点' }),
1163
- __metadata("design:type", Node)
1164
- ], CoreToast.prototype, "fixed_node", void 0);
1165
- __decorate([
1166
- property$7({ type: Node, tooltip: '滑动节点' }),
1167
- __metadata("design:type", Node)
1168
- ], CoreToast.prototype, "slide_node", void 0);
1169
- __decorate([
1170
- property$7({ type: Label, tooltip: '固定标签节点' }),
1171
- __metadata("design:type", Label)
1172
- ], CoreToast.prototype, "fixed_label", void 0);
1173
- __decorate([
1174
- property$7({ type: Label, tooltip: '滑动标签节点' }),
1175
- __metadata("design:type", Label)
1176
- ], CoreToast.prototype, "slide_label", void 0);
1177
- CoreToast = __decorate([
1178
- ccclass$7('CoreToast'),
1179
- menu$7("CATCORE/CoreToast")
1180
- ], CoreToast);
1150
+ __decorate([property$7({ type: Node, tooltip: '固定节点' }), __metadata('design:type', Node)], CoreToast.prototype, 'fixed_node', void 0);
1151
+ __decorate([property$7({ type: Node, tooltip: '滑动节点' }), __metadata('design:type', Node)], CoreToast.prototype, 'slide_node', void 0);
1152
+ __decorate([property$7({ type: Label, tooltip: '固定标签节点' }), __metadata('design:type', Label)], CoreToast.prototype, 'fixed_label', void 0);
1153
+ __decorate([property$7({ type: Label, tooltip: '滑动标签节点' }), __metadata('design:type', Label)], CoreToast.prototype, 'slide_label', void 0);
1154
+ CoreToast = __decorate([ccclass$7('CoreToast'), menu$7('CATCORE/CoreToast')], CoreToast);
1181
1155
 
1182
1156
  /**
1183
- * @describe 全局事件监听方法
1184
- * @author 游金宇(KM)
1185
- * @date 2023-08-03 18:13:36
1186
- */
1157
+ * @describe 全局事件监听方法
1158
+ * @author 游金宇(KM)
1159
+ * @date 2023-08-03 18:13:36
1160
+ */
1187
1161
  var GlobalEventConstant;
1188
1162
  (function (GlobalEventConstant) {
1189
1163
  /** 游戏从后台进入 */
1190
- GlobalEventConstant["EVENT_SHOW"] = "GlobalEventConstant/EVENT_SHOW";
1164
+ GlobalEventConstant['EVENT_SHOW'] = 'GlobalEventConstant/EVENT_SHOW';
1191
1165
  /** 游戏切到后台 */
1192
- GlobalEventConstant["EVENT_HIDE"] = "GlobalEventConstant/EVENT_HIDE";
1166
+ GlobalEventConstant['EVENT_HIDE'] = 'GlobalEventConstant/EVENT_HIDE';
1193
1167
  /** 游戏画笔尺寸变化事件 */
1194
- GlobalEventConstant["GAME_RESIZE"] = "GlobalEventConstant/GAME_RESIZE";
1168
+ GlobalEventConstant['GAME_RESIZE'] = 'GlobalEventConstant/GAME_RESIZE';
1195
1169
  /**游戏关闭时间 */
1196
- GlobalEventConstant["EVENT_CLOSE"] = "GlobalEventConstant/EVENT_CLOSE";
1170
+ GlobalEventConstant['EVENT_CLOSE'] = 'GlobalEventConstant/EVENT_CLOSE';
1197
1171
  /**网络连接 */
1198
- GlobalEventConstant["ONLINE"] = "GlobalEventConstant/ONLINE";
1172
+ GlobalEventConstant['ONLINE'] = 'GlobalEventConstant/ONLINE';
1199
1173
  /**网络断开 */
1200
- GlobalEventConstant["OFFLINE"] = "GlobalEventConstant/OFFLINE";
1174
+ GlobalEventConstant['OFFLINE'] = 'GlobalEventConstant/OFFLINE';
1201
1175
  /**ROOT_MASK更新 */
1202
- GlobalEventConstant["ROOT_MASK_UPDATE"] = "GlobalEventConstant/ROOT_MASK_UPDATE";
1176
+ GlobalEventConstant['ROOT_MASK_UPDATE'] = 'GlobalEventConstant/ROOT_MASK_UPDATE';
1203
1177
  /**ROOT_MASK更新变化 */
1204
- GlobalEventConstant["ROOT_MASK_CHANGE"] = "GlobalEventConstant/ROOT_MASK_CHANGE";
1178
+ GlobalEventConstant['ROOT_MASK_CHANGE'] = 'GlobalEventConstant/ROOT_MASK_CHANGE';
1205
1179
  })(GlobalEventConstant || (GlobalEventConstant = {}));
1206
1180
 
1207
1181
  /**
1208
- * @describe UI容器管理 在场景节点下 会随着场景销毁(非常驻节点)
1209
- * @author 游金宇(KM)
1210
- * @date 2024-09-12 11:45:31
1211
- */
1182
+ * @describe UI容器管理 在场景节点下 会随着场景销毁(非常驻节点)
1183
+ * @author 游金宇(KM)
1184
+ * @date 2024-09-12 11:45:31
1185
+ */
1212
1186
  const { ccclass: ccclass$6, property: property$6, menu: menu$6 } = _decorator;
1213
1187
  let CoreUIContainer = class CoreUIContainer extends UILayer {
1214
1188
  scene_mask_node;
@@ -1242,7 +1216,7 @@ let CoreUIContainer = class CoreUIContainer extends UILayer {
1242
1216
  this.blockMaskSiblingIndexChanged();
1243
1217
  }
1244
1218
  blockMaskSiblingIndexChanged() {
1245
- (this.tweenChildren.length > 1 || this.brother.length > 1) ? this.show() : this.hide();
1219
+ this.tweenChildren.length > 1 || this.brother.length > 1 ? this.show() : this.hide();
1246
1220
  }
1247
1221
  /**
1248
1222
  * 将UI节点挂载在tween上执行动画
@@ -1272,18 +1246,9 @@ let CoreUIContainer = class CoreUIContainer extends UILayer {
1272
1246
  this.scene_mask.node.active = active;
1273
1247
  }
1274
1248
  };
1275
- __decorate([
1276
- property$6({ type: Node }),
1277
- __metadata("design:type", Node)
1278
- ], CoreUIContainer.prototype, "scene_mask_node", void 0);
1279
- __decorate([
1280
- property$6({ type: Node }),
1281
- __metadata("design:type", Node)
1282
- ], CoreUIContainer.prototype, "ui_container", void 0);
1283
- CoreUIContainer = __decorate([
1284
- ccclass$6('CoreUIContainer'),
1285
- menu$6("CATCORE/CoreUIContainer")
1286
- ], CoreUIContainer);
1249
+ __decorate([property$6({ type: Node }), __metadata('design:type', Node)], CoreUIContainer.prototype, 'scene_mask_node', void 0);
1250
+ __decorate([property$6({ type: Node }), __metadata('design:type', Node)], CoreUIContainer.prototype, 'ui_container', void 0);
1251
+ CoreUIContainer = __decorate([ccclass$6('CoreUIContainer'), menu$6('CATCORE/CoreUIContainer')], CoreUIContainer);
1287
1252
 
1288
1253
  /**
1289
1254
  * @describe 根级别的UI层 所有的ROOT UI层需继承自该自组件
@@ -1306,10 +1271,10 @@ class RootUILayer extends UILayer {
1306
1271
 
1307
1272
  const { ccclass: ccclass$5, property: property$5, menu: menu$5 } = _decorator;
1308
1273
  /**
1309
- * @describe 加载框
1310
- * @author 游金宇(KM)
1311
- * @date 2024-09-12 11:49:51
1312
- */
1274
+ * @describe 加载框
1275
+ * @author 游金宇(KM)
1276
+ * @date 2024-09-12 11:49:51
1277
+ */
1313
1278
  let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1314
1279
  title;
1315
1280
  loadingTween;
@@ -1322,11 +1287,11 @@ let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1322
1287
  if (this.props?.title) {
1323
1288
  this.title.string = `${this.props?.title}`;
1324
1289
  }
1325
- this.title.node.active = !!(this.props?.title?.length);
1290
+ this.title.node.active = !!this.props?.title?.length;
1326
1291
  },
1327
1292
  () => {
1328
- this.getComponent(BlockInputEvents).enabled = !!(this.props?.mask);
1329
- }
1293
+ this.getComponent(BlockInputEvents).enabled = !!this.props?.mask;
1294
+ },
1330
1295
  ]);
1331
1296
  }
1332
1297
  update(deltaTime) {
@@ -1337,46 +1302,47 @@ let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1337
1302
  }
1338
1303
  }
1339
1304
  };
1340
- __decorate([
1341
- property$5({ type: Label, tooltip: '标题' }),
1342
- __metadata("design:type", Label)
1343
- ], CoreShowLoading.prototype, "title", void 0);
1344
- __decorate([
1345
- property$5({ type: Node, tooltip: '动画' }),
1346
- __metadata("design:type", Node
1347
- // @property({ type: Node, tooltip: '遮罩' })
1348
- // black: Node
1349
- )
1350
- ], CoreShowLoading.prototype, "loadingTween", void 0);
1351
- CoreShowLoading = __decorate([
1352
- ccclass$5('CoreShowLoading'),
1353
- menu$5("CATCORE/CoreShowLoading")
1354
- ], CoreShowLoading);
1305
+ __decorate([property$5({ type: Label, tooltip: '标题' }), __metadata('design:type', Label)], CoreShowLoading.prototype, 'title', void 0);
1306
+ __decorate(
1307
+ [
1308
+ property$5({ type: Node, tooltip: '动画' }),
1309
+ __metadata(
1310
+ 'design:type',
1311
+ Node
1312
+ // @property({ type: Node, tooltip: '遮罩' })
1313
+ // black: Node
1314
+ ),
1315
+ ],
1316
+ CoreShowLoading.prototype,
1317
+ 'loadingTween',
1318
+ void 0
1319
+ );
1320
+ CoreShowLoading = __decorate([ccclass$5('CoreShowLoading'), menu$5('CATCORE/CoreShowLoading')], CoreShowLoading);
1355
1321
 
1356
1322
  const { ccclass: ccclass$4, property: property$4, menu: menu$4 } = _decorator;
1357
1323
  var ReconnectPrompt;
1358
1324
  (function (ReconnectPrompt) {
1359
- ReconnectPrompt["RECONNECTED"] = "\u91CD\u8FDE\u6210\u529F";
1360
- ReconnectPrompt["RECONNECTING"] = "\u6B63\u5728\u91CD\u8FDE";
1361
- ReconnectPrompt["MAX_RECONNECT"] = "\u91CD\u8FDE\u6B21\u6570\u8D85\u51FA\u9650\u5236,\u8BF7\u68C0\u67E5\u7F51\u7EDC";
1362
- ReconnectPrompt["RECONNECTED_ERROR"] = "\u91CD\u8FDE\u5931\u8D25,\u8BF7\u68C0\u67E5\u7F51\u7EDC";
1363
- ReconnectPrompt["CONNECT_PARAM_ERROR"] = "\u6E38\u620F\u53C2\u6570\u9519\u8BEF,\u8BF7\u91CD\u65B0\u52A0\u8F7D";
1364
- ReconnectPrompt["KICK"] = "\u8D26\u53F7\u5DF2\u4E0B\u7EBF";
1365
- ReconnectPrompt["OFFLINE"] = "\u7F51\u7EDC\u5DF2\u65AD\u5F00";
1366
- ReconnectPrompt["ONLINE"] = "\u7F51\u7EDC\u5DF2\u8FDE\u63A5";
1367
- ReconnectPrompt["GAME_ERROR"] = "\u8FDE\u63A5\u6E38\u620F\u670D\u9519\u8BEF";
1325
+ ReconnectPrompt['RECONNECTED'] = '\u91CD\u8FDE\u6210\u529F';
1326
+ ReconnectPrompt['RECONNECTING'] = '\u6B63\u5728\u91CD\u8FDE';
1327
+ ReconnectPrompt['MAX_RECONNECT'] = '\u91CD\u8FDE\u6B21\u6570\u8D85\u51FA\u9650\u5236,\u8BF7\u68C0\u67E5\u7F51\u7EDC';
1328
+ ReconnectPrompt['RECONNECTED_ERROR'] = '\u91CD\u8FDE\u5931\u8D25,\u8BF7\u68C0\u67E5\u7F51\u7EDC';
1329
+ ReconnectPrompt['CONNECT_PARAM_ERROR'] = '\u6E38\u620F\u53C2\u6570\u9519\u8BEF,\u8BF7\u91CD\u65B0\u52A0\u8F7D';
1330
+ ReconnectPrompt['KICK'] = '\u8D26\u53F7\u5DF2\u4E0B\u7EBF';
1331
+ ReconnectPrompt['OFFLINE'] = '\u7F51\u7EDC\u5DF2\u65AD\u5F00';
1332
+ ReconnectPrompt['ONLINE'] = '\u7F51\u7EDC\u5DF2\u8FDE\u63A5';
1333
+ ReconnectPrompt['GAME_ERROR'] = '\u8FDE\u63A5\u6E38\u620F\u670D\u9519\u8BEF';
1368
1334
  })(ReconnectPrompt || (ReconnectPrompt = {}));
1369
1335
  /**
1370
- * @describe 重连框
1371
- * @author 游金宇(KM)
1372
- * @date 2024-09-12 11:49:51
1373
- */
1336
+ * @describe 重连框
1337
+ * @author 游金宇(KM)
1338
+ * @date 2024-09-12 11:49:51
1339
+ */
1374
1340
  let CoreReconnection = class CoreReconnection extends RootUILayer {
1375
1341
  common_prompt_text;
1376
1342
  btn_confirm;
1377
1343
  is_close = false;
1378
1344
  props = {
1379
- content: null
1345
+ content: null,
1380
1346
  };
1381
1347
  initUI() {
1382
1348
  this.btn_confirm.node.active = false;
@@ -1386,7 +1352,7 @@ let CoreReconnection = class CoreReconnection extends RootUILayer {
1386
1352
  this.addAutorun([
1387
1353
  () => {
1388
1354
  this.common_prompt_text.string = this.props.content ?? '';
1389
- }
1355
+ },
1390
1356
  ]);
1391
1357
  }
1392
1358
  onDestroy() {
@@ -1420,25 +1386,16 @@ let CoreReconnection = class CoreReconnection extends RootUILayer {
1420
1386
  cat.gui.hideReconnect();
1421
1387
  }
1422
1388
  };
1423
- __decorate([
1424
- property$4({ type: Label, tooltip: '通用提示文本' }),
1425
- __metadata("design:type", Label)
1426
- ], CoreReconnection.prototype, "common_prompt_text", void 0);
1427
- __decorate([
1428
- property$4({ type: Button, tooltip: '确定按钮' }),
1429
- __metadata("design:type", Button)
1430
- ], CoreReconnection.prototype, "btn_confirm", void 0);
1431
- CoreReconnection = __decorate([
1432
- ccclass$4('CoreReconnection'),
1433
- menu$4("CATCORE/CoreReconnection")
1434
- ], CoreReconnection);
1389
+ __decorate([property$4({ type: Label, tooltip: '通用提示文本' }), __metadata('design:type', Label)], CoreReconnection.prototype, 'common_prompt_text', void 0);
1390
+ __decorate([property$4({ type: Button, tooltip: '确定按钮' }), __metadata('design:type', Button)], CoreReconnection.prototype, 'btn_confirm', void 0);
1391
+ CoreReconnection = __decorate([ccclass$4('CoreReconnection'), menu$4('CATCORE/CoreReconnection')], CoreReconnection);
1435
1392
 
1436
1393
  const { ccclass: ccclass$3, property: property$3, menu: menu$3 } = _decorator;
1437
1394
  /**
1438
- * @describe 通知框
1439
- * @author 游金宇(KM)
1440
- * @date 2024-09-12 11:49:51
1441
- */
1395
+ * @describe 通知框
1396
+ * @author 游金宇(KM)
1397
+ * @date 2024-09-12 11:49:51
1398
+ */
1442
1399
  let CoreNotice = class CoreNotice extends RootUILayer {
1443
1400
  text;
1444
1401
  btn_confirm;
@@ -1456,18 +1413,9 @@ let CoreNotice = class CoreNotice extends RootUILayer {
1456
1413
  this.text.string = `${props.text}`;
1457
1414
  }
1458
1415
  };
1459
- __decorate([
1460
- property$3({ type: Label, tooltip: '提示文本' }),
1461
- __metadata("design:type", Label)
1462
- ], CoreNotice.prototype, "text", void 0);
1463
- __decorate([
1464
- property$3({ type: Button, tooltip: '确定按钮' }),
1465
- __metadata("design:type", Button)
1466
- ], CoreNotice.prototype, "btn_confirm", void 0);
1467
- CoreNotice = __decorate([
1468
- ccclass$3('CoreNotice'),
1469
- menu$3("CATCORE/CoreNotice")
1470
- ], CoreNotice);
1416
+ __decorate([property$3({ type: Label, tooltip: '提示文本' }), __metadata('design:type', Label)], CoreNotice.prototype, 'text', void 0);
1417
+ __decorate([property$3({ type: Button, tooltip: '确定按钮' }), __metadata('design:type', Button)], CoreNotice.prototype, 'btn_confirm', void 0);
1418
+ CoreNotice = __decorate([ccclass$3('CoreNotice'), menu$3('CATCORE/CoreNotice')], CoreNotice);
1471
1419
 
1472
1420
  /**
1473
1421
  * @describe Scene层 所有的UI层需继承自该自组件
@@ -1480,22 +1428,22 @@ class SceneLayer extends BaseComponent {
1480
1428
  }
1481
1429
 
1482
1430
  /**
1483
- * @describe GUI组件类
1484
- * @author 游金宇(KM)
1485
- * @date 2024-09-12 11:46:22
1486
- */
1431
+ * @describe GUI组件类
1432
+ * @author 游金宇(KM)
1433
+ * @date 2024-09-12 11:46:22
1434
+ */
1487
1435
  const { ccclass: ccclass$2, property: property$2, menu: menu$2 } = _decorator;
1488
1436
  var LayerType;
1489
1437
  (function (LayerType) {
1490
- LayerType[LayerType["UI"] = 0] = "UI";
1438
+ LayerType[(LayerType['UI'] = 0)] = 'UI';
1491
1439
  /**加载 */
1492
- LayerType[LayerType["LOADING"] = 1] = "LOADING";
1440
+ LayerType[(LayerType['LOADING'] = 1)] = 'LOADING';
1493
1441
  /**提示 */
1494
- LayerType[LayerType["TOAST"] = 2] = "TOAST";
1442
+ LayerType[(LayerType['TOAST'] = 2)] = 'TOAST';
1495
1443
  /**断线重连 */
1496
- LayerType[LayerType["RECONNECTTION"] = 3] = "RECONNECTTION";
1444
+ LayerType[(LayerType['RECONNECTTION'] = 3)] = 'RECONNECTTION';
1497
1445
  /**系统服务通知(停机维护) */
1498
- LayerType[LayerType["NOTICE"] = 4] = "NOTICE";
1446
+ LayerType[(LayerType['NOTICE'] = 4)] = 'NOTICE';
1499
1447
  })(LayerType || (LayerType = {}));
1500
1448
  /**Gui层 */
1501
1449
  let Gui = class Gui extends BaseComponent {
@@ -1562,8 +1510,7 @@ let Gui = class Gui extends BaseComponent {
1562
1510
  // 立即显示第一个
1563
1511
  if (this.root_toast.children.length === 0) {
1564
1512
  show();
1565
- }
1566
- else {
1513
+ } else {
1567
1514
  this.scheduleOnce(show, this.minInterval);
1568
1515
  }
1569
1516
  }
@@ -1590,18 +1537,17 @@ let Gui = class Gui extends BaseComponent {
1590
1537
  props: {
1591
1538
  title,
1592
1539
  mask,
1593
- black
1594
- }
1540
+ black,
1541
+ },
1595
1542
  });
1596
- }
1597
- else {
1543
+ } else {
1598
1544
  const node = instantiate(this.loading_ui_prefab);
1599
1545
  this.loading_ui_component = node.getComponent(CoreShowLoading).addToParent(this.root_ui, {
1600
1546
  props: {
1601
1547
  title,
1602
1548
  mask,
1603
- black
1604
- }
1549
+ black,
1550
+ },
1605
1551
  });
1606
1552
  }
1607
1553
  return this;
@@ -1621,13 +1567,12 @@ let Gui = class Gui extends BaseComponent {
1621
1567
  const node = instantiate(this.reconnection_ui_prefab);
1622
1568
  this.reconnection_ui_component = node.getComponent(CoreReconnection).addToParent(this.root_ui, {
1623
1569
  props: {
1624
- content: option
1625
- }
1570
+ content: option,
1571
+ },
1626
1572
  });
1627
- }
1628
- else {
1573
+ } else {
1629
1574
  this.reconnection_ui_component.setUpdateProps({
1630
- content: option
1575
+ content: option,
1631
1576
  });
1632
1577
  }
1633
1578
  return this;
@@ -1659,12 +1604,11 @@ let Gui = class Gui extends BaseComponent {
1659
1604
  let _isReload = isReload ?? false;
1660
1605
  if (typeof options === 'boolean') {
1661
1606
  _isReload = options;
1662
- }
1663
- else {
1607
+ } else {
1664
1608
  _options = options ?? {};
1665
1609
  }
1666
1610
  log('当前场景', director.getScene()?.uuid, director.getScene()?.name);
1667
- director.once(Director.EVENT_BEFORE_SCENE_LAUNCH, (scene) => {
1611
+ director.once(Director.EVENT_BEFORE_SCENE_LAUNCH, scene => {
1668
1612
  log('Director.EVENT_BEFORE_SCENE_LAUNCH', scene);
1669
1613
  this.changeScene(scene, _options, _isReload);
1670
1614
  });
@@ -1683,10 +1627,10 @@ let Gui = class Gui extends BaseComponent {
1683
1627
  }
1684
1628
  /**
1685
1629
  * 场景变化
1686
- * @param scene 场景
1687
- * @param options 选项
1688
- * @param isReload 是否重新加载
1689
- */
1630
+ * @param scene 场景
1631
+ * @param options 选项
1632
+ * @param isReload 是否重新加载
1633
+ */
1690
1634
  changeScene(scene, options, isReload) {
1691
1635
  this.currentScene = scene.name;
1692
1636
  // 获取当前场景
@@ -1728,7 +1672,7 @@ let Gui = class Gui extends BaseComponent {
1728
1672
  if (component) {
1729
1673
  component.setOptions({
1730
1674
  ...(options?.hook ?? {}),
1731
- ...(options?.props ?? {})
1675
+ ...(options?.props ?? {}),
1732
1676
  });
1733
1677
  // 调用uiNode组件下的showTween方法
1734
1678
  await component.hideTween(options || {});
@@ -1769,22 +1713,19 @@ let Gui = class Gui extends BaseComponent {
1769
1713
  rootNode = ui;
1770
1714
  // 获取组件
1771
1715
  const extendsBaseLayer = ui.components.filter(item => {
1772
- return (item instanceof UILayer);
1716
+ return item instanceof UILayer;
1773
1717
  });
1774
1718
  if (extendsBaseLayer.length) {
1775
1719
  if (extendsBaseLayer.length == 1) {
1776
1720
  component = extendsBaseLayer[0];
1777
- }
1778
- else {
1721
+ } else {
1779
1722
  warn(`${ui.name}节点存在多个继承自BaseLayer的组件`);
1780
1723
  }
1781
- }
1782
- else {
1724
+ } else {
1783
1725
  error(`${ui.name}节点未找到继承自BaseLayer的组件`);
1784
1726
  return { rootNode, component };
1785
1727
  }
1786
- }
1787
- else {
1728
+ } else {
1788
1729
  // ui为T组件
1789
1730
  // 定义一个变量用于保存根节点
1790
1731
  rootNode = ui.node;
@@ -1795,8 +1736,7 @@ let Gui = class Gui extends BaseComponent {
1795
1736
  rootNode = rootNode.parent;
1796
1737
  }
1797
1738
  component.root = rootNode;
1798
- }
1799
- else {
1739
+ } else {
1800
1740
  rootNode = ui.root;
1801
1741
  }
1802
1742
  }
@@ -1818,71 +1758,38 @@ let Gui = class Gui extends BaseComponent {
1818
1758
  this.cat.event.emit(GlobalEventConstant.ROOT_MASK_CHANGE);
1819
1759
  }
1820
1760
  };
1821
- __decorate([
1822
- property$2({ type: Prefab, tooltip: '断线重连UI预制体' }),
1823
- __metadata("design:type", Prefab)
1824
- ], Gui.prototype, "reconnection_ui_prefab", void 0);
1825
- __decorate([
1826
- property$2({ type: Prefab, tooltip: '提示UI预制体' }),
1827
- __metadata("design:type", Prefab)
1828
- ], Gui.prototype, "toast_ui_prefab", void 0);
1829
- __decorate([
1830
- property$2({ type: Prefab, tooltip: '加载UI预制体' }),
1831
- __metadata("design:type", Prefab)
1832
- ], Gui.prototype, "loading_ui_prefab", void 0);
1833
- __decorate([
1834
- property$2({ type: Prefab, tooltip: '公告UI预制体' }),
1835
- __metadata("design:type", Prefab)
1836
- ], Gui.prototype, "notice_ui_prefab", void 0);
1837
- __decorate([
1838
- property$2({ type: Prefab, tooltip: 'UI层预制体' }),
1839
- __metadata("design:type", Prefab)
1840
- ], Gui.prototype, "ui_prefab", void 0);
1841
- __decorate([
1842
- property$2({ type: Node, tooltip: 'root-UI层' }),
1843
- __metadata("design:type", Node)
1844
- ], Gui.prototype, "root_ui", void 0);
1845
- __decorate([
1846
- property$2({ type: Node, tooltip: 'root-组件层' }),
1847
- __metadata("design:type", Node)
1848
- ], Gui.prototype, "root_toast", void 0);
1849
- __decorate([
1850
- property$2({ type: Node, tooltip: 'root-mask' }),
1851
- __metadata("design:type", Node)
1852
- ], Gui.prototype, "root_mask", void 0);
1853
- Gui = __decorate([
1854
- ccclass$2('Gui'),
1855
- menu$2("CATCORE/Gui")
1856
- ], Gui);
1761
+ __decorate([property$2({ type: Prefab, tooltip: '断线重连UI预制体' }), __metadata('design:type', Prefab)], Gui.prototype, 'reconnection_ui_prefab', void 0);
1762
+ __decorate([property$2({ type: Prefab, tooltip: '提示UI预制体' }), __metadata('design:type', Prefab)], Gui.prototype, 'toast_ui_prefab', void 0);
1763
+ __decorate([property$2({ type: Prefab, tooltip: '加载UI预制体' }), __metadata('design:type', Prefab)], Gui.prototype, 'loading_ui_prefab', void 0);
1764
+ __decorate([property$2({ type: Prefab, tooltip: '公告UI预制体' }), __metadata('design:type', Prefab)], Gui.prototype, 'notice_ui_prefab', void 0);
1765
+ __decorate([property$2({ type: Prefab, tooltip: 'UI层预制体' }), __metadata('design:type', Prefab)], Gui.prototype, 'ui_prefab', void 0);
1766
+ __decorate([property$2({ type: Node, tooltip: 'root-UI' }), __metadata('design:type', Node)], Gui.prototype, 'root_ui', void 0);
1767
+ __decorate([property$2({ type: Node, tooltip: 'root-组件层' }), __metadata('design:type', Node)], Gui.prototype, 'root_toast', void 0);
1768
+ __decorate([property$2({ type: Node, tooltip: 'root-mask' }), __metadata('design:type', Node)], Gui.prototype, 'root_mask', void 0);
1769
+ Gui = __decorate([ccclass$2('Gui'), menu$2('CATCORE/Gui')], Gui);
1857
1770
 
1858
1771
  /**遮罩管理 TODO (每个层级都有一个遮罩 但是同时只能出现1个) */
1859
1772
  const { ccclass: ccclass$1, property: property$1, menu: menu$1 } = _decorator;
1860
1773
  let CoreBlackMask = class CoreBlackMask extends BaseComponent {
1861
1774
  tween;
1862
1775
  };
1863
- __decorate([
1864
- property$1({ type: Node, tooltip: '动画节点' }),
1865
- __metadata("design:type", Node)
1866
- ], CoreBlackMask.prototype, "tween", void 0);
1867
- CoreBlackMask = __decorate([
1868
- ccclass$1('CoreBlackMask'),
1869
- menu$1("CATCORE/CoreBlackMask")
1870
- ], CoreBlackMask);
1776
+ __decorate([property$1({ type: Node, tooltip: '动画节点' }), __metadata('design:type', Node)], CoreBlackMask.prototype, 'tween', void 0);
1777
+ CoreBlackMask = __decorate([ccclass$1('CoreBlackMask'), menu$1('CATCORE/CoreBlackMask')], CoreBlackMask);
1871
1778
 
1872
1779
  /**
1873
- * @describe 层级界面管理
1874
- * @author 游金宇(KM)
1875
- * @date 2023-08-03 20:02:45
1876
- */
1780
+ * @describe 层级界面管理
1781
+ * @author 游金宇(KM)
1782
+ * @date 2023-08-03 20:02:45
1783
+ */
1877
1784
  /**预制体路径 */
1878
1785
  var BasePrefab;
1879
1786
  (function (BasePrefab) {
1880
- BasePrefab["Root"] = "prefabs/root";
1881
- BasePrefab["Toast"] = "prefabs/toast";
1882
- BasePrefab["BlackMask"] = "prefabs/black-mask";
1883
- BasePrefab["Loading"] = "prefabs/loading";
1884
- BasePrefab["Notice"] = "prefabs/notice";
1885
- BasePrefab["Reconnection"] = "prefabs/reconnection";
1787
+ BasePrefab['Root'] = 'prefabs/root';
1788
+ BasePrefab['Toast'] = 'prefabs/toast';
1789
+ BasePrefab['BlackMask'] = 'prefabs/black-mask';
1790
+ BasePrefab['Loading'] = 'prefabs/loading';
1791
+ BasePrefab['Notice'] = 'prefabs/notice';
1792
+ BasePrefab['Reconnection'] = 'prefabs/reconnection';
1886
1793
  })(BasePrefab || (BasePrefab = {}));
1887
1794
  class GuiManager extends BaseManager {
1888
1795
  /**常驻顶层UI节点层级 */
@@ -1899,8 +1806,7 @@ class GuiManager extends BaseManager {
1899
1806
  this.cat.res.load(bundleName, type, (err, prefab) => {
1900
1807
  if (err) {
1901
1808
  reject(err);
1902
- }
1903
- else {
1809
+ } else {
1904
1810
  resolve(prefab);
1905
1811
  }
1906
1812
  });
@@ -1920,10 +1826,10 @@ class GuiManager extends BaseManager {
1920
1826
  }
1921
1827
 
1922
1828
  /**
1923
- * @describe 游戏资管理
1924
- * @author 游金宇(KM)
1925
- * @date 2023-08-03 17:40:51
1926
- */
1829
+ * @describe 游戏资管理
1830
+ * @author 游金宇(KM)
1831
+ * @date 2023-08-03 17:40:51
1832
+ */
1927
1833
  class ResLoader {
1928
1834
  /**
1929
1835
  * 获取资源
@@ -1938,7 +1844,7 @@ class ResLoader {
1938
1844
  /**
1939
1845
  * 获取资源类型
1940
1846
  */
1941
- isAssetType = (value) => {
1847
+ isAssetType = value => {
1942
1848
  return typeof value === 'function' && value.prototype instanceof Asset;
1943
1849
  };
1944
1850
  async load(...args) {
@@ -1975,11 +1881,9 @@ class ResLoader {
1975
1881
  }
1976
1882
  if (onProgress && onComplete) {
1977
1883
  nonce.load(paths, type, onProgress, onComplete);
1978
- }
1979
- else if (onComplete) {
1884
+ } else if (onComplete) {
1980
1885
  nonce.load(paths, type, onComplete);
1981
- }
1982
- else {
1886
+ } else {
1983
1887
  nonce.load(paths, type);
1984
1888
  }
1985
1889
  }
@@ -2014,11 +1918,9 @@ class ResLoader {
2014
1918
  }
2015
1919
  if (onProgress && onComplete) {
2016
1920
  nonce.loadDir(paths, type, onProgress, onComplete);
2017
- }
2018
- else if (onComplete) {
1921
+ } else if (onComplete) {
2019
1922
  nonce.loadDir(paths, type, onComplete);
2020
- }
2021
- else {
1923
+ } else {
2022
1924
  nonce.loadDir(paths, type);
2023
1925
  }
2024
1926
  }
@@ -2029,7 +1931,7 @@ class ResLoader {
2029
1931
  options = args.shift();
2030
1932
  }
2031
1933
  onComplete = args.shift();
2032
- assetManager.loadRemote(url, { ext: ".png", ...options }, onComplete);
1934
+ assetManager.loadRemote(url, { ext: '.png', ...options }, onComplete);
2033
1935
  }
2034
1936
  /**
2035
1937
  * 加载bundle
@@ -2046,13 +1948,11 @@ class ResLoader {
2046
1948
  }
2047
1949
  resolve(bundle);
2048
1950
  };
2049
- version ?
2050
- assetManager.loadBundle(url, { version }, onComplete) :
2051
- assetManager.loadBundle(url, onComplete);
1951
+ version ? assetManager.loadBundle(url, { version }, onComplete) : assetManager.loadBundle(url, onComplete);
2052
1952
  });
2053
1953
  };
2054
1954
  /** 释放预制依赖资源 */
2055
- releasePrefabtDepsRecursively = (uuid) => {
1955
+ releasePrefabtDepsRecursively = uuid => {
2056
1956
  var asset = assetManager.assets.get(uuid);
2057
1957
  assetManager.releaseAsset(asset);
2058
1958
  if (asset instanceof Prefab) {
@@ -2111,7 +2011,7 @@ let _iv = null;
2111
2011
  * MD5加密
2112
2012
  * @param msg 加密信息
2113
2013
  */
2114
- const md5 = (msg) => {
2014
+ const md5 = msg => {
2115
2015
  return CryptoES.MD5(msg).toString();
2116
2016
  };
2117
2017
  /** 初始化加密库 */
@@ -2144,7 +2044,7 @@ const aesDecrypt = (str, key, iv) => {
2144
2044
  return decrypted.toString(CryptoES.enc.Utf8);
2145
2045
  };
2146
2046
  const JsonFormatter = {
2147
- stringify: (cipherParams) => {
2047
+ stringify: cipherParams => {
2148
2048
  const jsonObj = { ct: cipherParams.ciphertext.toString(CryptoES.enc.Base64) };
2149
2049
  if (cipherParams.iv) {
2150
2050
  jsonObj.iv = cipherParams.iv.toString();
@@ -2154,7 +2054,7 @@ const JsonFormatter = {
2154
2054
  }
2155
2055
  return JSON.stringify(jsonObj);
2156
2056
  },
2157
- parse: (jsonStr) => {
2057
+ parse: jsonStr => {
2158
2058
  const jsonObj = JSON.parse(jsonStr);
2159
2059
  const cipherParams = CryptoES.lib.CipherParams.create({ ciphertext: CryptoES.enc.Base64.parse(jsonObj.ct) });
2160
2060
  if (jsonObj.iv) {
@@ -2167,34 +2067,34 @@ const JsonFormatter = {
2167
2067
  },
2168
2068
  };
2169
2069
 
2170
- var EncryptUtil = /*#__PURE__*/Object.freeze({
2070
+ var EncryptUtil = /*#__PURE__*/ Object.freeze({
2171
2071
  __proto__: null,
2172
2072
  JsonFormatter: JsonFormatter,
2173
2073
  aesDecrypt: aesDecrypt,
2174
2074
  aesEncrypt: aesEncrypt,
2175
2075
  initCrypto: initCrypto,
2176
- md5: md5
2076
+ md5: md5,
2177
2077
  });
2178
2078
 
2179
2079
  /**
2180
- * @describe 工具类
2181
- * @author 游金宇(KM)
2182
- * @date 2023-08-02 20:16:42
2183
- */
2080
+ * @describe 工具类
2081
+ * @author 游金宇(KM)
2082
+ * @date 2023-08-02 20:16:42
2083
+ */
2184
2084
  // 扩展 Manager 接口,添加 Util 属性
2185
2085
  class CoreUtil extends BaseManager {
2186
2086
  encryptUtil = EncryptUtil;
2187
2087
  }
2188
2088
 
2189
2089
  /**
2190
- * @describe 基于社交游戏封装的游戏基础ws类
2191
- * @author 游金宇(KM)
2192
- * @date 2024-09-12 11:47:51
2193
- */
2090
+ * @describe 基于社交游戏封装的游戏基础ws类
2091
+ * @author 游金宇(KM)
2092
+ * @date 2024-09-12 11:47:51
2093
+ */
2194
2094
  class WrapperSocialGameClient extends SocialGameClient {
2195
2095
  /**日志黑名单 */
2196
2096
  logBlackList = [];
2197
- ignore = (item) => {
2097
+ ignore = item => {
2198
2098
  return this.logBlackList.includes(item);
2199
2099
  };
2200
2100
  constructor(name, opts, eventResponsePairs, clientOption) {
@@ -2294,7 +2194,7 @@ class WrapperSocialGameClient extends SocialGameClient {
2294
2194
  // this.handleEvent({ type: 'reconnect' })
2295
2195
  // break;
2296
2196
  // case 'offline'://离线状态
2297
- // // 为了彻底清除上一次的ws(避免有重新连接已发起 但是没完成 导致下次重连时 可能重复重连) 需要将上一次的ws状态清理
2197
+ // // 为了彻底清除上一次的ws(避免有重新连接已发起 但是没完成 导致下次重连时 可能重复重连) 需要将上一次的ws状态清理
2298
2198
  // this.disconnect(true)
2299
2199
  // log('离线状态 offline');
2300
2200
  // this.isNeedReconnect = true;
@@ -2347,21 +2247,37 @@ class WrapperSocialGameClient extends SocialGameClient {
2347
2247
  // }
2348
2248
  async GameRequest(route, reqReflect, resp, audOptions) {
2349
2249
  return new Promise((resolve, reject) => {
2350
- super.GameRequest(route, reqReflect, resp, audOptions).then((res) => {
2351
- if (DEBUG) {
2352
- log(`%c ws服务端消息 %c [Response][${new Date()}] %c ${route} %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', clone(resp, res));
2250
+ super.GameRequest(route, reqReflect, resp, audOptions).then(
2251
+ res => {
2252
+ if (DEBUG) {
2253
+ log(
2254
+ `%c ws服务端消息 %c [Response][${new Date()}] %c ${route} %c`,
2255
+ 'background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
2256
+ 'background:#3d7daa ; padding: 1px; color: #fff',
2257
+ 'background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff',
2258
+ 'background:transparent',
2259
+ clone(resp, res)
2260
+ );
2261
+ }
2262
+ resolve(res);
2263
+ },
2264
+ err => {
2265
+ cat.gui.showToast({ title: err.msg });
2266
+ reject(err);
2353
2267
  }
2354
- resolve(res);
2355
- }, (err) => {
2356
- cat.gui.showToast({ title: err.msg });
2357
- reject(err);
2358
- });
2268
+ );
2359
2269
  });
2360
2270
  }
2361
2271
  subscribe(route, respType, fn) {
2362
- super.subscribe(route, respType, (data) => {
2272
+ super.subscribe(route, respType, data => {
2363
2273
  if (DEBUG && !this.ignore(route)) {
2364
- log(`%c ws服务端消息:[${new Date()}] %c ${route} %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', clone(respType, data));
2274
+ log(
2275
+ `%c ws服务端消息:[${new Date()}] %c ${route} %c`,
2276
+ 'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
2277
+ 'background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff',
2278
+ 'background:transparent',
2279
+ clone(respType, data)
2280
+ );
2365
2281
  }
2366
2282
  cat.event.emit(route, clone(respType, data));
2367
2283
  fn?.(data);
@@ -2384,12 +2300,12 @@ class SocialGameClientManager extends BaseManager {
2384
2300
  this.initGlobalListeners();
2385
2301
  }
2386
2302
  /**
2387
- * 创建并注册WebSocket客户端
2388
- * @param name 客户端唯一标识(如"game", "room")
2389
- * @param clientOption 客户端配置选项
2390
- * @param opts 社交游戏选项
2391
- * @param eventResponsePairs 事件响应配置
2392
- */
2303
+ * 创建并注册WebSocket客户端
2304
+ * @param name 客户端唯一标识(如"game", "room")
2305
+ * @param clientOption 客户端配置选项
2306
+ * @param opts 社交游戏选项
2307
+ * @param eventResponsePairs 事件响应配置
2308
+ */
2393
2309
  createWebSocket(name, clientOption, opts, eventResponsePairs) {
2394
2310
  // 清理同名旧客户端
2395
2311
  if (this.managedClients.has(name)) {
@@ -2399,12 +2315,19 @@ class SocialGameClientManager extends BaseManager {
2399
2315
  log(`清理旧的 ${name} 客户端`);
2400
2316
  }
2401
2317
  // 创建客户端实例
2402
- const client = new WrapperSocialGameClient(name, // 将名称注入配置
2403
- opts, eventResponsePairs, Object.assign({ reconnectMaxAttempts: Infinity }, {
2404
- ...clientOption,
2405
- // 强制关闭自动重连,由管理器统一控制
2406
- isAutoConnect: false
2407
- }));
2318
+ const client = new WrapperSocialGameClient(
2319
+ name, // 将名称注入配置
2320
+ opts,
2321
+ eventResponsePairs,
2322
+ Object.assign(
2323
+ { reconnectMaxAttempts: Infinity },
2324
+ {
2325
+ ...clientOption,
2326
+ // 强制关闭自动重连,由管理器统一控制
2327
+ isAutoConnect: false,
2328
+ }
2329
+ )
2330
+ );
2408
2331
  // 注册并返回
2409
2332
  this.register(client);
2410
2333
  return client;
@@ -2450,38 +2373,40 @@ class SocialGameClientManager extends BaseManager {
2450
2373
  }
2451
2374
  // 统一触发所有WS重连
2452
2375
  async triggerReconnectAll() {
2453
- if (!this.isGlobalOnline || this.isInBackground)
2454
- return;
2376
+ if (!this.isGlobalOnline || this.isInBackground) return;
2455
2377
  // 如果没有任何客户端需要重连,直接返回
2456
2378
  if (this.managedClients.size === 0) {
2457
- log("没有任何WS需要重连");
2379
+ log('没有任何WS需要重连');
2458
2380
  return;
2459
2381
  }
2460
2382
  cat.gui.showLoading({ title: '正在重连' });
2461
- await Promise.allSettled(this.activeClients.map(async (client) => {
2462
- try {
2463
- // 1. 等待物理层重连
2464
- await client.reconnectPromise();
2465
- }
2466
- catch (err) {
2467
- error(`${client.name}服重连失败`, err);
2468
- cat.gui.showToast({ title: `${client.name}服重连失败` });
2469
- // 不抛出错误,让 Promise.allSettled 收集结果
2470
- }
2471
- try {
2472
- // 2. 执行业务层连接请求
2473
- await client.connectRequest();
2474
- }
2475
- catch (err) {
2476
- error(`${client.name}服登录错误`, err);
2477
- cat.gui.showToast({ title: `登录${client.name}服错误` });
2478
- // 同样不抛出错误
2479
- }
2480
- }));
2383
+ await Promise.allSettled(
2384
+ this.activeClients.map(async client => {
2385
+ try {
2386
+ // 1. 等待物理层重连
2387
+ await client.reconnectPromise();
2388
+ } catch (err) {
2389
+ error(`${client.name}服重连失败`, err);
2390
+ cat.gui.showToast({ title: `${client.name}服重连失败` });
2391
+ // 不抛出错误,让 Promise.allSettled 收集结果
2392
+ }
2393
+ try {
2394
+ // 2. 执行业务层连接请求
2395
+ await client.connectRequest();
2396
+ } catch (err) {
2397
+ error(`${client.name}服登录错误`, err);
2398
+ cat.gui.showToast({ title: `登录${client.name}服错误` });
2399
+ // 同样不抛出错误
2400
+ }
2401
+ })
2402
+ );
2481
2403
  // 检查是否有客户端未成功连接
2482
2404
  const failedClients = this.activeClients.filter(client => client.socketConnectStatus !== SocketConnectStatus.CONNECTED);
2483
2405
  if (failedClients.length > 0) {
2484
- console.error("部分WS重连失败:", failedClients.map((name) => name));
2406
+ console.error(
2407
+ '部分WS重连失败:',
2408
+ failedClients.map(name => name)
2409
+ );
2485
2410
  // 可以在一段时间后再次尝试重连
2486
2411
  setTimeout(() => {
2487
2412
  this.triggerReconnectAll();
@@ -2506,10 +2431,10 @@ class SocialGameClientManager extends BaseManager {
2506
2431
 
2507
2432
  const { ccclass, property, menu } = _decorator;
2508
2433
  /**
2509
- * @describe 模态框
2510
- * @author 游金宇(KM)
2511
- * @date 2024-09-12 11:49:51
2512
- */
2434
+ * @describe 模态框
2435
+ * @author 游金宇(KM)
2436
+ * @date 2024-09-12 11:49:51
2437
+ */
2513
2438
  let CoreUIModal = class CoreUIModal extends UILayer {
2514
2439
  default_title = null;
2515
2440
  title;
@@ -2524,9 +2449,9 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2524
2449
  props = {
2525
2450
  title: this.default_title,
2526
2451
  content: null,
2527
- confirmCB: () => { },
2528
- cancelCB: () => { },
2529
- style: null
2452
+ confirmCB: () => {},
2453
+ cancelCB: () => {},
2454
+ style: null,
2530
2455
  };
2531
2456
  onLoad() {
2532
2457
  this.btn_cancel.node.on(Button.EventType.CLICK, this.onCancelHandler, this);
@@ -2537,32 +2462,29 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2537
2462
  this.title.spriteFrame = this.props?.title || this.default_title;
2538
2463
  },
2539
2464
  () => {
2540
- if (this.props.content instanceof SpriteFrame) { //图片
2465
+ if (this.props.content instanceof SpriteFrame) {
2466
+ //图片
2541
2467
  this.prompt_content_spriteFrame.spriteFrame = this.props.content;
2542
- }
2543
- else if (typeof this.props.content === 'string') {
2468
+ } else if (typeof this.props.content === 'string') {
2544
2469
  this.prompt_content_str.string = this.props.content;
2545
- }
2546
- else {
2470
+ } else {
2547
2471
  console.error('未知类型的【UIModal】内容');
2548
2472
  }
2549
2473
  },
2550
2474
  () => {
2551
2475
  if (this.props?.style?.confirm === null) {
2552
2476
  this.btn_confirm.node.active = false;
2553
- }
2554
- else {
2477
+ } else {
2555
2478
  this.btn_confirm.node.active = true;
2556
2479
  this.btn_confirm.getComponent(Sprite).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame;
2557
2480
  }
2558
2481
  if (this.props?.style?.cancel === null) {
2559
2482
  this.btn_cancel.node.active = false;
2560
- }
2561
- else {
2483
+ } else {
2562
2484
  this.btn_cancel.node.active = true;
2563
2485
  this.btn_cancel.getComponent(Sprite).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame;
2564
2486
  }
2565
- }
2487
+ },
2566
2488
  ]);
2567
2489
  }
2568
2490
  close() {
@@ -2576,63 +2498,47 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2576
2498
  this.props.confirmCB?.();
2577
2499
  }
2578
2500
  onDestroy() {
2579
- if (this.isConfirm)
2580
- this.props.onDestroy?.();
2501
+ if (this.isConfirm) this.props.onDestroy?.();
2581
2502
  }
2582
2503
  onCloseHandler() {
2583
2504
  this.close();
2584
2505
  }
2585
2506
  };
2586
- __decorate([
2587
- property({ type: SpriteFrame, tooltip: '默认标题' }),
2588
- __metadata("design:type", SpriteFrame)
2589
- ], CoreUIModal.prototype, "default_title", void 0);
2590
- __decorate([
2591
- property({ type: Sprite, tooltip: '标题节点' }),
2592
- __metadata("design:type", Sprite)
2593
- ], CoreUIModal.prototype, "title", void 0);
2594
- __decorate([
2595
- property({ type: Label, tooltip: '字符串内容按钮' }),
2596
- __metadata("design:type", Label)
2597
- ], CoreUIModal.prototype, "prompt_content_str", void 0);
2598
- __decorate([
2599
- property({ type: Sprite, tooltip: '图片精灵内容按钮' }),
2600
- __metadata("design:type", Sprite)
2601
- ], CoreUIModal.prototype, "prompt_content_spriteFrame", void 0);
2602
- __decorate([
2603
- property({ type: Button, tooltip: '确认按钮' }),
2604
- __metadata("design:type", Button)
2605
- ], CoreUIModal.prototype, "btn_confirm", void 0);
2606
- __decorate([
2607
- property({ type: SpriteFrame, tooltip: '确认按钮精灵图' }),
2608
- __metadata("design:type", SpriteFrame)
2609
- ], CoreUIModal.prototype, "confirm_spriteFrame", void 0);
2610
- __decorate([
2611
- property({ type: Button, tooltip: '取消按钮' }),
2612
- __metadata("design:type", Button)
2613
- ], CoreUIModal.prototype, "btn_cancel", void 0);
2614
- __decorate([
2615
- property({ type: SpriteFrame, tooltip: '取消按钮精灵图' }),
2616
- __metadata("design:type", SpriteFrame)
2617
- ], CoreUIModal.prototype, "cancel_spriteFrame", void 0);
2618
- __decorate([
2619
- property({ type: Button, tooltip: '关闭按钮' }),
2620
- __metadata("design:type", Button)
2621
- ], CoreUIModal.prototype, "btn_close", void 0);
2622
- CoreUIModal = __decorate([
2623
- ccclass('CoreUIModal'),
2624
- menu("CATCORE/CoreUIModal")
2625
- ], CoreUIModal);
2507
+ __decorate([property({ type: SpriteFrame, tooltip: '默认标题' }), __metadata('design:type', SpriteFrame)], CoreUIModal.prototype, 'default_title', void 0);
2508
+ __decorate([property({ type: Sprite, tooltip: '标题节点' }), __metadata('design:type', Sprite)], CoreUIModal.prototype, 'title', void 0);
2509
+ __decorate([property({ type: Label, tooltip: '字符串内容按钮' }), __metadata('design:type', Label)], CoreUIModal.prototype, 'prompt_content_str', void 0);
2510
+ __decorate(
2511
+ [property({ type: Sprite, tooltip: '图片精灵内容按钮' }), __metadata('design:type', Sprite)],
2512
+ CoreUIModal.prototype,
2513
+ 'prompt_content_spriteFrame',
2514
+ void 0
2515
+ );
2516
+ __decorate([property({ type: Button, tooltip: '确认按钮' }), __metadata('design:type', Button)], CoreUIModal.prototype, 'btn_confirm', void 0);
2517
+ __decorate(
2518
+ [property({ type: SpriteFrame, tooltip: '确认按钮精灵图' }), __metadata('design:type', SpriteFrame)],
2519
+ CoreUIModal.prototype,
2520
+ 'confirm_spriteFrame',
2521
+ void 0
2522
+ );
2523
+ __decorate([property({ type: Button, tooltip: '取消按钮' }), __metadata('design:type', Button)], CoreUIModal.prototype, 'btn_cancel', void 0);
2524
+ __decorate(
2525
+ [property({ type: SpriteFrame, tooltip: '取消按钮精灵图' }), __metadata('design:type', SpriteFrame)],
2526
+ CoreUIModal.prototype,
2527
+ 'cancel_spriteFrame',
2528
+ void 0
2529
+ );
2530
+ __decorate([property({ type: Button, tooltip: '关闭按钮' }), __metadata('design:type', Button)], CoreUIModal.prototype, 'btn_close', void 0);
2531
+ CoreUIModal = __decorate([ccclass('CoreUIModal'), menu('CATCORE/CoreUIModal')], CoreUIModal);
2626
2532
 
2627
2533
  /**
2628
- * @describe 时间管理
2629
- * @author 游金宇(KM)
2630
- * @date 2024-09-12 11:49:19
2631
- */
2534
+ * @describe 时间管理
2535
+ * @author 游金宇(KM)
2536
+ * @date 2024-09-12 11:49:19
2537
+ */
2632
2538
  var TimerType;
2633
2539
  (function (TimerType) {
2634
- TimerType[TimerType["Delay"] = 0] = "Delay";
2635
- TimerType[TimerType["Interval"] = 1] = "Interval";
2540
+ TimerType[(TimerType['Delay'] = 0)] = 'Delay';
2541
+ TimerType[(TimerType['Interval'] = 1)] = 'Interval';
2636
2542
  })(TimerType || (TimerType = {}));
2637
2543
  class TimerEntry {
2638
2544
  /** 唯一标识符 */
@@ -2678,7 +2584,7 @@ class TimerManager extends BaseManager {
2678
2584
  }
2679
2585
  onHandleAppForeground() {
2680
2586
  const currentTime = Date.now();
2681
- const elapsedTime = (currentTime - this.lastUpdateTime);
2587
+ const elapsedTime = currentTime - this.lastUpdateTime;
2682
2588
  log('elapsedTime', elapsedTime);
2683
2589
  for (const entry of this.timers.values()) {
2684
2590
  if (entry.remainingTime > 0) {
@@ -2717,9 +2623,9 @@ class TimerManager extends BaseManager {
2717
2623
  this.timers.set(tag, timerEntry);
2718
2624
  }
2719
2625
  /**
2720
- * 取消一个计时器或延时器
2721
- * @param tag 计时器或延时器的唯一标识
2722
- */
2626
+ * 取消一个计时器或延时器
2627
+ * @param tag 计时器或延时器的唯一标识
2628
+ */
2723
2629
  unregister(tag) {
2724
2630
  if (this.has(tag)) {
2725
2631
  this.timers.delete(tag);
@@ -2746,8 +2652,7 @@ class TimerManager extends BaseManager {
2746
2652
  // 如果是计时器,重置剩余时间
2747
2653
  if (entry.type === TimerType.Interval) {
2748
2654
  entry.remainingTime = entry.initialTime; // 重置为初始间隔时间
2749
- }
2750
- else {
2655
+ } else {
2751
2656
  // 如果是延时器,标记为待删除
2752
2657
  entriesToRemove.push(id);
2753
2658
  }
@@ -2762,10 +2667,10 @@ class TimerManager extends BaseManager {
2762
2667
 
2763
2668
  // 处理微信小程序的编码问题
2764
2669
  /**
2765
- * @describe 管理类
2766
- * @author 游金宇(KM)
2767
- * @date 2024-09-12 11:49:44
2768
- */
2670
+ * @describe 管理类
2671
+ * @author 游金宇(KM)
2672
+ * @date 2024-09-12 11:49:44
2673
+ */
2769
2674
  class Manager {
2770
2675
  static #ins;
2771
2676
  static get instance() {
@@ -2807,7 +2712,7 @@ class Manager {
2807
2712
  this.event = new EventEmitter();
2808
2713
  this.audio = new AudioManager(this);
2809
2714
  this.socialGameClient = new SocialGameClientManager(this);
2810
- this.gui = (await (new GuiManager(this)).init()).gui;
2715
+ this.gui = (await new GuiManager(this).init()).gui;
2811
2716
  }
2812
2717
  }
2813
2718
  const cat = Manager.instance;
@@ -2819,4 +2724,34 @@ game.onPostProjectInitDelegate.add(async () => {
2819
2724
  console.timeEnd('[Init App]');
2820
2725
  });
2821
2726
 
2822
- export { AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, CoreBlackMask, CoreNotice, CoreReconnection, CoreShowLoading, CoreToast, CoreUIContainer, CoreUIModal, CoreUtil, GlobalEventConstant, Gui, GuiManager, LayerType, Manager, ReconnectPrompt, RootUILayer, SceneLayer, TimerManager, ToastType, UILayer, WrapperSocialGameClient, cat };
2727
+ export {
2728
+ AudioEventConstant,
2729
+ AudioManager,
2730
+ AudioSourceBaseComponent,
2731
+ AudioSourceUILayer,
2732
+ AudioTypeEnum,
2733
+ BaseComponent,
2734
+ BaseManager,
2735
+ BasePrefab,
2736
+ CoreBlackMask,
2737
+ CoreNotice,
2738
+ CoreReconnection,
2739
+ CoreShowLoading,
2740
+ CoreToast,
2741
+ CoreUIContainer,
2742
+ CoreUIModal,
2743
+ CoreUtil,
2744
+ GlobalEventConstant,
2745
+ Gui,
2746
+ GuiManager,
2747
+ LayerType,
2748
+ Manager,
2749
+ ReconnectPrompt,
2750
+ RootUILayer,
2751
+ SceneLayer,
2752
+ TimerManager,
2753
+ ToastType,
2754
+ UILayer,
2755
+ WrapperSocialGameClient,
2756
+ cat,
2757
+ };