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