@shimotsuki/core 3.0.47 → 3.1.0

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