@shimotsuki/core 3.0.30 → 3.0.31

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.
@@ -1,2504 +1 @@
1
- import e from "@babel/runtime-corejs3/core-js/global-this";
2
-
3
- import { AudioSource as t, _decorator as i, AudioClip as n, error as o, Node as s, director as r, log as a, Component as l, Prefab as c, instantiate as h, isValid as u, Layers as d, view as p, Widget as f, v3 as m, tween as g, Enum as y, game as _, Label as b, UIOpacity as v, Tween as C, BlockInputEvents as E, Button as S, assetManager as w, Director as O, warn as A, AsyncDelegate as T, Game as I, Asset as k, resources as R, sys as M, SpriteFrame as U, Sprite as N } from "cc";
4
-
5
- import D from "@babel/runtime-corejs3/core-js-stable/reflect/get";
6
-
7
- import L from "@babel/runtime-corejs3/core-js-stable/reflect/set";
8
-
9
- import j from "@babel/runtime-corejs3/core-js-stable/object/assign";
10
-
11
- import x from "@babel/runtime-corejs3/core-js-stable/promise";
12
-
13
- import B from "eventemitter3";
14
-
15
- import F from "@babel/runtime-corejs3/core-js-stable/instance/includes";
16
-
17
- import P from "@babel/runtime-corejs3/core-js-stable/json/stringify";
18
-
19
- import G from "@babel/runtime-corejs3/core-js-stable/map";
20
-
21
- import H from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
22
-
23
- import $ from "@babel/runtime-corejs3/core-js-stable/instance/filter";
24
-
25
- import K from "@babel/runtime-corejs3/core-js-stable/array/is-array";
26
-
27
- import W from "@babel/runtime-corejs3/core-js-stable/reflect/own-keys";
28
-
29
- import V from "@babel/runtime-corejs3/core-js-stable/instance/bind";
30
-
31
- import { makeObservable as z, observable as q, autorun as Q, reaction as J } from "@shimotsuki/mobx";
32
-
33
- import X from "@babel/runtime-corejs3/core-js-stable/set-timeout";
34
-
35
- import Z from "@babel/runtime-corejs3/core-js-stable/instance/map";
36
-
37
- import Y from "@babel/runtime-corejs3/core-js-stable/array/from";
38
-
39
- import ee from "@babel/runtime-corejs3/core-js-stable/date/now";
40
-
41
- import te from "@babel/runtime-corejs3/core-js-stable/instance/every";
42
-
43
- import { SocketConnectStatus as ie } from "pitayaclient";
44
-
45
- import { DEBUG as ne, WECHAT as oe, PREVIEW as se } from "cc/env";
46
-
47
- import { SocialGameClient as re } from "sgc";
48
-
49
- import ae from "crypto-es";
50
-
51
- import le from "@babel/runtime-corejs3/core-js-stable/set-interval";
52
-
53
- import ce from "@babel/runtime-corejs3/core-js-stable/instance/values";
54
-
55
- import he from "@babel/runtime-corejs3/core-js-stable/instance/entries";
56
-
57
- class CommonAudio extends t {
58
- cat;
59
- initAudio(e) {
60
- this.cat = e;
61
- return this;
62
- }
63
- }
64
-
65
- const {ccclass: ue, menu: de} = i;
66
-
67
- let pe = class AudioEffect extends CommonAudio {
68
- effects=(() => new G)();
69
- load(e, t) {
70
- return new x((i, o) => {
71
- let s = null;
72
- let r;
73
- if (t !== undefined) {
74
- s = e;
75
- r = t;
76
- } else {
77
- r = e;
78
- }
79
- const a = (e, t) => {
80
- if (e) {
81
- return o(e);
82
- }
83
- this.effects.set(r, t);
84
- this.playOneShot(t, this.volume);
85
- i(t);
86
- };
87
- s ? this.cat.res.load(s, r, n, a) : this.cat.res.load(r, n, a);
88
- });
89
- }
90
- release() {
91
- for (let e in this.effects) {
92
- this.cat.res.release(e);
93
- }
94
- this.effects.clear();
95
- }
96
- };
97
-
98
- const {ccclass: fe, menu: me} = i;
99
-
100
- class AudioMusic extends CommonAudio {
101
- onComplete=null;
102
- _progress=0;
103
- _url=null;
104
- _isPlay=false;
105
- get progress() {
106
- if (this.duration > 0) this._progress = this.currentTime / this.duration;
107
- return this._progress;
108
- }
109
- set progress(e) {
110
- this._progress = e;
111
- this.currentTime = e * this.duration;
112
- }
113
- load(e, t) {
114
- return new x((i, s) => {
115
- let r = null;
116
- let a;
117
- if (t !== undefined) {
118
- r = e;
119
- a = t;
120
- } else {
121
- a = e;
122
- }
123
- const l = (e, t) => {
124
- if (e) {
125
- o(e);
126
- return s(e);
127
- }
128
- if (this.playing) {
129
- this._isPlay = false;
130
- this.stop();
131
- this.cat.res.release(this._url);
132
- }
133
- this.playOnAwake = false;
134
- this.enabled = true;
135
- this.clip = t;
136
- this._url = a;
137
- i(t);
138
- };
139
- r ? this.cat.res.load(r, a, n, l) : this.cat.res.load(a, n, l);
140
- });
141
- }
142
- update(e) {
143
- if (this.currentTime > 0) {
144
- this._isPlay = true;
145
- }
146
- if (this._isPlay && this.playing == false) {
147
- this._isPlay = false;
148
- this.enabled = false;
149
- this.onComplete && this.onComplete();
150
- }
151
- }
152
- release() {
153
- if (this._url) {
154
- this.cat.res.release(this._url);
155
- this._url = null;
156
- }
157
- }
158
- }
159
-
160
- class BaseManager {
161
- cat;
162
- constructor(e) {
163
- this.cat = e;
164
- }
165
- }
166
-
167
- var ge;
168
-
169
- (function(e) {
170
- e["MUSIC_ON"] = "AudioEventConstant/MUSIC_ON";
171
- e["MUSIC_OFF"] = "AudioEventConstant/MUSIC_OFF";
172
- e["EFFECT_ON"] = "AudioEventConstant/EFFECT_ON";
173
- e["EFFECT_OFF"] = "AudioEventConstant/EFFECT_OFF";
174
- e["PAUSE_AUDIO"] = "AudioEventConstant/PAUSE_AUDIO";
175
- e["RESUME_AUDIO"] = "AudioEventConstant/RESUME_AUDIO";
176
- })(ge || (ge = {}));
177
-
178
- class AudioManager extends BaseManager {
179
- local_data={};
180
- music;
181
- effect;
182
- _volume_music=1;
183
- _volume_effect=1;
184
- _switch_music=true;
185
- _switch_effect=true;
186
- local_store_key="game_audio";
187
- extra={};
188
- constructor(e) {
189
- super(e);
190
- this.local_store_key = this.cat.audio_local_store_key;
191
- var t = new s("UIAudioManager");
192
- r.addPersistRootNode(t);
193
- var i = new s("UIMusic");
194
- i.parent = t;
195
- this.music = i.addComponent(AudioMusic).initAudio(e);
196
- var n = new s("UIEffect");
197
- n.parent = t;
198
- this.effect = n.addComponent(pe).initAudio(e);
199
- this.load();
200
- }
201
- setMusicComplete() {
202
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
203
- this.music.onComplete = e;
204
- }
205
- async playMusic(e, t) {
206
- this.music.loop = true;
207
- let i;
208
- let n;
209
- if (t !== undefined) {
210
- n = e;
211
- i = t;
212
- } else {
213
- i = e;
214
- }
215
- if (!i.length) return;
216
- await (n ? this.music.load(n, i) : this.music.load(i)).then(() => {
217
- if (this._switch_music) {
218
- this.music.play();
219
- }
220
- });
221
- }
222
- stopMusic() {
223
- if (this.music.state != 0) this.music?.stop();
224
- }
225
- pauseMusic() {
226
- if (this.music.state == 1) this.music?.pause();
227
- }
228
- resumeMusic() {
229
- var e;
230
- if (F(e = [ 0, 2 ]).call(e, this.music.state)) this.music?.play();
231
- }
232
- get progressMusic() {
233
- return this.music.progress;
234
- }
235
- set progressMusic(e) {
236
- this.music.progress = e;
237
- }
238
- get volumeMusic() {
239
- return this._volume_music;
240
- }
241
- set volumeMusic(e) {
242
- this._volume_music = e;
243
- this.music.volume = e;
244
- }
245
- get switchMusic() {
246
- return this._switch_music;
247
- }
248
- set switchMusic(e) {
249
- a("设置背景音乐开关值", e, this._switch_music);
250
- if (e == this._switch_music) return;
251
- this._switch_music = e;
252
- e ? this.resumeMusic() : this.pauseMusic();
253
- const t = e ? ge.MUSIC_ON : ge.MUSIC_OFF;
254
- this.cat.event.emit(t);
255
- this.save();
256
- }
257
- async playEffect(e, t) {
258
- if (!this._switch_effect) return;
259
- let i;
260
- let n;
261
- if (t !== undefined) {
262
- n = e;
263
- i = t;
264
- } else {
265
- i = e;
266
- }
267
- if (!i.length) return;
268
- await (n ? this.effect.load(n, i) : this.effect.load(i)).then(() => {
269
- this.effect.play();
270
- });
271
- }
272
- stopEffect() {
273
- this.effect?.stop();
274
- }
275
- get volumeEffect() {
276
- return this._volume_effect;
277
- }
278
- set volumeEffect(e) {
279
- this._volume_effect = e;
280
- this.effect.volume = e;
281
- }
282
- get switchEffect() {
283
- return this._switch_effect;
284
- }
285
- set switchEffect(e) {
286
- if (e == this._switch_effect) return;
287
- this._switch_effect = e;
288
- e ? this.effect?.play() : this.effect?.stop();
289
- const t = e ? ge.EFFECT_ON : ge.EFFECT_OFF;
290
- this.cat.event.emit(t);
291
- this.save();
292
- }
293
- resumeAll() {
294
- this.switchMusic && this.music?.play();
295
- this.switchEffect && this.effect?.play();
296
- }
297
- pauseAll() {
298
- this.music?.pause();
299
- this.effect?.pause();
300
- }
301
- stopAll() {
302
- this.music?.stop();
303
- this.effect?.stop();
304
- }
305
- save() {
306
- this.local_data.volume_music = this._volume_music;
307
- this.local_data.volume_effect = this._volume_effect;
308
- this.local_data.switch_music = this._switch_music;
309
- this.local_data.switch_effect = this._switch_effect;
310
- this.local_data.extra = this.extra;
311
- let e = P(this.local_data);
312
- this.cat.storage.set(this.local_store_key, e);
313
- return this;
314
- }
315
- load() {
316
- try {
317
- let e = this.cat.storage.get(this.local_store_key);
318
- this.local_data = JSON.parse(e);
319
- this._volume_music = this.local_data.volume_music;
320
- this._volume_effect = this.local_data.volume_effect;
321
- this._switch_music = this.local_data.switch_music;
322
- this._switch_effect = this.local_data.switch_effect;
323
- this.extra = this.local_data.extra;
324
- } catch (e) {
325
- this.local_data = {};
326
- this._volume_music = .6;
327
- this._volume_effect = 1;
328
- this._switch_music = true;
329
- this._switch_effect = true;
330
- this.extra = {};
331
- }
332
- if (this.music) this.music.volume = this._volume_music;
333
- if (this.effect) this.effect.volume = this._volume_effect;
334
- }
335
- }
336
-
337
- function ye(e, t, i, n) {
338
- var o = arguments.length, s = o < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, i) : n, r;
339
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") s = Reflect.decorate(e, t, i, n); else for (var a = e.length - 1; a >= 0; a--) if (r = e[a]) s = (o < 3 ? r(s) : o > 3 ? r(t, i, s) : r(t, i)) || s;
340
- return o > 3 && s && Object.defineProperty(t, i, s), s;
341
- }
342
-
343
- function _e(e, t) {
344
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(e, t);
345
- }
346
-
347
- typeof SuppressedError === "function" ? SuppressedError : function(e, t, i) {
348
- var n = new Error(i);
349
- return n.name = "SuppressedError", n.error = e, n.suppressed = t, n;
350
- };
351
-
352
- class BaseComponent extends l {
353
- props={};
354
- data={};
355
- cat=(() => e._cat)();
356
- autorunDisposers=[];
357
- reactionDisposers=[];
358
- eventEmitter=[];
359
- hook={
360
- destroyed: () => {},
361
- started: () => {}
362
- };
363
- initUI() {}
364
- __preload() {
365
- this.initUI();
366
- this.onAutoObserver();
367
- }
368
- constructor() {
369
- super();
370
- z(this, {
371
- props: q,
372
- data: q
373
- });
374
- }
375
- onAutoObserver() {}
376
- addAutorun(e) {
377
- const t = K(e) ? e : [ e ];
378
- H(t).call(t, e => {
379
- const t = Q(e);
380
- this.autorunDisposers.push(t);
381
- });
382
- return this;
383
- }
384
- addReaction(e, t, i) {
385
- const n = J(e, t, i);
386
- this.reactionDisposers.push(n);
387
- return this;
388
- }
389
- addAudoListener(e) {
390
- var t;
391
- if (!F(t = this.eventEmitter).call(t, e) && e !== this.cat.event) {
392
- this.eventEmitter.push(e);
393
- }
394
- return e;
395
- }
396
- _onPreDestroy() {
397
- var e, t;
398
- H(e = this.autorunDisposers).call(e, e => {
399
- e();
400
- });
401
- H(t = this.reactionDisposers).call(t, e => {
402
- e();
403
- });
404
- this.autorunDisposers = [];
405
- this.reactionDisposers = [];
406
- if (!super._onPreDestroy) {
407
- throw new Error("_onPreDestroy已弃用");
408
- } else {
409
- super._onPreDestroy();
410
- }
411
- }
412
- onDisable() {
413
- var e;
414
- this.onHide();
415
- this.deleteAllEventByEmitter(this.cat.event);
416
- H(e = this.eventEmitter).call(e, e => {
417
- this.deleteAllEventByEmitter(e);
418
- });
419
- this.eventEmitter = [];
420
- this.removeListener();
421
- }
422
- deleteAllEventByEmitter(e) {
423
- const t = e["_events"];
424
- for (const i in t) {
425
- let n = t[i];
426
- if (!K(n)) {
427
- n = [ n ];
428
- }
429
- H(n).call(n, t => {
430
- if (t.context === this) {
431
- e.off(i, t.fn, this);
432
- }
433
- });
434
- }
435
- }
436
- onEnable() {
437
- this.onShow();
438
- this.addListener();
439
- this.onEventListener();
440
- }
441
- onEventListener() {}
442
- addListener() {}
443
- removeListener() {}
444
- addToParent(e, t, i) {
445
- const n = e instanceof c ? h(e) : e instanceof l ? e.node : e;
446
- if (typeof t === "number") {
447
- const e = t;
448
- const o = i;
449
- this.setOptions(o);
450
- n.insertChild(this.node, e);
451
- } else {
452
- const e = t;
453
- this.setOptions(e);
454
- n.addChild(this.node);
455
- }
456
- return this;
457
- }
458
- setOptions(e) {
459
- if (!e) return;
460
- for (let t in e) {
461
- switch (t) {
462
- case "hook":
463
- e.hook && (this.hook = e.hook);
464
- break;
465
-
466
- case "props":
467
- if (e.props !== null && typeof e.props === "object") {
468
- this.props = e.props;
469
- }
470
- break;
471
-
472
- case "data":
473
- if (e.data !== null && typeof e.data === "object") {
474
- this.data = e.data;
475
- }
476
- break;
477
- }
478
- }
479
- }
480
- setUpdateData(e) {
481
- if (!this.data) return;
482
- e && j(this.data, this.toPlainObject(e));
483
- return this;
484
- }
485
- setUpdateProps(e) {
486
- if (!this.props) return;
487
- e && j(this.props, this.toPlainObject(e));
488
- return this;
489
- }
490
- toPlainObject(e) {
491
- const t = {};
492
- for (const i of W(e)) {
493
- if (typeof i === "string") {
494
- try {
495
- t[i] = e[i];
496
- } catch {}
497
- }
498
- }
499
- return t;
500
- }
501
- removeAndDestroy() {
502
- if (u(this?.node)) {
503
- this.node.removeFromParent();
504
- this.node.destroy();
505
- }
506
- }
507
- setPosition(e) {
508
- this.node.setPosition(e);
509
- return this;
510
- }
511
- setScale(e) {
512
- this.node.setScale(e);
513
- return this;
514
- }
515
- setAngle(e) {
516
- this.node.angle = e;
517
- return this;
518
- }
519
- setRotation(e) {
520
- this.node.setRotation(e);
521
- return this;
522
- }
523
- setRotationFromEuler(e) {
524
- this.node.setRotationFromEuler(e);
525
- return this;
526
- }
527
- onShow() {}
528
- onHide() {}
529
- setNodeAndChildrenLayer(e) {
530
- be(this.node, e);
531
- return this;
532
- }
533
- }
534
-
535
- const be = (e, t) => {
536
- var i, n, o;
537
- e.layer = typeof t === "string" ? 2 ** d.nameToLayer(t) : t;
538
- ((i = e) == null ? void 0 : V(o = Function.call).call(o, H(n = i.children), n))?.(e => {
539
- be(e, t);
540
- });
541
- };
542
-
543
- class UILayer extends BaseComponent {
544
- lastEnterDirection="center";
545
- screen;
546
- isClosing=false;
547
- root;
548
- constructor() {
549
- super();
550
- this._init();
551
- }
552
- _init() {
553
- this.root = this.node;
554
- this.screen = p.getVisibleSize();
555
- }
556
- async showTween(e) {
557
- let {isMotion: t = true, direction: i = "center", duration: n = .1, isBounce: o = true, bounceDuration: s = .05} = e;
558
- this.lastEnterDirection = i;
559
- if (t) {
560
- const e = this.node.getComponent(f);
561
- if (e) {
562
- e.updateAlignment();
563
- e.enabled = false;
564
- }
565
- let t;
566
- let s;
567
- m(1.1, 1.1, 1);
568
- if (i == "center") {
569
- t = m(.01, .01, .01);
570
- s = m(1, 1, 1);
571
- } else {
572
- if (i == "left") {
573
- t = m(-this.screen.width, 0, 0);
574
- } else if (i == "right") {
575
- t = m(this.screen.width, 0, 0);
576
- } else if (i == "top") {
577
- t = m(0, this.screen.height, 0);
578
- } else {
579
- t = m(0, -this.screen.height, 0);
580
- }
581
- s = m(0, 0, 0);
582
- }
583
- await this.handle(i, n, t, s, o);
584
- if (e) e.enabled = true;
585
- }
586
- }
587
- async hideTween(e) {
588
- let {isMotion: t = true, direction: i, duration: n = .1} = e;
589
- i = i || this.lastEnterDirection;
590
- if (this.isClosing) return;
591
- this.isClosing = true;
592
- g(this.node).removeSelf();
593
- if (t) {
594
- const e = this.node.getComponent(f);
595
- if (e) e.enabled = false;
596
- let t;
597
- let o;
598
- if (i == "center") {
599
- t = this.node.scale;
600
- o = m(0, 0, 0);
601
- } else {
602
- if (i == "left") {
603
- o = m(-this.screen.width, 0, 0);
604
- } else if (i == "right") {
605
- o = m(this.screen.width, 0, 0);
606
- } else if (i == "top") {
607
- o = m(0, this.screen.height, 0);
608
- } else {
609
- o = m(0, -this.screen.height, 0);
610
- }
611
- t = this.node.getPosition();
612
- }
613
- await this.handle(i, n, t, o, false);
614
- }
615
- this.removeAndDestroy();
616
- }
617
- async handle(e, t, i, n, o) {
618
- if (e == "center") {
619
- this.node.setScale(i);
620
- } else {
621
- this.node.setPosition(i);
622
- }
623
- await this.deftween(t, {
624
- [e == "center" ? "scale" : "position"]: n
625
- }, o);
626
- }
627
- deftween(e, t, i, n) {
628
- return new x((i, n) => {
629
- g(this.node).to(e, t).call(() => {
630
- i();
631
- }).start();
632
- });
633
- }
634
- }
635
-
636
- var ve;
637
-
638
- const {ccclass: Ce, property: Ee} = i;
639
-
640
- var Se;
641
-
642
- (function(e) {
643
- e[e["EFFECT"] = 0] = "EFFECT";
644
- e[e["BGM"] = 1] = "BGM";
645
- })(Se || (Se = {}));
646
-
647
- class AudioSourceBaseComponent extends BaseComponent {
648
- type=(() => Se.EFFECT)();
649
- clip=null;
650
- loop=false;
651
- volume=1;
652
- playOnAwake=false;
653
- audioSource=(() => new t)();
654
- onEnable() {
655
- super.onEnable();
656
- this.clip && (this.audioSource.clip = this.clip);
657
- this.audioSource.loop = this.loop;
658
- this.audioSource.volume = this.volume;
659
- this.audioSource.playOnAwake = this.playOnAwake;
660
- this.cat.event.on(ge.EFFECT_ON, this.onPlayEffectHandler, this).on(ge.EFFECT_OFF, this.onStopEffectHandler, this).on(ge.MUSIC_ON, this.onPlayMusicHandler, this).on(ge.MUSIC_OFF, this.onStopMusicHandler, this);
661
- }
662
- __preload() {
663
- super.__preload();
664
- const {volumeEffect: e, volumeMusic: t} = this.cat.audio;
665
- this.audioSource.volume = this.type === Se.BGM ? t : e;
666
- }
667
- start() {}
668
- stopAudio() {
669
- this.audioSource.stop();
670
- }
671
- playAudio() {
672
- const {switchEffect: e, switchMusic: t} = this.cat.audio;
673
- if (!this.audioSource.playing && (this.type === Se.BGM ? t : e) && !_._paused) this.audioSource.play();
674
- }
675
- onPlayEffectHandler() {}
676
- onStopEffectHandler() {
677
- this.stopAudio();
678
- }
679
- onPlayMusicHandler() {}
680
- onStopMusicHandler() {
681
- this.stopAudio();
682
- }
683
- _onPreDestroy() {
684
- this.onStopMusicHandler();
685
- super._onPreDestroy();
686
- }
687
- }
688
-
689
- ye([ Ee({
690
- tooltip: `类型:\n EFFECT 音效\n BGM 音乐`,
691
- type: y(Se)
692
- }), _e("design:type", Number) ], AudioSourceBaseComponent.prototype, "type", void 0);
693
-
694
- ye([ Ee({
695
- tooltip: "音源",
696
- type: n
697
- }), _e("design:type", typeof (ve = typeof n !== "undefined" && n) === "function" ? ve : Object) ], AudioSourceBaseComponent.prototype, "clip", void 0);
698
-
699
- ye([ Ee({
700
- tooltip: "循环"
701
- }), _e("design:type", Boolean) ], AudioSourceBaseComponent.prototype, "loop", void 0);
702
-
703
- ye([ Ee({
704
- tooltip: "音量"
705
- }), _e("design:type", Number) ], AudioSourceBaseComponent.prototype, "volume", void 0);
706
-
707
- ye([ Ee({
708
- tooltip: "是否启用自动播放"
709
- }), _e("design:type", Boolean) ], AudioSourceBaseComponent.prototype, "playOnAwake", void 0);
710
-
711
- var we;
712
-
713
- const {ccclass: Oe, property: Ae} = i;
714
-
715
- class AudioSourceUILayer extends UILayer {
716
- type=(() => Se.EFFECT)();
717
- clip=null;
718
- loop=false;
719
- volume=1;
720
- playOnAwake=false;
721
- audioSource=(() => new t)();
722
- onEnable() {
723
- super.onEnable();
724
- this.cat.event.on(ge.EFFECT_ON, this.onPlayEffectHandler, this).on(ge.EFFECT_OFF, this.onStopEffectHandler, this).on(ge.MUSIC_ON, this.onPlayMusicHandler, this).on(ge.MUSIC_OFF, this.onStopMusicHandler, this);
725
- }
726
- __preload() {
727
- this.clip && (this.audioSource.clip = this.clip);
728
- this.audioSource.loop = this.loop;
729
- this.audioSource.volume = this.volume;
730
- this.audioSource.playOnAwake = this.playOnAwake;
731
- super.__preload();
732
- const {volumeEffect: e, volumeMusic: t} = this.cat.audio;
733
- this.audioSource.volume = this.type === Se.BGM ? t : e;
734
- }
735
- stopAudio() {
736
- this.audioSource.stop();
737
- }
738
- playAudio() {
739
- const {switchEffect: e, switchMusic: t} = this.cat.audio;
740
- if (!this.audioSource.playing && (this.type === Se.BGM ? t : e) && !_._paused) this.audioSource.play();
741
- }
742
- onPlayEffectHandler() {}
743
- onStopEffectHandler() {
744
- this.stopAudio();
745
- }
746
- onPlayMusicHandler() {}
747
- onStopMusicHandler() {
748
- this.stopAudio();
749
- }
750
- _onPreDestroy() {
751
- this.onStopMusicHandler();
752
- super._onPreDestroy();
753
- }
754
- }
755
-
756
- ye([ Ae({
757
- tooltip: `类型:\n EFFECT 音效\n BGM 音乐`,
758
- type: y(Se)
759
- }), _e("design:type", Number) ], AudioSourceUILayer.prototype, "type", void 0);
760
-
761
- ye([ Ae({
762
- tooltip: "音源",
763
- type: n
764
- }), _e("design:type", typeof (we = typeof n !== "undefined" && n) === "function" ? we : Object) ], AudioSourceUILayer.prototype, "clip", void 0);
765
-
766
- ye([ Ae({
767
- tooltip: "循环"
768
- }), _e("design:type", Boolean) ], AudioSourceUILayer.prototype, "loop", void 0);
769
-
770
- ye([ Ae({
771
- tooltip: "音量"
772
- }), _e("design:type", Number) ], AudioSourceUILayer.prototype, "volume", void 0);
773
-
774
- ye([ Ae({
775
- tooltip: "是否启用自动播放"
776
- }), _e("design:type", Boolean) ], AudioSourceUILayer.prototype, "playOnAwake", void 0);
777
-
778
- var Te, Ie, ke, Re;
779
-
780
- const {ccclass: Me, property: Ue, menu: Ne} = i;
781
-
782
- var De;
783
-
784
- (function(e) {
785
- e[e["FIXED"] = 0] = "FIXED";
786
- e[e["SLIDE"] = 1] = "SLIDE";
787
- })(De || (De = {}));
788
-
789
- let Le = class CoreToast extends BaseComponent {
790
- fixed_node;
791
- slide_node;
792
- fixed_label;
793
- slide_label;
794
- onLoad() {
795
- this.fixed_node.active = this.slide_node.active = false;
796
- }
797
- start() {
798
- this.show();
799
- }
800
- async show() {
801
- return new x(async (e, t) => {
802
- const {title: i, type: n, fixed_time: o} = this.props;
803
- if (n == De.FIXED) {
804
- this.fixed_node.active = true;
805
- this.fixed_label.string = `${i}`;
806
- this.scheduleOnce(() => {
807
- this.node.destroy();
808
- e();
809
- }, o);
810
- } else {
811
- this.slide_node.active = true;
812
- this.slide_label.string = `${i}`;
813
- this.playAnim(this.node).then(() => {
814
- e();
815
- });
816
- }
817
- });
818
- }
819
- playAnim(e) {
820
- return new x((t, i) => {
821
- const n = 1.2;
822
- const o = .5;
823
- const s = this.node.getComponent(v);
824
- const r = g(s).delay(n).to(o, {
825
- opacity: 0
826
- }).call(() => {
827
- C.stopAllByTarget(e);
828
- this.node.destroy();
829
- t();
830
- });
831
- g(e).by(o, {
832
- position: m(0, 400, 0)
833
- }).call(() => {
834
- r.start();
835
- }).start();
836
- });
837
- }
838
- onDestroy() {
839
- C.stopAllByTarget(this.node);
840
- this.unscheduleAllCallbacks();
841
- }
842
- };
843
-
844
- ye([ Ue({
845
- type: s,
846
- tooltip: "固定节点"
847
- }), _e("design:type", typeof (Te = typeof s !== "undefined" && s) === "function" ? Te : Object) ], Le.prototype, "fixed_node", void 0);
848
-
849
- ye([ Ue({
850
- type: s,
851
- tooltip: "滑动节点"
852
- }), _e("design:type", typeof (Ie = typeof s !== "undefined" && s) === "function" ? Ie : Object) ], Le.prototype, "slide_node", void 0);
853
-
854
- ye([ Ue({
855
- type: b,
856
- tooltip: "固定标签节点"
857
- }), _e("design:type", typeof (ke = typeof b !== "undefined" && b) === "function" ? ke : Object) ], Le.prototype, "fixed_label", void 0);
858
-
859
- ye([ Ue({
860
- type: b,
861
- tooltip: "滑动标签节点"
862
- }), _e("design:type", typeof (Re = typeof b !== "undefined" && b) === "function" ? Re : Object) ], Le.prototype, "slide_label", void 0);
863
-
864
- Le = ye([ Me("CoreToast"), Ne("CATCORE/CoreToast") ], Le);
865
-
866
- var je;
867
-
868
- (function(e) {
869
- e["EVENT_SHOW"] = "GlobalEventConstant/EVENT_SHOW";
870
- e["EVENT_HIDE"] = "GlobalEventConstant/EVENT_HIDE";
871
- e["GAME_RESIZE"] = "GlobalEventConstant/GAME_RESIZE";
872
- e["EVENT_CLOSE"] = "GlobalEventConstant/EVENT_CLOSE";
873
- e["ONLINE"] = "GlobalEventConstant/ONLINE";
874
- e["OFFLINE"] = "GlobalEventConstant/OFFLINE";
875
- e["ROOT_MASK_UPDATE"] = "GlobalEventConstant/ROOT_MASK_UPDATE";
876
- e["ROOT_MASK_CHANGE"] = "GlobalEventConstant/ROOT_MASK_CHANGE";
877
- })(je || (je = {}));
878
-
879
- var xe;
880
-
881
- const {ccclass: Be, property: Fe, menu: Pe} = i;
882
-
883
- let Ge = class CoreBlackMask extends BaseComponent {
884
- tween;
885
- };
886
-
887
- ye([ Fe({
888
- type: s,
889
- tooltip: "动画节点"
890
- }), _e("design:type", typeof (xe = typeof s !== "undefined" && s) === "function" ? xe : Object) ], Ge.prototype, "tween", void 0);
891
-
892
- Ge = ye([ Be("CoreBlackMask"), Pe("CATCORE/CoreBlackMask") ], Ge);
893
-
894
- var He, $e;
895
-
896
- const {ccclass: Ke, property: We, menu: Ve} = i;
897
-
898
- let ze = class CoreUIContainer extends UILayer {
899
- scene_mask_node;
900
- ui_container;
901
- gui=null;
902
- onLoad() {
903
- this.setSceneMaskActive(false);
904
- }
905
- get scene_mask() {
906
- return this.scene_mask_node.getComponent(Ge);
907
- }
908
- get brother() {
909
- return this.ui_container.children || [];
910
- }
911
- get tweenChildren() {
912
- return this.scene_mask.tween.children;
913
- }
914
- onEventListener() {
915
- this.cat.event.on(je.ROOT_MASK_CHANGE, this.uiMaskChanged, this);
916
- }
917
- addMask() {
918
- const e = this.brother[this.brother.length - 1];
919
- e && this.scene_mask.node.setSiblingIndex(e.getSiblingIndex());
920
- this.blockMaskSiblingIndexChanged();
921
- }
922
- subMask() {
923
- const e = this.brother[this.brother.length - 2];
924
- e && this.scene_mask.node.setSiblingIndex(e.getSiblingIndex());
925
- this.blockMaskSiblingIndexChanged();
926
- }
927
- blockMaskSiblingIndexChanged() {
928
- this.tweenChildren.length > 1 || this.brother.length > 1 ? this.show() : this.hide();
929
- }
930
- addNodeToTween(e) {
931
- if (u(this) && this.scene_mask) {
932
- this.scene_mask.tween.addChild(e);
933
- }
934
- return this;
935
- }
936
- show() {
937
- this.setSceneMaskActive(true);
938
- }
939
- hide() {
940
- this.setSceneMaskActive(false);
941
- }
942
- setGui(e) {
943
- this.gui = e;
944
- return this;
945
- }
946
- uiMaskChanged() {
947
- this.blockMaskSiblingIndexChanged();
948
- }
949
- setSceneMaskActive(e) {
950
- this.scene_mask.node.active = e;
951
- }
952
- };
953
-
954
- ye([ We({
955
- type: s
956
- }), _e("design:type", typeof (He = typeof s !== "undefined" && s) === "function" ? He : Object) ], ze.prototype, "scene_mask_node", void 0);
957
-
958
- ye([ We({
959
- type: s
960
- }), _e("design:type", typeof ($e = typeof s !== "undefined" && s) === "function" ? $e : Object) ], ze.prototype, "ui_container", void 0);
961
-
962
- ze = ye([ Ke("CoreUIContainer"), Ve("CATCORE/CoreUIContainer") ], ze);
963
-
964
- class RootUILayer extends UILayer {
965
- onEnable() {
966
- super.onEnable();
967
- this.updateMask();
968
- }
969
- onDisable() {
970
- super.onDisable();
971
- this.updateMask();
972
- }
973
- updateMask() {
974
- this.cat.event.emit(je.ROOT_MASK_UPDATE);
975
- }
976
- }
977
-
978
- var qe, Qe;
979
-
980
- const {ccclass: Je, property: Xe, menu: Ze} = i;
981
-
982
- let Ye = class CoreShowLoading extends RootUILayer {
983
- title;
984
- loadingTween;
985
- loading_rotate=0;
986
- onAutoObserver() {
987
- this.addAutorun([ () => {
988
- if (this.props?.title) {
989
- this.title.string = `${this.props?.title}`;
990
- }
991
- this.title.node.active = !!this.props?.title?.length;
992
- }, () => {
993
- this.getComponent(E).enabled = !!this.props?.mask;
994
- } ]);
995
- }
996
- update(e) {
997
- this.loading_rotate += e * 220;
998
- this.loadingTween.setRotationFromEuler(0, 0, -this.loading_rotate % 360);
999
- if (this.loading_rotate > 360) {
1000
- this.loading_rotate -= 360;
1001
- }
1002
- }
1003
- };
1004
-
1005
- ye([ Xe({
1006
- type: b,
1007
- tooltip: "标题"
1008
- }), _e("design:type", typeof (qe = typeof b !== "undefined" && b) === "function" ? qe : Object) ], Ye.prototype, "title", void 0);
1009
-
1010
- ye([ Xe({
1011
- type: s,
1012
- tooltip: "动画"
1013
- }), _e("design:type", typeof (Qe = typeof s !== "undefined" && s) === "function" ? Qe : Object) ], Ye.prototype, "loadingTween", void 0);
1014
-
1015
- Ye = ye([ Je("CoreShowLoading"), Ze("CATCORE/CoreShowLoading") ], Ye);
1016
-
1017
- var et;
1018
-
1019
- (function(e) {
1020
- e["RECONNECTED"] = "重连成功";
1021
- e["RECONNECTING"] = "正在重连";
1022
- e["MAX_RECONNECT"] = "重连次数超出限制,请检查网络";
1023
- e["RECONNECTED_ERROR"] = "重连失败,请检查网络";
1024
- e["CONNECT_PARAM_ERROR"] = "游戏参数错误,请重新加载";
1025
- e["KICK"] = "账号已下线";
1026
- e["OFFLINE"] = "网络已断开";
1027
- e["ONLINE"] = "网络已连接";
1028
- e["GAME_ERROR"] = "连接游戏服错误";
1029
- })(et || (et = {}));
1030
-
1031
- var tt, it, nt;
1032
-
1033
- const {ccclass: ot, property: st, menu: rt} = i;
1034
-
1035
- let at = class CoreReconnection extends RootUILayer {
1036
- common_prompt_text;
1037
- btn_confirm;
1038
- btn_close;
1039
- is_close=false;
1040
- props={
1041
- content: null
1042
- };
1043
- initUI() {}
1044
- onLoad() {
1045
- this.btn_confirm.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
1046
- this.btn_close.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
1047
- this.addAutorun([ () => {
1048
- this.common_prompt_text.string = this.props.content ?? "";
1049
- } ]);
1050
- }
1051
- onDestroy() {
1052
- this.unscheduleAllCallbacks();
1053
- }
1054
- updateProps(e) {
1055
- this.updatePromptText(e, e == et.RECONNECTING);
1056
- }
1057
- updatePromptText(e) {
1058
- let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1059
- this.unscheduleAllCallbacks();
1060
- this.props.content = e;
1061
- a("更新提示文案:", e);
1062
- if (t) {
1063
- let t = 0;
1064
- const i = () => {
1065
- t = (t + 1) % 4;
1066
- this.common_prompt_text.string = e + [ "", "·", "··", "···" ][t];
1067
- };
1068
- this.schedule(i, .5);
1069
- }
1070
- }
1071
- onConfirmHandler() {
1072
- this.is_close = true;
1073
- this.cat.gui.hideReconnect();
1074
- }
1075
- };
1076
-
1077
- ye([ st({
1078
- type: b,
1079
- tooltip: "通用提示文本"
1080
- }), _e("design:type", typeof (tt = typeof b !== "undefined" && b) === "function" ? tt : Object) ], at.prototype, "common_prompt_text", void 0);
1081
-
1082
- ye([ st({
1083
- type: S,
1084
- tooltip: "确定按钮"
1085
- }), _e("design:type", typeof (it = typeof S !== "undefined" && S) === "function" ? it : Object) ], at.prototype, "btn_confirm", void 0);
1086
-
1087
- ye([ st({
1088
- type: S,
1089
- tooltip: "关闭按钮"
1090
- }), _e("design:type", typeof (nt = typeof S !== "undefined" && S) === "function" ? nt : Object) ], at.prototype, "btn_close", void 0);
1091
-
1092
- at = ye([ ot("CoreReconnection"), rt("CATCORE/CoreReconnection") ], at);
1093
-
1094
- var lt, ct, ht;
1095
-
1096
- const {ccclass: ut, property: dt, menu: pt} = i;
1097
-
1098
- let ft = class CoreNotice extends RootUILayer {
1099
- text;
1100
- btn_confirm;
1101
- btn_close;
1102
- onLoad() {
1103
- this.btn_confirm.node.on(S.EventType.CLICK, this.onConfrimHandler, this);
1104
- }
1105
- start() {
1106
- this.props && this.updateProps(this.props);
1107
- }
1108
- onConfrimHandler() {
1109
- this.props?.confrim?.();
1110
- this.cat.gui.hideNotice();
1111
- }
1112
- updateProps(e) {
1113
- this.text.string = `${e.text}`;
1114
- }
1115
- };
1116
-
1117
- ye([ dt({
1118
- type: b,
1119
- tooltip: "提示文本"
1120
- }), _e("design:type", typeof (lt = typeof b !== "undefined" && b) === "function" ? lt : Object) ], ft.prototype, "text", void 0);
1121
-
1122
- ye([ dt({
1123
- type: S,
1124
- tooltip: "确定按钮"
1125
- }), _e("design:type", typeof (ct = typeof S !== "undefined" && S) === "function" ? ct : Object) ], ft.prototype, "btn_confirm", void 0);
1126
-
1127
- ye([ dt({
1128
- type: S,
1129
- tooltip: "关闭按钮"
1130
- }), _e("design:type", typeof (ht = typeof S !== "undefined" && S) === "function" ? ht : Object) ], ft.prototype, "btn_close", void 0);
1131
-
1132
- ft = ye([ ut("CoreNotice"), pt("CATCORE/CoreNotice") ], ft);
1133
-
1134
- class SceneLayer extends BaseComponent {
1135
- isReload;
1136
- }
1137
-
1138
- var mt, gt, yt, _t, bt, vt, Ct, Et;
1139
-
1140
- const {ccclass: St, property: wt, menu: Ot} = i;
1141
-
1142
- var At;
1143
-
1144
- (function(e) {
1145
- e[e["UI"] = 0] = "UI";
1146
- e[e["LOADING"] = 1] = "LOADING";
1147
- e[e["TOAST"] = 2] = "TOAST";
1148
- e[e["RECONNECTTION"] = 3] = "RECONNECTTION";
1149
- e[e["NOTICE"] = 4] = "NOTICE";
1150
- })(At || (At = {}));
1151
-
1152
- let Tt = class Gui extends BaseComponent {
1153
- reconnection_ui_prefab;
1154
- toast_ui_prefab;
1155
- loading_ui_prefab;
1156
- notice_ui_prefab;
1157
- ui_prefab;
1158
- root_ui;
1159
- root_toast;
1160
- root_mask;
1161
- ui_container_component;
1162
- reconnection_ui_component;
1163
- notice_ui_component;
1164
- loading_ui_component;
1165
- toast_ui_component;
1166
- currentScene;
1167
- currentSceneUUID;
1168
- onEventListener() {
1169
- this.cat.event.on(je.ROOT_MASK_UPDATE, this.onRootUpdate, this);
1170
- }
1171
- init(e) {
1172
- this.cat = e;
1173
- const t = r.getScene();
1174
- a("init scene");
1175
- t && this.changeScene(t);
1176
- return this;
1177
- }
1178
- start() {
1179
- this.onRootUpdate();
1180
- }
1181
- toastQueue=[];
1182
- isScheduling=false;
1183
- minInterval=.2;
1184
- showToast(e) {
1185
- this.toastQueue.push(e);
1186
- if (!this.isScheduling) {
1187
- this.processQueueWithInterval();
1188
- }
1189
- }
1190
- processQueueWithInterval() {
1191
- if (this.toastQueue.length === 0) {
1192
- this.isScheduling = false;
1193
- return;
1194
- }
1195
- this.isScheduling = true;
1196
- const e = this.toastQueue.shift();
1197
- const t = () => {
1198
- const t = h(this.toast_ui_prefab);
1199
- const i = t.getComponent(Le);
1200
- i.addToParent(this.root_toast, {
1201
- props: e
1202
- });
1203
- this.scheduleOnce(() => {
1204
- this.processQueueWithInterval();
1205
- }, this.minInterval);
1206
- };
1207
- if (this.root_toast.children.length === 0) {
1208
- t();
1209
- } else {
1210
- this.scheduleOnce(t, this.minInterval);
1211
- }
1212
- }
1213
- hideToast() {
1214
- if (this.root_toast) {
1215
- var e;
1216
- H(e = this.root_toast.children).call(e, e => {
1217
- e.getComponent(Le)?.removeAndDestroy();
1218
- });
1219
- }
1220
- this.toastQueue = [];
1221
- this.unschedule(this.processQueueWithInterval);
1222
- this.isScheduling = false;
1223
- return this;
1224
- }
1225
- showLoading() {
1226
- let {title: e = "", mask: t = true, black: i = true} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1227
- a("showLoading", e);
1228
- if (this.loading_ui_component) {
1229
- this.loading_ui_component.setOptions({
1230
- props: {
1231
- title: e,
1232
- mask: t,
1233
- black: i
1234
- }
1235
- });
1236
- } else {
1237
- const n = h(this.loading_ui_prefab);
1238
- this.loading_ui_component = n.getComponent(Ye).addToParent(this.root_ui, {
1239
- props: {
1240
- title: e,
1241
- mask: t,
1242
- black: i
1243
- }
1244
- });
1245
- }
1246
- return this;
1247
- }
1248
- hideLoading() {
1249
- this.loading_ui_component?.removeAndDestroy();
1250
- this.loading_ui_component = null;
1251
- return this;
1252
- }
1253
- showReconnect(e) {
1254
- if (!this.reconnection_ui_component) {
1255
- const t = h(this.reconnection_ui_prefab);
1256
- this.reconnection_ui_component = t.getComponent(at).addToParent(this.root_ui, {
1257
- props: {
1258
- content: e
1259
- }
1260
- });
1261
- } else {
1262
- this.reconnection_ui_component.setUpdateProps({
1263
- content: e
1264
- });
1265
- }
1266
- return this;
1267
- }
1268
- hideReconnect() {
1269
- this.reconnection_ui_component?.removeAndDestroy();
1270
- this.reconnection_ui_component = null;
1271
- return this;
1272
- }
1273
- showNotice(e) {
1274
- const t = h(this.notice_ui_prefab);
1275
- this.notice_ui_component = t.getComponent(ft).addToParent(this.root_ui, {
1276
- props: e
1277
- });
1278
- return this;
1279
- }
1280
- hideNotice() {
1281
- this.notice_ui_component?.removeAndDestroy();
1282
- return this;
1283
- }
1284
- findBundleBySceneUUID(e) {
1285
- const t = w.bundles._map;
1286
- for (const i in t) {
1287
- const n = t[i];
1288
- const o = n.config?.scenes?._map;
1289
- if (!o) continue;
1290
- for (const t in o) {
1291
- const i = o[t];
1292
- if (i?.uuid === e) {
1293
- return n;
1294
- }
1295
- }
1296
- }
1297
- return null;
1298
- }
1299
- findSceneByUUIDFromBundle(e, t) {
1300
- return;
1301
- }
1302
- loadScene(e, t, i, n) {
1303
- console.log("[加载场景参数]", e, t, i, n);
1304
- let s;
1305
- let a = true;
1306
- let l;
1307
- const c = [ t, i, n ];
1308
- for (const e of c) {
1309
- if (typeof e === "boolean") a = e; else if (typeof e === "function") l = e; else if (e && typeof e === "object") s = e;
1310
- }
1311
- r.once(O.EVENT_BEFORE_SCENE_LAUNCH, e => {
1312
- this.changeScene(e, s ?? {}, a);
1313
- });
1314
- r.once(O.EVENT_AFTER_SCENE_LAUNCH, () => {
1315
- l?.();
1316
- });
1317
- if (typeof e === "string") {
1318
- const t = this.findBundleBySceneUUID(e);
1319
- if (t) {
1320
- if (t.name !== "main") {
1321
- t.loadScene(this.currentScene, (e, t) => {
1322
- if (e) return o("loadScene err", e);
1323
- r.runScene(t);
1324
- });
1325
- } else {
1326
- const i = t.getAssetInfo(e);
1327
- if (i?.url) r.loadScene(i.url);
1328
- }
1329
- } else {
1330
- r.loadScene(e);
1331
- }
1332
- } else {
1333
- r.runScene(e);
1334
- }
1335
- return this;
1336
- }
1337
- resetScene() {
1338
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1339
- e = e || this.currentScene;
1340
- return this.loadScene(e);
1341
- }
1342
- cleanScene() {
1343
- this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast();
1344
- }
1345
- changeScene(e, t, i) {
1346
- this.currentScene = e.name;
1347
- this.currentSceneUUID = e.uuid;
1348
- this.createUILayer(e);
1349
- const n = e.getComponentInChildren(SceneLayer);
1350
- a("给场景传递属性值=======", n);
1351
- if (n) {
1352
- n.isReload = i ?? true;
1353
- }
1354
- n?.setOptions(t);
1355
- }
1356
- createUILayer(e) {
1357
- this.ui_container_component?.removeAndDestroy();
1358
- this.ui_container_component = null;
1359
- const t = h(this.ui_prefab);
1360
- this.ui_container_component = t.getComponent(ze);
1361
- this.ui_container_component?.setGui(this).addToParent(e, this.node.getSiblingIndex());
1362
- }
1363
- reloadScene() {
1364
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
1365
- a("重新加载当前场景");
1366
- this.loadScene(this.currentSceneUUID, true, e);
1367
- }
1368
- async closeUI(e, t) {
1369
- const {component: i} = this.findUIBaseLayer(e, false);
1370
- if (i) {
1371
- i.setOptions({
1372
- ...t?.hook ?? {},
1373
- ...t?.props ?? {}
1374
- });
1375
- await i.hideTween(t || {});
1376
- this.ui_container_component?.subMask();
1377
- }
1378
- }
1379
- async openUI(e, t) {
1380
- const {rootNode: i, component: n} = this.findUIBaseLayer(e, true);
1381
- i.getComponent(UILayer);
1382
- n?.setOptions(t);
1383
- if (i) {
1384
- this.ui_container_component?.addNodeToTween(i).addMask();
1385
- }
1386
- if (n) {
1387
- await n.showTween(t || {});
1388
- }
1389
- this.ui_container_component?.ui_container && n?.addToParent(this.ui_container_component.ui_container);
1390
- }
1391
- findUIBaseLayer(e, t) {
1392
- let i;
1393
- let n = null;
1394
- if (e instanceof s) {
1395
- var r;
1396
- i = e;
1397
- const t = $(r = e.components).call(r, e => e instanceof UILayer);
1398
- if (t.length) {
1399
- if (t.length == 1) {
1400
- n = t[0];
1401
- } else {
1402
- A(`${e.name}节点存在多个继承自BaseLayer的组件`);
1403
- }
1404
- } else {
1405
- o(`${e.name}节点未找到继承自BaseLayer的组件`);
1406
- return {
1407
- rootNode: i,
1408
- component: n
1409
- };
1410
- }
1411
- } else {
1412
- i = e.node;
1413
- n = e;
1414
- if (t) {
1415
- while (i.parent) {
1416
- i = i.parent;
1417
- }
1418
- n.root = i;
1419
- } else {
1420
- i = e.root;
1421
- }
1422
- }
1423
- return {
1424
- rootNode: i,
1425
- component: n
1426
- };
1427
- }
1428
- onRootUpdate() {
1429
- const e = this.root_ui.children.findLastIndex(e => e.active && e != this.root_mask);
1430
- this.root_mask.active = e != -1;
1431
- if (e > -1) {
1432
- const t = this.root_ui.children[e];
1433
- const i = t.getSiblingIndex() - 1;
1434
- this.root_mask.setSiblingIndex(i < 0 ? 0 : i);
1435
- }
1436
- this.cat.event.emit(je.ROOT_MASK_CHANGE);
1437
- }
1438
- };
1439
-
1440
- ye([ wt({
1441
- type: c,
1442
- tooltip: "断线重连UI预制体"
1443
- }), _e("design:type", typeof (mt = typeof c !== "undefined" && c) === "function" ? mt : Object) ], Tt.prototype, "reconnection_ui_prefab", void 0);
1444
-
1445
- ye([ wt({
1446
- type: c,
1447
- tooltip: "提示UI预制体"
1448
- }), _e("design:type", typeof (gt = typeof c !== "undefined" && c) === "function" ? gt : Object) ], Tt.prototype, "toast_ui_prefab", void 0);
1449
-
1450
- ye([ wt({
1451
- type: c,
1452
- tooltip: "加载UI预制体"
1453
- }), _e("design:type", typeof (yt = typeof c !== "undefined" && c) === "function" ? yt : Object) ], Tt.prototype, "loading_ui_prefab", void 0);
1454
-
1455
- ye([ wt({
1456
- type: c,
1457
- tooltip: "公告UI预制体"
1458
- }), _e("design:type", typeof (_t = typeof c !== "undefined" && c) === "function" ? _t : Object) ], Tt.prototype, "notice_ui_prefab", void 0);
1459
-
1460
- ye([ wt({
1461
- type: c,
1462
- tooltip: "UI层预制体"
1463
- }), _e("design:type", typeof (bt = typeof c !== "undefined" && c) === "function" ? bt : Object) ], Tt.prototype, "ui_prefab", void 0);
1464
-
1465
- ye([ wt({
1466
- type: s,
1467
- tooltip: "root-UI层"
1468
- }), _e("design:type", typeof (vt = typeof s !== "undefined" && s) === "function" ? vt : Object) ], Tt.prototype, "root_ui", void 0);
1469
-
1470
- ye([ wt({
1471
- type: s,
1472
- tooltip: "root-组件层"
1473
- }), _e("design:type", typeof (Ct = typeof s !== "undefined" && s) === "function" ? Ct : Object) ], Tt.prototype, "root_toast", void 0);
1474
-
1475
- ye([ wt({
1476
- type: s,
1477
- tooltip: "root-mask"
1478
- }), _e("design:type", typeof (Et = typeof s !== "undefined" && s) === "function" ? Et : Object) ], Tt.prototype, "root_mask", void 0);
1479
-
1480
- Tt = ye([ St("Gui"), Ot("CATCORE/Gui") ], Tt);
1481
-
1482
- var It;
1483
-
1484
- (function(e) {
1485
- e["Root"] = "prefabs/root";
1486
- e["Toast"] = "prefabs/toast";
1487
- e["BlackMask"] = "prefabs/black-mask";
1488
- e["Loading"] = "prefabs/loading";
1489
- e["Notice"] = "prefabs/notice";
1490
- e["Reconnection"] = "prefabs/reconnection";
1491
- })(It || (It = {}));
1492
-
1493
- class GuiManager extends BaseManager {
1494
- gui;
1495
- #e="core";
1496
- getGuiPrefabByType=(e, t) => new x((i, n) => {
1497
- a(e, `${t}`);
1498
- this.cat.res.load(e, t, (e, t) => {
1499
- if (e) {
1500
- n(e);
1501
- } else {
1502
- i(t);
1503
- }
1504
- });
1505
- });
1506
- async init() {
1507
- this.cat.gui_bundle_name && (this.#e = this.cat.gui_bundle_name);
1508
- const e = await this.getGuiPrefabByType(this.#e, It.Root);
1509
- const t = h(e);
1510
- this.gui = t.getComponent(Tt).init(this.cat);
1511
- r.addPersistRootNode(t);
1512
- return this;
1513
- }
1514
- }
1515
-
1516
- class WrapperSocialGameClient extends re {
1517
- showRequestErrInfo=false;
1518
- logBlackList=[];
1519
- ignore=e => {
1520
- var t;
1521
- return F(t = this.logBlackList).call(t, e);
1522
- };
1523
- constructor(e, t, i, n) {
1524
- super(t, i, n, e);
1525
- this.showRequestErrInfo = n?.showRequestErrInfo ?? false;
1526
- }
1527
- destroy() {
1528
- this.disconnect(true);
1529
- e._cat.socialGameClient.unregister(this);
1530
- }
1531
- async GameRequest(t, i, n) {
1532
- let {forwardReq: s = false, forwardResp: r = false} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1533
- return new x((l, c) => {
1534
- super.GameRequest(t, i, n, {
1535
- forwardReq: s,
1536
- forwardResp: r
1537
- }).then(e => {
1538
- if (ne) {
1539
- a(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`, "background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff", "background:#3d7daa ; padding: 1px; color: #fff", "background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff", "background:transparent", i);
1540
- }
1541
- l(e);
1542
- }, t => {
1543
- o(t);
1544
- this.showRequestErrInfo && t?.msg && e._cat.gui.showToast({
1545
- title: t.msg
1546
- });
1547
- c(t);
1548
- });
1549
- });
1550
- }
1551
- subscribe(t, i, n) {
1552
- super.subscribe(t, i, i => {
1553
- if (ne && !this.ignore(t)) {
1554
- a(`%c ws服务端消息:[subscribe][${new Date}] %c ${t} %c`, "background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff", "background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff", "background:transparent", i);
1555
- }
1556
- e._cat.event.emit(t, i);
1557
- n?.(i);
1558
- });
1559
- return this;
1560
- }
1561
- }
1562
-
1563
- class SocialGameClientManager extends BaseManager {
1564
- managedClients=(() => new G)();
1565
- isGlobalOnline=true;
1566
- isInBackground=false;
1567
- reconnecting=false;
1568
- onEventHideDelegate=(() => new T)();
1569
- onEventShowDelegate=(() => new T)();
1570
- onEventReloadSceneDelegate=(() => new T)();
1571
- reconnectTimer=null;
1572
- lastReconnectTime=0;
1573
- RECONNECT_COOLDOWN=1500;
1574
- pendingShowOptions=[];
1575
- scheduleReconnect() {
1576
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
1577
- if (this.reconnectTimer) {
1578
- clearTimeout(this.reconnectTimer);
1579
- this.reconnectTimer = null;
1580
- }
1581
- this.reconnectTimer = X(() => {
1582
- this.reconnectTimer = null;
1583
- this.triggerReconnectAll();
1584
- }, e);
1585
- }
1586
- get activeClients() {
1587
- var e, t;
1588
- return $(e = Z(t = Y(this.managedClients)).call(t, e => {
1589
- let [t, i] = e;
1590
- return i;
1591
- })).call(e, e => e.socket);
1592
- }
1593
- constructor(e) {
1594
- super(e);
1595
- this.initGlobalListeners();
1596
- }
1597
- createWebSocket(e, t, i, n) {
1598
- if (this.managedClients.has(e)) {
1599
- const t = this.managedClients.get(e);
1600
- t.destroy();
1601
- a(`清理旧的 ${e} 客户端`);
1602
- }
1603
- const o = new WrapperSocialGameClient(e, i, n, j({
1604
- reconnectMaxAttempts: Infinity
1605
- }, {
1606
- ...t,
1607
- isAutoConnect: false,
1608
- isArrayBuffer: oe
1609
- }));
1610
- this.register(o);
1611
- return o;
1612
- }
1613
- register(e) {
1614
- e.on("reconnected", this.handleSingleReconnect);
1615
- e.on("close", this.handleSingleClose);
1616
- e.on("kick", this.handleSingleKick);
1617
- this.managedClients.set(e.name, e);
1618
- }
1619
- unregister(e) {
1620
- e.off("reconnected", this.handleSingleReconnect);
1621
- e.off("close", this.handleSingleClose);
1622
- e.off("kick", this.handleSingleKick);
1623
- this.managedClients.delete(e.name);
1624
- }
1625
- initGlobalListeners() {
1626
- console.log("设置监听");
1627
- this.cat.event.on(je.ONLINE, () => this.handleGlobalStateChange("online"), this).on(je.OFFLINE, () => this.handleGlobalStateChange("offline"), this);
1628
- if (oe) {
1629
- wx.onShow(e => {
1630
- this.handleGlobalStateChange("show", e);
1631
- });
1632
- wx.onHide(e => {
1633
- this.handleGlobalStateChange("hide", e);
1634
- });
1635
- } else {
1636
- _.on(I.EVENT_SHOW, () => this.handleGlobalStateChange("show"));
1637
- _.on(I.EVENT_HIDE, () => this.handleGlobalStateChange("hide"));
1638
- }
1639
- }
1640
- async handleGlobalStateChange(e, t) {
1641
- switch (e) {
1642
- case "online":
1643
- this.cat.gui.hideLoading().showToast({
1644
- title: et.ONLINE
1645
- });
1646
- this.isGlobalOnline = true;
1647
- this.safeTriggerReconnectAll();
1648
- break;
1649
-
1650
- case "offline":
1651
- this.isGlobalOnline = false;
1652
- this.disconnectAll(true);
1653
- this.cat.gui.showLoading({
1654
- title: et.OFFLINE
1655
- });
1656
- break;
1657
-
1658
- case "show":
1659
- this.isInBackground = false;
1660
- console.log("监听前台 show", t);
1661
- if (t) this.pendingShowOptions.push(t);
1662
- await this.safeTriggerReconnectAll();
1663
- break;
1664
-
1665
- case "hide":
1666
- console.log("监听前台 hide");
1667
- await this.onEventHideDelegate.dispatch(t);
1668
- this.isInBackground = true;
1669
- this.disconnectAll(true);
1670
- break;
1671
- }
1672
- }
1673
- async safeTriggerReconnectAll() {
1674
- const e = ee();
1675
- if (this.reconnecting || !this.isGlobalOnline || this.isInBackground || this.managedClients.size === 0) {
1676
- console.log("[safeTriggerReconnectAll] 没有需要重连的客户端,直接 dispatch");
1677
- await this.dispatchReloadAndShow();
1678
- return;
1679
- }
1680
- if (this.reconnecting) {
1681
- console.log("[safeTriggerReconnectAll] 正在重连中,跳过本次");
1682
- return;
1683
- }
1684
- if (e - this.lastReconnectTime < this.RECONNECT_COOLDOWN) {
1685
- console.log("[safeTriggerReconnectAll] 距上次重连过近,跳过本次");
1686
- return;
1687
- }
1688
- this.lastReconnectTime = e;
1689
- await this.triggerReconnectAll();
1690
- }
1691
- async dispatchReloadAndShow() {
1692
- await this.onEventReloadSceneDelegate.dispatch();
1693
- while (this.pendingShowOptions.length > 0) {
1694
- const e = this.pendingShowOptions.shift();
1695
- this.onEventShowDelegate.dispatch(e);
1696
- }
1697
- }
1698
- async triggerReconnectAll() {
1699
- console.log("触发所有客户端重连[正在重连][在线][后台][ws数量]", this.reconnecting, this.isGlobalOnline, this.isInBackground, this.managedClients.size);
1700
- if (this.reconnecting || !this.isGlobalOnline || this.isInBackground || this.managedClients.size === 0) {
1701
- await this.dispatchReloadAndShow();
1702
- return;
1703
- }
1704
- this.reconnecting = true;
1705
- this.cat.gui.showLoading({
1706
- title: "正在重连"
1707
- });
1708
- try {
1709
- var e, t;
1710
- await x.allSettled(Z(e = this.activeClients).call(e, async e => {
1711
- try {
1712
- await e.reconnectPromise();
1713
- } catch (t) {
1714
- o(`${e.name}服重连失败`, t);
1715
- }
1716
- }));
1717
- const i = $(t = this.activeClients).call(t, e => e.socketConnectStatus !== ie.CONNECTED);
1718
- if (i.length > 0) {
1719
- Z(i).call(i, e => {
1720
- console.error("部分WS重连失败:", e);
1721
- });
1722
- a("2s后重连所有客户端");
1723
- this.reconnecting = false;
1724
- this.scheduleReconnect();
1725
- } else {
1726
- this.reconnecting = false;
1727
- }
1728
- } catch (e) {
1729
- this.reconnecting = false;
1730
- throw e;
1731
- }
1732
- }
1733
- disconnectAll(e) {
1734
- var t, i;
1735
- if (te(t = this.activeClients).call(t, e => e.socket?.readyState !== WebSocket.OPEN)) return;
1736
- H(i = this.managedClients).call(i, t => {
1737
- a("断开连接", t.name, e, t.socket);
1738
- t.disconnect(e);
1739
- });
1740
- }
1741
- handleSingleClose=() => {
1742
- if (!this.reconnecting) {
1743
- a("3s后重连所有客户端");
1744
- this.scheduleReconnect(3e3);
1745
- }
1746
- };
1747
- handleSingleReconnect=async () => {
1748
- var e;
1749
- if (te(e = this.activeClients).call(e, e => e.socketConnectStatus === ie.CONNECTED)) {
1750
- var t;
1751
- a("单个WS重连成功回调===", this.managedClients);
1752
- await x.allSettled(Z(t = this.activeClients).call(t, async e => {
1753
- try {
1754
- await e.connectRequest();
1755
- } catch (t) {
1756
- o(`${e.name}服登录错误`, t);
1757
- this.cat.gui.showToast({
1758
- title: `登录${e.name}服错误`
1759
- });
1760
- }
1761
- }));
1762
- if (this.reconnectTimer) {
1763
- clearTimeout(this.reconnectTimer);
1764
- this.reconnectTimer = null;
1765
- }
1766
- await this.onEventReloadSceneDelegate.dispatch();
1767
- this.cat.gui.hideLoading();
1768
- if (r.getScene()?.getComponentInChildren(SceneLayer)?.isReload) this.cat.gui.reloadScene(() => {
1769
- while (this.pendingShowOptions.length > 0) {
1770
- const e = this.pendingShowOptions.shift();
1771
- this.onEventShowDelegate.dispatch(e);
1772
- }
1773
- });
1774
- }
1775
- };
1776
- handleSingleKick=() => {
1777
- this.cat.gui.showReconnect(et.KICK);
1778
- };
1779
- }
1780
-
1781
- class ResLoader {
1782
- get=(() => function(e, t) {
1783
- let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "resources";
1784
- var n = w.getBundle(i);
1785
- return n.get(e, t);
1786
- })();
1787
- isAssetType=e => typeof e === "function" && e.prototype instanceof k;
1788
- async load() {
1789
- let e = null;
1790
- let t = null;
1791
- let i = null;
1792
- for (var n = arguments.length, o = new Array(n), s = 0; s < n; s++) {
1793
- o[s] = arguments[s];
1794
- }
1795
- if (typeof o[0] === "string" && typeof o[1] === "string") {
1796
- e = o.shift();
1797
- }
1798
- let r = o.shift();
1799
- if (this.isAssetType(o[0])) {
1800
- t = o.shift();
1801
- }
1802
- if (o.length == 2) {
1803
- i = o.shift();
1804
- }
1805
- const a = o.shift();
1806
- let l = R;
1807
- if (e && e != "resources") {
1808
- if (!w.bundles.has(e)) {
1809
- await this.loadBundle(e);
1810
- }
1811
- let t = w.bundles.get(e);
1812
- if (t) {
1813
- l = t;
1814
- }
1815
- }
1816
- if (i && a) {
1817
- l.load(r, t, i, a);
1818
- } else if (a) {
1819
- l.load(r, t, a);
1820
- } else {
1821
- l.load(r, t);
1822
- }
1823
- }
1824
- async loadDir() {
1825
- let e = null;
1826
- let t = null;
1827
- let i = null;
1828
- let n = null;
1829
- for (var o = arguments.length, s = new Array(o), r = 0; r < o; r++) {
1830
- s[r] = arguments[r];
1831
- }
1832
- if (typeof s[0] === "string" && typeof s[1] === "string") {
1833
- e = s.shift();
1834
- }
1835
- let a = s.shift();
1836
- if (this.isAssetType(s[0])) {
1837
- t = s.shift();
1838
- }
1839
- if (s.length == 2) {
1840
- i = s.shift();
1841
- }
1842
- n = s.shift();
1843
- let l = R;
1844
- if (e && e != "resources") {
1845
- if (!w.bundles.has(e)) {
1846
- await this.loadBundle(e);
1847
- }
1848
- let t = w.bundles.get(e);
1849
- if (t) {
1850
- l = t;
1851
- }
1852
- }
1853
- if (i && n) {
1854
- l.loadDir(a, t, i, n);
1855
- } else if (n) {
1856
- l.loadDir(a, t, n);
1857
- } else {
1858
- l.loadDir(a, t);
1859
- }
1860
- }
1861
- loadRemote(e) {
1862
- var t = null;
1863
- var i = null;
1864
- for (var n = arguments.length, o = new Array(n > 1 ? n - 1 : 0), s = 1; s < n; s++) {
1865
- o[s - 1] = arguments[s];
1866
- }
1867
- if (o.length == 2) {
1868
- t = o.shift();
1869
- }
1870
- i = o.shift();
1871
- w.loadRemote(e, {
1872
- ext: ".png",
1873
- ...t
1874
- }, i);
1875
- }
1876
- loadBundle=(e, t) => new x((i, n) => {
1877
- const o = (e, t) => {
1878
- if (e) {
1879
- return n(e);
1880
- }
1881
- i(t);
1882
- };
1883
- t ? w.loadBundle(e, {
1884
- version: t
1885
- }, o) : w.loadBundle(e, o);
1886
- });
1887
- releasePrefabtDepsRecursively=e => {
1888
- var t = w.assets.get(e);
1889
- w.releaseAsset(t);
1890
- if (t instanceof c) {
1891
- var i = w.dependUtil.getDepsRecursively(e);
1892
- H(i).call(i, e => {
1893
- var t = w.assets.get(e);
1894
- t.decRef();
1895
- });
1896
- }
1897
- };
1898
- release=(() => {
1899
- var e = this;
1900
- return function(t) {
1901
- let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1902
- var n = w.getBundle(i);
1903
- if (n) {
1904
- var o = n.get(t);
1905
- if (o) {
1906
- e.releasePrefabtDepsRecursively(o._uuid);
1907
- }
1908
- }
1909
- };
1910
- })();
1911
- releaseDir=(() => {
1912
- var e = this;
1913
- return function(t) {
1914
- var i, n;
1915
- let o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1916
- var s = w.getBundle(o);
1917
- var r = s?.getDirWithPath(t);
1918
- ((i = r) == null ? void 0 : V(n = Function.call).call(n, Z(i), i))?.(t => {
1919
- e.releasePrefabtDepsRecursively(t.uuid);
1920
- });
1921
- if (!t && o != "resources" && s) {
1922
- w.removeBundle(s);
1923
- }
1924
- };
1925
- })();
1926
- dump=() => {
1927
- var e;
1928
- H(e = w.assets).call(e, (e, t) => {
1929
- a(w.assets.get(t));
1930
- });
1931
- a(`当前资源总数:${w.assets.count}`);
1932
- };
1933
- loadAssetsWithProgress(e, t) {
1934
- return new x((i, n) => {
1935
- const o = e.getDirWithPath("");
1936
- const s = o.length;
1937
- let r = 0;
1938
- if (s === 0) {
1939
- t(1);
1940
- i();
1941
- return;
1942
- }
1943
- H(o).call(o, o => {
1944
- e.load(o.path, e => {
1945
- if (e) {
1946
- n(e);
1947
- return;
1948
- }
1949
- r++;
1950
- t(r / s);
1951
- if (r === s) {
1952
- i();
1953
- }
1954
- });
1955
- });
1956
- });
1957
- }
1958
- }
1959
-
1960
- class BaseStore {
1961
- rootStore;
1962
- constructor(e) {
1963
- this.rootStore = e;
1964
- }
1965
- }
1966
-
1967
- class CoreStore extends BaseManager {}
1968
-
1969
- let kt = null;
1970
-
1971
- const Rt = e => ae.MD5(e).toString();
1972
-
1973
- const Mt = (e, t) => {
1974
- kt = ae.enc.Hex.parse(t);
1975
- };
1976
-
1977
- const Ut = (e, t, i) => ae.AES.encrypt(e, t, {
1978
- iv: kt,
1979
- format: Dt
1980
- }).toString();
1981
-
1982
- const Nt = (e, t, i) => {
1983
- const n = ae.AES.decrypt(e, t, {
1984
- iv: kt,
1985
- format: Dt
1986
- });
1987
- return n.toString(ae.enc.Utf8);
1988
- };
1989
-
1990
- const Dt = {
1991
- stringify: e => {
1992
- const t = {
1993
- ct: e.ciphertext.toString(ae.enc.Base64)
1994
- };
1995
- if (e.iv) {
1996
- t.iv = e.iv.toString();
1997
- }
1998
- if (e.salt) {
1999
- t.s = e.salt.toString();
2000
- }
2001
- return P(t);
2002
- },
2003
- parse: e => {
2004
- const t = JSON.parse(e);
2005
- const i = ae.lib.CipherParams.create({
2006
- ciphertext: ae.enc.Base64.parse(t.ct)
2007
- });
2008
- if (t.iv) {
2009
- i.iv = ae.enc.Hex.parse(t.iv);
2010
- }
2011
- if (t.s) {
2012
- i.salt = ae.enc.Hex.parse(t.s);
2013
- }
2014
- return i;
2015
- }
2016
- };
2017
-
2018
- var Lt = Object.freeze({
2019
- __proto__: null,
2020
- JsonFormatter: Dt,
2021
- aesDecrypt: Nt,
2022
- aesEncrypt: Ut,
2023
- initCrypto: Mt,
2024
- md5: Rt
2025
- });
2026
-
2027
- class CoreUtil extends BaseManager {
2028
- encryptUtil=(() => Lt)();
2029
- }
2030
-
2031
- class StorageManager extends BaseManager {
2032
- _key=null;
2033
- _iv=null;
2034
- _id="";
2035
- init(e, t) {
2036
- this.cat.util.encryptUtil.initCrypto(e, t);
2037
- this._key = this.cat.util.encryptUtil.md5(e);
2038
- this._iv = this.cat.util.encryptUtil.md5(t);
2039
- }
2040
- setUser(e) {
2041
- this._id = e;
2042
- }
2043
- set(e, t) {
2044
- e = `${e}_${this._id}`;
2045
- if (null == e) {
2046
- console.error("存储的key不能为空");
2047
- return;
2048
- }
2049
- if (!se) {
2050
- e = this.cat.util.encryptUtil.md5(e);
2051
- }
2052
- if (null == t) {
2053
- console.warn("存储的值为空,则直接移除该存储");
2054
- this.remove(e);
2055
- return;
2056
- }
2057
- if (typeof t === "function") {
2058
- console.error("储存的值不能为方法");
2059
- return;
2060
- }
2061
- if (typeof t === "object") {
2062
- try {
2063
- t = P(t);
2064
- } catch (e) {
2065
- console.error(`解析失败,str = ${t}`);
2066
- return;
2067
- }
2068
- } else if (typeof t === "number") {
2069
- t = t + "";
2070
- }
2071
- if (!se && null != this._key && null != this._iv) {
2072
- t = this.cat.util.encryptUtil.aesEncrypt(`${t}`, this._key, this._iv);
2073
- }
2074
- M.localStorage.setItem(e, t);
2075
- }
2076
- get(e, t) {
2077
- if (null == e) {
2078
- console.error("存储的key不能为空");
2079
- return null;
2080
- }
2081
- e = `${e}_${this._id}`;
2082
- if (!se) {
2083
- e = this.cat.util.encryptUtil.md5(e);
2084
- }
2085
- let i = M.localStorage.getItem(e);
2086
- if (null != i && "" !== i && !se && null != this._key && null != this._iv) {
2087
- i = this.cat.util.encryptUtil.aesDecrypt(i, this._key, this._iv);
2088
- }
2089
- if (null === i) {
2090
- return t;
2091
- }
2092
- return i;
2093
- }
2094
- getNumber(e) {
2095
- let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2096
- var i = this.get(e);
2097
- return Number(i) || t;
2098
- }
2099
- getBoolean(e) {
2100
- var t = this.get(e);
2101
- return Boolean(t) || false;
2102
- }
2103
- getJson(e, t) {
2104
- var i = this.get(e);
2105
- return i && JSON.parse(i) || t;
2106
- }
2107
- remove(e) {
2108
- if (null == e) {
2109
- console.error("存储的key不能为空");
2110
- return;
2111
- }
2112
- e = `${e}_${this._id}`;
2113
- if (!se) {
2114
- e = this.cat.util.encryptUtil.md5(e);
2115
- }
2116
- M.localStorage.removeItem(e);
2117
- }
2118
- clear() {
2119
- M.localStorage.clear();
2120
- }
2121
- }
2122
-
2123
- class Manager {
2124
- static #t=null;
2125
- #i=false;
2126
- static get instance() {
2127
- return this.#t ?? (this.#t = new Manager);
2128
- }
2129
- onAppInitDelegate=(() => new T)();
2130
- onPlugInInitDelegate=(() => new T)();
2131
- #n=null;
2132
- get audio() {
2133
- return this.#n;
2134
- }
2135
- #o=null;
2136
- get event() {
2137
- return this.#o;
2138
- }
2139
- #s=null;
2140
- get gui() {
2141
- return this.#s;
2142
- }
2143
- #r=null;
2144
- get storage() {
2145
- return this.#r;
2146
- }
2147
- #a=null;
2148
- get res() {
2149
- return this.#a;
2150
- }
2151
- #l=null;
2152
- get util() {
2153
- return this.#l;
2154
- }
2155
- #c=null;
2156
- get socialGameClient() {
2157
- return this.#c;
2158
- }
2159
- #h=null;
2160
- get store() {
2161
- return this.#h;
2162
- }
2163
- #u="";
2164
- get gui_bundle_name() {
2165
- return this.#u;
2166
- }
2167
- #d="";
2168
- get audio_local_store_key() {
2169
- return this.#d;
2170
- }
2171
- #p="";
2172
- get default_audio_effect() {
2173
- return this.#p;
2174
- }
2175
- setConfig=(() => {
2176
- var e = this;
2177
- return function() {
2178
- let {default_audio_effect: t = "", gui_bundleName: i = "resources", audio_local_store_key: n = "game_audio"} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2179
- if (e.#i) {
2180
- throw new Error("[CAT] 已初始化,无法修改配置");
2181
- }
2182
- e.#u = i;
2183
- e.#d = n;
2184
- e.#p = t;
2185
- return e;
2186
- };
2187
- })();
2188
- async boot() {
2189
- if (this.#i) {
2190
- throw new Error("[CAT] 已初始化");
2191
- }
2192
- try {
2193
- this.#h = new CoreStore(this);
2194
- this.#a = new ResLoader;
2195
- this.#l = new CoreUtil(this);
2196
- this.#r = new StorageManager(this);
2197
- this.#o = new B;
2198
- this.#n = new AudioManager(this);
2199
- this.#c = new SocialGameClientManager(this);
2200
- this.#s = (await new GuiManager(this).init()).gui;
2201
- this.#i = true;
2202
- } catch (e) {
2203
- console.error(`[CAT] 初始化失败:`, e);
2204
- throw e;
2205
- }
2206
- }
2207
- merge(e, t) {
2208
- if (!this.#i) throw new Error("[CAT] 未初始化");
2209
- if (typeof e !== "string") {
2210
- throw new Error(`merge方法第一个参数应该为string类型`);
2211
- }
2212
- if (!D(this, e)) {
2213
- L(this, e, t);
2214
- }
2215
- j(D(this, e), t);
2216
- return this;
2217
- }
2218
- appendPlugInInitDelegate(e) {
2219
- if (this.#i) {
2220
- x.resolve().then(e).catch(e => {
2221
- console.error("[CAT] appendPlugInInitDelegate 回调执行失败:", e);
2222
- });
2223
- } else {
2224
- this.onPlugInInitDelegate.add(e);
2225
- }
2226
- return this;
2227
- }
2228
- }
2229
-
2230
- var jt, xt, Bt, Ft, Pt, Gt, Ht, $t, Kt;
2231
-
2232
- const {ccclass: Wt, property: Vt, menu: zt} = i;
2233
-
2234
- let qt = class CoreUIModal extends UILayer {
2235
- default_title=null;
2236
- title;
2237
- prompt_content_str;
2238
- prompt_content_spriteFrame;
2239
- btn_confirm;
2240
- confirm_spriteFrame;
2241
- btn_cancel;
2242
- cancel_spriteFrame;
2243
- btn_close;
2244
- isConfirm=false;
2245
- props={
2246
- title: this.default_title,
2247
- content: null,
2248
- confirmCB: () => {},
2249
- cancelCB: () => {},
2250
- style: null
2251
- };
2252
- onLoad() {
2253
- this.btn_cancel.node.on(S.EventType.CLICK, this.onCancelHandler, this);
2254
- this.btn_confirm.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
2255
- this.btn_close.node.on(S.EventType.CLICK, this.onCloseHandler, this);
2256
- this.addAutorun([ () => {
2257
- this.title.spriteFrame = this.props?.title || this.default_title;
2258
- }, () => {
2259
- if (this.props.content) {
2260
- if (this.props.content instanceof U) {
2261
- this.prompt_content_spriteFrame.spriteFrame = this.props.content;
2262
- } else if (typeof this.props.content === "string") {
2263
- this.prompt_content_str.string = this.props.content;
2264
- } else {
2265
- console.error("未知类型的【UIModal】内容");
2266
- }
2267
- }
2268
- }, () => {
2269
- if (this.props?.style?.confirm === null) {
2270
- this.btn_confirm.node.active = false;
2271
- } else {
2272
- this.btn_confirm.node.active = true;
2273
- this.btn_confirm.getComponent(N).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame;
2274
- }
2275
- if (this.props?.style?.cancel === null) {
2276
- this.btn_cancel.node.active = false;
2277
- } else {
2278
- this.btn_cancel.node.active = true;
2279
- this.btn_cancel.getComponent(N).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame;
2280
- }
2281
- } ]);
2282
- }
2283
- close() {
2284
- this.props.cancelCB?.();
2285
- this.cat.gui.closeUI(this);
2286
- }
2287
- onCancelHandler() {
2288
- this.close();
2289
- }
2290
- onConfirmHandler() {
2291
- this.props.confirmCB?.();
2292
- }
2293
- onDestroy() {
2294
- if (this.isConfirm) this.props.onDestroy?.();
2295
- }
2296
- onCloseHandler() {
2297
- this.close();
2298
- }
2299
- };
2300
-
2301
- ye([ Vt({
2302
- type: U,
2303
- tooltip: "默认标题"
2304
- }), _e("design:type", typeof (jt = typeof U !== "undefined" && U) === "function" ? jt : Object) ], qt.prototype, "default_title", void 0);
2305
-
2306
- ye([ Vt({
2307
- type: N,
2308
- tooltip: "标题节点"
2309
- }), _e("design:type", typeof (xt = typeof N !== "undefined" && N) === "function" ? xt : Object) ], qt.prototype, "title", void 0);
2310
-
2311
- ye([ Vt({
2312
- type: b,
2313
- tooltip: "字符串内容按钮"
2314
- }), _e("design:type", typeof (Bt = typeof b !== "undefined" && b) === "function" ? Bt : Object) ], qt.prototype, "prompt_content_str", void 0);
2315
-
2316
- ye([ Vt({
2317
- type: N,
2318
- tooltip: "图片精灵内容按钮"
2319
- }), _e("design:type", typeof (Ft = typeof N !== "undefined" && N) === "function" ? Ft : Object) ], qt.prototype, "prompt_content_spriteFrame", void 0);
2320
-
2321
- ye([ Vt({
2322
- type: S,
2323
- tooltip: "确认按钮"
2324
- }), _e("design:type", typeof (Pt = typeof S !== "undefined" && S) === "function" ? Pt : Object) ], qt.prototype, "btn_confirm", void 0);
2325
-
2326
- ye([ Vt({
2327
- type: U,
2328
- tooltip: "确认按钮精灵图"
2329
- }), _e("design:type", typeof (Gt = typeof U !== "undefined" && U) === "function" ? Gt : Object) ], qt.prototype, "confirm_spriteFrame", void 0);
2330
-
2331
- ye([ Vt({
2332
- type: S,
2333
- tooltip: "取消按钮"
2334
- }), _e("design:type", typeof (Ht = typeof S !== "undefined" && S) === "function" ? Ht : Object) ], qt.prototype, "btn_cancel", void 0);
2335
-
2336
- ye([ Vt({
2337
- type: U,
2338
- tooltip: "取消按钮精灵图"
2339
- }), _e("design:type", typeof ($t = typeof U !== "undefined" && U) === "function" ? $t : Object) ], qt.prototype, "cancel_spriteFrame", void 0);
2340
-
2341
- ye([ Vt({
2342
- type: S,
2343
- tooltip: "关闭按钮"
2344
- }), _e("design:type", typeof (Kt = typeof S !== "undefined" && S) === "function" ? Kt : Object) ], qt.prototype, "btn_close", void 0);
2345
-
2346
- qt = ye([ Wt("CoreUIModal"), zt("CATCORE/CoreUIModal") ], qt);
2347
-
2348
- var Qt;
2349
-
2350
- (function(e) {
2351
- e[e["Delay"] = 0] = "Delay";
2352
- e[e["Interval"] = 1] = "Interval";
2353
- })(Qt || (Qt = {}));
2354
-
2355
- class TimerEntry {
2356
- tag;
2357
- type;
2358
- callback;
2359
- remainingTime;
2360
- executionTime=0;
2361
- initialTime;
2362
- constructor(e, t, i, n) {
2363
- this.tag = e;
2364
- this.type = t;
2365
- this.remainingTime = i;
2366
- this.initialTime = i;
2367
- this.callback = n;
2368
- }
2369
- }
2370
-
2371
- class TimerManager extends BaseManager {
2372
- timers=(() => new G)();
2373
- lastUpdateTime=(() => ee())();
2374
- constructor(e) {
2375
- var t;
2376
- super(e);
2377
- e.event.on(je.EVENT_HIDE, this.onHandleAppBackground, this);
2378
- e.event.on(je.EVENT_SHOW, this.onHandleAppForeground, this);
2379
- le(V(t = this.update).call(t, this), 1e3);
2380
- }
2381
- onHandleAppBackground() {
2382
- this.lastUpdateTime = ee();
2383
- }
2384
- onHandleAppForeground() {
2385
- const e = ee();
2386
- const t = e - this.lastUpdateTime;
2387
- a("elapsedTime", t);
2388
- for (const e of ce(i = this.timers).call(i)) {
2389
- var i;
2390
- if (e.remainingTime > 0) {
2391
- e.remainingTime -= t;
2392
- e.executionTime += t;
2393
- }
2394
- }
2395
- this.lastUpdateTime = e;
2396
- }
2397
- registerInterval(e, t, i) {
2398
- if (this.has(e)) {
2399
- return o(`${e}定时器已存在,请勿重复注册`);
2400
- }
2401
- const n = new TimerEntry(e, Qt.Interval, t, i);
2402
- this.timers.set(e, n);
2403
- }
2404
- registerDelay(e, t, i) {
2405
- if (this.has(e)) {
2406
- return o(`${e}延时器已存在,请勿重复注册`);
2407
- }
2408
- const n = new TimerEntry(e, Qt.Delay, t, i);
2409
- this.timers.set(e, n);
2410
- }
2411
- unregister(e) {
2412
- if (this.has(e)) {
2413
- this.timers.delete(e);
2414
- }
2415
- }
2416
- has(e) {
2417
- return this.timers.has(e);
2418
- }
2419
- update() {
2420
- const e = [];
2421
- for (const [i, n] of he(t = this.timers).call(t)) {
2422
- var t;
2423
- n.remainingTime -= 1e3;
2424
- if (n.remainingTime <= 0) {
2425
- if (n.type === Qt.Interval) {
2426
- n.executionTime += n.initialTime;
2427
- }
2428
- n.callback(n.executionTime);
2429
- if (n.type === Qt.Interval) {
2430
- n.remainingTime = n.initialTime;
2431
- } else {
2432
- e.push(i);
2433
- }
2434
- }
2435
- }
2436
- for (const t of e) {
2437
- this.timers.delete(t);
2438
- }
2439
- }
2440
- }
2441
-
2442
- const Jt = (t, i) => (n, o, s) => {
2443
- let r = s.value;
2444
- s.value = function() {
2445
- const n = t ?? e._cat.default_audio_effect;
2446
- if (n) {
2447
- e._cat.audio.playEffect(n);
2448
- } else {
2449
- console.warn(`请添加音效路径参数`);
2450
- }
2451
- if (i) {
2452
- i();
2453
- }
2454
- for (var o = arguments.length, s = new Array(o), a = 0; a < o; a++) {
2455
- s[a] = arguments[a];
2456
- }
2457
- r.apply(this, s);
2458
- };
2459
- return s;
2460
- };
2461
-
2462
- const Xt = function() {
2463
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2464
- let t = arguments.length > 1 ? arguments[1] : undefined;
2465
- return function(i, n, o) {
2466
- let s = o.value;
2467
- let r = false;
2468
- o.value = function() {
2469
- if (r) {
2470
- if (t) {
2471
- t();
2472
- }
2473
- return;
2474
- }
2475
- r = true;
2476
- X(() => {
2477
- r = false;
2478
- }, e * 1e3);
2479
- for (var i = arguments.length, n = new Array(i), o = 0; o < i; o++) {
2480
- n[o] = arguments[o];
2481
- }
2482
- s.apply(this, n);
2483
- };
2484
- return o;
2485
- };
2486
- };
2487
-
2488
- const Zt = e._cat ??= Manager.instance;
2489
-
2490
- _.onPostProjectInitDelegate.add(async () => {
2491
- console.time("[Init App]");
2492
- try {
2493
- await Zt.boot();
2494
- await Zt.onAppInitDelegate.dispatch();
2495
- await Zt.onPlugInInitDelegate.dispatch();
2496
- } catch (e) {
2497
- o(`[Init App] 初始化失败: ${e instanceof Error ? e.message : String(e)}`);
2498
- throw e;
2499
- } finally {
2500
- console.timeEnd("[Init App]");
2501
- }
2502
- });
2503
-
2504
- export { Jt as AudioEffect, ge as AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, Se as AudioTypeEnum, BaseComponent, BaseManager, It as BasePrefab, BaseStore, Xt as ButtonLock, Ge as CoreBlackMask, ft as CoreNotice, at as CoreReconnection, Ye as CoreShowLoading, CoreStore, Le as CoreToast, ze as CoreUIContainer, qt as CoreUIModal, CoreUtil, je as GlobalEventConstant, Tt as Gui, GuiManager, At as LayerType, Manager, et as ReconnectPrompt, RootUILayer, SceneLayer, TimerManager, De as ToastType, UILayer, WrapperSocialGameClient, Zt as cat };
1
+ import e from"@babel/runtime-corejs3/core-js/global-this";import{AudioSource as t,_decorator as i,AudioClip as o,error as n,Node as s,director as r,log as a,Component as c,Prefab as l,instantiate as h,isValid as d,Layers as u,view as p,Widget as f,v3 as m,tween as g,Enum as _,game as y,Label as v,UIOpacity as b,Tween as C,BlockInputEvents as E,Button as S,assetManager as w,Director as O,warn as A,AsyncDelegate as T,Game as I,Asset as k,resources as R,sys as M,SpriteFrame as U,Sprite as N}from"cc";import D from"@babel/runtime-corejs3/core-js-stable/reflect/get";import L from"@babel/runtime-corejs3/core-js-stable/reflect/set";import j from"@babel/runtime-corejs3/core-js-stable/object/assign";import x from"@babel/runtime-corejs3/core-js-stable/promise";import B from"eventemitter3";import F from"@babel/runtime-corejs3/core-js-stable/instance/includes";import P from"@babel/runtime-corejs3/core-js-stable/json/stringify";import G from"@babel/runtime-corejs3/core-js-stable/map";import H from"@babel/runtime-corejs3/core-js-stable/instance/for-each";import $ from"@babel/runtime-corejs3/core-js-stable/instance/filter";import K from"@babel/runtime-corejs3/core-js-stable/array/is-array";import W from"@babel/runtime-corejs3/core-js-stable/reflect/own-keys";import V from"@babel/runtime-corejs3/core-js-stable/instance/bind";import{makeObservable as z,observable as q,autorun as Q,reaction as J}from"@shimotsuki/mobx";import X from"@babel/runtime-corejs3/core-js-stable/set-timeout";import Z from"@babel/runtime-corejs3/core-js-stable/instance/map";import Y from"@babel/runtime-corejs3/core-js-stable/array/from";import ee from"@babel/runtime-corejs3/core-js-stable/date/now";import te from"@babel/runtime-corejs3/core-js-stable/instance/every";import{SocketConnectStatus as ie}from"pitayaclient";import{DEBUG as oe,WECHAT as ne,PREVIEW as se}from"cc/env";import{SocialGameClient as re}from"sgc";import ae from"crypto-es";import ce from"@babel/runtime-corejs3/core-js-stable/set-interval";import le from"@babel/runtime-corejs3/core-js-stable/instance/values";import he from"@babel/runtime-corejs3/core-js-stable/instance/entries";class CommonAudio extends t{cat;initAudio(e){return this.cat=e,this}}const{ccclass:de,menu:ue}=i;let pe=class AudioEffect extends CommonAudio{effects=(()=>new G)();load(e,t){return new x((i,n)=>{let s,r=null;void 0!==t?(r=e,s=t):s=e;const a=(e,t)=>{if(e)return n(e);this.effects.set(s,t),this.playOneShot(t,this.volume),i(t)};r?this.cat.res.load(r,s,o,a):this.cat.res.load(s,o,a)})}release(){for(let e in this.effects)this.cat.res.release(e);this.effects.clear()}};const{ccclass:fe,menu:me}=i;class AudioMusic extends CommonAudio{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(e){this._progress=e,this.currentTime=e*this.duration}load(e,t){return new x((i,s)=>{let r,a=null;void 0!==t?(a=e,r=t):r=e;const c=(e,t)=>{if(e)return n(e),s(e);this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=t,this._url=r,i(t)};a?this.cat.res.load(a,r,o,c):this.cat.res.load(r,o,c)})}update(e){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class BaseManager{cat;constructor(e){this.cat=e}}var ge;!function(e){e.MUSIC_ON="AudioEventConstant/MUSIC_ON",e.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",e.EFFECT_ON="AudioEventConstant/EFFECT_ON",e.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",e.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",e.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(ge||(ge={}));class AudioManager extends BaseManager{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(e){super(e),this.local_store_key=this.cat.audio_local_store_key;var t=new s("UIAudioManager");r.addPersistRootNode(t);var i=new s("UIMusic");i.parent=t,this.music=i.addComponent(AudioMusic).initAudio(e);var o=new s("UIEffect");o.parent=t,this.effect=o.addComponent(pe).initAudio(e),this.load()}setMusicComplete(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.music.onComplete=e}async playMusic(e,t){let i,o;this.music.loop=!0,void 0!==t?(o=e,i=t):i=e,i.length&&await(o?this.music.load(o,i):this.music.load(i)).then(()=>{this._switch_music&&this.music.play()})}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){var e;F(e=[0,2]).call(e,this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(e){this.music.progress=e}get volumeMusic(){return this._volume_music}set volumeMusic(e){this._volume_music=e,this.music.volume=e}get switchMusic(){return this._switch_music}set switchMusic(e){if(a("设置背景音乐开关值",e,this._switch_music),e==this._switch_music)return;this._switch_music=e,e?this.resumeMusic():this.pauseMusic();const t=e?ge.MUSIC_ON:ge.MUSIC_OFF;this.cat.event.emit(t),this.save()}async playEffect(e,t){if(!this._switch_effect)return;let i,o;void 0!==t?(o=e,i=t):i=e,i.length&&await(o?this.effect.load(o,i):this.effect.load(i)).then(()=>{this.effect.play()})}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(e){this._volume_effect=e,this.effect.volume=e}get switchEffect(){return this._switch_effect}set switchEffect(e){if(e==this._switch_effect)return;this._switch_effect=e,e?this.effect?.play():this.effect?.stop();const t=e?ge.EFFECT_ON:ge.EFFECT_OFF;this.cat.event.emit(t),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let e=P(this.local_data);return this.cat.storage.set(this.local_store_key,e),this}load(){try{let e=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(e),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(e){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}function _e(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(s<3?n(r):s>3?n(t,i,r):n(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r}function ye(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}"function"==typeof SuppressedError&&SuppressedError;class BaseComponent extends c{props={};data={};cat=(()=>e._cat)();autorunDisposers=[];reactionDisposers=[];eventEmitter=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),z(this,{props:q,data:q})}onAutoObserver(){}addAutorun(e){const t=K(e)?e:[e];return H(t).call(t,e=>{const t=Q(e);this.autorunDisposers.push(t)}),this}addReaction(e,t,i){const o=J(e,t,i);return this.reactionDisposers.push(o),this}addAudoListener(e){var t;return F(t=this.eventEmitter).call(t,e)||e===this.cat.event||this.eventEmitter.push(e),e}_onPreDestroy(){var e,t;if(H(e=this.autorunDisposers).call(e,e=>{e()}),H(t=this.reactionDisposers).call(t,e=>{e()}),this.autorunDisposers=[],this.reactionDisposers=[],!super._onPreDestroy)throw new Error("_onPreDestroy已弃用");super._onPreDestroy()}onDisable(){var e;this.onHide(),this.deleteAllEventByEmitter(this.cat.event),H(e=this.eventEmitter).call(e,e=>{this.deleteAllEventByEmitter(e)}),this.eventEmitter=[],this.removeListener()}deleteAllEventByEmitter(e){const t=e._events;for(const i in t){let o=t[i];K(o)||(o=[o]),H(o).call(o,t=>{t.context===this&&e.off(i,t.fn,this)})}}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(e,t,i){const o=e instanceof l?h(e):e instanceof c?e.node:e;if("number"==typeof t){const e=t,n=i;this.setOptions(n),o.insertChild(this.node,e)}else{const e=t;this.setOptions(e),o.addChild(this.node)}return this}setOptions(e){if(e)for(let t in e)switch(t){case"hook":e.hook&&(this.hook=e.hook);break;case"props":null!==e.props&&"object"==typeof e.props&&(this.props=e.props);break;case"data":null!==e.data&&"object"==typeof e.data&&(this.data=e.data)}}setUpdateData(e){if(this.data)return e&&j(this.data,this.toPlainObject(e)),this}setUpdateProps(e){if(this.props)return e&&j(this.props,this.toPlainObject(e)),this}toPlainObject(e){const t={};for(const i of W(e))if("string"==typeof i)try{t[i]=e[i]}catch{}return t}removeAndDestroy(){d(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(e){return this.node.setPosition(e),this}setScale(e){return this.node.setScale(e),this}setAngle(e){return this.node.angle=e,this}setRotation(e){return this.node.setRotation(e),this}setRotationFromEuler(e){return this.node.setRotationFromEuler(e),this}onShow(){}onHide(){}setNodeAndChildrenLayer(e){return ve(this.node,e),this}}const ve=(e,t)=>{var i,o,n;e.layer="string"==typeof t?2**u.nameToLayer(t):t,(null==(i=e)?void 0:V(n=Function.call).call(n,H(o=i.children),o))?.(e=>{ve(e,t)})};class UILayer extends BaseComponent{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=p.getVisibleSize()}async showTween(e){let{isMotion:t=!0,direction:i="center",duration:o=.1,isBounce:n=!0,bounceDuration:s=.05}=e;if(this.lastEnterDirection=i,t){const e=this.node.getComponent(f);let t,s;e&&(e.updateAlignment(),e.enabled=!1),m(1.1,1.1,1),"center"==i?(t=m(.01,.01,.01),s=m(1,1,1)):(t="left"==i?m(-this.screen.width,0,0):"right"==i?m(this.screen.width,0,0):m(0,"top"==i?this.screen.height:-this.screen.height,0),s=m(0,0,0)),await this.handle(i,o,t,s,n),e&&(e.enabled=!0)}}async hideTween(e){let{isMotion:t=!0,direction:i,duration:o=.1}=e;if(i=i||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,g(this.node).removeSelf(),t){const e=this.node.getComponent(f);let t,n;e&&(e.enabled=!1),"center"==i?(t=this.node.scale,n=m(0,0,0)):(n="left"==i?m(-this.screen.width,0,0):"right"==i?m(this.screen.width,0,0):m(0,"top"==i?this.screen.height:-this.screen.height,0),t=this.node.getPosition()),await this.handle(i,o,t,n,!1)}this.removeAndDestroy()}}async handle(e,t,i,o,n){"center"==e?this.node.setScale(i):this.node.setPosition(i),await this.deftween(t,{["center"==e?"scale":"position"]:o},n)}deftween(e,t,i,o){return new x((i,o)=>{g(this.node).to(e,t).call(()=>{i()}).start()})}}var be;const{ccclass:Ce,property:Ee}=i;var Se,we;!function(e){e[e.EFFECT=0]="EFFECT",e[e.BGM=1]="BGM"}(Se||(Se={}));class AudioSourceBaseComponent extends BaseComponent{type=(()=>Se.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new t)();onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,this.cat.event.on(ge.EFFECT_ON,this.onPlayEffectHandler,this).on(ge.EFFECT_OFF,this.onStopEffectHandler,this).on(ge.MUSIC_ON,this.onPlayMusicHandler,this).on(ge.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:e,volumeMusic:t}=this.cat.audio;this.audioSource.volume=this.type===Se.BGM?t:e}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=this.cat.audio;this.audioSource.playing||!(this.type===Se.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}_e([Ee({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:_(Se)}),ye("design:type",Number)],AudioSourceBaseComponent.prototype,"type",void 0),_e([Ee({tooltip:"音源",type:o}),ye("design:type","function"==typeof(be=void 0!==o&&o)?be:Object)],AudioSourceBaseComponent.prototype,"clip",void 0),_e([Ee({tooltip:"循环"}),ye("design:type",Boolean)],AudioSourceBaseComponent.prototype,"loop",void 0),_e([Ee({tooltip:"音量"}),ye("design:type",Number)],AudioSourceBaseComponent.prototype,"volume",void 0),_e([Ee({tooltip:"是否启用自动播放"}),ye("design:type",Boolean)],AudioSourceBaseComponent.prototype,"playOnAwake",void 0);const{ccclass:Oe,property:Ae}=i;class AudioSourceUILayer extends UILayer{type=(()=>Se.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new t)();onEnable(){super.onEnable(),this.cat.event.on(ge.EFFECT_ON,this.onPlayEffectHandler,this).on(ge.EFFECT_OFF,this.onStopEffectHandler,this).on(ge.MUSIC_ON,this.onPlayMusicHandler,this).on(ge.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:e,volumeMusic:t}=this.cat.audio;this.audioSource.volume=this.type===Se.BGM?t:e}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:e,switchMusic:t}=this.cat.audio;this.audioSource.playing||!(this.type===Se.BGM?t:e)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}var Te,Ie,ke,Re;_e([Ae({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:_(Se)}),ye("design:type",Number)],AudioSourceUILayer.prototype,"type",void 0),_e([Ae({tooltip:"音源",type:o}),ye("design:type","function"==typeof(we=void 0!==o&&o)?we:Object)],AudioSourceUILayer.prototype,"clip",void 0),_e([Ae({tooltip:"循环"}),ye("design:type",Boolean)],AudioSourceUILayer.prototype,"loop",void 0),_e([Ae({tooltip:"音量"}),ye("design:type",Number)],AudioSourceUILayer.prototype,"volume",void 0),_e([Ae({tooltip:"是否启用自动播放"}),ye("design:type",Boolean)],AudioSourceUILayer.prototype,"playOnAwake",void 0);const{ccclass:Me,property:Ue,menu:Ne}=i;var De;!function(e){e[e.FIXED=0]="FIXED",e[e.SLIDE=1]="SLIDE"}(De||(De={}));let Le=class CoreToast extends BaseComponent{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new x(async(e,t)=>{const{title:i,type:o,fixed_time:n}=this.props;o==De.FIXED?(this.fixed_node.active=!0,this.fixed_label.string=`${i}`,this.scheduleOnce(()=>{this.node.destroy(),e()},n)):(this.slide_node.active=!0,this.slide_label.string=`${i}`,this.playAnim(this.node).then(()=>{e()}))})}playAnim(e){return new x((t,i)=>{const o=this.node.getComponent(b),n=g(o).delay(1.2).to(.5,{opacity:0}).call(()=>{C.stopAllByTarget(e),this.node.destroy(),t()});g(e).by(.5,{position:m(0,400,0)}).call(()=>{n.start()}).start()})}onDestroy(){C.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var je,xe;_e([Ue({type:s,tooltip:"固定节点"}),ye("design:type","function"==typeof(Te=void 0!==s&&s)?Te:Object)],Le.prototype,"fixed_node",void 0),_e([Ue({type:s,tooltip:"滑动节点"}),ye("design:type","function"==typeof(Ie=void 0!==s&&s)?Ie:Object)],Le.prototype,"slide_node",void 0),_e([Ue({type:v,tooltip:"固定标签节点"}),ye("design:type","function"==typeof(ke=void 0!==v&&v)?ke:Object)],Le.prototype,"fixed_label",void 0),_e([Ue({type:v,tooltip:"滑动标签节点"}),ye("design:type","function"==typeof(Re=void 0!==v&&v)?Re:Object)],Le.prototype,"slide_label",void 0),Le=_e([Me("CoreToast"),Ne("CATCORE/CoreToast")],Le),function(e){e.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",e.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",e.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",e.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",e.ONLINE="GlobalEventConstant/ONLINE",e.OFFLINE="GlobalEventConstant/OFFLINE",e.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",e.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(je||(je={}));const{ccclass:Be,property:Fe,menu:Pe}=i;let Ge=class CoreBlackMask extends BaseComponent{tween};var He,$e;_e([Fe({type:s,tooltip:"动画节点"}),ye("design:type","function"==typeof(xe=void 0!==s&&s)?xe:Object)],Ge.prototype,"tween",void 0),Ge=_e([Be("CoreBlackMask"),Pe("CATCORE/CoreBlackMask")],Ge);const{ccclass:Ke,property:We,menu:Ve}=i;let ze=class CoreUIContainer extends UILayer{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Ge)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){this.cat.event.on(je.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const e=this.brother[this.brother.length-1];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const e=this.brother[this.brother.length-2];e&&this.scene_mask.node.setSiblingIndex(e.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(e){return d(this)&&this.scene_mask&&this.scene_mask.tween.addChild(e),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(e){return this.gui=e,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(e){this.scene_mask.node.active=e}};_e([We({type:s}),ye("design:type","function"==typeof(He=void 0!==s&&s)?He:Object)],ze.prototype,"scene_mask_node",void 0),_e([We({type:s}),ye("design:type","function"==typeof($e=void 0!==s&&s)?$e:Object)],ze.prototype,"ui_container",void 0),ze=_e([Ke("CoreUIContainer"),Ve("CATCORE/CoreUIContainer")],ze);class RootUILayer extends UILayer{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){this.cat.event.emit(je.ROOT_MASK_UPDATE)}}var qe,Qe;const{ccclass:Je,property:Xe,menu:Ze}=i;let Ye=class CoreShowLoading extends RootUILayer{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(E).enabled=!!this.props?.mask}])}update(e){this.loading_rotate+=220*e,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};var et,tt,it,ot;_e([Xe({type:v,tooltip:"标题"}),ye("design:type","function"==typeof(qe=void 0!==v&&v)?qe:Object)],Ye.prototype,"title",void 0),_e([Xe({type:s,tooltip:"动画"}),ye("design:type","function"==typeof(Qe=void 0!==s&&s)?Qe:Object)],Ye.prototype,"loadingTween",void 0),Ye=_e([Je("CoreShowLoading"),Ze("CATCORE/CoreShowLoading")],Ye),function(e){e.RECONNECTED="重连成功",e.RECONNECTING="正在重连",e.MAX_RECONNECT="重连次数超出限制,请检查网络",e.RECONNECTED_ERROR="重连失败,请检查网络",e.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",e.KICK="账号已下线",e.OFFLINE="网络已断开",e.ONLINE="网络已连接",e.GAME_ERROR="连接游戏服错误"}(et||(et={}));const{ccclass:nt,property:st,menu:rt}=i;let at=class CoreReconnection extends RootUILayer{common_prompt_text;btn_confirm;btn_close;is_close=!1;props={content:null};initUI(){}onLoad(){this.btn_confirm.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(e){this.updatePromptText(e,e==et.RECONNECTING)}updatePromptText(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.unscheduleAllCallbacks(),this.props.content=e,a("更新提示文案:",e),t){let t=0;const i=()=>{t=(t+1)%4,this.common_prompt_text.string=e+["","·","··","···"][t]};this.schedule(i,.5)}}onConfirmHandler(){this.is_close=!0,this.cat.gui.hideReconnect()}};var ct,lt,ht;_e([st({type:v,tooltip:"通用提示文本"}),ye("design:type","function"==typeof(tt=void 0!==v&&v)?tt:Object)],at.prototype,"common_prompt_text",void 0),_e([st({type:S,tooltip:"确定按钮"}),ye("design:type","function"==typeof(it=void 0!==S&&S)?it:Object)],at.prototype,"btn_confirm",void 0),_e([st({type:S,tooltip:"关闭按钮"}),ye("design:type","function"==typeof(ot=void 0!==S&&S)?ot:Object)],at.prototype,"btn_close",void 0),at=_e([nt("CoreReconnection"),rt("CATCORE/CoreReconnection")],at);const{ccclass:dt,property:ut,menu:pt}=i;let ft=class CoreNotice extends RootUILayer{text;btn_confirm;btn_close;onLoad(){this.btn_confirm.node.on(S.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),this.cat.gui.hideNotice()}updateProps(e){this.text.string=`${e.text}`}};_e([ut({type:v,tooltip:"提示文本"}),ye("design:type","function"==typeof(ct=void 0!==v&&v)?ct:Object)],ft.prototype,"text",void 0),_e([ut({type:S,tooltip:"确定按钮"}),ye("design:type","function"==typeof(lt=void 0!==S&&S)?lt:Object)],ft.prototype,"btn_confirm",void 0),_e([ut({type:S,tooltip:"关闭按钮"}),ye("design:type","function"==typeof(ht=void 0!==S&&S)?ht:Object)],ft.prototype,"btn_close",void 0),ft=_e([dt("CoreNotice"),pt("CATCORE/CoreNotice")],ft);class SceneLayer extends BaseComponent{isReload}var mt,gt,_t,yt,vt,bt,Ct,Et;const{ccclass:St,property:wt,menu:Ot}=i;var At;!function(e){e[e.UI=0]="UI",e[e.LOADING=1]="LOADING",e[e.TOAST=2]="TOAST",e[e.RECONNECTTION=3]="RECONNECTTION",e[e.NOTICE=4]="NOTICE"}(At||(At={}));let Tt=class Gui extends BaseComponent{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;currentSceneUUID;onEventListener(){this.cat.event.on(je.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(e){this.cat=e;const t=r.getScene();return a("init scene"),t&&this.changeScene(t),this}start(){this.onRootUpdate()}toastQueue=[];isScheduling=!1;minInterval=.2;showToast(e){this.toastQueue.push(e),this.isScheduling||this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return void(this.isScheduling=!1);this.isScheduling=!0;const e=this.toastQueue.shift(),t=()=>{h(this.toast_ui_prefab).getComponent(Le).addToParent(this.root_toast,{props:e}),this.scheduleOnce(()=>{this.processQueueWithInterval()},this.minInterval)};0===this.root_toast.children.length?t():this.scheduleOnce(t,this.minInterval)}hideToast(){var e;this.root_toast&&H(e=this.root_toast.children).call(e,e=>{e.getComponent(Le)?.removeAndDestroy()});return this.toastQueue=[],this.unschedule(this.processQueueWithInterval),this.isScheduling=!1,this}showLoading(){let{title:e="",mask:t=!0,black:i=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a("showLoading",e),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:e,mask:t,black:i}});else{const o=h(this.loading_ui_prefab);this.loading_ui_component=o.getComponent(Ye).addToParent(this.root_ui,{props:{title:e,mask:t,black:i}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(e){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:e});else{const t=h(this.reconnection_ui_prefab);this.reconnection_ui_component=t.getComponent(at).addToParent(this.root_ui,{props:{content:e}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(e){const t=h(this.notice_ui_prefab);return this.notice_ui_component=t.getComponent(ft).addToParent(this.root_ui,{props:e}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}findBundleBySceneUUID(e){const t=w.bundles._map;for(const i in t){const o=t[i],n=o.config?.scenes?._map;if(n)for(const t in n){const i=n[t];if(i?.uuid===e)return o}}return null}findSceneByUUIDFromBundle(e,t){}loadScene(e,t,i,o){let s;a("[加载场景参数]",e,t,i,o);let c,l=!0;const h=[t,i,o];for(const e of h)"boolean"==typeof e?l=e:"function"==typeof e?c=e:e&&"object"==typeof e&&(s=e);if(r.once(O.EVENT_BEFORE_SCENE_LAUNCH,e=>{this.changeScene(e,s??{},l)}),r.once(O.EVENT_AFTER_SCENE_LAUNCH,()=>{c?.()}),"string"==typeof e){const t=this.findBundleBySceneUUID(e);if(t)if("main"!==t.name)t.loadScene(this.currentScene,(e,t)=>{if(e)return n("loadScene err",e);r.runScene(t)});else{const i=t.getAssetInfo(e);i?.url&&r.loadScene(i.url)}else r.loadScene(e)}else r.runScene(e);return this}resetScene(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e=e||this.currentScene,this.loadScene(e)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(e,t,i){this.currentScene=e.name,this.currentSceneUUID=e.uuid,this.createUILayer(e);const o=e.getComponentInChildren(SceneLayer);a("给场景传递属性值=======",o),o&&(o.isReload=i??!0),o?.setOptions(t)}createUILayer(e){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const t=h(this.ui_prefab);this.ui_container_component=t.getComponent(ze),this.ui_container_component?.setGui(this).addToParent(e,this.node.getSiblingIndex())}reloadScene(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>{};a("重新加载当前场景"),this.loadScene(this.currentSceneUUID,!0,e)}async closeUI(e,t){const{component:i}=this.findUIBaseLayer(e,!1);i&&(i.setOptions({...t?.hook??{},...t?.props??{}}),await i.hideTween(t||{}),this.ui_container_component?.subMask())}async openUI(e,t){const{rootNode:i,component:o}=this.findUIBaseLayer(e,!0);i.getComponent(UILayer),o?.setOptions(t),i&&this.ui_container_component?.addNodeToTween(i).addMask(),o&&await o.showTween(t||{}),this.ui_container_component?.ui_container&&o?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(e,t){let i,o=null;if(e instanceof s){var r;i=e;const t=$(r=e.components).call(r,e=>e instanceof UILayer);if(!t.length)return n(`${e.name}节点未找到继承自BaseLayer的组件`),{rootNode:i,component:o};1==t.length?o=t[0]:A(`${e.name}节点存在多个继承自BaseLayer的组件`)}else if(i=e.node,o=e,t){for(;i.parent;)i=i.parent;o.root=i}else i=e.root;return{rootNode:i,component:o}}onRootUpdate(){const e=this.root_ui.children.findLastIndex(e=>e.active&&e!=this.root_mask);if(this.root_mask.active=-1!=e,e>-1){const t=this.root_ui.children[e].getSiblingIndex()-1;this.root_mask.setSiblingIndex(t<0?0:t)}this.cat.event.emit(je.ROOT_MASK_CHANGE)}};var It;_e([wt({type:l,tooltip:"断线重连UI预制体"}),ye("design:type","function"==typeof(mt=void 0!==l&&l)?mt:Object)],Tt.prototype,"reconnection_ui_prefab",void 0),_e([wt({type:l,tooltip:"提示UI预制体"}),ye("design:type","function"==typeof(gt=void 0!==l&&l)?gt:Object)],Tt.prototype,"toast_ui_prefab",void 0),_e([wt({type:l,tooltip:"加载UI预制体"}),ye("design:type","function"==typeof(_t=void 0!==l&&l)?_t:Object)],Tt.prototype,"loading_ui_prefab",void 0),_e([wt({type:l,tooltip:"公告UI预制体"}),ye("design:type","function"==typeof(yt=void 0!==l&&l)?yt:Object)],Tt.prototype,"notice_ui_prefab",void 0),_e([wt({type:l,tooltip:"UI层预制体"}),ye("design:type","function"==typeof(vt=void 0!==l&&l)?vt:Object)],Tt.prototype,"ui_prefab",void 0),_e([wt({type:s,tooltip:"root-UI层"}),ye("design:type","function"==typeof(bt=void 0!==s&&s)?bt:Object)],Tt.prototype,"root_ui",void 0),_e([wt({type:s,tooltip:"root-组件层"}),ye("design:type","function"==typeof(Ct=void 0!==s&&s)?Ct:Object)],Tt.prototype,"root_toast",void 0),_e([wt({type:s,tooltip:"root-mask"}),ye("design:type","function"==typeof(Et=void 0!==s&&s)?Et:Object)],Tt.prototype,"root_mask",void 0),Tt=_e([St("Gui"),Ot("CATCORE/Gui")],Tt),function(e){e.Root="prefabs/root",e.Toast="prefabs/toast",e.BlackMask="prefabs/black-mask",e.Loading="prefabs/loading",e.Notice="prefabs/notice",e.Reconnection="prefabs/reconnection"}(It||(It={}));class GuiManager extends BaseManager{gui;#e="core";getGuiPrefabByType=(e,t)=>new x((i,o)=>{a(e,`${t}`),this.cat.res.load(e,t,(e,t)=>{e?o(e):i(t)})});async init(){this.cat.gui_bundle_name&&(this.#e=this.cat.gui_bundle_name);const e=await this.getGuiPrefabByType(this.#e,It.Root),t=h(e);return this.gui=t.getComponent(Tt).init(this.cat),r.addPersistRootNode(t),this}}class WrapperSocialGameClient extends re{showRequestErrInfo=!1;logBlackList=[];ignore=e=>{var t;return F(t=this.logBlackList).call(t,e)};constructor(e,t,i,o){super(t,i,o,e),this.showRequestErrInfo=o?.showRequestErrInfo??!1}destroy(){this.disconnect(!0),e._cat.socialGameClient.unregister(this)}async GameRequest(t,i,o){let{forwardReq:s=!1,forwardResp:r=!1}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new x((c,l)=>{super.GameRequest(t,i,o,{forwardReq:s,forwardResp:r}).then(e=>{oe&&a(`%c ws服务端消息 %c [Response][${new Date}] %c ${t} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),c(e)},t=>{n(t),this.showRequestErrInfo&&t?.msg&&e._cat.gui.showToast({title:t.msg}),l(t)})})}subscribe(t,i,o){return super.subscribe(t,i,i=>{oe&&!this.ignore(t)&&a(`%c ws服务端消息:[subscribe][${new Date}] %c ${t} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),e._cat.event.emit(t,i),o?.(i)}),this}}class SocialGameClientManager extends BaseManager{managedClients=(()=>new G)();isGlobalOnline=!0;isInBackground=!1;reconnecting=!1;onEventHideDelegate=(()=>new T)();onEventShowDelegate=(()=>new T)();onEventReloadSceneDelegate=(()=>new T)();reconnectTimer=null;lastReconnectTime=0;RECONNECT_COOLDOWN=1500;pendingShowOptions=[];scheduleReconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectTimer=X(()=>{this.reconnectTimer=null,this.triggerReconnectAll()},e)}get activeClients(){var e,t;return $(e=Z(t=Y(this.managedClients)).call(t,e=>{let[t,i]=e;return i})).call(e,e=>e.socket)}constructor(e){super(e),this.initGlobalListeners()}createWebSocket(e,t,i,o){if(this.managedClients.has(e)){this.managedClients.get(e).destroy(),a(`清理旧的 ${e} 客户端`)}const n=new WrapperSocialGameClient(e,i,o,j({reconnectMaxAttempts:1/0},{...t,isAutoConnect:!1,isArrayBuffer:ne}));return this.register(n),n}register(e){e.on("reconnected",this.handleSingleReconnect),e.on("close",this.handleSingleClose),e.on("kick",this.handleSingleKick),this.managedClients.set(e.name,e)}unregister(e){e.off("reconnected",this.handleSingleReconnect),e.off("close",this.handleSingleClose),e.off("kick",this.handleSingleKick),this.managedClients.delete(e.name)}initGlobalListeners(){this.cat.event.on(je.ONLINE,()=>this.handleGlobalStateChange("online"),this).on(je.OFFLINE,()=>this.handleGlobalStateChange("offline"),this),ne?(wx.onShow(e=>{this.handleGlobalStateChange("show",e)}),wx.onHide(e=>{this.handleGlobalStateChange("hide",e)})):(y.on(I.EVENT_SHOW,()=>this.handleGlobalStateChange("show")),y.on(I.EVENT_HIDE,()=>this.handleGlobalStateChange("hide")))}async handleGlobalStateChange(e,t){switch(e){case"online":this.cat.gui.hideLoading().showToast({title:et.ONLINE}),this.isGlobalOnline=!0,this.safeTriggerReconnectAll();break;case"offline":this.isGlobalOnline=!1,this.disconnectAll(!0),this.cat.gui.showLoading({title:et.OFFLINE});break;case"show":this.isInBackground=!1,a("监听前台 show",t),t&&this.pendingShowOptions.push(t),await this.safeTriggerReconnectAll();break;case"hide":a("监听前台 hide"),await this.onEventHideDelegate.dispatch(t),this.isInBackground=!0,this.disconnectAll(!0)}}async safeTriggerReconnectAll(){const e=ee();if(this.reconnecting||!this.isGlobalOnline||this.isInBackground||0===this.managedClients.size)return console.log("[safeTriggerReconnectAll] 没有需要重连的客户端,直接 dispatch"),void await this.dispatchReloadAndShow();this.reconnecting?console.log("[safeTriggerReconnectAll] 正在重连中,跳过本次"):e-this.lastReconnectTime<this.RECONNECT_COOLDOWN?console.log("[safeTriggerReconnectAll] 距上次重连过近,跳过本次"):(this.lastReconnectTime=e,await this.triggerReconnectAll())}async dispatchReloadAndShow(){for(await this.onEventReloadSceneDelegate.dispatch();this.pendingShowOptions.length>0;){const e=this.pendingShowOptions.shift();this.onEventShowDelegate.dispatch(e)}}async triggerReconnectAll(){if(console.log("触发所有客户端重连[正在重连][在线][后台][ws数量]",this.reconnecting,this.isGlobalOnline,this.isInBackground,this.managedClients.size),this.reconnecting||!this.isGlobalOnline||this.isInBackground||0===this.managedClients.size)await this.dispatchReloadAndShow();else{this.reconnecting=!0,this.cat.gui.showLoading({title:"正在重连"});try{var e,t;await x.allSettled(Z(e=this.activeClients).call(e,async e=>{try{await e.reconnectPromise()}catch(t){n(`${e.name}服重连失败`,t)}}));const i=$(t=this.activeClients).call(t,e=>e.socketConnectStatus!==ie.CONNECTED);i.length>0?(Z(i).call(i,e=>{console.error("部分WS重连失败:",e)}),a("2s后重连所有客户端"),this.reconnecting=!1,this.scheduleReconnect()):this.reconnecting=!1}catch(e){throw this.reconnecting=!1,e}}}disconnectAll(e){var t,i;te(t=this.activeClients).call(t,e=>e.socket?.readyState!==WebSocket.OPEN)||H(i=this.managedClients).call(i,t=>{a("断开连接",t.name,e,t.socket),t.disconnect(e)})}handleSingleClose=()=>{this.reconnecting||(a("3s后重连所有客户端"),this.scheduleReconnect(3e3))};handleSingleReconnect=async()=>{var e,t;te(e=this.activeClients).call(e,e=>e.socketConnectStatus===ie.CONNECTED)&&(a("单个WS重连成功回调===",this.managedClients),await x.allSettled(Z(t=this.activeClients).call(t,async e=>{try{await e.connectRequest()}catch(t){n(`${e.name}服登录错误`,t),this.cat.gui.showToast({title:`登录${e.name}服错误`})}})),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),await this.onEventReloadSceneDelegate.dispatch(),this.cat.gui.hideLoading(),r.getScene()?.getComponentInChildren(SceneLayer)?.isReload&&this.cat.gui.reloadScene(()=>{for(;this.pendingShowOptions.length>0;){const e=this.pendingShowOptions.shift();this.onEventShowDelegate.dispatch(e)}}))};handleSingleKick=()=>{this.cat.gui.showReconnect(et.KICK)}}class ResLoader{get=(()=>function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"resources";return w.getBundle(i).get(e,t)})();isAssetType=e=>"function"==typeof e&&e.prototype instanceof k;async load(){let e=null,t=null,i=null;for(var o=arguments.length,n=new Array(o),s=0;s<o;s++)n[s]=arguments[s];"string"==typeof n[0]&&"string"==typeof n[1]&&(e=n.shift());let r=n.shift();this.isAssetType(n[0])&&(t=n.shift()),2==n.length&&(i=n.shift());const a=n.shift();let c=R;if(e&&"resources"!=e){w.bundles.has(e)||await this.loadBundle(e);let t=w.bundles.get(e);t&&(c=t)}i&&a?c.load(r,t,i,a):a?c.load(r,t,a):c.load(r,t)}async loadDir(){let e=null,t=null,i=null,o=null;for(var n=arguments.length,s=new Array(n),r=0;r<n;r++)s[r]=arguments[r];"string"==typeof s[0]&&"string"==typeof s[1]&&(e=s.shift());let a=s.shift();this.isAssetType(s[0])&&(t=s.shift()),2==s.length&&(i=s.shift()),o=s.shift();let c=R;if(e&&"resources"!=e){w.bundles.has(e)||await this.loadBundle(e);let t=w.bundles.get(e);t&&(c=t)}i&&o?c.loadDir(a,t,i,o):o?c.loadDir(a,t,o):c.loadDir(a,t)}loadRemote(e){for(var t,i=null,o=arguments.length,n=new Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];2==n.length&&(i=n.shift()),t=n.shift(),w.loadRemote(e,{ext:".png",...i},t)}loadBundle=(e,t)=>new x((i,o)=>{const n=(e,t)=>{if(e)return o(e);i(t)};t?w.loadBundle(e,{version:t},n):w.loadBundle(e,n)});releasePrefabtDepsRecursively=e=>{var t=w.assets.get(e);if(w.releaseAsset(t),t instanceof l){var i=w.dependUtil.getDepsRecursively(e);H(i).call(i,e=>{w.assets.get(e).decRef()})}};release=(()=>{var e=this;return function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var o=w.getBundle(i);if(o){var n=o.get(t);n&&e.releasePrefabtDepsRecursively(n._uuid)}}})();releaseDir=(()=>{var e=this;return function(t){var i,o;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var s=w.getBundle(n),r=s?.getDirWithPath(t);(null==(i=r)?void 0:V(o=Function.call).call(o,Z(i),i))?.(t=>{e.releasePrefabtDepsRecursively(t.uuid)}),!t&&"resources"!=n&&s&&w.removeBundle(s)}})();dump=()=>{var e;H(e=w.assets).call(e,(e,t)=>{a(w.assets.get(t))}),a(`当前资源总数:${w.assets.count}`)};loadAssetsWithProgress(e,t){return new x((i,o)=>{const n=e.getDirWithPath(""),s=n.length;let r=0;if(0===s)return t(1),void i();H(n).call(n,n=>{e.load(n.path,e=>{e?o(e):(r++,t(r/s),r===s&&i())})})})}}class BaseStore{rootStore;constructor(e){this.rootStore=e}}class CoreStore extends BaseManager{}let kt=null;const Rt={stringify:e=>{const t={ct:e.ciphertext.toString(ae.enc.Base64)};return e.iv&&(t.iv=e.iv.toString()),e.salt&&(t.s=e.salt.toString()),P(t)},parse:e=>{const t=JSON.parse(e),i=ae.lib.CipherParams.create({ciphertext:ae.enc.Base64.parse(t.ct)});return t.iv&&(i.iv=ae.enc.Hex.parse(t.iv)),t.s&&(i.salt=ae.enc.Hex.parse(t.s)),i}};var Mt,Ut,Nt,Dt,Lt,jt,xt,Bt,Ft,Pt=Object.freeze({__proto__:null,JsonFormatter:Rt,aesDecrypt:(e,t,i)=>ae.AES.decrypt(e,t,{iv:kt,format:Rt}).toString(ae.enc.Utf8),aesEncrypt:(e,t,i)=>ae.AES.encrypt(e,t,{iv:kt,format:Rt}).toString(),initCrypto:(e,t)=>{kt=ae.enc.Hex.parse(t)},md5:e=>ae.MD5(e).toString()});class CoreUtil extends BaseManager{encryptUtil=(()=>Pt)()}class StorageManager extends BaseManager{_key=null;_iv=null;_id="";init(e,t){this.cat.util.encryptUtil.initCrypto(e,t),this._key=this.cat.util.encryptUtil.md5(e),this._iv=this.cat.util.encryptUtil.md5(t)}setUser(e){this._id=e}set(e,t){if(null!=(e=`${e}_${this._id}`)){if(se||(e=this.cat.util.encryptUtil.md5(e)),null==t)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(e);if("function"!=typeof t){if("object"==typeof t)try{t=P(t)}catch(e){return void console.error(`解析失败,str = ${t}`)}else"number"==typeof t&&(t+="");se||null==this._key||null==this._iv||(t=this.cat.util.encryptUtil.aesEncrypt(`${t}`,this._key,this._iv)),M.localStorage.setItem(e,t)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(e,t){if(null==e)return console.error("存储的key不能为空"),null;e=`${e}_${this._id}`,se||(e=this.cat.util.encryptUtil.md5(e));let i=M.localStorage.getItem(e);return null==i||""===i||se||null==this._key||null==this._iv||(i=this.cat.util.encryptUtil.aesDecrypt(i,this._key,this._iv)),null===i?t:i}getNumber(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;var i=this.get(e);return Number(i)||t}getBoolean(e){var t=this.get(e);return Boolean(t)||!1}getJson(e,t){var i=this.get(e);return i&&JSON.parse(i)||t}remove(e){null!=e?(e=`${e}_${this._id}`,se||(e=this.cat.util.encryptUtil.md5(e)),M.localStorage.removeItem(e)):console.error("存储的key不能为空")}clear(){M.localStorage.clear()}}class Manager{static#t=null;#i=!1;static get instance(){return this.#t??(this.#t=new Manager)}onAppInitDelegate=(()=>new T)();onPlugInInitDelegate=(()=>new T)();#o=null;get audio(){return this.#o}#n=null;get event(){return this.#n}#s=null;get gui(){return this.#s}#r=null;get storage(){return this.#r}#a=null;get res(){return this.#a}#c=null;get util(){return this.#c}#l=null;get socialGameClient(){return this.#l}#h=null;get store(){return this.#h}#d="";get gui_bundle_name(){return this.#d}#u="";get audio_local_store_key(){return this.#u}#p="";get default_audio_effect(){return this.#p}setConfig=(()=>{var e=this;return function(){let{default_audio_effect:t="",gui_bundleName:i="resources",audio_local_store_key:o="game_audio"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(e.#i)throw new Error("[CAT] 已初始化,无法修改配置");return e.#d=i,e.#u=o,e.#p=t,e}})();async boot(){if(this.#i)throw new Error("[CAT] 已初始化");try{this.#h=new CoreStore(this),this.#a=new ResLoader,this.#c=new CoreUtil(this),this.#r=new StorageManager(this),this.#n=new B,this.#o=new AudioManager(this),this.#l=new SocialGameClientManager(this),this.#s=(await new GuiManager(this).init()).gui,this.#i=!0}catch(e){throw console.error("[CAT] 初始化失败:",e),e}}merge(e,t){if(!this.#i)throw new Error("[CAT] 未初始化");if("string"!=typeof e)throw new Error("merge方法第一个参数应该为string类型");return D(this,e)||L(this,e,t),j(D(this,e),t),this}appendPlugInInitDelegate(e){return this.#i?x.resolve().then(e).catch(e=>{console.error("[CAT] appendPlugInInitDelegate 回调执行失败:",e)}):this.onPlugInInitDelegate.add(e),this}}const{ccclass:Gt,property:Ht,menu:$t}=i;let Kt=class CoreUIModal extends UILayer{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(S.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(S.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(S.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content&&(this.props.content instanceof U?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容"))},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(N).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(N).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),this.cat.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Wt;_e([Ht({type:U,tooltip:"默认标题"}),ye("design:type","function"==typeof(Mt=void 0!==U&&U)?Mt:Object)],Kt.prototype,"default_title",void 0),_e([Ht({type:N,tooltip:"标题节点"}),ye("design:type","function"==typeof(Ut=void 0!==N&&N)?Ut:Object)],Kt.prototype,"title",void 0),_e([Ht({type:v,tooltip:"字符串内容按钮"}),ye("design:type","function"==typeof(Nt=void 0!==v&&v)?Nt:Object)],Kt.prototype,"prompt_content_str",void 0),_e([Ht({type:N,tooltip:"图片精灵内容按钮"}),ye("design:type","function"==typeof(Dt=void 0!==N&&N)?Dt:Object)],Kt.prototype,"prompt_content_spriteFrame",void 0),_e([Ht({type:S,tooltip:"确认按钮"}),ye("design:type","function"==typeof(Lt=void 0!==S&&S)?Lt:Object)],Kt.prototype,"btn_confirm",void 0),_e([Ht({type:U,tooltip:"确认按钮精灵图"}),ye("design:type","function"==typeof(jt=void 0!==U&&U)?jt:Object)],Kt.prototype,"confirm_spriteFrame",void 0),_e([Ht({type:S,tooltip:"取消按钮"}),ye("design:type","function"==typeof(xt=void 0!==S&&S)?xt:Object)],Kt.prototype,"btn_cancel",void 0),_e([Ht({type:U,tooltip:"取消按钮精灵图"}),ye("design:type","function"==typeof(Bt=void 0!==U&&U)?Bt:Object)],Kt.prototype,"cancel_spriteFrame",void 0),_e([Ht({type:S,tooltip:"关闭按钮"}),ye("design:type","function"==typeof(Ft=void 0!==S&&S)?Ft:Object)],Kt.prototype,"btn_close",void 0),Kt=_e([Gt("CoreUIModal"),$t("CATCORE/CoreUIModal")],Kt),function(e){e[e.Delay=0]="Delay",e[e.Interval=1]="Interval"}(Wt||(Wt={}));class TimerEntry{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(e,t,i,o){this.tag=e,this.type=t,this.remainingTime=i,this.initialTime=i,this.callback=o}}class TimerManager extends BaseManager{timers=(()=>new G)();lastUpdateTime=(()=>ee())();constructor(e){var t;super(e),e.event.on(je.EVENT_HIDE,this.onHandleAppBackground,this),e.event.on(je.EVENT_SHOW,this.onHandleAppForeground,this),ce(V(t=this.update).call(t,this),1e3)}onHandleAppBackground(){this.lastUpdateTime=ee()}onHandleAppForeground(){const e=ee(),t=e-this.lastUpdateTime;a("elapsedTime",t);for(const e of le(i=this.timers).call(i)){var i;e.remainingTime>0&&(e.remainingTime-=t,e.executionTime+=t)}this.lastUpdateTime=e}registerInterval(e,t,i){if(this.has(e))return n(`${e}定时器已存在,请勿重复注册`);const o=new TimerEntry(e,Wt.Interval,t,i);this.timers.set(e,o)}registerDelay(e,t,i){if(this.has(e))return n(`${e}延时器已存在,请勿重复注册`);const o=new TimerEntry(e,Wt.Delay,t,i);this.timers.set(e,o)}unregister(e){this.has(e)&&this.timers.delete(e)}has(e){return this.timers.has(e)}update(){const e=[];for(const[i,o]of he(t=this.timers).call(t)){var t;o.remainingTime-=1e3,o.remainingTime<=0&&(o.type===Wt.Interval&&(o.executionTime+=o.initialTime),o.callback(o.executionTime),o.type===Wt.Interval?o.remainingTime=o.initialTime:e.push(i))}for(const t of e)this.timers.delete(t)}}const Vt=(t,i)=>(o,n,s)=>{let r=s.value;return s.value=function(){const o=t??e._cat.default_audio_effect;o?e._cat.audio.playEffect(o):console.warn("请添加音效路径参数"),i&&i();for(var n=arguments.length,s=new Array(n),a=0;a<n;a++)s[a]=arguments[a];r.apply(this,s)},s},zt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1?arguments[1]:void 0;return function(i,o,n){let s=n.value,r=!1;return n.value=function(){if(r)t&&t();else{r=!0,X(()=>{r=!1},1e3*e);for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];s.apply(this,o)}},n}},qt=e._cat??=Manager.instance;y.onPostProjectInitDelegate.add(async()=>{console.time("[Init App]");try{await qt.boot(),await qt.onAppInitDelegate.dispatch(),await qt.onPlugInInitDelegate.dispatch()}catch(e){throw n(`[Init App] 初始化失败: ${e instanceof Error?e.message:String(e)}`),e}finally{console.timeEnd("[Init App]")}});export{Vt as AudioEffect,ge as AudioEventConstant,AudioManager,AudioSourceBaseComponent,AudioSourceUILayer,Se as AudioTypeEnum,BaseComponent,BaseManager,It as BasePrefab,BaseStore,zt as ButtonLock,Ge as CoreBlackMask,ft as CoreNotice,at as CoreReconnection,Ye as CoreShowLoading,CoreStore,Le as CoreToast,ze as CoreUIContainer,Kt as CoreUIModal,CoreUtil,je as GlobalEventConstant,Tt as Gui,GuiManager,At as LayerType,Manager,et as ReconnectPrompt,RootUILayer,SceneLayer,TimerManager,De as ToastType,UILayer,WrapperSocialGameClient,qt as cat};