@shimotsuki/core 2.0.14 → 2.0.15

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 +593 -555
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,63 +1,4 @@
1
- import { configureTextEncoding } from '@bufbuild/protobuf/wire';
2
- import TextEncoding from 'text-encoding';
3
- console.log('===== TextEncoding Polyfil 开始加载 =====', TextEncoding);
4
- // 全局挂载(必须在所有页面加载前执行)
5
- const te = new TextEncoding.TextEncoder();
6
- const td = new TextEncoding.TextDecoder();
7
- debugger;
8
- configureTextEncoding({
9
- encodeUtf8(text) {
10
- return te.encode(text);
11
- },
12
- decodeUtf8(bytes) {
13
- return td.decode(bytes);
14
- },
15
- checkUtf8(text) {
16
- try {
17
- encodeURIComponent(text);
18
- return true;
19
- } catch (e) {
20
- return false;
21
- }
22
- },
23
- });
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';
1
+ 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';
61
2
  import { PREVIEW, DEBUG } from 'cc/env';
62
3
  import { makeObservable, observable, autorun, reaction } from '@shimotsuki/mobx';
63
4
  import CryptoES from 'crypto-es';
@@ -68,10 +9,10 @@ import { EventEmitter } from 'eventemitter3';
68
9
  import 'core-js/es/array/index.js';
69
10
 
