@shimotsuki/core 3.0.15 → 3.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,2426 @@
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 f,Enum as g,game as y,Label as v,UIOpacity as b,Tween as C,BlockInputEvents as E,Button as S,assetManager as w,Director as A,warn as I,AsyncDelegate as T,Game as k,Asset as O,resources as M,sys as R,SpriteFrame as U,Sprite as N}from"cc";import D from"@babel/runtime-corejs3/core-js-stable/reflect/get";import L from"@babel/runtime-corejs3/core-js-stable/reflect/set";import 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 fe;!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"}(fe||(fe={}));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?fe.MUSIC_ON:fe.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?fe.EFFECT_ON:fe.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 ge(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,f(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)=>{f(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(fe.EFFECT_ON,this.onPlayEffectHandler,this).on(fe.EFFECT_OFF,this.onStopEffectHandler,this).on(fe.MUSIC_ON,this.onPlayMusicHandler,this).on(fe.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()}}ge([Ce({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(Ee)}),ye("design:type",Number)],AudioSourceBaseComponent.prototype,"type",void 0),ge([Ce({tooltip:"音源",type:o}),ye("design:type",o)],AudioSourceBaseComponent.prototype,"clip",void 0),ge([Ce({tooltip:"循环"}),ye("design:type",Boolean)],AudioSourceBaseComponent.prototype,"loop",void 0),ge([Ce({tooltip:"音量"}),ye("design:type",Number)],AudioSourceBaseComponent.prototype,"volume",void 0),ge([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(fe.EFFECT_ON,this.onPlayEffectHandler,this).on(fe.EFFECT_OFF,this.onStopEffectHandler,this).on(fe.MUSIC_ON,this.onPlayMusicHandler,this).on(fe.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()}}ge([we({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(Ee)}),ye("design:type",Number)],AudioSourceUILayer.prototype,"type",void 0),ge([we({tooltip:"音源",type:o}),ye("design:type",o)],AudioSourceUILayer.prototype,"clip",void 0),ge([we({tooltip:"循环"}),ye("design:type",Boolean)],AudioSourceUILayer.prototype,"loop",void 0),ge([we({tooltip:"音量"}),ye("design:type",Number)],AudioSourceUILayer.prototype,"volume",void 0),ge([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=f(o).delay(1.2).to(.5,{opacity:0}).call(()=>{C.stopAllByTarget(e),this.node.destroy(),t()});f(e).by(.5,{position:_(0,400,0)}).call(()=>{s.start()}).start()})}onDestroy(){C.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var Me;ge([Ie({type:n,tooltip:"固定节点"}),ye("design:type",n)],Oe.prototype,"fixed_node",void 0),ge([Ie({type:n,tooltip:"滑动节点"}),ye("design:type",n)],Oe.prototype,"slide_node",void 0),ge([Ie({type:v,tooltip:"固定标签节点"}),ye("design:type",v)],Oe.prototype,"fixed_label",void 0),ge([Ie({type:v,tooltip:"滑动标签节点"}),ye("design:type",v)],Oe.prototype,"slide_label",void 0),Oe=ge([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:Ue,menu:Ne}=i;let De=class CoreBlackMask extends BaseComponent{tween};ge([Ue({type:n,tooltip:"动画节点"}),ye("design:type",n)],De.prototype,"tween",void 0),De=ge([Re("CoreBlackMask"),Ne("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}};ge([Fe({type:n}),ye("design:type",n)],Be.prototype,"scene_mask_node",void 0),ge([Fe({type:n}),ye("design:type",n)],Be.prototype,"ui_container",void 0),Be=ge([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;ge([Ge({type:v,tooltip:"标题"}),ye("design:type",v)],He.prototype,"title",void 0),ge([Ge({type:n,tooltip:"动画"}),ye("design:type",n)],He.prototype,"loadingTween",void 0),He=ge([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()}};ge([We({type:v,tooltip:"通用提示文本"}),ye("design:type",v)],ze.prototype,"common_prompt_text",void 0),ge([We({type:S,tooltip:"确定按钮"}),ye("design:type",S)],ze.prototype,"btn_confirm",void 0),ge([We({type:S,tooltip:"关闭按钮"}),ye("design:type",S)],ze.prototype,"btn_close",void 0),ze=ge([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}`}};ge([Qe({type:v,tooltip:"提示文本"}),ye("design:type",v)],Xe.prototype,"text",void 0),ge([Qe({type:S,tooltip:"确定按钮"}),ye("design:type",S)],Xe.prototype,"btn_confirm",void 0),ge([Qe({type:S,tooltip:"关闭按钮"}),ye("design:type",S)],Xe.prototype,"btn_close",void 0),Xe=ge([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;currentSceneUUID;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}findBundleBySceneUUID(e){const t=w.bundles._map;for(const i in t){const o=t[i],s=o.config?.scenes?._map;if(s)for(const t in s){const i=s[t];if(i?.uuid===e)return o}}return null}loadScene(e,t,i){a("[加载场景名][参数][重新加载]",e,t,i);let o={},n=i??!0;if("boolean"==typeof t?n=t:o=t??{},r.once(A.EVENT_BEFORE_SCENE_LAUNCH,e=>{a("Director.EVENT_BEFORE_SCENE_LAUNCH",e),this.changeScene(e,o,n)}),"string"==typeof e){const t=this.findBundleBySceneUUID(e);t&&"main"!==t.name?t.loadScene(this.currentScene,(e,t)=>{e?s("loadScene err",e):r.runScene(t)}):r.loadScene(e)}else r.runScene(e);return this}resetScene(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e=e||this.currentScene,this.loadScene(e)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(e,t,i){this.currentScene=e.name,this.currentSceneUUID=e.uuid,this.createUILayer(e);const o=e.getComponentInChildren(SceneLayer);a("给场景传递属性值=======",o),o&&(o.isReload=i??!0),o?.setOptions(t)}createUILayer(e){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const t=h(this.ui_prefab);this.ui_container_component=t.getComponent(Be),this.ui_container_component?.setGui(this).addToParent(e,this.node.getSiblingIndex())}reloadScene(){a("重新加载当前场景"),this.loadScene(this.currentSceneUUID,!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]:I(`${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;ge([Ye({type:c,tooltip:"断线重连UI预制体"}),ye("design:type",c)],it.prototype,"reconnection_ui_prefab",void 0),ge([Ye({type:c,tooltip:"提示UI预制体"}),ye("design:type",c)],it.prototype,"toast_ui_prefab",void 0),ge([Ye({type:c,tooltip:"加载UI预制体"}),ye("design:type",c)],it.prototype,"loading_ui_prefab",void 0),ge([Ye({type:c,tooltip:"公告UI预制体"}),ye("design:type",c)],it.prototype,"notice_ui_prefab",void 0),ge([Ye({type:c,tooltip:"UI层预制体"}),ye("design:type",c)],it.prototype,"ui_prefab",void 0),ge([Ye({type:n,tooltip:"root-UI层"}),ye("design:type",n)],it.prototype,"root_ui",void 0),ge([Ye({type:n,tooltip:"root-组件层"}),ye("design:type",n)],it.prototype,"root_toast",void 0),ge([Ye({type:n,tooltip:"root-mask"}),ye("design:type",n)],it.prototype,"root_mask",void 0),it=ge([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 T)();onEventShowDelegate=(()=>new T)();onEventReloadSceneDelegate=(()=>new T)();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(k.EVENT_SHOW,()=>this.handleGlobalStateChange("show")),y.on(k.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 w.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){w.bundles.has(e)||await this.loadBundle(e);let t=w.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){w.bundles.has(e)||await this.loadBundle(e);let t=w.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(),w.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?w.loadBundle(e,{version:t},s):w.loadBundle(e,s)});releasePrefabtDepsRecursively=e=>{var t=w.assets.get(e);if(w.releaseAsset(t),t instanceof c){var i=w.dependUtil.getDepsRecursively(e);H(i).call(i,e=>{w.assets.get(e).decRef()})}};release=(()=>{var e=this;return function(t){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var o=w.getBundle(i);if(o){var 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=w.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&&w.removeBundle(n)}})();dump=()=>{var e;H(e=w.assets).call(e,(e,t)=>{a(w.assets.get(t))}),a(`当前资源总数:${w.assets.count}`)};loadAssetsWithProgress(e,t){return new x((i,o)=>{const 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 T)();onPlugInInitDelegate=(()=>new T)();#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 U?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容"))},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(N).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(N).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),this.cat.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var ut;ge([lt({type:U,tooltip:"默认标题"}),ye("design:type",U)],ht.prototype,"default_title",void 0),ge([lt({type:N,tooltip:"标题节点"}),ye("design:type",N)],ht.prototype,"title",void 0),ge([lt({type:v,tooltip:"字符串内容按钮"}),ye("design:type",v)],ht.prototype,"prompt_content_str",void 0),ge([lt({type:N,tooltip:"图片精灵内容按钮"}),ye("design:type",N)],ht.prototype,"prompt_content_spriteFrame",void 0),ge([lt({type:S,tooltip:"确认按钮"}),ye("design:type",S)],ht.prototype,"btn_confirm",void 0),ge([lt({type:U,tooltip:"确认按钮精灵图"}),ye("design:type",U)],ht.prototype,"confirm_spriteFrame",void 0),ge([lt({type:S,tooltip:"取消按钮"}),ye("design:type",S)],ht.prototype,"btn_cancel",void 0),ge([lt({type:U,tooltip:"取消按钮精灵图"}),ye("design:type",U)],ht.prototype,"cancel_spriteFrame",void 0),ge([lt({type:S,tooltip:"关闭按钮"}),ye("design:type",S)],ht.prototype,"btn_close",void 0),ht=ge([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,fe 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};
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 n, Node as o, director as r, log as a, Component as l, Prefab as c, instantiate as h, isValid as u, Layers as d, view as p, Widget as f, v3 as m, tween as _, Enum as g, game as y, Label as v, UIOpacity as b, Tween as C, BlockInputEvents as E, Button as S, assetManager as w, Director as A, warn as I, AsyncDelegate as T, Game as k, Asset as O, resources as M, sys as R, SpriteFrame as U, Sprite as N } from "cc";
4
+
5
+ import D from "@babel/runtime-corejs3/core-js-stable/reflect/get";
6
+
7
+ import L from "@babel/runtime-corejs3/core-js-stable/reflect/set";
8
+
9
+ import 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 ne } from "cc/env";
44
+
45
+ import { SocialGameClient as oe } from "sgc";
46
+
47
+ import re from "crypto-es";
48
+
49
+ import ae from "@babel/runtime-corejs3/core-js-stable/date/now";
50
+
51
+ import le from "@babel/runtime-corejs3/core-js-stable/set-interval";
52
+
53
+ import ce from "@babel/runtime-corejs3/core-js-stable/instance/values";
54
+
55
+ import he from "@babel/runtime-corejs3/core-js-stable/instance/entries";
56
+
57
+ class CommonAudio extends t {
58
+ cat;
59
+ initAudio(e) {
60
+ this.cat = e;
61
+ return this;
62
+ }
63
+ }
64
+
65
+ const {ccclass: ue, menu: de} = i;
66
+
67
+ let pe = class AudioEffect extends CommonAudio {
68
+ effects=(() => new j)();
69
+ load(e, t) {
70
+ return new x((i, n) => {
71
+ let o = null;
72
+ let r;
73
+ if (t !== undefined) {
74
+ o = e;
75
+ r = t;
76
+ } else {
77
+ r = e;
78
+ }
79
+ const a = (e, t) => {
80
+ if (e) {
81
+ return n(e);
82
+ }
83
+ this.effects.set(r, t);
84
+ this.playOneShot(t, this.volume);
85
+ i(t);
86
+ };
87
+ o ? this.cat.res.load(o, 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, o) => {
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
+ n(e);
126
+ return o(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 o("UIAudioManager");
192
+ r.addPersistRootNode(t);
193
+ var i = new o("UIMusic");
194
+ i.parent = t;
195
+ this.music = i.addComponent(AudioMusic).initAudio(e);
196
+ var s = new o("UIEffect");
197
+ s.parent = t;
198
+ this.effect = s.addComponent(pe).initAudio(e);
199
+ this.load();
200
+ }
201
+ setMusicComplete() {
202
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
203
+ this.music.onComplete = e;
204
+ }
205
+ async playMusic(e, t) {
206
+ this.music.loop = true;
207
+ 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 n = arguments.length, o = n < 3 ? t : s === null ? s = Object.getOwnPropertyDescriptor(t, i) : s, r;
340
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") o = Reflect.decorate(e, t, i, s); else for (var a = e.length - 1; a >= 0; a--) if (r = e[a]) o = (n < 3 ? r(o) : n > 3 ? r(t, i, o) : r(t, i)) || o;
341
+ return n > 3 && o && Object.defineProperty(t, i, o), o;
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 n = i;
450
+ this.setOptions(n);
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, n;
538
+ e.layer = typeof t === "string" ? 2 ** d.nameToLayer(t) : t;
539
+ ((i = e) == null ? void 0 : V(n = Function.call).call(n, 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 = p.getVisibleSize();
556
+ }
557
+ async showTween(e) {
558
+ let {isMotion: t = true, direction: i = "center", duration: s = .1, isBounce: n = true, bounceDuration: o = .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 o;
568
+ m(1.1, 1.1, 1);
569
+ if (i == "center") {
570
+ t = m(.01, .01, .01);
571
+ o = 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
+ o = m(0, 0, 0);
583
+ }
584
+ await this.handle(i, s, t, o, n);
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 n;
599
+ if (i == "center") {
600
+ t = this.node.scale;
601
+ n = m(0, 0, 0);
602
+ } else {
603
+ if (i == "left") {
604
+ n = m(-this.screen.width, 0, 0);
605
+ } else if (i == "right") {
606
+ n = m(this.screen.width, 0, 0);
607
+ } else if (i == "top") {
608
+ n = m(0, this.screen.height, 0);
609
+ } else {
610
+ n = m(0, -this.screen.height, 0);
611
+ }
612
+ t = this.node.getPosition();
613
+ }
614
+ await this.handle(i, s, t, n, false);
615
+ }
616
+ this.removeAndDestroy();
617
+ }
618
+ async handle(e, t, i, s, n) {
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
+ }, n);
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: n} = 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
+ }, n);
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 n = .5;
818
+ const o = this.node.getComponent(b);
819
+ const r = _(o).delay(s).to(n, {
820
+ opacity: 0
821
+ }).call(() => {
822
+ C.stopAllByTarget(e);
823
+ this.node.destroy();
824
+ t();
825
+ });
826
+ _(e).by(n, {
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: o,
841
+ tooltip: "固定节点"
842
+ }), ye("design:type", o) ], Oe.prototype, "fixed_node", void 0);
843
+
844
+ ge([ Ie({
845
+ type: o,
846
+ tooltip: "滑动节点"
847
+ }), ye("design:type", o) ], 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: Ue, menu: Ne} = i;
875
+
876
+ let De = class CoreBlackMask extends BaseComponent {
877
+ tween;
878
+ };
879
+
880
+ ge([ Ue({
881
+ type: o,
882
+ tooltip: "动画节点"
883
+ }), ye("design:type", o) ], De.prototype, "tween", void 0);
884
+
885
+ De = ge([ Re("CoreBlackMask"), Ne("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: o
947
+ }), ye("design:type", o) ], Be.prototype, "scene_mask_node", void 0);
948
+
949
+ ge([ Fe({
950
+ type: o
951
+ }), ye("design:type", o) ], 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: o,
1001
+ tooltip: "动画"
1002
+ }), ye("design:type", o) ], 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
+ currentSceneUUID;
1151
+ onEventListener() {
1152
+ this.cat.event.on(Me.ROOT_MASK_UPDATE, this.onRootUpdate, this);
1153
+ }
1154
+ init(e) {
1155
+ this.cat = e;
1156
+ const t = r.getScene();
1157
+ a("init scene");
1158
+ t && this.changeScene(t);
1159
+ return this;
1160
+ }
1161
+ start() {
1162
+ this.onRootUpdate();
1163
+ }
1164
+ toastQueue=[];
1165
+ isScheduling=false;
1166
+ minInterval=.2;
1167
+ showToast(e) {
1168
+ this.toastQueue.push(e);
1169
+ if (!this.isScheduling) {
1170
+ this.processQueueWithInterval();
1171
+ }
1172
+ }
1173
+ processQueueWithInterval() {
1174
+ if (this.toastQueue.length === 0) {
1175
+ this.isScheduling = false;
1176
+ return;
1177
+ }
1178
+ this.isScheduling = true;
1179
+ const e = this.toastQueue.shift();
1180
+ const t = () => {
1181
+ const t = h(this.toast_ui_prefab);
1182
+ const i = t.getComponent(Oe);
1183
+ i.addToParent(this.root_toast, {
1184
+ props: e
1185
+ });
1186
+ this.scheduleOnce(() => {
1187
+ this.processQueueWithInterval();
1188
+ }, this.minInterval);
1189
+ };
1190
+ if (this.root_toast.children.length === 0) {
1191
+ t();
1192
+ } else {
1193
+ this.scheduleOnce(t, this.minInterval);
1194
+ }
1195
+ }
1196
+ hideToast() {
1197
+ if (this.root_toast) {
1198
+ var e;
1199
+ H(e = this.root_toast.children).call(e, e => {
1200
+ e.getComponent(Oe)?.removeAndDestroy();
1201
+ });
1202
+ }
1203
+ this.toastQueue = [];
1204
+ this.unschedule(this.processQueueWithInterval);
1205
+ this.isScheduling = false;
1206
+ return this;
1207
+ }
1208
+ showLoading() {
1209
+ let {title: e = "", mask: t = true, black: i = true} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1210
+ a("showLoading", e);
1211
+ if (this.loading_ui_component) {
1212
+ this.loading_ui_component.setOptions({
1213
+ props: {
1214
+ title: e,
1215
+ mask: t,
1216
+ black: i
1217
+ }
1218
+ });
1219
+ } else {
1220
+ const s = h(this.loading_ui_prefab);
1221
+ this.loading_ui_component = s.getComponent(He).addToParent(this.root_ui, {
1222
+ props: {
1223
+ title: e,
1224
+ mask: t,
1225
+ black: i
1226
+ }
1227
+ });
1228
+ }
1229
+ return this;
1230
+ }
1231
+ hideLoading() {
1232
+ this.loading_ui_component?.removeAndDestroy();
1233
+ this.loading_ui_component = null;
1234
+ return this;
1235
+ }
1236
+ showReconnect(e) {
1237
+ if (!this.reconnection_ui_component) {
1238
+ const t = h(this.reconnection_ui_prefab);
1239
+ this.reconnection_ui_component = t.getComponent(ze).addToParent(this.root_ui, {
1240
+ props: {
1241
+ content: e
1242
+ }
1243
+ });
1244
+ } else {
1245
+ this.reconnection_ui_component.setUpdateProps({
1246
+ content: e
1247
+ });
1248
+ }
1249
+ return this;
1250
+ }
1251
+ hideReconnect() {
1252
+ this.reconnection_ui_component?.removeAndDestroy();
1253
+ this.reconnection_ui_component = null;
1254
+ return this;
1255
+ }
1256
+ showNotice(e) {
1257
+ const t = h(this.notice_ui_prefab);
1258
+ this.notice_ui_component = t.getComponent(Xe).addToParent(this.root_ui, {
1259
+ props: e
1260
+ });
1261
+ return this;
1262
+ }
1263
+ hideNotice() {
1264
+ this.notice_ui_component?.removeAndDestroy();
1265
+ return this;
1266
+ }
1267
+ findBundleBySceneUUID(e) {
1268
+ const t = w.bundles._map;
1269
+ for (const i in t) {
1270
+ const s = t[i];
1271
+ const n = s.config?.scenes?._map;
1272
+ if (!n) continue;
1273
+ for (const t in n) {
1274
+ const i = n[t];
1275
+ if (i?.uuid === e) {
1276
+ return s;
1277
+ }
1278
+ }
1279
+ }
1280
+ return null;
1281
+ }
1282
+ loadScene(e, t, i) {
1283
+ a("[加载场景名][参数][重新加载]", e, t, i);
1284
+ let s = {};
1285
+ let o = i ?? true;
1286
+ if (typeof t === "boolean") {
1287
+ o = t;
1288
+ } else {
1289
+ s = t ?? {};
1290
+ }
1291
+ r.once(A.EVENT_BEFORE_SCENE_LAUNCH, e => {
1292
+ a("Director.EVENT_BEFORE_SCENE_LAUNCH", e);
1293
+ this.changeScene(e, s, o);
1294
+ });
1295
+ if (typeof e === "string") {
1296
+ const t = this.findBundleBySceneUUID(e);
1297
+ if (t && t.name !== "main") {
1298
+ t.loadScene(this.currentScene, (e, t) => {
1299
+ if (e) {
1300
+ n("loadScene err", e);
1301
+ } else {
1302
+ r.runScene(t);
1303
+ }
1304
+ });
1305
+ } else {
1306
+ r.loadScene(e);
1307
+ }
1308
+ } else {
1309
+ r.runScene(e);
1310
+ }
1311
+ return this;
1312
+ }
1313
+ resetScene() {
1314
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1315
+ e = e || this.currentScene;
1316
+ return this.loadScene(e);
1317
+ }
1318
+ cleanScene() {
1319
+ this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast();
1320
+ }
1321
+ changeScene(e, t, i) {
1322
+ this.currentScene = e.name;
1323
+ this.currentSceneUUID = e.uuid;
1324
+ this.createUILayer(e);
1325
+ const s = e.getComponentInChildren(SceneLayer);
1326
+ a("给场景传递属性值=======", s);
1327
+ if (s) {
1328
+ s.isReload = i ?? true;
1329
+ }
1330
+ s?.setOptions(t);
1331
+ }
1332
+ createUILayer(e) {
1333
+ this.ui_container_component?.removeAndDestroy();
1334
+ this.ui_container_component = null;
1335
+ const t = h(this.ui_prefab);
1336
+ this.ui_container_component = t.getComponent(Be);
1337
+ this.ui_container_component?.setGui(this).addToParent(e, this.node.getSiblingIndex());
1338
+ }
1339
+ reloadScene() {
1340
+ a("重新加载当前场景");
1341
+ this.loadScene(this.currentSceneUUID, true);
1342
+ }
1343
+ async closeUI(e, t) {
1344
+ const {component: i} = this.findUIBaseLayer(e, false);
1345
+ if (i) {
1346
+ i.setOptions({
1347
+ ...t?.hook ?? {},
1348
+ ...t?.props ?? {}
1349
+ });
1350
+ await i.hideTween(t || {});
1351
+ this.ui_container_component?.subMask();
1352
+ }
1353
+ }
1354
+ async openUI(e, t) {
1355
+ const {rootNode: i, component: s} = this.findUIBaseLayer(e, true);
1356
+ i.getComponent(UILayer);
1357
+ s?.setOptions(t);
1358
+ if (i) {
1359
+ this.ui_container_component?.addNodeToTween(i).addMask();
1360
+ }
1361
+ if (s) {
1362
+ await s.showTween(t || {});
1363
+ }
1364
+ this.ui_container_component?.ui_container && s?.addToParent(this.ui_container_component.ui_container);
1365
+ }
1366
+ findUIBaseLayer(e, t) {
1367
+ let i;
1368
+ let s = null;
1369
+ if (e instanceof o) {
1370
+ var r;
1371
+ i = e;
1372
+ const t = $(r = e.components).call(r, e => e instanceof UILayer);
1373
+ if (t.length) {
1374
+ if (t.length == 1) {
1375
+ s = t[0];
1376
+ } else {
1377
+ I(`${e.name}节点存在多个继承自BaseLayer的组件`);
1378
+ }
1379
+ } else {
1380
+ n(`${e.name}节点未找到继承自BaseLayer的组件`);
1381
+ return {
1382
+ rootNode: i,
1383
+ component: s
1384
+ };
1385
+ }
1386
+ } else {
1387
+ i = e.node;
1388
+ s = e;
1389
+ if (t) {
1390
+ while (i.parent) {
1391
+ i = i.parent;
1392
+ }
1393
+ s.root = i;
1394
+ } else {
1395
+ i = e.root;
1396
+ }
1397
+ }
1398
+ return {
1399
+ rootNode: i,
1400
+ component: s
1401
+ };
1402
+ }
1403
+ onRootUpdate() {
1404
+ const e = this.root_ui.children.findLastIndex(e => e.active && e != this.root_mask);
1405
+ this.root_mask.active = e != -1;
1406
+ if (e > -1) {
1407
+ const t = this.root_ui.children[e];
1408
+ const i = t.getSiblingIndex() - 1;
1409
+ this.root_mask.setSiblingIndex(i < 0 ? 0 : i);
1410
+ }
1411
+ this.cat.event.emit(Me.ROOT_MASK_CHANGE);
1412
+ }
1413
+ };
1414
+
1415
+ ge([ Ye({
1416
+ type: c,
1417
+ tooltip: "断线重连UI预制体"
1418
+ }), ye("design:type", c) ], it.prototype, "reconnection_ui_prefab", void 0);
1419
+
1420
+ ge([ Ye({
1421
+ type: c,
1422
+ tooltip: "提示UI预制体"
1423
+ }), ye("design:type", c) ], it.prototype, "toast_ui_prefab", void 0);
1424
+
1425
+ ge([ Ye({
1426
+ type: c,
1427
+ tooltip: "加载UI预制体"
1428
+ }), ye("design:type", c) ], it.prototype, "loading_ui_prefab", void 0);
1429
+
1430
+ ge([ Ye({
1431
+ type: c,
1432
+ tooltip: "公告UI预制体"
1433
+ }), ye("design:type", c) ], it.prototype, "notice_ui_prefab", void 0);
1434
+
1435
+ ge([ Ye({
1436
+ type: c,
1437
+ tooltip: "UI层预制体"
1438
+ }), ye("design:type", c) ], it.prototype, "ui_prefab", void 0);
1439
+
1440
+ ge([ Ye({
1441
+ type: o,
1442
+ tooltip: "root-UI层"
1443
+ }), ye("design:type", o) ], it.prototype, "root_ui", void 0);
1444
+
1445
+ ge([ Ye({
1446
+ type: o,
1447
+ tooltip: "root-组件层"
1448
+ }), ye("design:type", o) ], it.prototype, "root_toast", void 0);
1449
+
1450
+ ge([ Ye({
1451
+ type: o,
1452
+ tooltip: "root-mask"
1453
+ }), ye("design:type", o) ], it.prototype, "root_mask", void 0);
1454
+
1455
+ it = ge([ Ze("Gui"), et("CATCORE/Gui") ], it);
1456
+
1457
+ var st;
1458
+
1459
+ (function(e) {
1460
+ e["Root"] = "prefabs/root";
1461
+ e["Toast"] = "prefabs/toast";
1462
+ e["BlackMask"] = "prefabs/black-mask";
1463
+ e["Loading"] = "prefabs/loading";
1464
+ e["Notice"] = "prefabs/notice";
1465
+ e["Reconnection"] = "prefabs/reconnection";
1466
+ })(st || (st = {}));
1467
+
1468
+ class GuiManager extends BaseManager {
1469
+ gui;
1470
+ #e="core";
1471
+ getGuiPrefabByType=(e, t) => new x((i, s) => {
1472
+ a(e, `${t}`);
1473
+ this.cat.res.load(e, t, (e, t) => {
1474
+ if (e) {
1475
+ s(e);
1476
+ } else {
1477
+ i(t);
1478
+ }
1479
+ });
1480
+ });
1481
+ async init() {
1482
+ this.cat.gui_bundle_name && (this.#e = this.cat.gui_bundle_name);
1483
+ const e = await this.getGuiPrefabByType(this.#e, st.Root);
1484
+ const t = h(e);
1485
+ this.gui = t.getComponent(it).init(this.cat);
1486
+ r.addPersistRootNode(t);
1487
+ return this;
1488
+ }
1489
+ }
1490
+
1491
+ class WrapperSocialGameClient extends oe {
1492
+ showRequestErrInfo=false;
1493
+ logBlackList=[];
1494
+ ignore=e => {
1495
+ var t;
1496
+ return P(t = this.logBlackList).call(t, e);
1497
+ };
1498
+ constructor(e, t, i, s) {
1499
+ super(t, i, s, e);
1500
+ this.showRequestErrInfo = s?.showRequestErrInfo ?? false;
1501
+ }
1502
+ destroy() {
1503
+ this.disconnect(true);
1504
+ e._cat.socialGameClient.unregister(this);
1505
+ }
1506
+ async GameRequest(t, i, s) {
1507
+ let {forwardReq: o = false, forwardResp: r = false} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1508
+ return new x((l, c) => {
1509
+ super.GameRequest(t, i, s, {
1510
+ forwardReq: o,
1511
+ forwardResp: r
1512
+ }).then(e => {
1513
+ if (ie) {
1514
+ 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);
1515
+ }
1516
+ l(e);
1517
+ }, t => {
1518
+ n(t);
1519
+ this.showRequestErrInfo && t?.msg && e._cat.gui.showToast({
1520
+ title: t.msg
1521
+ });
1522
+ c(t);
1523
+ });
1524
+ });
1525
+ }
1526
+ subscribe(t, i, s) {
1527
+ super.subscribe(t, i, i => {
1528
+ if (ie && !this.ignore(t)) {
1529
+ 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);
1530
+ }
1531
+ e._cat.event.emit(t, i);
1532
+ s?.(i);
1533
+ });
1534
+ return this;
1535
+ }
1536
+ }
1537
+
1538
+ class SocialGameClientManager extends BaseManager {
1539
+ managedClients=(() => new j)();
1540
+ isGlobalOnline=true;
1541
+ isInBackground=false;
1542
+ reconnecting=false;
1543
+ onEventHideDelegate=(() => new T)();
1544
+ onEventShowDelegate=(() => new T)();
1545
+ onEventReloadSceneDelegate=(() => new T)();
1546
+ reconnectTimer=null;
1547
+ scheduleReconnect() {
1548
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
1549
+ if (this.reconnectTimer) {
1550
+ clearTimeout(this.reconnectTimer);
1551
+ this.reconnectTimer = null;
1552
+ }
1553
+ this.reconnectTimer = X(() => {
1554
+ this.reconnectTimer = null;
1555
+ this.triggerReconnectAll();
1556
+ }, e);
1557
+ }
1558
+ get activeClients() {
1559
+ var e, t;
1560
+ return $(e = Z(t = Y(this.managedClients)).call(t, e => {
1561
+ let [t, i] = e;
1562
+ return i;
1563
+ })).call(e, e => e.socket);
1564
+ }
1565
+ constructor(e) {
1566
+ super(e);
1567
+ this.initGlobalListeners();
1568
+ }
1569
+ createWebSocket(e, t, i, s) {
1570
+ if (this.managedClients.has(e)) {
1571
+ const t = this.managedClients.get(e);
1572
+ t.destroy();
1573
+ a(`清理旧的 ${e} 客户端`);
1574
+ }
1575
+ const n = new WrapperSocialGameClient(e, i, s, F({
1576
+ reconnectMaxAttempts: Infinity
1577
+ }, {
1578
+ ...t,
1579
+ isAutoConnect: false,
1580
+ isArrayBuffer: se
1581
+ }));
1582
+ this.register(n);
1583
+ return n;
1584
+ }
1585
+ register(e) {
1586
+ e.on("reconnected", this.handleSingleReconnect);
1587
+ e.on("close", this.handleSingleClose);
1588
+ e.on("kick", this.handleSingleKick);
1589
+ this.managedClients.set(e.name, e);
1590
+ }
1591
+ unregister(e) {
1592
+ e.off("reconnected", this.handleSingleReconnect);
1593
+ e.off("close", this.handleSingleClose);
1594
+ e.off("kick", this.handleSingleKick);
1595
+ this.managedClients.delete(e.name);
1596
+ }
1597
+ initGlobalListeners() {
1598
+ this.cat.event.on(Me.ONLINE, () => this.handleGlobalStateChange("online"), this).on(Me.OFFLINE, () => this.handleGlobalStateChange("offline"), this);
1599
+ y.on(k.EVENT_SHOW, () => this.handleGlobalStateChange("show"));
1600
+ y.on(k.EVENT_HIDE, () => this.handleGlobalStateChange("hide"));
1601
+ }
1602
+ async handleGlobalStateChange(e) {
1603
+ switch (e) {
1604
+ case "online":
1605
+ this.cat.gui.hideLoading().showToast({
1606
+ title: $e.ONLINE
1607
+ });
1608
+ this.isGlobalOnline = true;
1609
+ this.triggerReconnectAll();
1610
+ break;
1611
+
1612
+ case "offline":
1613
+ this.isGlobalOnline = false;
1614
+ this.disconnectAll(true);
1615
+ this.cat.gui.showLoading({
1616
+ title: $e.OFFLINE
1617
+ });
1618
+ break;
1619
+
1620
+ case "show":
1621
+ this.isInBackground = false;
1622
+ await this.triggerReconnectAll();
1623
+ await this.onEventShowDelegate.dispatch();
1624
+ break;
1625
+
1626
+ case "hide":
1627
+ await this.onEventHideDelegate.dispatch();
1628
+ this.isInBackground = true;
1629
+ this.disconnectAll(true);
1630
+ break;
1631
+ }
1632
+ }
1633
+ async triggerReconnectAll() {
1634
+ a("触发所有客户端重连[正在重连][在线][后台][ws数量]", this.reconnecting, this.isGlobalOnline, this.isInBackground, this.managedClients.size);
1635
+ if (this.reconnecting || !this.isGlobalOnline || this.isInBackground || this.managedClients.size === 0) return this.onEventReloadSceneDelegate.dispatch();
1636
+ this.reconnecting = true;
1637
+ this.cat.gui.showLoading({
1638
+ title: "正在重连"
1639
+ });
1640
+ try {
1641
+ var e, t;
1642
+ await x.allSettled(Z(e = this.activeClients).call(e, async e => {
1643
+ try {
1644
+ await e.reconnectPromise();
1645
+ } catch (t) {
1646
+ n(`${e.name}服重连失败`, t);
1647
+ }
1648
+ }));
1649
+ const i = $(t = this.activeClients).call(t, e => e.socketConnectStatus !== te.CONNECTED);
1650
+ if (i.length > 0) {
1651
+ console.error("部分WS重连失败:", Z(i).call(i, e => e));
1652
+ a("2s后重连所有客户端");
1653
+ this.reconnecting = false;
1654
+ this.scheduleReconnect();
1655
+ } else {
1656
+ this.reconnecting = false;
1657
+ }
1658
+ } catch (e) {
1659
+ this.reconnecting = false;
1660
+ throw e;
1661
+ }
1662
+ }
1663
+ disconnectAll(e) {
1664
+ var t;
1665
+ H(t = this.managedClients).call(t, t => {
1666
+ a("断开连接", t.name, e, t.socket);
1667
+ t.disconnect(e);
1668
+ });
1669
+ }
1670
+ handleSingleClose=() => {
1671
+ if (!this.reconnecting) {
1672
+ a("3s后重连所有客户端");
1673
+ this.scheduleReconnect(3e3);
1674
+ }
1675
+ };
1676
+ handleSingleReconnect=async () => {
1677
+ var e;
1678
+ if (ee(e = this.activeClients).call(e, e => e.socketConnectStatus === te.CONNECTED)) {
1679
+ var t;
1680
+ a("单个WS重连成功回调===", this.managedClients);
1681
+ await x.allSettled(Z(t = this.activeClients).call(t, async e => {
1682
+ try {
1683
+ await e.connectRequest();
1684
+ } catch (t) {
1685
+ n(`${e.name}服登录错误`, t);
1686
+ this.cat.gui.showToast({
1687
+ title: `登录${e.name}服错误`
1688
+ });
1689
+ }
1690
+ }));
1691
+ if (this.reconnectTimer) {
1692
+ clearTimeout(this.reconnectTimer);
1693
+ this.reconnectTimer = null;
1694
+ }
1695
+ await this.onEventReloadSceneDelegate.dispatch();
1696
+ this.cat.gui.hideLoading();
1697
+ if (r.getScene()?.getComponentInChildren(SceneLayer)?.isReload) this.cat.gui.reloadScene();
1698
+ }
1699
+ };
1700
+ handleSingleKick=() => {
1701
+ this.cat.gui.showReconnect($e.KICK);
1702
+ };
1703
+ }
1704
+
1705
+ class ResLoader {
1706
+ get=(() => function(e, t) {
1707
+ let i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "resources";
1708
+ var s = w.getBundle(i);
1709
+ return s.get(e, t);
1710
+ })();
1711
+ isAssetType=e => typeof e === "function" && e.prototype instanceof O;
1712
+ async load() {
1713
+ let e = null;
1714
+ let t = null;
1715
+ let i = null;
1716
+ for (var s = arguments.length, n = new Array(s), o = 0; o < s; o++) {
1717
+ n[o] = arguments[o];
1718
+ }
1719
+ if (typeof n[0] === "string" && typeof n[1] === "string") {
1720
+ e = n.shift();
1721
+ }
1722
+ let r = n.shift();
1723
+ if (this.isAssetType(n[0])) {
1724
+ t = n.shift();
1725
+ }
1726
+ if (n.length == 2) {
1727
+ i = n.shift();
1728
+ }
1729
+ const a = n.shift();
1730
+ let l = M;
1731
+ if (e && e != "resources") {
1732
+ if (!w.bundles.has(e)) {
1733
+ await this.loadBundle(e);
1734
+ }
1735
+ let t = w.bundles.get(e);
1736
+ if (t) {
1737
+ l = t;
1738
+ }
1739
+ }
1740
+ if (i && a) {
1741
+ l.load(r, t, i, a);
1742
+ } else if (a) {
1743
+ l.load(r, t, a);
1744
+ } else {
1745
+ l.load(r, t);
1746
+ }
1747
+ }
1748
+ async loadDir() {
1749
+ let e = null;
1750
+ let t = null;
1751
+ let i = null;
1752
+ let s = null;
1753
+ for (var n = arguments.length, o = new Array(n), r = 0; r < n; r++) {
1754
+ o[r] = arguments[r];
1755
+ }
1756
+ if (typeof o[0] === "string" && typeof o[1] === "string") {
1757
+ e = o.shift();
1758
+ }
1759
+ let a = o.shift();
1760
+ if (this.isAssetType(o[0])) {
1761
+ t = o.shift();
1762
+ }
1763
+ if (o.length == 2) {
1764
+ i = o.shift();
1765
+ }
1766
+ s = o.shift();
1767
+ let l = M;
1768
+ if (e && e != "resources") {
1769
+ if (!w.bundles.has(e)) {
1770
+ await this.loadBundle(e);
1771
+ }
1772
+ let t = w.bundles.get(e);
1773
+ if (t) {
1774
+ l = t;
1775
+ }
1776
+ }
1777
+ if (i && s) {
1778
+ l.loadDir(a, t, i, s);
1779
+ } else if (s) {
1780
+ l.loadDir(a, t, s);
1781
+ } else {
1782
+ l.loadDir(a, t);
1783
+ }
1784
+ }
1785
+ loadRemote(e) {
1786
+ var t = null;
1787
+ var i = null;
1788
+ for (var s = arguments.length, n = new Array(s > 1 ? s - 1 : 0), o = 1; o < s; o++) {
1789
+ n[o - 1] = arguments[o];
1790
+ }
1791
+ if (n.length == 2) {
1792
+ t = n.shift();
1793
+ }
1794
+ i = n.shift();
1795
+ w.loadRemote(e, {
1796
+ ext: ".png",
1797
+ ...t
1798
+ }, i);
1799
+ }
1800
+ loadBundle=(e, t) => new x((i, s) => {
1801
+ const n = (e, t) => {
1802
+ if (e) {
1803
+ return s(e);
1804
+ }
1805
+ i(t);
1806
+ };
1807
+ t ? w.loadBundle(e, {
1808
+ version: t
1809
+ }, n) : w.loadBundle(e, n);
1810
+ });
1811
+ releasePrefabtDepsRecursively=e => {
1812
+ var t = w.assets.get(e);
1813
+ w.releaseAsset(t);
1814
+ if (t instanceof c) {
1815
+ var i = w.dependUtil.getDepsRecursively(e);
1816
+ H(i).call(i, e => {
1817
+ var t = w.assets.get(e);
1818
+ t.decRef();
1819
+ });
1820
+ }
1821
+ };
1822
+ release=(() => {
1823
+ var e = this;
1824
+ return function(t) {
1825
+ let i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1826
+ var s = w.getBundle(i);
1827
+ if (s) {
1828
+ var n = s.get(t);
1829
+ if (n) {
1830
+ e.releasePrefabtDepsRecursively(n._uuid);
1831
+ }
1832
+ }
1833
+ };
1834
+ })();
1835
+ releaseDir=(() => {
1836
+ var e = this;
1837
+ return function(t) {
1838
+ var i, s;
1839
+ let n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "resources";
1840
+ var o = w.getBundle(n);
1841
+ var r = o?.getDirWithPath(t);
1842
+ ((i = r) == null ? void 0 : V(s = Function.call).call(s, Z(i), i))?.(t => {
1843
+ e.releasePrefabtDepsRecursively(t.uuid);
1844
+ });
1845
+ if (!t && n != "resources" && o) {
1846
+ w.removeBundle(o);
1847
+ }
1848
+ };
1849
+ })();
1850
+ dump=() => {
1851
+ var e;
1852
+ H(e = w.assets).call(e, (e, t) => {
1853
+ a(w.assets.get(t));
1854
+ });
1855
+ a(`当前资源总数:${w.assets.count}`);
1856
+ };
1857
+ loadAssetsWithProgress(e, t) {
1858
+ return new x((i, s) => {
1859
+ const n = e.getDirWithPath("");
1860
+ const o = n.length;
1861
+ let r = 0;
1862
+ if (o === 0) {
1863
+ t(1);
1864
+ i();
1865
+ return;
1866
+ }
1867
+ H(n).call(n, n => {
1868
+ e.load(n.path, e => {
1869
+ if (e) {
1870
+ s(e);
1871
+ return;
1872
+ }
1873
+ r++;
1874
+ t(r / o);
1875
+ if (r === o) {
1876
+ i();
1877
+ }
1878
+ });
1879
+ });
1880
+ });
1881
+ }
1882
+ }
1883
+
1884
+ class BaseStore {
1885
+ rootStore;
1886
+ constructor(e) {
1887
+ this.rootStore = e;
1888
+ }
1889
+ }
1890
+
1891
+ class CoreStore extends BaseManager {}
1892
+
1893
+ let nt = null;
1894
+
1895
+ const ot = e => re.MD5(e).toString();
1896
+
1897
+ const rt = (e, t) => {
1898
+ nt = re.enc.Hex.parse(t);
1899
+ };
1900
+
1901
+ const at = (e, t, i) => re.AES.encrypt(e, t, {
1902
+ iv: nt,
1903
+ format: ct
1904
+ }).toString();
1905
+
1906
+ const lt = (e, t, i) => {
1907
+ const s = re.AES.decrypt(e, t, {
1908
+ iv: nt,
1909
+ format: ct
1910
+ });
1911
+ return s.toString(re.enc.Utf8);
1912
+ };
1913
+
1914
+ const ct = {
1915
+ stringify: e => {
1916
+ const t = {
1917
+ ct: e.ciphertext.toString(re.enc.Base64)
1918
+ };
1919
+ if (e.iv) {
1920
+ t.iv = e.iv.toString();
1921
+ }
1922
+ if (e.salt) {
1923
+ t.s = e.salt.toString();
1924
+ }
1925
+ return G(t);
1926
+ },
1927
+ parse: e => {
1928
+ const t = JSON.parse(e);
1929
+ const i = re.lib.CipherParams.create({
1930
+ ciphertext: re.enc.Base64.parse(t.ct)
1931
+ });
1932
+ if (t.iv) {
1933
+ i.iv = re.enc.Hex.parse(t.iv);
1934
+ }
1935
+ if (t.s) {
1936
+ i.salt = re.enc.Hex.parse(t.s);
1937
+ }
1938
+ return i;
1939
+ }
1940
+ };
1941
+
1942
+ var ht = Object.freeze({
1943
+ __proto__: null,
1944
+ JsonFormatter: ct,
1945
+ aesDecrypt: lt,
1946
+ aesEncrypt: at,
1947
+ initCrypto: rt,
1948
+ md5: ot
1949
+ });
1950
+
1951
+ class CoreUtil extends BaseManager {
1952
+ encryptUtil=(() => ht)();
1953
+ }
1954
+
1955
+ class StorageManager extends BaseManager {
1956
+ _key=null;
1957
+ _iv=null;
1958
+ _id="";
1959
+ init(e, t) {
1960
+ this.cat.util.encryptUtil.initCrypto(e, t);
1961
+ this._key = this.cat.util.encryptUtil.md5(e);
1962
+ this._iv = this.cat.util.encryptUtil.md5(t);
1963
+ }
1964
+ setUser(e) {
1965
+ this._id = e;
1966
+ }
1967
+ set(e, t) {
1968
+ e = `${e}_${this._id}`;
1969
+ if (null == e) {
1970
+ console.error("存储的key不能为空");
1971
+ return;
1972
+ }
1973
+ if (!ne) {
1974
+ e = this.cat.util.encryptUtil.md5(e);
1975
+ }
1976
+ if (null == t) {
1977
+ console.warn("存储的值为空,则直接移除该存储");
1978
+ this.remove(e);
1979
+ return;
1980
+ }
1981
+ if (typeof t === "function") {
1982
+ console.error("储存的值不能为方法");
1983
+ return;
1984
+ }
1985
+ if (typeof t === "object") {
1986
+ try {
1987
+ t = G(t);
1988
+ } catch (e) {
1989
+ console.error(`解析失败,str = ${t}`);
1990
+ return;
1991
+ }
1992
+ } else if (typeof t === "number") {
1993
+ t = t + "";
1994
+ }
1995
+ if (!ne && null != this._key && null != this._iv) {
1996
+ t = this.cat.util.encryptUtil.aesEncrypt(`${t}`, this._key, this._iv);
1997
+ }
1998
+ R.localStorage.setItem(e, t);
1999
+ }
2000
+ get(e, t) {
2001
+ if (null == e) {
2002
+ console.error("存储的key不能为空");
2003
+ return null;
2004
+ }
2005
+ e = `${e}_${this._id}`;
2006
+ if (!ne) {
2007
+ e = this.cat.util.encryptUtil.md5(e);
2008
+ }
2009
+ let i = R.localStorage.getItem(e);
2010
+ if (null != i && "" !== i && !ne && null != this._key && null != this._iv) {
2011
+ i = this.cat.util.encryptUtil.aesDecrypt(i, this._key, this._iv);
2012
+ }
2013
+ if (null === i) {
2014
+ return t;
2015
+ }
2016
+ return i;
2017
+ }
2018
+ getNumber(e) {
2019
+ let t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2020
+ var i = this.get(e);
2021
+ return Number(i) || t;
2022
+ }
2023
+ getBoolean(e) {
2024
+ var t = this.get(e);
2025
+ return Boolean(t) || false;
2026
+ }
2027
+ getJson(e, t) {
2028
+ var i = this.get(e);
2029
+ return i && JSON.parse(i) || t;
2030
+ }
2031
+ remove(e) {
2032
+ if (null == e) {
2033
+ console.error("存储的key不能为空");
2034
+ return;
2035
+ }
2036
+ e = `${e}_${this._id}`;
2037
+ if (!ne) {
2038
+ e = this.cat.util.encryptUtil.md5(e);
2039
+ }
2040
+ R.localStorage.removeItem(e);
2041
+ }
2042
+ clear() {
2043
+ R.localStorage.clear();
2044
+ }
2045
+ }
2046
+
2047
+ class Manager {
2048
+ static #t=null;
2049
+ #i=false;
2050
+ static get instance() {
2051
+ return this.#t ?? (this.#t = new Manager);
2052
+ }
2053
+ onAppInitDelegate=(() => new T)();
2054
+ onPlugInInitDelegate=(() => new T)();
2055
+ #s=null;
2056
+ get audio() {
2057
+ return this.#s;
2058
+ }
2059
+ #n=null;
2060
+ get event() {
2061
+ return this.#n;
2062
+ }
2063
+ #o=null;
2064
+ get gui() {
2065
+ return this.#o;
2066
+ }
2067
+ #r=null;
2068
+ get storage() {
2069
+ return this.#r;
2070
+ }
2071
+ #a=null;
2072
+ get res() {
2073
+ return this.#a;
2074
+ }
2075
+ #l=null;
2076
+ get util() {
2077
+ return this.#l;
2078
+ }
2079
+ #c=null;
2080
+ get socialGameClient() {
2081
+ return this.#c;
2082
+ }
2083
+ #h=null;
2084
+ get store() {
2085
+ return this.#h;
2086
+ }
2087
+ #u="";
2088
+ get gui_bundle_name() {
2089
+ return this.#u;
2090
+ }
2091
+ #d="";
2092
+ get audio_local_store_key() {
2093
+ return this.#d;
2094
+ }
2095
+ #p="";
2096
+ get default_audio_effect() {
2097
+ return this.#p;
2098
+ }
2099
+ setConfig=(() => {
2100
+ var e = this;
2101
+ return function() {
2102
+ let {default_audio_effect: t = "", gui_bundleName: i = "resources", audio_local_store_key: s = "game_audio"} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2103
+ if (e.#i) {
2104
+ throw new Error("[CAT] 已初始化,无法修改配置");
2105
+ }
2106
+ e.#u = i;
2107
+ e.#d = s;
2108
+ e.#p = t;
2109
+ return e;
2110
+ };
2111
+ })();
2112
+ async boot() {
2113
+ if (this.#i) {
2114
+ throw new Error("[CAT] 已初始化");
2115
+ }
2116
+ try {
2117
+ this.#h = new CoreStore(this);
2118
+ this.#a = new ResLoader;
2119
+ this.#l = new CoreUtil(this);
2120
+ this.#r = new StorageManager(this);
2121
+ this.#n = new B;
2122
+ this.#s = new AudioManager(this);
2123
+ this.#c = new SocialGameClientManager(this);
2124
+ this.#o = (await new GuiManager(this).init()).gui;
2125
+ this.#i = true;
2126
+ } catch (e) {
2127
+ console.error(`[CAT] 初始化失败:`, e);
2128
+ throw e;
2129
+ }
2130
+ }
2131
+ merge(e, t) {
2132
+ if (!this.#i) throw new Error("[CAT] 未初始化");
2133
+ if (typeof e !== "string") {
2134
+ throw new Error(`merge方法第一个参数应该为string类型`);
2135
+ }
2136
+ if (!D(this, e)) {
2137
+ L(this, e, t);
2138
+ }
2139
+ F(D(this, e), t);
2140
+ return this;
2141
+ }
2142
+ appendPlugInInitDelegate(e) {
2143
+ if (this.#i) {
2144
+ x.resolve().then(e).catch(e => {
2145
+ console.error("[CAT] appendPlugInInitDelegate 回调执行失败:", e);
2146
+ });
2147
+ } else {
2148
+ this.onPlugInInitDelegate.add(e);
2149
+ }
2150
+ return this;
2151
+ }
2152
+ }
2153
+
2154
+ const {ccclass: ut, property: dt, menu: pt} = i;
2155
+
2156
+ let ft = class CoreUIModal extends UILayer {
2157
+ default_title=null;
2158
+ title;
2159
+ prompt_content_str;
2160
+ prompt_content_spriteFrame;
2161
+ btn_confirm;
2162
+ confirm_spriteFrame;
2163
+ btn_cancel;
2164
+ cancel_spriteFrame;
2165
+ btn_close;
2166
+ isConfirm=false;
2167
+ props={
2168
+ title: this.default_title,
2169
+ content: null,
2170
+ confirmCB: () => {},
2171
+ cancelCB: () => {},
2172
+ style: null
2173
+ };
2174
+ onLoad() {
2175
+ this.btn_cancel.node.on(S.EventType.CLICK, this.onCancelHandler, this);
2176
+ this.btn_confirm.node.on(S.EventType.CLICK, this.onConfirmHandler, this);
2177
+ this.btn_close.node.on(S.EventType.CLICK, this.onCloseHandler, this);
2178
+ this.addAutorun([ () => {
2179
+ this.title.spriteFrame = this.props?.title || this.default_title;
2180
+ }, () => {
2181
+ if (this.props.content) {
2182
+ if (this.props.content instanceof U) {
2183
+ this.prompt_content_spriteFrame.spriteFrame = this.props.content;
2184
+ } else if (typeof this.props.content === "string") {
2185
+ this.prompt_content_str.string = this.props.content;
2186
+ } else {
2187
+ console.error("未知类型的【UIModal】内容");
2188
+ }
2189
+ }
2190
+ }, () => {
2191
+ if (this.props?.style?.confirm === null) {
2192
+ this.btn_confirm.node.active = false;
2193
+ } else {
2194
+ this.btn_confirm.node.active = true;
2195
+ this.btn_confirm.getComponent(N).spriteFrame = this.props.style?.confirm || this.confirm_spriteFrame;
2196
+ }
2197
+ if (this.props?.style?.cancel === null) {
2198
+ this.btn_cancel.node.active = false;
2199
+ } else {
2200
+ this.btn_cancel.node.active = true;
2201
+ this.btn_cancel.getComponent(N).spriteFrame = this.props.style?.cancel || this.cancel_spriteFrame;
2202
+ }
2203
+ } ]);
2204
+ }
2205
+ close() {
2206
+ this.props.cancelCB?.();
2207
+ this.cat.gui.closeUI(this);
2208
+ }
2209
+ onCancelHandler() {
2210
+ this.close();
2211
+ }
2212
+ onConfirmHandler() {
2213
+ this.props.confirmCB?.();
2214
+ }
2215
+ onDestroy() {
2216
+ if (this.isConfirm) this.props.onDestroy?.();
2217
+ }
2218
+ onCloseHandler() {
2219
+ this.close();
2220
+ }
2221
+ };
2222
+
2223
+ ge([ dt({
2224
+ type: U,
2225
+ tooltip: "默认标题"
2226
+ }), ye("design:type", U) ], ft.prototype, "default_title", void 0);
2227
+
2228
+ ge([ dt({
2229
+ type: N,
2230
+ tooltip: "标题节点"
2231
+ }), ye("design:type", N) ], ft.prototype, "title", void 0);
2232
+
2233
+ ge([ dt({
2234
+ type: v,
2235
+ tooltip: "字符串内容按钮"
2236
+ }), ye("design:type", v) ], ft.prototype, "prompt_content_str", void 0);
2237
+
2238
+ ge([ dt({
2239
+ type: N,
2240
+ tooltip: "图片精灵内容按钮"
2241
+ }), ye("design:type", N) ], ft.prototype, "prompt_content_spriteFrame", void 0);
2242
+
2243
+ ge([ dt({
2244
+ type: S,
2245
+ tooltip: "确认按钮"
2246
+ }), ye("design:type", S) ], ft.prototype, "btn_confirm", void 0);
2247
+
2248
+ ge([ dt({
2249
+ type: U,
2250
+ tooltip: "确认按钮精灵图"
2251
+ }), ye("design:type", U) ], ft.prototype, "confirm_spriteFrame", void 0);
2252
+
2253
+ ge([ dt({
2254
+ type: S,
2255
+ tooltip: "取消按钮"
2256
+ }), ye("design:type", S) ], ft.prototype, "btn_cancel", void 0);
2257
+
2258
+ ge([ dt({
2259
+ type: U,
2260
+ tooltip: "取消按钮精灵图"
2261
+ }), ye("design:type", U) ], ft.prototype, "cancel_spriteFrame", void 0);
2262
+
2263
+ ge([ dt({
2264
+ type: S,
2265
+ tooltip: "关闭按钮"
2266
+ }), ye("design:type", S) ], ft.prototype, "btn_close", void 0);
2267
+
2268
+ ft = ge([ ut("CoreUIModal"), pt("CATCORE/CoreUIModal") ], ft);
2269
+
2270
+ var mt;
2271
+
2272
+ (function(e) {
2273
+ e[e["Delay"] = 0] = "Delay";
2274
+ e[e["Interval"] = 1] = "Interval";
2275
+ })(mt || (mt = {}));
2276
+
2277
+ class TimerEntry {
2278
+ tag;
2279
+ type;
2280
+ callback;
2281
+ remainingTime;
2282
+ executionTime=0;
2283
+ initialTime;
2284
+ constructor(e, t, i, s) {
2285
+ this.tag = e;
2286
+ this.type = t;
2287
+ this.remainingTime = i;
2288
+ this.initialTime = i;
2289
+ this.callback = s;
2290
+ }
2291
+ }
2292
+
2293
+ class TimerManager extends BaseManager {
2294
+ timers=(() => new j)();
2295
+ lastUpdateTime=(() => ae())();
2296
+ constructor(e) {
2297
+ var t;
2298
+ super(e);
2299
+ e.event.on(Me.EVENT_HIDE, this.onHandleAppBackground, this);
2300
+ e.event.on(Me.EVENT_SHOW, this.onHandleAppForeground, this);
2301
+ le(V(t = this.update).call(t, this), 1e3);
2302
+ }
2303
+ onHandleAppBackground() {
2304
+ this.lastUpdateTime = ae();
2305
+ }
2306
+ onHandleAppForeground() {
2307
+ const e = ae();
2308
+ const t = e - this.lastUpdateTime;
2309
+ a("elapsedTime", t);
2310
+ for (const e of ce(i = this.timers).call(i)) {
2311
+ var i;
2312
+ if (e.remainingTime > 0) {
2313
+ e.remainingTime -= t;
2314
+ e.executionTime += t;
2315
+ }
2316
+ }
2317
+ this.lastUpdateTime = e;
2318
+ }
2319
+ registerInterval(e, t, i) {
2320
+ if (this.has(e)) {
2321
+ return n(`${e}定时器已存在,请勿重复注册`);
2322
+ }
2323
+ const s = new TimerEntry(e, mt.Interval, t, i);
2324
+ this.timers.set(e, s);
2325
+ }
2326
+ registerDelay(e, t, i) {
2327
+ if (this.has(e)) {
2328
+ return n(`${e}延时器已存在,请勿重复注册`);
2329
+ }
2330
+ const s = new TimerEntry(e, mt.Delay, t, i);
2331
+ this.timers.set(e, s);
2332
+ }
2333
+ unregister(e) {
2334
+ if (this.has(e)) {
2335
+ this.timers.delete(e);
2336
+ }
2337
+ }
2338
+ has(e) {
2339
+ return this.timers.has(e);
2340
+ }
2341
+ update() {
2342
+ const e = [];
2343
+ for (const [i, s] of he(t = this.timers).call(t)) {
2344
+ var t;
2345
+ s.remainingTime -= 1e3;
2346
+ if (s.remainingTime <= 0) {
2347
+ if (s.type === mt.Interval) {
2348
+ s.executionTime += s.initialTime;
2349
+ }
2350
+ s.callback(s.executionTime);
2351
+ if (s.type === mt.Interval) {
2352
+ s.remainingTime = s.initialTime;
2353
+ } else {
2354
+ e.push(i);
2355
+ }
2356
+ }
2357
+ }
2358
+ for (const t of e) {
2359
+ this.timers.delete(t);
2360
+ }
2361
+ }
2362
+ }
2363
+
2364
+ const _t = (t, i) => (s, n, o) => {
2365
+ let r = o.value;
2366
+ o.value = function() {
2367
+ const s = t ?? e._cat.default_audio_effect;
2368
+ if (s) {
2369
+ e._cat.audio.playEffect(s);
2370
+ } else {
2371
+ console.warn(`请添加音效路径参数`);
2372
+ }
2373
+ if (i) {
2374
+ i();
2375
+ }
2376
+ for (var n = arguments.length, o = new Array(n), a = 0; a < n; a++) {
2377
+ o[a] = arguments[a];
2378
+ }
2379
+ r.apply(this, o);
2380
+ };
2381
+ return o;
2382
+ };
2383
+
2384
+ const gt = function() {
2385
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2386
+ let t = arguments.length > 1 ? arguments[1] : undefined;
2387
+ return function(i, s, n) {
2388
+ let o = n.value;
2389
+ let r = false;
2390
+ n.value = function() {
2391
+ if (r) {
2392
+ if (t) {
2393
+ t();
2394
+ }
2395
+ return;
2396
+ }
2397
+ r = true;
2398
+ X(() => {
2399
+ r = false;
2400
+ }, e * 1e3);
2401
+ for (var i = arguments.length, s = new Array(i), n = 0; n < i; n++) {
2402
+ s[n] = arguments[n];
2403
+ }
2404
+ o.apply(this, s);
2405
+ };
2406
+ return n;
2407
+ };
2408
+ };
2409
+
2410
+ const yt = e._cat ??= Manager.instance;
2411
+
2412
+ y.onPostProjectInitDelegate.add(async () => {
2413
+ console.time("[Init App]");
2414
+ try {
2415
+ await yt.boot();
2416
+ await yt.onAppInitDelegate.dispatch();
2417
+ await yt.onPlugInInitDelegate.dispatch();
2418
+ } catch (e) {
2419
+ n(`[Init App] 初始化失败: ${e instanceof Error ? e.message : String(e)}`);
2420
+ throw e;
2421
+ } finally {
2422
+ console.timeEnd("[Init App]");
2423
+ }
2424
+ });
2425
+
2426
+ 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 };