@shimotsuki/core 2.0.14 → 2.0.16

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