@shimotsuki/core 3.0.7 → 3.0.8

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