70
11
  /**
71
- * @describe 音频公共类
72
- * @author 游金宇(KM)
73
- * @date 2024-09-12 11:42:58
74
- */
12
+ * @describe 音频公共类
13
+ * @author 游金宇(KM)
14
+ * @date 2024-09-12 11:42:58
15
+ */
75
16
  class CommonAudio extends AudioSource {
76
17
  cat;
77
18
  initAudio(cat) {
@@ -81,10 +22,10 @@ class CommonAudio extends AudioSource {
81
22
  }
82
23
 
83
24
  /**
84
- * @describe 音效
85
- * @author 游金宇(KM)
86
- * @date 2023-08-03 10:59:44
87
- */
25
+ * @describe 音效
26
+ * @author 游金宇(KM)
27
+ * @date 2023-08-03 10:59:44
28
+ */
88
29
  const { ccclass: ccclass$b, menu: menu$9 } = _decorator;
89
30
  /**
90
31
  * 注:用playOneShot播放的音乐效果,在播放期间暂时没办法即时关闭音乐
@@ -133,7 +74,8 @@ class AudioMusic extends CommonAudio {
133
74
  _isPlay = false;
134
75
  /** 获取音乐播放进度 */
135
76
  get progress() {
136
- if (this.duration > 0) this._progress = this.currentTime / this.duration;
77
+ if (this.duration > 0)
78
+ this._progress = this.currentTime / this.duration;
137
79
  return this._progress;
138
80
  }
139
81
  /**
@@ -188,10 +130,10 @@ class AudioMusic extends CommonAudio {
188
130
  }
189
131
 
190
132
  /**
191
- * @describe 基础管理类
192
- * @author 游金宇(KM)
193
- * @date 2024-09-12 11:49:30
194
- */
133
+ * @describe 基础管理类
134
+ * @author 游金宇(KM)
135
+ * @date 2024-09-12 11:49:30
136
+ */
195
137
  class BaseManager {
196
138
  cat;
197
139
  constructor(manager) {
@@ -202,24 +144,24 @@ class BaseManager {
202
144
  var AudioEventConstant;
203
145
  (function (AudioEventConstant) {
204
146
  /**音乐开 */
205
- AudioEventConstant['MUSIC_ON'] = 'AudioEventConstant/MUSIC_ON';
147
+ AudioEventConstant["MUSIC_ON"] = "AudioEventConstant/MUSIC_ON";
206
148
  /**音乐关 */
207
- AudioEventConstant['MUSIC_OFF'] = 'AudioEventConstant/MUSIC_OFF';
149
+ AudioEventConstant["MUSIC_OFF"] = "AudioEventConstant/MUSIC_OFF";
208
150
  /**音效开 */
209
- AudioEventConstant['EFFECT_ON'] = 'AudioEventConstant/EFFECT_ON';
151
+ AudioEventConstant["EFFECT_ON"] = "AudioEventConstant/EFFECT_ON";
210
152
  /**音效关 */
211
- AudioEventConstant['EFFECT_OFF'] = 'AudioEventConstant/EFFECT_OFF';
153
+ AudioEventConstant["EFFECT_OFF"] = "AudioEventConstant/EFFECT_OFF";
212
154
  /**暂停音频 */
213
- AudioEventConstant['PAUSE_AUDIO'] = 'AudioEventConstant/PAUSE_AUDIO';
155
+ AudioEventConstant["PAUSE_AUDIO"] = "AudioEventConstant/PAUSE_AUDIO";
214
156
  /**恢复音频 */
215
- AudioEventConstant['RESUME_AUDIO'] = 'AudioEventConstant/RESUME_AUDIO';
157
+ AudioEventConstant["RESUME_AUDIO"] = "AudioEventConstant/RESUME_AUDIO";
216
158
  })(AudioEventConstant || (AudioEventConstant = {}));
217
159
 
218
160
  /**
219
- * @describe 音频管理
220
- * @author 游金宇(KM)
221
- * @date 2023-08-03 17:54:31
222
- */
161
+ * @describe 音频管理
162
+ * @author 游金宇(KM)
163
+ * @date 2023-08-03 17:54:31
164
+ */
223
165
  /**
224
166
  * 音频管理
225
167
  */
@@ -260,25 +202,27 @@ class AudioManager extends BaseManager {
260
202
  */
261
203
  playMusic(url, callback) {
262
204
  this.music.loop = true;
263
- url &&
264
- this.music.load(url, () => {
265
- this._switch_music && this.music?.play();
266
- callback && callback();
267
- });
205
+ url && this.music.load(url, () => {
206
+ this._switch_music && this.music?.play();
207
+ callback && callback();
208
+ });
268
209
  }
269
210
  /**
270
211
  * 停止音乐
271
212
  */
272
213
  stopMusic() {
273
- if (this.music.state != 0) this.music?.stop();
214
+ if (this.music.state != 0)
215
+ this.music?.stop();
274
216
  }
275
217
  /**暂停音乐 */
276
218
  pauseMusic() {
277
- if (this.music.state == 1) this.music?.pause();
219
+ if (this.music.state == 1)
220
+ this.music?.pause();
278
221
  }
279
222
  /**恢复音乐 */
280
223
  resumeMusic() {
281
- if ([0, 2].includes(this.music.state)) this.music?.play();
224
+ if ([0, 2].includes(this.music.state))
225
+ this.music?.play();
282
226
  }
283
227
  /**
284
228
  * 获取背景音乐播放进度
@@ -319,7 +263,8 @@ class AudioManager extends BaseManager {
319
263
  */
320
264
  set switchMusic(value) {
321
265
  log('设置背景音乐开关值', value, this._switch_music);
322
- if (value == this._switch_music) return;
266
+ if (value == this._switch_music)
267
+ return;
323
268
  this._switch_music = value;
324
269
  value ? this.resumeMusic() : this.pauseMusic();
325
270
  const nonce = value ? AudioEventConstant.MUSIC_ON : AudioEventConstant.MUSIC_OFF;
@@ -331,11 +276,11 @@ class AudioManager extends BaseManager {
331
276
  * @param url 资源地址
332
277
  */
333
278
  async playEffect(url) {
334
- if (!this._switch_effect) return;
335
- url &&
336
- (await this.effect.load(url).then(() => {
337
- this.effect.play();
338
- }));
279
+ if (!this._switch_effect)
280
+ return;
281
+ url && await this.effect.load(url).then(() => {
282
+ this.effect.play();
283
+ });
339
284
  }
340
285
  /**
341
286
  * 停止音效
@@ -368,7 +313,8 @@ class AudioManager extends BaseManager {
368
313
  * @param value 音效开关值
369
314
  */
370
315
  set switchEffect(value) {
371
- if (value == this._switch_effect) return;
316
+ if (value == this._switch_effect)
317
+ return;
372
318
  this._switch_effect = value;
373
319
  value ? this.effect?.play() : this.effect?.stop();
374
320
  const nonce = value ? AudioEventConstant.EFFECT_ON : AudioEventConstant.EFFECT_OFF;
@@ -411,7 +357,8 @@ class AudioManager extends BaseManager {
411
357
  this._switch_music = this.local_data.switch_music;
412
358
  this._switch_effect = this.local_data.switch_effect;
413
359
  this.extra = this.local_data.extra;
414
- } catch (e) {
360
+ }
361
+ catch (e) {
415
362
  this.local_data = {};
416
363
  this._volume_music = 0.6;
417
364
  this._volume_effect = 1.0;
@@ -419,16 +366,18 @@ class AudioManager extends BaseManager {
419
366
  this._switch_effect = true;
420
367
  this.extra = {};
421
368
  }
422
- if (this.music) this.music.volume = this._volume_music;
423
- if (this.effect) this.effect.volume = this._volume_effect;
369
+ if (this.music)
370
+ this.music.volume = this._volume_music;
371
+ if (this.effect)
372
+ this.effect.volume = this._volume_effect;
424
373
  }
425
374
  }
426
375
 
427
376
  /**
428
- * @describe 本地存储管理
429
- * @author 游金宇(KM)
430
- * @date 2023-08-03 17:58:51
431
- */
377
+ * @describe 本地存储管理
378
+ * @author 游金宇(KM)
379
+ * @date 2023-08-03 17:58:51
380
+ */
432
381
  class StorageManager extends BaseManager {
433
382
  _key = null;
434
383
  _iv = null;
@@ -477,11 +426,13 @@ class StorageManager extends BaseManager {
477
426
  if (typeof value === 'object') {
478
427
  try {
479
428
  value = JSON.stringify(value);
480
- } catch (e) {
429
+ }
430
+ catch (e) {
481
431
  console.error(`解析失败,str = ${value}`);
482
432
  return;
483
433
  }
484
- } else if (typeof value === 'number') {
434
+ }
435
+ else if (typeof value === 'number') {
485
436
  value = value + '';
486
437
  }
487
438
  if (!PREVIEW && null != this._key && null != this._iv) {
@@ -550,41 +501,38 @@ class StorageManager extends BaseManager {
550
501
  }
551
502
  }
552
503
 
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
- };
504
+ /******************************************************************************
505
+ Copyright (c) Microsoft Corporation.
506
+
507
+ Permission to use, copy, modify, and/or distribute this software for any
508
+ purpose with or without fee is hereby granted.
509
+
510
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
511
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
512
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
513
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
514
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
515
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
516
+ PERFORMANCE OF THIS SOFTWARE.
517
+ ***************************************************************************** */
518
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
519
+
520
+
521
+ function __decorate(decorators, target, key, desc) {
522
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
523
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
524
+ 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;
525
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
526
+ }
527
+
528
+ function __metadata(metadataKey, metadataValue) {
529
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
530
+ }
531
+
532
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
533
+ var e = new Error(message);
534
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
535
+ };
588
536
 
589
537
  /**
590
538
  * @describe 组件基类
@@ -603,11 +551,12 @@ class BaseComponent extends Component {
603
551
  reactionDisposers = [];
604
552
  eventEmitter = [];
605
553
  hook = {
606
- destroyed: () => {},
607
- started: () => {},
554
+ destroyed: () => { },
555
+ started: () => { },
608
556
  };
609
557
  /**初始化UI(可在本函数中进行节点赋值或注册节点事件等...) */
610
- initUI() {}
558
+ initUI() {
559
+ }
611
560
  __preload() {
612
561
  this.initUI();
613
562
  this.onAutoObserver();
@@ -616,11 +565,12 @@ class BaseComponent extends Component {
616
565
  super();
617
566
  makeObservable(this, {
618
567
  props: observable,
619
- data: observable,
568
+ data: observable
620
569
  });
621
570
  }
622
571
  /**依赖收集生命周期(可以在该生命周期中注册依赖收集回调) */
623
- onAutoObserver() {}
572
+ onAutoObserver() {
573
+ }
624
574
  /**添加自动收集 */
625
575
  addAutorun(cb) {
626
576
  const cbs = Array.isArray(cb) ? cb : [cb];
@@ -649,10 +599,10 @@ class BaseComponent extends Component {
649
599
  return eventEmitter;
650
600
  }
651
601
  _onPreDestroy() {
652
- this.autorunDisposers.forEach(item => {
602
+ this.autorunDisposers.forEach((item) => {
653
603
  item();
654
604
  });
655
- this.reactionDisposers.forEach(item => {
605
+ this.reactionDisposers.forEach((item) => {
656
606
  item();
657
607
  });
658
608
  this.autorunDisposers = [];
@@ -677,7 +627,7 @@ class BaseComponent extends Component {
677
627
  if (!Array.isArray(handlers)) {
678
628
  handlers = [handlers]; // 统一处理,单个和数组情况
679
629
  }
680
- handlers.forEach(handler => {
630
+ handlers.forEach((handler) => {
681
631
  if (handler.context === this) {
682
632
  emitter.off(key, handler.fn, this); // 移除事件
683
633
  }
@@ -690,17 +640,17 @@ class BaseComponent extends Component {
690
640
  this.onEventListener();
691
641
  }
692
642
  /**子类继承该方法(全局事件(cat.event)注册在components上的事件可以不添加取消监听(自动取消监听了)) */
693
- onEventListener() {}
643
+ onEventListener() { }
694
644
  /**子类继承该方法 */
695
- addListener() {}
645
+ addListener() { }
696
646
  /**子类继承该方法 */
697
- removeListener() {}
647
+ removeListener() { }
698
648
  /**
699
649
  * 添加到父节点
700
- * @param parent 父节点
701
- * @param option 参数
702
- * @returns 自身组件
703
- */
650
+ * @param parent 父节点
651
+ * @param option 参数
652
+ * @returns 自身组件
653
+ */
704
654
  addToParent(parent, options) {
705
655
  let _parent = parent instanceof Prefab ? instantiate(parent) : parent instanceof Component ? parent.node : parent;
706
656
  this.setOptions(options);
@@ -710,7 +660,8 @@ class BaseComponent extends Component {
710
660
  /**设置属性(覆盖原有属性) */
711
661
  setOptions(options) {
712
662
  // 使用类型断言来确保 options 的正确类型
713
- if (!options) return;
663
+ if (!options)
664
+ return;
714
665
  // 如果 options 是 IUIOption<T> 类型,则可以安全地访问 props 属性
715
666
  for (let key in options) {
716
667
  switch (key) {
@@ -718,12 +669,12 @@ class BaseComponent extends Component {
718
669
  options.hook && (this.hook = options.hook);
719
670
  break;
720
671
  case 'props':
721
- if (options.props !== null && typeof options.props === 'object') {
672
+ if (options.props !== null && typeof options.props === "object") {
722
673
  this.props = options.props;
723
674
  }
724
675
  break;
725
676
  case 'data':
726
- if (options.data !== null && typeof options.data === 'object') {
677
+ if (options.data !== null && typeof options.data === "object") {
727
678
  this.data = options.data;
728
679
  }
729
680
  break;
@@ -737,7 +688,8 @@ class BaseComponent extends Component {
737
688
  }
738
689
  /**设置props属性(更新)*/
739
690
  setUpdateProps(props) {
740
- if (!this.props) debugger;
691
+ if (!this.props)
692
+ debugger;
741
693
  props && Object.assign(this.props, props);
742
694
  return this;
743
695
  }
@@ -770,9 +722,11 @@ class BaseComponent extends Component {
770
722
  return this;
771
723
  }
772
724
  /**显示(同onEnable) */
773
- onShow() {}
725
+ onShow() {
726
+ }
774
727
  /**隐藏(同onDisable) */
775
- onHide() {}
728
+ onHide() {
729
+ }
776
730
  /**设置节点和子节点的层级 */
777
731
  setNodeAndChildrenLayer(layer) {
778
732
  setNodeAndChildrenLayer(this.node, layer);
@@ -781,7 +735,7 @@ class BaseComponent extends Component {
781
735
  }
782
736
  /**设置节点及子节点的层级 */
783
737
  const setNodeAndChildrenLayer = (node, layer) => {
784
- node.layer = typeof layer === 'string' ? 2 ** Layers.nameToLayer(layer) : layer;
738
+ node.layer = (typeof layer === 'string' ? 2 ** Layers.nameToLayer(layer) : layer);
785
739
  node?.children.forEach(item => {
786
740
  setNodeAndChildrenLayer(item, layer);
787
741
  });
@@ -832,33 +786,40 @@ class UILayer extends BaseComponent {
832
786
  // 从中间放大
833
787
  start = v3(0.01, 0.01, 0.01);
834
788
  end = v3(1, 1, 1);
835
- } else {
789
+ }
790
+ else {
836
791
  if (direction == 'left') {
837
792
  start = v3(-this.screen.width, 0, 0);
838
- } else if (direction == 'right') {
793
+ }
794
+ else if (direction == 'right') {
839
795
  start = v3(this.screen.width, 0, 0);
840
- } else if (direction == 'top') {
796
+ }
797
+ else if (direction == 'top') {
841
798
  start = v3(0, this.screen.height, 0);
842
- } else {
799
+ }
800
+ else {
843
801
  start = v3(0, -this.screen.height, 0);
844
802
  }
845
803
  end = v3(0, 0, 0);
846
804
  }
847
805
  await this.handle(direction, duration, start, end, isBounce);
848
- if (widget) widget.enabled = true;
806
+ if (widget)
807
+ widget.enabled = true;
849
808
  }
850
809
  }
851
810
  /**隐藏动画 */
852
811
  async hideTween({ isMotion = true, direction, duration = 0.1 }) {
853
812
  direction = direction || this.lastEnterDirection;
854
813
  // 避免重复点击关闭
855
- if (this.isClosing) return;
814
+ if (this.isClosing)
815
+ return;
856
816
  this.isClosing = true;
857
817
  // 停止当前动画
858
818
  tween(this.node).removeSelf();
859
819
  if (isMotion) {
860
820
  const widget = this.node.getComponent(Widget);
861
- if (widget) widget.enabled = false;
821
+ if (widget)
822
+ widget.enabled = false;
862
823
  // 设置起始坐标
863
824
  // 起点坐标
864
825
  let start;
@@ -868,14 +829,18 @@ class UILayer extends BaseComponent {
868
829
  // 从中间缩小
869
830
  start = this.node.scale;
870
831
  end = v3(0, 0, 0);
871
- } else {
832
+ }
833
+ else {
872
834
  if (direction == 'left') {
873
835
  end = v3(-this.screen.width, 0, 0);
874
- } else if (direction == 'right') {
836
+ }
837
+ else if (direction == 'right') {
875
838
  end = v3(this.screen.width, 0, 0);
876
- } else if (direction == 'top') {
839
+ }
840
+ else if (direction == 'top') {
877
841
  end = v3(0, this.screen.height, 0);
878
- } else {
842
+ }
843
+ else {
879
844
  end = v3(0, -this.screen.height, 0);
880
845
  }
881
846
  start = this.node.getPosition();
@@ -888,7 +853,8 @@ class UILayer extends BaseComponent {
888
853
  if (direction == 'center') {
889
854
  // 从中间放大
890
855
  this.node.setScale(start);
891
- } else {
856
+ }
857
+ else {
892
858
  this.node.setPosition(start);
893
859
  }
894
860
  await this.deftween(duration, { [direction == 'center' ? 'scale' : 'position']: end }, isBounce);
@@ -898,9 +864,9 @@ class UILayer extends BaseComponent {
898
864
  tween(this.node)
899
865
  .to(duration, props)
900
866
  .call(() => {
901
- // tween_node.removeSelf();
902
- resolve();
903
- })
867
+ // tween_node.removeSelf();
868
+ resolve();
869
+ })
904
870
  .start();
905
871
  // if (options.isBounce) {
906
872
  // this.node.scale = start;
@@ -917,10 +883,10 @@ class UILayer extends BaseComponent {
917
883
  }
918
884
 
919
885
  /**
920
- * @describe 音频组件基类
921
- * @author 游金宇(KM)
922
- * @date 2023-12-22 16:20:20
923
- */
886
+ * @describe 音频组件基类
887
+ * @author 游金宇(KM)
888
+ * @date 2023-12-22 16:20:20
889
+ */
924
890
  const { ccclass: ccclass$9, property: property$9 } = _decorator;
925
891
  /**
926
892
  * EFFECT 音效
@@ -928,8 +894,8 @@ const { ccclass: ccclass$9, property: property$9 } = _decorator;
928
894
  */
929
895
  var AudioTypeEnum;
930
896
  (function (AudioTypeEnum) {
931
- AudioTypeEnum[(AudioTypeEnum['EFFECT'] = 0)] = 'EFFECT';
932
- AudioTypeEnum[(AudioTypeEnum['BGM'] = 1)] = 'BGM';
897
+ AudioTypeEnum[AudioTypeEnum["EFFECT"] = 0] = "EFFECT";
898
+ AudioTypeEnum[AudioTypeEnum["BGM"] = 1] = "BGM";
933
899
  })(AudioTypeEnum || (AudioTypeEnum = {}));
934
900
  class AudioSourceBaseComponent extends BaseComponent {
935
901
  type = AudioTypeEnum.EFFECT;
@@ -944,8 +910,7 @@ class AudioSourceBaseComponent extends BaseComponent {
944
910
  this.audioSource.loop = this.loop;
945
911
  this.audioSource.volume = this.volume;
946
912
  this.audioSource.playOnAwake = this.playOnAwake;
947
- cat.event
948
- .on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
913
+ cat.event.on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
949
914
  .on(AudioEventConstant.EFFECT_OFF, this.onStopEffectHandler, this)
950
915
  .on(AudioEventConstant.MUSIC_ON, this.onPlayMusicHandler, this)
951
916
  .on(AudioEventConstant.MUSIC_OFF, this.onStopMusicHandler, this);
@@ -955,20 +920,23 @@ class AudioSourceBaseComponent extends BaseComponent {
955
920
  const { volumeEffect, volumeMusic } = cat.audio;
956
921
  this.audioSource.volume = this.type === AudioTypeEnum.BGM ? volumeMusic : volumeEffect;
957
922
  }
958
- start() {}
923
+ start() { }
959
924
  stopAudio() {
960
925
  this.audioSource.stop();
961
926
  }
962
927
  playAudio() {
963
928
  const { switchEffect, switchMusic } = cat.audio;
964
929
  // @ts-ignore 保证在游戏运行的时候才播放
965
- if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused) this.audioSource.play();
930
+ if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused)
931
+ this.audioSource.play();
932
+ }
933
+ onPlayEffectHandler() {
966
934
  }
967
- onPlayEffectHandler() {}
968
935
  onStopEffectHandler() {
969
936
  this.stopAudio();
970
937
  }
971
- onPlayMusicHandler() {}
938
+ onPlayMusicHandler() {
939
+ }
972
940
  onStopMusicHandler() {
973
941
  this.stopAudio();
974
942
  }
@@ -977,24 +945,31 @@ class AudioSourceBaseComponent extends BaseComponent {
977
945
  super._onPreDestroy();
978
946
  }
979
947
  }
980
- __decorate(
981
- [
982
- property$9({
983
- tooltip: `类型:
984
- EFFECT 音效
948
+ __decorate([
949
+ property$9({
950
+ tooltip: `类型:
951
+ EFFECT 音效
985
952
  BGM 音乐`,
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);
953
+ type: Enum(AudioTypeEnum)
954
+ }),
955
+ __metadata("design:type", Object)
956
+ ], AudioSourceBaseComponent.prototype, "type", void 0);
957
+ __decorate([
958
+ property$9({ tooltip: '音源', type: AudioClip }),
959
+ __metadata("design:type", Object)
960
+ ], AudioSourceBaseComponent.prototype, "clip", void 0);
961
+ __decorate([
962
+ property$9({ tooltip: '循环' }),
963
+ __metadata("design:type", Object)
964
+ ], AudioSourceBaseComponent.prototype, "loop", void 0);
965
+ __decorate([
966
+ property$9({ tooltip: '音量' }),
967
+ __metadata("design:type", Object)
968
+ ], AudioSourceBaseComponent.prototype, "volume", void 0);
969
+ __decorate([
970
+ property$9({ tooltip: '是否启用自动播放' }),
971
+ __metadata("design:type", Object)
972
+ ], AudioSourceBaseComponent.prototype, "playOnAwake", void 0);
998
973
 
999
974
  const { ccclass: ccclass$8, property: property$8 } = _decorator;
1000
975
  /**带有音频通道的UIlayer组件 */
@@ -1007,8 +982,7 @@ class AudioSourceUILayer extends UILayer {
1007
982
  audioSource = new AudioSource();
1008
983
  onEnable() {
1009
984
  super.onEnable();
1010
- cat.event
1011
- .on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
985
+ cat.event.on(AudioEventConstant.EFFECT_ON, this.onPlayEffectHandler, this)
1012
986
  .on(AudioEventConstant.EFFECT_OFF, this.onStopEffectHandler, this)
1013
987
  .on(AudioEventConstant.MUSIC_ON, this.onPlayMusicHandler, this)
1014
988
  .on(AudioEventConstant.MUSIC_OFF, this.onStopMusicHandler, this);
@@ -1028,13 +1002,16 @@ class AudioSourceUILayer extends UILayer {
1028
1002
  playAudio() {
1029
1003
  const { switchEffect, switchMusic } = cat.audio;
1030
1004
  // @ts-ignore 保证在游戏运行的时候才播放
1031
- if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused) this.audioSource.play();
1005
+ if (!this.audioSource.playing && (this.type === AudioTypeEnum.BGM ? switchMusic : switchEffect) && !game._paused)
1006
+ this.audioSource.play();
1007
+ }
1008
+ onPlayEffectHandler() {
1032
1009
  }
1033
- onPlayEffectHandler() {}
1034
1010
  onStopEffectHandler() {
1035
1011
  this.stopAudio();
1036
1012
  }
1037
- onPlayMusicHandler() {}
1013
+ onPlayMusicHandler() {
1014
+ }
1038
1015
  onStopMusicHandler() {
1039
1016
  this.stopAudio();
1040
1017
  }
@@ -1043,35 +1020,42 @@ class AudioSourceUILayer extends UILayer {
1043
1020
  super._onPreDestroy();
1044
1021
  }
1045
1022
  }
1046
- __decorate(
1047
- [
1048
- property$8({
1049
- tooltip: `类型:
1050
- EFFECT 音效
1023
+ __decorate([
1024
+ property$8({
1025
+ tooltip: `类型:
1026
+ EFFECT 音效
1051
1027
  BGM 音乐`,
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);
1028
+ type: Enum(AudioTypeEnum)
1029
+ }),
1030
+ __metadata("design:type", Object)
1031
+ ], AudioSourceUILayer.prototype, "type", void 0);
1032
+ __decorate([
1033
+ property$8({ tooltip: '音源', type: AudioClip }),
1034
+ __metadata("design:type", Object)
1035
+ ], AudioSourceUILayer.prototype, "clip", void 0);
1036
+ __decorate([
1037
+ property$8({ tooltip: '循环' }),
1038
+ __metadata("design:type", Object)
1039
+ ], AudioSourceUILayer.prototype, "loop", void 0);
1040
+ __decorate([
1041
+ property$8({ tooltip: '音量' }),
1042
+ __metadata("design:type", Object)
1043
+ ], AudioSourceUILayer.prototype, "volume", void 0);
1044
+ __decorate([
1045
+ property$8({ tooltip: '是否启用自动播放' }),
1046
+ __metadata("design:type", Object)
1047
+ ], AudioSourceUILayer.prototype, "playOnAwake", void 0);
1064
1048
 
1065
1049
  /**
1066
- * @describe TOAST弹窗组件
1067
- * @author 游金宇(KM)
1068
- * @date 2024-09-12 11:42:29
1069
- */
1050
+ * @describe TOAST弹窗组件
1051
+ * @author 游金宇(KM)
1052
+ * @date 2024-09-12 11:42:29
1053
+ */
1070
1054
  const { ccclass: ccclass$7, property: property$7, menu: menu$7 } = _decorator;
1071
1055
  var ToastType;
1072
1056
  (function (ToastType) {
1073
- ToastType[(ToastType['FIXED'] = 0)] = 'FIXED';
1074
- ToastType[(ToastType['SLIDE'] = 1)] = 'SLIDE';
1057
+ ToastType[ToastType["FIXED"] = 0] = "FIXED";
1058
+ ToastType[ToastType["SLIDE"] = 1] = "SLIDE";
1075
1059
  })(ToastType || (ToastType = {}));
1076
1060
  let CoreToast = class CoreToast extends BaseComponent {
1077
1061
  fixed_node;
@@ -1103,7 +1087,8 @@ let CoreToast = class CoreToast extends BaseComponent {
1103
1087
  this.node.destroy();
1104
1088
  resolve();
1105
1089
  }, fixed_time);
1106
- } else {
1090
+ }
1091
+ else {
1107
1092
  this.slide_node.active = true;
1108
1093
  this.slide_label.string = `${title}`;
1109
1094
  // v2.4
@@ -1130,15 +1115,15 @@ let CoreToast = class CoreToast extends BaseComponent {
1130
1115
  .delay(delay)
1131
1116
  .to(duration, { opacity: 0 })
1132
1117
  .call(() => {
1133
- Tween.stopAllByTarget(node);
1134
- this.node.destroy();
1135
- resolve();
1136
- });
1118
+ Tween.stopAllByTarget(node);
1119
+ this.node.destroy();
1120
+ resolve();
1121
+ });
1137
1122
  tween(node)
1138
1123
  .by(duration, { position: v3(0, 400, 0) })
1139
1124
  .call(() => {
1140
- uiOpacityTween.start();
1141
- })
1125
+ uiOpacityTween.start();
1126
+ })
1142
1127
  .start();
1143
1128
  });
1144
1129
  }
@@ -1147,42 +1132,57 @@ let CoreToast = class CoreToast extends BaseComponent {
1147
1132
  this.unscheduleAllCallbacks();
1148
1133
  }
1149
1134
  };
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);
1135
+ __decorate([
1136
+ property$7({ type: Node, tooltip: '固定节点' }),
1137
+ __metadata("design:type", Node)
1138
+ ], CoreToast.prototype, "fixed_node", void 0);
1139
+ __decorate([
1140
+ property$7({ type: Node, tooltip: '滑动节点' }),
1141
+ __metadata("design:type", Node)
1142
+ ], CoreToast.prototype, "slide_node", void 0);
1143
+ __decorate([
1144
+ property$7({ type: Label, tooltip: '固定标签节点' }),
1145
+ __metadata("design:type", Label)
1146
+ ], CoreToast.prototype, "fixed_label", void 0);
1147
+ __decorate([
1148
+ property$7({ type: Label, tooltip: '滑动标签节点' }),
1149
+ __metadata("design:type", Label)
1150
+ ], CoreToast.prototype, "slide_label", void 0);
1151
+ CoreToast = __decorate([
1152
+ ccclass$7('CoreToast'),
1153
+ menu$7("CATCORE/CoreToast")
1154
+ ], CoreToast);
1155
1155
 
1156
1156
  /**
1157
- * @describe 全局事件监听方法
1158
- * @author 游金宇(KM)
1159
- * @date 2023-08-03 18:13:36
1160
- */
1157
+ * @describe 全局事件监听方法
1158
+ * @author 游金宇(KM)
1159
+ * @date 2023-08-03 18:13:36
1160
+ */
1161
1161
  var GlobalEventConstant;
1162
1162
  (function (GlobalEventConstant) {
1163
1163
  /** 游戏从后台进入 */
1164
- GlobalEventConstant['EVENT_SHOW'] = 'GlobalEventConstant/EVENT_SHOW';
1164
+ GlobalEventConstant["EVENT_SHOW"] = "GlobalEventConstant/EVENT_SHOW";
1165
1165
  /** 游戏切到后台 */
1166
- GlobalEventConstant['EVENT_HIDE'] = 'GlobalEventConstant/EVENT_HIDE';
1166
+ GlobalEventConstant["EVENT_HIDE"] = "GlobalEventConstant/EVENT_HIDE";
1167
1167
  /** 游戏画笔尺寸变化事件 */
1168
- GlobalEventConstant['GAME_RESIZE'] = 'GlobalEventConstant/GAME_RESIZE';
1168
+ GlobalEventConstant["GAME_RESIZE"] = "GlobalEventConstant/GAME_RESIZE";
1169
1169
  /**游戏关闭时间 */
1170
- GlobalEventConstant['EVENT_CLOSE'] = 'GlobalEventConstant/EVENT_CLOSE';
1170
+ GlobalEventConstant["EVENT_CLOSE"] = "GlobalEventConstant/EVENT_CLOSE";
1171
1171
  /**网络连接 */
1172
- GlobalEventConstant['ONLINE'] = 'GlobalEventConstant/ONLINE';
1172
+ GlobalEventConstant["ONLINE"] = "GlobalEventConstant/ONLINE";
1173
1173
  /**网络断开 */
1174
- GlobalEventConstant['OFFLINE'] = 'GlobalEventConstant/OFFLINE';
1174
+ GlobalEventConstant["OFFLINE"] = "GlobalEventConstant/OFFLINE";
1175
1175
  /**ROOT_MASK更新 */
1176
- GlobalEventConstant['ROOT_MASK_UPDATE'] = 'GlobalEventConstant/ROOT_MASK_UPDATE';
1176
+ GlobalEventConstant["ROOT_MASK_UPDATE"] = "GlobalEventConstant/ROOT_MASK_UPDATE";
1177
1177
  /**ROOT_MASK更新变化 */
1178
- GlobalEventConstant['ROOT_MASK_CHANGE'] = 'GlobalEventConstant/ROOT_MASK_CHANGE';
1178
+ GlobalEventConstant["ROOT_MASK_CHANGE"] = "GlobalEventConstant/ROOT_MASK_CHANGE";
1179
1179
  })(GlobalEventConstant || (GlobalEventConstant = {}));
1180
1180
 
1181
1181
  /**
1182
- * @describe UI容器管理 在场景节点下 会随着场景销毁(非常驻节点)
1183
- * @author 游金宇(KM)
1184
- * @date 2024-09-12 11:45:31
1185
- */
1182
+ * @describe UI容器管理 在场景节点下 会随着场景销毁(非常驻节点)
1183
+ * @author 游金宇(KM)
1184
+ * @date 2024-09-12 11:45:31
1185
+ */
1186
1186
  const { ccclass: ccclass$6, property: property$6, menu: menu$6 } = _decorator;
1187
1187
  let CoreUIContainer = class CoreUIContainer extends UILayer {
1188
1188
  scene_mask_node;
@@ -1216,7 +1216,7 @@ let CoreUIContainer = class CoreUIContainer extends UILayer {
1216
1216
  this.blockMaskSiblingIndexChanged();
1217
1217
  }
1218
1218
  blockMaskSiblingIndexChanged() {
1219
- 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();
1220
1220
  }
1221
1221
  /**
1222
1222
  * 将UI节点挂载在tween上执行动画
@@ -1246,9 +1246,18 @@ let CoreUIContainer = class CoreUIContainer extends UILayer {
1246
1246
  this.scene_mask.node.active = active;
1247
1247
  }
1248
1248
  };
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);
1249
+ __decorate([
1250
+ property$6({ type: Node }),
1251
+ __metadata("design:type", Node)
1252
+ ], CoreUIContainer.prototype, "scene_mask_node", void 0);
1253
+ __decorate([
1254
+ property$6({ type: Node }),
1255
+ __metadata("design:type", Node)
1256
+ ], CoreUIContainer.prototype, "ui_container", void 0);
1257
+ CoreUIContainer = __decorate([
1258
+ ccclass$6('CoreUIContainer'),
1259
+ menu$6("CATCORE/CoreUIContainer")
1260
+ ], CoreUIContainer);
1252
1261
 
1253
1262
  /**
1254
1263
  * @describe 根级别的UI层 所有的ROOT UI层需继承自该自组件
@@ -1271,10 +1280,10 @@ class RootUILayer extends UILayer {
1271
1280
 
1272
1281
  const { ccclass: ccclass$5, property: property$5, menu: menu$5 } = _decorator;
1273
1282
  /**
1274
- * @describe 加载框
1275
- * @author 游金宇(KM)
1276
- * @date 2024-09-12 11:49:51
1277
- */
1283
+ * @describe 加载框
1284
+ * @author 游金宇(KM)
1285
+ * @date 2024-09-12 11:49:51
1286
+ */
1278
1287
  let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1279
1288
  title;
1280
1289
  loadingTween;
@@ -1287,11 +1296,11 @@ let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1287
1296
  if (this.props?.title) {
1288
1297
  this.title.string = `${this.props?.title}`;
1289
1298
  }
1290
- this.title.node.active = !!this.props?.title?.length;
1299
+ this.title.node.active = !!(this.props?.title?.length);
1291
1300
  },
1292
1301
  () => {
1293
- this.getComponent(BlockInputEvents).enabled = !!this.props?.mask;
1294
- },
1302
+ this.getComponent(BlockInputEvents).enabled = !!(this.props?.mask);
1303
+ }
1295
1304
  ]);
1296
1305
  }
1297
1306
  update(deltaTime) {
@@ -1302,47 +1311,46 @@ let CoreShowLoading = class CoreShowLoading extends RootUILayer {
1302
1311
  }
1303
1312
  }
1304
1313
  };
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);
1314
+ __decorate([
1315
+ property$5({ type: Label, tooltip: '标题' }),
1316
+ __metadata("design:type", Label)
1317
+ ], CoreShowLoading.prototype, "title", void 0);
1318
+ __decorate([
1319
+ property$5({ type: Node, tooltip: '动画' }),
1320
+ __metadata("design:type", Node
1321
+ // @property({ type: Node, tooltip: '遮罩' })
1322
+ // black: Node
1323
+ )
1324
+ ], CoreShowLoading.prototype, "loadingTween", void 0);
1325
+ CoreShowLoading = __decorate([
1326
+ ccclass$5('CoreShowLoading'),
1327
+ menu$5("CATCORE/CoreShowLoading")
1328
+ ], CoreShowLoading);
1321
1329
 
1322
1330
  const { ccclass: ccclass$4, property: property$4, menu: menu$4 } = _decorator;
1323
1331
  var ReconnectPrompt;
1324
1332
  (function (ReconnectPrompt) {
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';
1333
+ ReconnectPrompt["RECONNECTED"] = "\u91CD\u8FDE\u6210\u529F";
1334
+ ReconnectPrompt["RECONNECTING"] = "\u6B63\u5728\u91CD\u8FDE";
1335
+ ReconnectPrompt["MAX_RECONNECT"] = "\u91CD\u8FDE\u6B21\u6570\u8D85\u51FA\u9650\u5236,\u8BF7\u68C0\u67E5\u7F51\u7EDC";
1336
+ ReconnectPrompt["RECONNECTED_ERROR"] = "\u91CD\u8FDE\u5931\u8D25,\u8BF7\u68C0\u67E5\u7F51\u7EDC";
1337
+ ReconnectPrompt["CONNECT_PARAM_ERROR"] = "\u6E38\u620F\u53C2\u6570\u9519\u8BEF,\u8BF7\u91CD\u65B0\u52A0\u8F7D";
1338
+ ReconnectPrompt["KICK"] = "\u8D26\u53F7\u5DF2\u4E0B\u7EBF";
1339
+ ReconnectPrompt["OFFLINE"] = "\u7F51\u7EDC\u5DF2\u65AD\u5F00";
1340
+ ReconnectPrompt["ONLINE"] = "\u7F51\u7EDC\u5DF2\u8FDE\u63A5";
1341
+ ReconnectPrompt["GAME_ERROR"] = "\u8FDE\u63A5\u6E38\u620F\u670D\u9519\u8BEF";
1334
1342
  })(ReconnectPrompt || (ReconnectPrompt = {}));
1335
1343
  /**
1336
- * @describe 重连框
1337
- * @author 游金宇(KM)
1338
- * @date 2024-09-12 11:49:51
1339
- */
1344
+ * @describe 重连框
1345
+ * @author 游金宇(KM)
1346
+ * @date 2024-09-12 11:49:51
1347
+ */
1340
1348
  let CoreReconnection = class CoreReconnection extends RootUILayer {
1341
1349
  common_prompt_text;
1342
1350
  btn_confirm;
1343
1351
  is_close = false;
1344
1352
  props = {
1345
- content: null,
1353
+ content: null
1346
1354
  };
1347
1355
  initUI() {
1348
1356
  this.btn_confirm.node.active = false;
@@ -1352,7 +1360,7 @@ let CoreReconnection = class CoreReconnection extends RootUILayer {
1352
1360
  this.addAutorun([
1353
1361
  () => {
1354
1362
  this.common_prompt_text.string = this.props.content ?? '';
1355
- },
1363
+ }
1356
1364
  ]);
1357
1365
  }
1358
1366
  onDestroy() {
@@ -1386,16 +1394,25 @@ let CoreReconnection = class CoreReconnection extends RootUILayer {
1386
1394
  cat.gui.hideReconnect();
1387
1395
  }
1388
1396
  };
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);
1397
+ __decorate([
1398
+ property$4({ type: Label, tooltip: '通用提示文本' }),
1399
+ __metadata("design:type", Label)
1400
+ ], CoreReconnection.prototype, "common_prompt_text", void 0);
1401
+ __decorate([
1402
+ property$4({ type: Button, tooltip: '确定按钮' }),
1403
+ __metadata("design:type", Button)
1404
+ ], CoreReconnection.prototype, "btn_confirm", void 0);
1405
+ CoreReconnection = __decorate([
1406
+ ccclass$4('CoreReconnection'),
1407
+ menu$4("CATCORE/CoreReconnection")
1408
+ ], CoreReconnection);
1392
1409
 
1393
1410
  const { ccclass: ccclass$3, property: property$3, menu: menu$3 } = _decorator;
1394
1411
  /**
1395
- * @describe 通知框
1396
- * @author 游金宇(KM)
1397
- * @date 2024-09-12 11:49:51
1398
- */
1412
+ * @describe 通知框
1413
+ * @author 游金宇(KM)
1414
+ * @date 2024-09-12 11:49:51
1415
+ */
1399
1416
  let CoreNotice = class CoreNotice extends RootUILayer {
1400
1417
  text;
1401
1418
  btn_confirm;
@@ -1413,9 +1430,18 @@ let CoreNotice = class CoreNotice extends RootUILayer {
1413
1430
  this.text.string = `${props.text}`;
1414
1431
  }
1415
1432
  };
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);
1433
+ __decorate([
1434
+ property$3({ type: Label, tooltip: '提示文本' }),
1435
+ __metadata("design:type", Label)
1436
+ ], CoreNotice.prototype, "text", void 0);
1437
+ __decorate([
1438
+ property$3({ type: Button, tooltip: '确定按钮' }),
1439
+ __metadata("design:type", Button)
1440
+ ], CoreNotice.prototype, "btn_confirm", void 0);
1441
+ CoreNotice = __decorate([
1442
+ ccclass$3('CoreNotice'),
1443
+ menu$3("CATCORE/CoreNotice")
1444
+ ], CoreNotice);
1419
1445
 
1420
1446
  /**
1421
1447
  * @describe Scene层 所有的UI层需继承自该自组件
@@ -1428,22 +1454,22 @@ class SceneLayer extends BaseComponent {
1428
1454
  }
1429
1455
 
1430
1456
  /**
1431
- * @describe GUI组件类
1432
- * @author 游金宇(KM)
1433
- * @date 2024-09-12 11:46:22
1434
- */
1457
+ * @describe GUI组件类
1458
+ * @author 游金宇(KM)
1459
+ * @date 2024-09-12 11:46:22
1460
+ */
1435
1461
  const { ccclass: ccclass$2, property: property$2, menu: menu$2 } = _decorator;
1436
1462
  var LayerType;
1437
1463
  (function (LayerType) {
1438
- LayerType[(LayerType['UI'] = 0)] = 'UI';
1464
+ LayerType[LayerType["UI"] = 0] = "UI";
1439
1465
  /**加载 */
1440
- LayerType[(LayerType['LOADING'] = 1)] = 'LOADING';
1466
+ LayerType[LayerType["LOADING"] = 1] = "LOADING";
1441
1467
  /**提示 */
1442
- LayerType[(LayerType['TOAST'] = 2)] = 'TOAST';
1468
+ LayerType[LayerType["TOAST"] = 2] = "TOAST";
1443
1469
  /**断线重连 */
1444
- LayerType[(LayerType['RECONNECTTION'] = 3)] = 'RECONNECTTION';
1470
+ LayerType[LayerType["RECONNECTTION"] = 3] = "RECONNECTTION";
1445
1471
  /**系统服务通知(停机维护) */
1446
- LayerType[(LayerType['NOTICE'] = 4)] = 'NOTICE';
1472
+ LayerType[LayerType["NOTICE"] = 4] = "NOTICE";
1447
1473
  })(LayerType || (LayerType = {}));
1448
1474
  /**Gui层 */
1449
1475
  let Gui = class Gui extends BaseComponent {
@@ -1510,7 +1536,8 @@ let Gui = class Gui extends BaseComponent {
1510
1536
  // 立即显示第一个
1511
1537
  if (this.root_toast.children.length === 0) {
1512
1538
  show();
1513
- } else {
1539
+ }
1540
+ else {
1514
1541
  this.scheduleOnce(show, this.minInterval);
1515
1542
  }
1516
1543
  }
@@ -1537,17 +1564,18 @@ let Gui = class Gui extends BaseComponent {
1537
1564
  props: {
1538
1565
  title,
1539
1566
  mask,
1540
- black,
1541
- },
1567
+ black
1568
+ }
1542
1569
  });
1543
- } else {
1570
+ }
1571
+ else {
1544
1572
  const node = instantiate(this.loading_ui_prefab);
1545
1573
  this.loading_ui_component = node.getComponent(CoreShowLoading).addToParent(this.root_ui, {
1546
1574
  props: {
1547
1575
  title,
1548
1576
  mask,
1549
- black,
1550
- },
1577
+ black
1578
+ }
1551
1579
  });
1552
1580
  }
1553
1581
  return this;
@@ -1567,12 +1595,13 @@ let Gui = class Gui extends BaseComponent {
1567
1595
  const node = instantiate(this.reconnection_ui_prefab);
1568
1596
  this.reconnection_ui_component = node.getComponent(CoreReconnection).addToParent(this.root_ui, {
1569
1597
  props: {
1570
- content: option,
1571
- },
1598
+ content: option
1599
+ }
1572
1600
  });
1573
- } else {
1601
+ }
1602
+ else {
1574
1603
  this.reconnection_ui_component.setUpdateProps({
1575
- content: option,
1604
+ content: option
1576
1605
  });
1577
1606
  }
1578
1607
  return this;
@@ -1604,11 +1633,12 @@ let Gui = class Gui extends BaseComponent {
1604
1633
  let _isReload = isReload ?? false;
1605
1634
  if (typeof options === 'boolean') {
1606
1635
  _isReload = options;
1607
- } else {
1636
+ }
1637
+ else {
1608
1638
  _options = options ?? {};
1609
1639
  }
1610
1640
  log('当前场景', director.getScene()?.uuid, director.getScene()?.name);
1611
- director.once(Director.EVENT_BEFORE_SCENE_LAUNCH, scene => {
1641
+ director.once(Director.EVENT_BEFORE_SCENE_LAUNCH, (scene) => {
1612
1642
  log('Director.EVENT_BEFORE_SCENE_LAUNCH', scene);
1613
1643
  this.changeScene(scene, _options, _isReload);
1614
1644
  });
@@ -1627,10 +1657,10 @@ let Gui = class Gui extends BaseComponent {
1627
1657
  }
1628
1658
  /**
1629
1659
  * 场景变化
1630
- * @param scene 场景
1631
- * @param options 选项
1632
- * @param isReload 是否重新加载
1633
- */
1660
+ * @param scene 场景
1661
+ * @param options 选项
1662
+ * @param isReload 是否重新加载
1663
+ */
1634
1664
  changeScene(scene, options, isReload) {
1635
1665
  this.currentScene = scene.name;
1636
1666
  // 获取当前场景
@@ -1672,7 +1702,7 @@ let Gui = class Gui extends BaseComponent {
1672
1702
  if (component) {
1673
1703
  component.setOptions({
1674
1704
  ...(options?.hook ?? {}),
1675
- ...(options?.props ?? {}),
1705
+ ...(options?.props ?? {})
1676
1706
  });
1677
1707
  // 调用uiNode组件下的showTween方法
1678
1708
  await component.hideTween(options || {});
@@ -1713,19 +1743,22 @@ let Gui = class Gui extends BaseComponent {
1713
1743
  rootNode = ui;
1714
1744
  // 获取组件
1715
1745
  const extendsBaseLayer = ui.components.filter(item => {
1716
- return item instanceof UILayer;
1746
+ return (item instanceof UILayer);
1717
1747
  });
1718
1748
  if (extendsBaseLayer.length) {
1719
1749
  if (extendsBaseLayer.length == 1) {
1720
1750
  component = extendsBaseLayer[0];
1721
- } else {
1751
+ }
1752
+ else {
1722
1753
  warn(`${ui.name}节点存在多个继承自BaseLayer的组件`);
1723
1754
  }
1724
- } else {
1755
+ }
1756
+ else {
1725
1757
  error(`${ui.name}节点未找到继承自BaseLayer的组件`);
1726
1758
  return { rootNode, component };
1727
1759
  }
1728
- } else {
1760
+ }
1761
+ else {
1729
1762
  // ui为T组件
1730
1763
  // 定义一个变量用于保存根节点
1731
1764
  rootNode = ui.node;
@@ -1736,7 +1769,8 @@ let Gui = class Gui extends BaseComponent {
1736
1769
  rootNode = rootNode.parent;
1737
1770
  }
1738
1771
  component.root = rootNode;
1739
- } else {
1772
+ }
1773
+ else {
1740
1774
  rootNode = ui.root;
1741
1775
  }
1742
1776
  }
@@ -1758,38 +1792,71 @@ let Gui = class Gui extends BaseComponent {
1758
1792
  this.cat.event.emit(GlobalEventConstant.ROOT_MASK_CHANGE);
1759
1793
  }
1760
1794
  };
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);
1795
+ __decorate([
1796
+ property$2({ type: Prefab, tooltip: '断线重连UI预制体' }),
1797
+ __metadata("design:type", Prefab)
1798
+ ], Gui.prototype, "reconnection_ui_prefab", void 0);
1799
+ __decorate([
1800
+ property$2({ type: Prefab, tooltip: '提示UI预制体' }),
1801
+ __metadata("design:type", Prefab)
1802
+ ], Gui.prototype, "toast_ui_prefab", void 0);
1803
+ __decorate([
1804
+ property$2({ type: Prefab, tooltip: '加载UI预制体' }),
1805
+ __metadata("design:type", Prefab)
1806
+ ], Gui.prototype, "loading_ui_prefab", void 0);
1807
+ __decorate([
1808
+ property$2({ type: Prefab, tooltip: '公告UI预制体' }),
1809
+ __metadata("design:type", Prefab)
1810
+ ], Gui.prototype, "notice_ui_prefab", void 0);
1811
+ __decorate([
1812
+ property$2({ type: Prefab, tooltip: 'UI层预制体' }),
1813
+ __metadata("design:type", Prefab)
1814
+ ], Gui.prototype, "ui_prefab", void 0);
1815
+ __decorate([
1816
+ property$2({ type: Node, tooltip: 'root-UI层' }),
1817
+ __metadata("design:type", Node)
1818
+ ], Gui.prototype, "root_ui", void 0);
1819
+ __decorate([
1820
+ property$2({ type: Node, tooltip: 'root-组件层' }),
1821
+ __metadata("design:type", Node)
1822
+ ], Gui.prototype, "root_toast", void 0);
1823
+ __decorate([
1824
+ property$2({ type: Node, tooltip: 'root-mask' }),
1825
+ __metadata("design:type", Node)
1826
+ ], Gui.prototype, "root_mask", void 0);
1827
+ Gui = __decorate([
1828
+ ccclass$2('Gui'),
1829
+ menu$2("CATCORE/Gui")
1830
+ ], Gui);
1770
1831
 
1771
1832
  /**遮罩管理 TODO (每个层级都有一个遮罩 但是同时只能出现1个) */
1772
1833
  const { ccclass: ccclass$1, property: property$1, menu: menu$1 } = _decorator;
1773
1834
  let CoreBlackMask = class CoreBlackMask extends BaseComponent {
1774
1835
  tween;
1775
1836
  };
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);
1837
+ __decorate([
1838
+ property$1({ type: Node, tooltip: '动画节点' }),
1839
+ __metadata("design:type", Node)
1840
+ ], CoreBlackMask.prototype, "tween", void 0);
1841
+ CoreBlackMask = __decorate([
1842
+ ccclass$1('CoreBlackMask'),
1843
+ menu$1("CATCORE/CoreBlackMask")
1844
+ ], CoreBlackMask);
1778
1845
 
1779
1846
  /**
1780
- * @describe 层级界面管理
1781
- * @author 游金宇(KM)
1782
- * @date 2023-08-03 20:02:45
1783
- */
1847
+ * @describe 层级界面管理
1848
+ * @author 游金宇(KM)
1849
+ * @date 2023-08-03 20:02:45
1850
+ */
1784
1851
  /**预制体路径 */
1785
1852
  var BasePrefab;
1786
1853
  (function (BasePrefab) {
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';
1854
+ BasePrefab["Root"] = "prefabs/root";
1855
+ BasePrefab["Toast"] = "prefabs/toast";
1856
+ BasePrefab["BlackMask"] = "prefabs/black-mask";
1857
+ BasePrefab["Loading"] = "prefabs/loading";
1858
+ BasePrefab["Notice"] = "prefabs/notice";
1859
+ BasePrefab["Reconnection"] = "prefabs/reconnection";
1793
1860
  })(BasePrefab || (BasePrefab = {}));
1794
1861
  class GuiManager extends BaseManager {
1795
1862
  /**常驻顶层UI节点层级 */
@@ -1806,7 +1873,8 @@ class GuiManager extends BaseManager {
1806
1873
  this.cat.res.load(bundleName, type, (err, prefab) => {
1807
1874
  if (err) {
1808
1875
  reject(err);
1809
- } else {
1876
+ }
1877
+ else {
1810
1878
  resolve(prefab);
1811
1879
  }
1812
1880
  });
@@ -1826,10 +1894,10 @@ class GuiManager extends BaseManager {
1826
1894
  }
1827
1895
 
1828
1896
  /**
1829
- * @describe 游戏资管理
1830
- * @author 游金宇(KM)
1831
- * @date 2023-08-03 17:40:51
1832
- */
1897
+ * @describe 游戏资管理
1898
+ * @author 游金宇(KM)
1899
+ * @date 2023-08-03 17:40:51
1900
+ */
1833
1901
  class ResLoader {
1834
1902
  /**
1835
1903
  * 获取资源
@@ -1844,7 +1912,7 @@ class ResLoader {
1844
1912
  /**
1845
1913
  * 获取资源类型
1846
1914
  */
1847
- isAssetType = value => {
1915
+ isAssetType = (value) => {
1848
1916
  return typeof value === 'function' && value.prototype instanceof Asset;
1849
1917
  };
1850
1918
  async load(...args) {
@@ -1881,9 +1949,11 @@ class ResLoader {
1881
1949
  }
1882
1950
  if (onProgress && onComplete) {
1883
1951
  nonce.load(paths, type, onProgress, onComplete);
1884
- } else if (onComplete) {
1952
+ }
1953
+ else if (onComplete) {
1885
1954
  nonce.load(paths, type, onComplete);
1886
- } else {
1955
+ }
1956
+ else {
1887
1957
  nonce.load(paths, type);
1888
1958
  }
1889
1959
  }
@@ -1918,9 +1988,11 @@ class ResLoader {
1918
1988
  }
1919
1989
  if (onProgress && onComplete) {
1920
1990
  nonce.loadDir(paths, type, onProgress, onComplete);
1921
- } else if (onComplete) {
1991
+ }
1992
+ else if (onComplete) {
1922
1993
  nonce.loadDir(paths, type, onComplete);
1923
- } else {
1994
+ }
1995
+ else {
1924
1996
  nonce.loadDir(paths, type);
1925
1997
  }
1926
1998
  }
@@ -1931,7 +2003,7 @@ class ResLoader {
1931
2003
  options = args.shift();
1932
2004
  }
1933
2005
  onComplete = args.shift();
1934
- assetManager.loadRemote(url, { ext: '.png', ...options }, onComplete);
2006
+ assetManager.loadRemote(url, { ext: ".png", ...options }, onComplete);
1935
2007
  }
1936
2008
  /**
1937
2009
  * 加载bundle
@@ -1948,11 +2020,13 @@ class ResLoader {
1948
2020
  }
1949
2021
  resolve(bundle);
1950
2022
  };
1951
- version ? assetManager.loadBundle(url, { version }, onComplete) : assetManager.loadBundle(url, onComplete);
2023
+ version ?
2024
+ assetManager.loadBundle(url, { version }, onComplete) :
2025
+ assetManager.loadBundle(url, onComplete);
1952
2026
  });
1953
2027
  };
1954
2028
  /** 释放预制依赖资源 */
1955
- releasePrefabtDepsRecursively = uuid => {
2029
+ releasePrefabtDepsRecursively = (uuid) => {
1956
2030
  var asset = assetManager.assets.get(uuid);
1957
2031
  assetManager.releaseAsset(asset);
1958
2032
  if (asset instanceof Prefab) {
@@ -2011,7 +2085,7 @@ let _iv = null;
2011
2085
  * MD5加密
2012
2086
  * @param msg 加密信息
2013
2087
  */
2014
- const md5 = msg => {
2088
+ const md5 = (msg) => {
2015
2089
  return CryptoES.MD5(msg).toString();
2016
2090
  };
2017
2091
  /** 初始化加密库 */
@@ -2044,7 +2118,7 @@ const aesDecrypt = (str, key, iv) => {
2044
2118
  return decrypted.toString(CryptoES.enc.Utf8);
2045
2119
  };
2046
2120
  const JsonFormatter = {
2047
- stringify: cipherParams => {
2121
+ stringify: (cipherParams) => {
2048
2122
  const jsonObj = { ct: cipherParams.ciphertext.toString(CryptoES.enc.Base64) };
2049
2123
  if (cipherParams.iv) {
2050
2124
  jsonObj.iv = cipherParams.iv.toString();
@@ -2054,7 +2128,7 @@ const JsonFormatter = {
2054
2128
  }
2055
2129
  return JSON.stringify(jsonObj);
2056
2130
  },
2057
- parse: jsonStr => {
2131
+ parse: (jsonStr) => {
2058
2132
  const jsonObj = JSON.parse(jsonStr);
2059
2133
  const cipherParams = CryptoES.lib.CipherParams.create({ ciphertext: CryptoES.enc.Base64.parse(jsonObj.ct) });
2060
2134
  if (jsonObj.iv) {
@@ -2067,34 +2141,34 @@ const JsonFormatter = {
2067
2141
  },
2068
2142
  };
2069
2143
 
2070
- var EncryptUtil = /*#__PURE__*/ Object.freeze({
2144
+ var EncryptUtil = /*#__PURE__*/Object.freeze({
2071
2145
  __proto__: null,
2072
2146
  JsonFormatter: JsonFormatter,
2073
2147
  aesDecrypt: aesDecrypt,
2074
2148
  aesEncrypt: aesEncrypt,
2075
2149
  initCrypto: initCrypto,
2076
- md5: md5,
2150
+ md5: md5
2077
2151
  });
2078
2152
 
2079
2153
  /**
2080
- * @describe 工具类
2081
- * @author 游金宇(KM)
2082
- * @date 2023-08-02 20:16:42
2083
- */
2154
+ * @describe 工具类
2155
+ * @author 游金宇(KM)
2156
+ * @date 2023-08-02 20:16:42
2157
+ */
2084
2158
  // 扩展 Manager 接口,添加 Util 属性
2085
2159
  class CoreUtil extends BaseManager {
2086
2160
  encryptUtil = EncryptUtil;
2087
2161
  }
2088
2162
 
2089
2163
  /**
2090
- * @describe 基于社交游戏封装的游戏基础ws类
2091
- * @author 游金宇(KM)
2092
- * @date 2024-09-12 11:47:51
2093
- */
2164
+ * @describe 基于社交游戏封装的游戏基础ws类
2165
+ * @author 游金宇(KM)
2166
+ * @date 2024-09-12 11:47:51
2167
+ */
2094
2168
  class WrapperSocialGameClient extends SocialGameClient {
2095
2169
  /**日志黑名单 */
2096
2170
  logBlackList = [];
2097
- ignore = item => {
2171
+ ignore = (item) => {
2098
2172
  return this.logBlackList.includes(item);
2099
2173
  };
2100
2174
  constructor(name, opts, eventResponsePairs, clientOption) {
@@ -2194,7 +2268,7 @@ class WrapperSocialGameClient extends SocialGameClient {
2194
2268
  // this.handleEvent({ type: 'reconnect' })
2195
2269
  // break;
2196
2270
  // case 'offline'://离线状态
2197
- // // 为了彻底清除上一次的ws(避免有重新连接已发起 但是没完成 导致下次重连时 可能重复重连) 需要将上一次的ws状态清理
2271
+ // // 为了彻底清除上一次的ws(避免有重新连接已发起 但是没完成 导致下次重连时 可能重复重连) 需要将上一次的ws状态清理
2198
2272
  // this.disconnect(true)
2199
2273
  // log('离线状态 offline');
2200
2274
  // this.isNeedReconnect = true;
@@ -2247,37 +2321,21 @@ class WrapperSocialGameClient extends SocialGameClient {
2247
2321
  // }
2248
2322
  async GameRequest(route, reqReflect, resp, audOptions) {
2249
2323
  return new Promise((resolve, reject) => {
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);
2324
+ super.GameRequest(route, reqReflect, resp, audOptions).then((res) => {
2325
+ if (DEBUG) {
2326
+ 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));
2267
2327
  }
2268
- );
2328
+ resolve(res);
2329
+ }, (err) => {
2330
+ cat.gui.showToast({ title: err.msg });
2331
+ reject(err);
2332
+ });
2269
2333
  });
2270
2334
  }
2271
2335
  subscribe(route, respType, fn) {
2272
- super.subscribe(route, respType, data => {
2336
+ super.subscribe(route, respType, (data) => {
2273
2337
  if (DEBUG && !this.ignore(route)) {
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
- );
2338
+ 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));
2281
2339
  }
2282
2340
  cat.event.emit(route, clone(respType, data));
2283
2341
  fn?.(data);
@@ -2300,12 +2358,12 @@ class SocialGameClientManager extends BaseManager {
2300
2358
  this.initGlobalListeners();
2301
2359
  }
2302
2360
  /**
2303
- * 创建并注册WebSocket客户端
2304
- * @param name 客户端唯一标识(如"game", "room")
2305
- * @param clientOption 客户端配置选项
2306
- * @param opts 社交游戏选项
2307
- * @param eventResponsePairs 事件响应配置
2308
- */
2361
+ * 创建并注册WebSocket客户端
2362
+ * @param name 客户端唯一标识(如"game", "room")
2363
+ * @param clientOption 客户端配置选项
2364
+ * @param opts 社交游戏选项
2365
+ * @param eventResponsePairs 事件响应配置
2366
+ */
2309
2367
  createWebSocket(name, clientOption, opts, eventResponsePairs) {
2310
2368
  // 清理同名旧客户端
2311
2369
  if (this.managedClients.has(name)) {
@@ -2315,19 +2373,12 @@ class SocialGameClientManager extends BaseManager {
2315
2373
  log(`清理旧的 ${name} 客户端`);
2316
2374
  }
2317
2375
  // 创建客户端实例
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
- );
2376
+ const client = new WrapperSocialGameClient(name, // 将名称注入配置
2377
+ opts, eventResponsePairs, Object.assign({ reconnectMaxAttempts: Infinity }, {
2378
+ ...clientOption,
2379
+ // 强制关闭自动重连,由管理器统一控制
2380
+ isAutoConnect: false
2381
+ }));
2331
2382
  // 注册并返回
2332
2383
  this.register(client);
2333
2384
  return client;
@@ -2373,40 +2424,38 @@ class SocialGameClientManager extends BaseManager {
2373
2424
  }
2374
2425
  // 统一触发所有WS重连
2375
2426
  async triggerReconnectAll() {
2376
- if (!this.isGlobalOnline || this.isInBackground) return;
2427
+ if (!this.isGlobalOnline || this.isInBackground)
2428
+ return;
2377
2429
  // 如果没有任何客户端需要重连,直接返回
2378
2430
  if (this.managedClients.size === 0) {
2379
- log('没有任何WS需要重连');
2431
+ log("没有任何WS需要重连");
2380
2432
  return;
2381
2433
  }
2382
2434
  cat.gui.showLoading({ title: '正在重连' });
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
- );
2435
+ await Promise.allSettled(this.activeClients.map(async (client) => {
2436
+ try {
2437
+ // 1. 等待物理层重连
2438
+ await client.reconnectPromise();
2439
+ }
2440
+ catch (err) {
2441
+ error(`${client.name}服重连失败`, err);
2442
+ cat.gui.showToast({ title: `${client.name}服重连失败` });
2443
+ // 不抛出错误,让 Promise.allSettled 收集结果
2444
+ }
2445
+ try {
2446
+ // 2. 执行业务层连接请求
2447
+ await client.connectRequest();
2448
+ }
2449
+ catch (err) {
2450
+ error(`${client.name}服登录错误`, err);
2451
+ cat.gui.showToast({ title: `登录${client.name}服错误` });
2452
+ // 同样不抛出错误
2453
+ }
2454
+ }));
2403
2455
  // 检查是否有客户端未成功连接
2404
2456
  const failedClients = this.activeClients.filter(client => client.socketConnectStatus !== SocketConnectStatus.CONNECTED);
2405
2457
  if (failedClients.length > 0) {
2406
- console.error(
2407
- '部分WS重连失败:',
2408
- failedClients.map(name => name)
2409
- );
2458
+ console.error("部分WS重连失败:", failedClients.map((name) => name));
2410
2459
  // 可以在一段时间后再次尝试重连
2411
2460
  setTimeout(() => {
2412
2461
  this.triggerReconnectAll();
@@ -2431,10 +2480,10 @@ class SocialGameClientManager extends BaseManager {
2431
2480
 
2432
2481
  const { ccclass, property, menu } = _decorator;
2433
2482
  /**
2434
- * @describe 模态框
2435
- * @author 游金宇(KM)
2436
- * @date 2024-09-12 11:49:51
2437
- */
2483
+ * @describe 模态框
2484
+ * @author 游金宇(KM)
2485
+ * @date 2024-09-12 11:49:51
2486
+ */
2438
2487
  let CoreUIModal = class CoreUIModal extends UILayer {
2439
2488
  default_title = null;
2440
2489
  title;
@@ -2449,9 +2498,9 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2449
2498
  props = {
2450
2499
  title: this.default_title,
2451
2500
  content: null,
2452
- confirmCB: () => {},
2453
- cancelCB: () => {},
2454
- style: null,
2501
+ confirmCB: () => { },
2502
+ cancelCB: () => { },
2503
+ style: null
2455
2504
  };
2456
2505
  onLoad() {
2457
2506
  this.btn_cancel.node.on(Button.EventType.CLICK, this.onCancelHandler, this);
@@ -2462,29 +2511,32 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2462
2511
  this.title.spriteFrame = this.props?.title || this.default_title;
2463
2512
  },
2464
2513
  () => {
2465
- if (this.props.content instanceof SpriteFrame) {
2466
- //图片
2514
+ if (this.props.content instanceof SpriteFrame) { //图片
2467
2515
  this.prompt_content_spriteFrame.spriteFrame = this.props.content;
2468
- } else if (typeof this.props.content === 'string') {
2516
+ }
2517
+ else if (typeof this.props.content === 'string') {
2469
2518
  this.prompt_content_str.string = this.props.content;
2470
- } else {
2519
+ }
2520
+ else {
2471
2521
  console.error('未知类型的【UIModal】内容');
2472
2522
  }
2473
2523
  },
2474
2524
  () => {
2475
2525
  if (this.props?.style?.confirm === null) {
2476
2526
  this.btn_confirm.node.active = false;
2477
- } else {
2527
+ }
2528
+ else {
2478
2529
  this.btn_confirm.node.active = true;
2479
2530
  this.btn_confirm.getComponent(Sprite).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame;
2480
2531
  }
2481
2532
  if (this.props?.style?.cancel === null) {
2482
2533
  this.btn_cancel.node.active = false;
2483
- } else {
2534
+ }
2535
+ else {
2484
2536
  this.btn_cancel.node.active = true;
2485
2537
  this.btn_cancel.getComponent(Sprite).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame;
2486
2538
  }
2487
- },
2539
+ }
2488
2540
  ]);
2489
2541
  }
2490
2542
  close() {
@@ -2498,47 +2550,63 @@ let CoreUIModal = class CoreUIModal extends UILayer {
2498
2550
  this.props.confirmCB?.();
2499
2551
  }
2500
2552
  onDestroy() {
2501
- if (this.isConfirm) this.props.onDestroy?.();
2553
+ if (this.isConfirm)
2554
+ this.props.onDestroy?.();
2502
2555
  }
2503
2556
  onCloseHandler() {
2504
2557
  this.close();
2505
2558
  }
2506
2559
  };
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);
2560
+ __decorate([
2561
+ property({ type: SpriteFrame, tooltip: '默认标题' }),
2562
+ __metadata("design:type", SpriteFrame)
2563
+ ], CoreUIModal.prototype, "default_title", void 0);
2564
+ __decorate([
2565
+ property({ type: Sprite, tooltip: '标题节点' }),
2566
+ __metadata("design:type", Sprite)
2567
+ ], CoreUIModal.prototype, "title", void 0);
2568
+ __decorate([
2569
+ property({ type: Label, tooltip: '字符串内容按钮' }),
2570
+ __metadata("design:type", Label)
2571
+ ], CoreUIModal.prototype, "prompt_content_str", void 0);
2572
+ __decorate([
2573
+ property({ type: Sprite, tooltip: '图片精灵内容按钮' }),
2574
+ __metadata("design:type", Sprite)
2575
+ ], CoreUIModal.prototype, "prompt_content_spriteFrame", void 0);
2576
+ __decorate([
2577
+ property({ type: Button, tooltip: '确认按钮' }),
2578
+ __metadata("design:type", Button)
2579
+ ], CoreUIModal.prototype, "btn_confirm", void 0);
2580
+ __decorate([
2581
+ property({ type: SpriteFrame, tooltip: '确认按钮精灵图' }),
2582
+ __metadata("design:type", SpriteFrame)
2583
+ ], CoreUIModal.prototype, "confirm_spriteFrame", void 0);
2584
+ __decorate([
2585
+ property({ type: Button, tooltip: '取消按钮' }),
2586
+ __metadata("design:type", Button)
2587
+ ], CoreUIModal.prototype, "btn_cancel", void 0);
2588
+ __decorate([
2589
+ property({ type: SpriteFrame, tooltip: '取消按钮精灵图' }),
2590
+ __metadata("design:type", SpriteFrame)
2591
+ ], CoreUIModal.prototype, "cancel_spriteFrame", void 0);
2592
+ __decorate([
2593
+ property({ type: Button, tooltip: '关闭按钮' }),
2594
+ __metadata("design:type", Button)
2595
+ ], CoreUIModal.prototype, "btn_close", void 0);
2596
+ CoreUIModal = __decorate([
2597
+ ccclass('CoreUIModal'),
2598
+ menu("CATCORE/CoreUIModal")
2599
+ ], CoreUIModal);
2532
2600
 
2533
2601
  /**
2534
- * @describe 时间管理
2535
- * @author 游金宇(KM)
2536
- * @date 2024-09-12 11:49:19
2537
- */
2602
+ * @describe 时间管理
2603
+ * @author 游金宇(KM)
2604
+ * @date 2024-09-12 11:49:19
2605
+ */
2538
2606
  var TimerType;
2539
2607
  (function (TimerType) {
2540
- TimerType[(TimerType['Delay'] = 0)] = 'Delay';
2541
- TimerType[(TimerType['Interval'] = 1)] = 'Interval';
2608
+ TimerType[TimerType["Delay"] = 0] = "Delay";
2609
+ TimerType[TimerType["Interval"] = 1] = "Interval";
2542
2610
  })(TimerType || (TimerType = {}));
2543
2611
  class TimerEntry {
2544
2612
  /** 唯一标识符 */
@@ -2584,7 +2652,7 @@ class TimerManager extends BaseManager {
2584
2652
  }
2585
2653
  onHandleAppForeground() {
2586
2654
  const currentTime = Date.now();
2587
- const elapsedTime = currentTime - this.lastUpdateTime;
2655
+ const elapsedTime = (currentTime - this.lastUpdateTime);
2588
2656
  log('elapsedTime', elapsedTime);
2589
2657
  for (const entry of this.timers.values()) {
2590
2658
  if (entry.remainingTime > 0) {
@@ -2623,9 +2691,9 @@ class TimerManager extends BaseManager {
2623
2691
  this.timers.set(tag, timerEntry);
2624
2692
  }
2625
2693
  /**
2626
- * 取消一个计时器或延时器
2627
- * @param tag 计时器或延时器的唯一标识
2628
- */
2694
+ * 取消一个计时器或延时器
2695
+ * @param tag 计时器或延时器的唯一标识
2696
+ */
2629
2697
  unregister(tag) {
2630
2698
  if (this.has(tag)) {
2631
2699
  this.timers.delete(tag);
@@ -2652,7 +2720,8 @@ class TimerManager extends BaseManager {
2652
2720
  // 如果是计时器,重置剩余时间
2653
2721
  if (entry.type === TimerType.Interval) {
2654
2722
  entry.remainingTime = entry.initialTime; // 重置为初始间隔时间
2655
- } else {
2723
+ }
2724
+ else {
2656
2725
  // 如果是延时器,标记为待删除
2657
2726
  entriesToRemove.push(id);
2658
2727
  }
@@ -2665,12 +2734,11 @@ class TimerManager extends BaseManager {
2665
2734
  }
2666
2735
  }
2667
2736
 
2668
- // 处理微信小程序的编码问题
2669
2737
  /**
2670
- * @describe 管理类
2671
- * @author 游金宇(KM)
2672
- * @date 2024-09-12 11:49:44
2673
- */
2738
+ * @describe 管理类
2739
+ * @author 游金宇(KM)
2740
+ * @date 2024-09-12 11:49:44
2741
+ */
2674
2742
  class Manager {
2675
2743
  static #ins;
2676
2744
  static get instance() {
@@ -2712,7 +2780,7 @@ class Manager {
2712
2780
  this.event = new EventEmitter();
2713
2781
  this.audio = new AudioManager(this);
2714
2782
  this.socialGameClient = new SocialGameClientManager(this);
2715
- this.gui = (await new GuiManager(this).init()).gui;
2783
+ this.gui = (await (new GuiManager(this)).init()).gui;
2716
2784
  }
2717
2785
  }
2718
2786
  const cat = Manager.instance;
@@ -2724,34 +2792,4 @@ game.onPostProjectInitDelegate.add(async () => {
2724
2792
  console.timeEnd('[Init App]');
2725
2793
  });
2726
2794
 
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
- };
2795
+ 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 };