index.js 553 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930
  1. System.register("chunks:///_virtual/Action.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  2. var _createClass, cclegacy;
  3. return {
  4. setters: [function (module) {
  5. _createClass = module.createClass;
  6. }, function (module) {
  7. cclegacy = module.cclegacy;
  8. }],
  9. execute: function () {
  10. exports('default', get_new_action_center);
  11. cclegacy._RF.push({}, "24a1fbkvW9AQJ+cc5f2eMnl", "Action", undefined);
  12. function get_new_action_center() {
  13. return new ActionCenter();
  14. }
  15. /**行为机*/
  16. var ActionCenter = /*#__PURE__*/function () {
  17. function ActionCenter() {
  18. this._list = [];
  19. this._current = void 0;
  20. }
  21. var _proto = ActionCenter.prototype;
  22. /**加入一个创建行为的闭包的函数
  23. * ActionCreat = (...args: any) => Action;
  24. * Action ={check:() => boolean,entry:() => void,do:(dt:number)=>void}
  25. */
  26. _proto.add = function add(actionCreat) {
  27. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  28. args[_key - 1] = arguments[_key];
  29. }
  30. this._list.push(actionCreat.apply(void 0, args));
  31. }
  32. /**检测和进入行为*/;
  33. _proto.check_entry = function check_entry() {
  34. var _this$_current;
  35. if ((_this$_current = this._current) != null && _this$_current.check()) return;
  36. for (var i = 0; i < this._list.length; i++) {
  37. if (this._current != this._list[i] && this._list[i].check()) {
  38. this._current = this._list[i];
  39. this._current.entry();
  40. return;
  41. }
  42. }
  43. this._current = null;
  44. }
  45. /**是否有正在执行的行为 */;
  46. /**执行行为*/
  47. _proto["do"] = function _do(dt) {
  48. if (this._current) this._current["do"](dt);
  49. }
  50. /**清除所有行为*/;
  51. _proto.clean = function clean() {
  52. for (var i = 0; i < this._list.length; i++) {
  53. this._list[i].dispose();
  54. }
  55. this._list.length = 0;
  56. this._current = null;
  57. }
  58. /*例子
  59. public test():void{
  60. const who={state:0};
  61. this.add((who:{state:number})=>{
  62. const w = who;
  63. let time:number=0;
  64. return{
  65. check:()=>{
  66. if(w.state==0){
  67. return true;
  68. }
  69. return false;
  70. },
  71. entry:()=>{
  72. time=0;
  73. console.log("entry 行为1",time);
  74. },
  75. do:(dt:number)=>{
  76. time+=dt;
  77. if(time>=2){
  78. console.log("do",time);
  79. w.state=1;
  80. };
  81. }
  82. }
  83. },who);
  84. this.add((who:{state:number})=>{
  85. const w = who;
  86. let time:number=0;
  87. return{
  88. check:()=>{
  89. if(w.state==1){
  90. return true;
  91. }
  92. return false;
  93. },
  94. entry:()=>{
  95. time=0;
  96. console.log("entry 行为2",time);
  97. },
  98. do:(dt:number)=>{
  99. time+=dt;
  100. if(time>=2){
  101. console.log("do",time);
  102. w.state=0;
  103. };
  104. }
  105. }
  106. },who);
  107. }*/;
  108. _createClass(ActionCenter, [{
  109. key: "isAction",
  110. get: function get() {
  111. return this._current != null;
  112. }
  113. }]);
  114. return ActionCenter;
  115. }();
  116. cclegacy._RF.pop();
  117. }
  118. };
  119. });
  120. System.register("chunks:///_virtual/ArrayUtil.ts", ['cc'], function (exports) {
  121. var cclegacy;
  122. return {
  123. setters: [function (module) {
  124. cclegacy = module.cclegacy;
  125. }],
  126. execute: function () {
  127. cclegacy._RF.push({}, "83341COeitPRIHcw18VS7g3", "ArrayUtil", undefined);
  128. var ArrayUtil = exports('default', /*#__PURE__*/function () {
  129. function ArrayUtil() {}
  130. /**随机打乱一个数组 */
  131. ArrayUtil.shuffleArray = function shuffleArray(array) {
  132. var currentIndex = array.length;
  133. var temporaryValue;
  134. var randomIndex;
  135. // While there remain elements to shuffle...
  136. while (currentIndex !== 0) {
  137. // Pick a remaining element...
  138. randomIndex = Math.floor(Math.random() * currentIndex);
  139. currentIndex--;
  140. // And swap it with the current element.
  141. temporaryValue = array[currentIndex];
  142. array[currentIndex] = array[randomIndex];
  143. array[randomIndex] = temporaryValue;
  144. }
  145. return array;
  146. }
  147. // Fisher-Yates 洗牌算法
  148. //const originalArray = [1, 2, 3, 4, 5];
  149. //const shuffledArray = shuffleArray([...originalArray]);
  150. ;
  151. ArrayUtil.shuffleArray2 = function shuffleArray2(array) {
  152. for (var i = array.length - 1; i > 0; i--) {
  153. // 生成一个随机索引
  154. var j = Math.floor(Math.random() * (i + 1));
  155. // 交换元素
  156. var _ref = [array[j], array[i]];
  157. array[i] = _ref[0];
  158. array[j] = _ref[1];
  159. }
  160. return array;
  161. }
  162. /**合并两个数组元素,移除相同的 */;
  163. ArrayUtil.MergeAndRemoveDuplicates = function MergeAndRemoveDuplicates(arr1, arr2) {
  164. var merged = [].concat(arr1, arr2); // 合并两个数组
  165. var uniqueValues = Array.from(new Set(merged)); // 去重
  166. return uniqueValues;
  167. }
  168. /**排除数组1在数组2里有的元素,返回新数组*/;
  169. ArrayUtil.ExcludeElements = function ExcludeElements(array1, array2) {
  170. var set = new Set(array2); // 将 array2 转换为 Set
  171. return array1.filter(function (item) {
  172. return !set.has(item);
  173. });
  174. }
  175. /**检测数组元素是否能满足顺序的组合*/;
  176. ArrayUtil.checkSequentialCombination = function checkSequentialCombination(arr) {
  177. var sortedArr = arr.slice().sort(function (a, b) {
  178. return a - b;
  179. });
  180. for (var i = 0; i < sortedArr.length - 1; i++) {
  181. if (sortedArr[i] + 1 !== sortedArr[i + 1]) {
  182. return [];
  183. }
  184. }
  185. return sortedArr;
  186. }
  187. /**从一个数组中找出是否有连续的组合*/;
  188. ArrayUtil.findSequentialCombinations = function findSequentialCombinations(arr) {
  189. var result = [];
  190. arr.sort(function (a, b) {
  191. return a - b;
  192. });
  193. var currentSequence = [];
  194. for (var i = 0; i < arr.length; i++) {
  195. if (currentSequence.length === 0 || arr[i] === currentSequence[currentSequence.length - 1] + 1) {
  196. currentSequence.push(arr[i]);
  197. } else {
  198. if (currentSequence.length > 1) {
  199. result.push(currentSequence);
  200. }
  201. currentSequence = [arr[i]];
  202. }
  203. }
  204. if (currentSequence.length > 1) {
  205. result.push(currentSequence);
  206. }
  207. return result;
  208. }
  209. /*eg:const arr = [2, 4,2, 5, 3, 6, 9,9,10,11,];
  210. const combinations = this.findSequentialCombinations(arr);
  211. if (combinations.length > 0) {
  212. console.log("所有可能的连续顺序组合为:");
  213. combinations.forEach(combination => {
  214. console.log(combination);
  215. });
  216. } else {
  217. console.log("无法找到连续顺序组合");
  218. }*/
  219. /**数组中删除一个合条件的*/;
  220. ArrayUtil.DeleteOneItem = function DeleteOneItem(list, check) {
  221. var length = list.length;
  222. for (var i = 0; i < length; i++) {
  223. if (check(list[i])) {
  224. return list.splice(i, 1)[0];
  225. //i--;
  226. //length--;
  227. }
  228. }
  229. return null;
  230. }
  231. /**插入排序(适用于差异不会很大,相对有序的数据)Array.sort() 快速排序 算法更适用于混乱无章的数据 */;
  232. ArrayUtil.InsertionSort = function InsertionSort(array) {
  233. var count = array.length;
  234. if (count <= 1) return;
  235. var t1;
  236. var t2;
  237. for (var i = 1; i < count; i++) {
  238. t1 = array[i];
  239. var j = void 0;
  240. for (j = i; j > 0 && t1.sortValue > (t2 = array[j - 1]).sortValue; j--) {
  241. array[j] = t2;
  242. }
  243. array[j] = t1;
  244. }
  245. }
  246. // 元素排序
  247. /*示例
  248. 负数在前
  249. const checkMinusNumber = function (val: number) {
  250. return val > 0;
  251. };
  252. const arr = [2, 4, 5, 6, 7, -8, -10 - 12, -2];
  253. adjustArrayOrder.reorder(arr, checkMinusNumber);
  254. console.log(arr);
  255. */;
  256. ArrayUtil.reorder = function reorder(arr, checkFun) {
  257. var end = arr.length - 1;
  258. var begin = 0;
  259. while (begin < end) {
  260. // 向后移动begin
  261. while (begin < end && !checkFun(arr[begin])) {
  262. begin++;
  263. }
  264. // 向前移动end
  265. while (begin < end && checkFun(arr[end])) {
  266. end--;
  267. }
  268. // begin与end都指向了正确的位置
  269. if (begin < end) {
  270. // 交换两个元素的顺序
  271. var _ref2 = [arr[end], arr[begin]];
  272. arr[begin] = _ref2[0];
  273. arr[end] = _ref2[1];
  274. }
  275. }
  276. }
  277. //冒泡排序
  278. /// <summary>
  279. /// 各种类型冒泡排序比
  280. /// </summary>/// 例子:
  281. /// CommonSort<int>(new int[]{2,3,1,45,123,4},compare)
  282. /// bool compare(int a,int b){
  283. /// if(a>b)return true;
  284. /// reutn false;
  285. /// }
  286. /// <param name="sortArray"></param>
  287. /// <param name="compareMethod"></param>
  288. /// <typeparam name="T"></typeparam>
  289. ;
  290. ArrayUtil.CommonSort = function CommonSort(sortArray, compareMethod) {
  291. var swapped = true;
  292. do {
  293. swapped = false;
  294. for (var i = 0; i < sortArray.length - 1; i++) {
  295. if (compareMethod(sortArray[i], sortArray[i + 1])) {
  296. var temp = sortArray[i];
  297. sortArray[i] = sortArray[i + 1];
  298. sortArray[i + 1] = temp;
  299. swapped = true;
  300. }
  301. }
  302. } while (swapped);
  303. }
  304. /**归并排序 */
  305. /*var arr: number[] = [];
  306. for (var i: number = 0; i < 1000; i++) {
  307. arr.push(Math.floor(1000 - i));//生成降序的数组
  308. }
  309. MergeSort(arr, 0, arr.length);//调用归并排序算法*/
  310. //拆分数组 分
  311. ;
  312. ArrayUtil.MergeSort = function MergeSort(arr, lo, hi) {
  313. if (hi - lo < 2) return; //单个元素无需考虑
  314. var mi = lo + hi >> 1; //已中点为界 或者改成Math.floor((lo + hi) / 2)
  315. this.MergeSort(arr, lo, mi); //对左边排序
  316. this.MergeSort(arr, mi, hi); //对右边排序
  317. this.merge(arr, lo, mi, hi); //归并
  318. }
  319. //归并算法实现 合
  320. ;
  321. ArrayUtil.merge = function merge(arr, lo, mi, hi) {
  322. var A = arr.slice(lo, hi); //A[lo, hi)=arr[lo, hi)
  323. var lb = mi - lo;
  324. var B = new Array(lb);
  325. for (var i = 0; i < lb; B[i] = A[i++]); //复制左子向量B[0, lb) = arr[lo, mi)
  326. var lc = hi - mi;
  327. var C = arr.slice(mi, hi); //后子向量C[0,lc) = arr[mi, hi)
  328. for (var i = 0, j = 0, k = 0; j < lb;) {
  329. //反复冲B和C中取出更小者
  330. if (k < lc && C[k] < B[j]) {
  331. //将其归入A中
  332. A[i++] = C[k++];
  333. }
  334. if (lc <= k || B[j] <= C[k]) {
  335. A[i++] = B[j++];
  336. }
  337. }
  338. for (var i = 0; i < A.length; arr[lo + i] = A[i++]); //把A中的值赋给原来的数组
  339. B.length = 0;
  340. C.length = 0;
  341. A.length = 0;
  342. };
  343. return ArrayUtil;
  344. }());
  345. cclegacy._RF.pop();
  346. }
  347. };
  348. });
  349. System.register("chunks:///_virtual/audio.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  350. var _createClass, cclegacy, AudioSource, assetManager, AudioClip, Node, director;
  351. return {
  352. setters: [function (module) {
  353. _createClass = module.createClass;
  354. }, function (module) {
  355. cclegacy = module.cclegacy;
  356. AudioSource = module.AudioSource;
  357. assetManager = module.assetManager;
  358. AudioClip = module.AudioClip;
  359. Node = module.Node;
  360. director = module.director;
  361. }],
  362. execute: function () {
  363. cclegacy._RF.push({}, "e1803S2AupKB5LQvJ7w31/E", "audio", undefined);
  364. var ch_log = chsdk.log;
  365. var ch_storage = chsdk.storage;
  366. /**音频等资源加载方式*/
  367. var loadType = exports('loadType', /*#__PURE__*/function (loadType) {
  368. loadType[loadType["none"] = 0] = "none";
  369. loadType[loadType["bundle"] = 1] = "bundle";
  370. loadType[loadType["remote"] = 2] = "remote";
  371. return loadType;
  372. }({}));
  373. /**音频播放控制
  374. * 需要初始化资源加载方式
  375. * loadType.bundle 时需要设置 bundle名
  376. * loadType.remote 测试使用远程的音频需要设置远程地址
  377. */
  378. var ch_audio = exports('default', /*#__PURE__*/function () {
  379. ch_audio.getInstance = function getInstance() {
  380. if (!this._instance) this._instance = new ch_audio();
  381. return this._instance;
  382. };
  383. function ch_audio() {
  384. this._volume_music = 1;
  385. this._volume_effect = 1;
  386. this._switch_music = true;
  387. this._switch_effect = true;
  388. this._effect_max = 5;
  389. this._effect_index = 0;
  390. this._effect_source_pool = [];
  391. this._music_source = void 0;
  392. this._load_type = loadType.none;
  393. this._bundle_name = void 0;
  394. this._remote_url = void 0;
  395. this._playing_sound = new Set();
  396. var audio = new Node();
  397. audio.name = '__ch_audio__';
  398. director.getScene().addChild(audio);
  399. director.addPersistRootNode(audio);
  400. this._music_source = this._create(audio);
  401. for (var i = 0; i < this._effect_max; i++) {
  402. this._effect_source_pool.push(this._create(audio));
  403. }
  404. this.load();
  405. }
  406. /**
  407. * 创建音频源
  408. * @param node 节点
  409. * @param volume 音量
  410. * @returns AudioSource 音频源组件
  411. */
  412. var _proto = ch_audio.prototype;
  413. _proto._create = function _create(node) {
  414. var source = node.addComponent(AudioSource);
  415. source.loop = false;
  416. source.playOnAwake = false;
  417. source.volume = 0.5;
  418. return source;
  419. }
  420. /**初始化*/;
  421. _proto.init = function init(load_type, bundle_name, remote_url) {
  422. this._load_type = load_type;
  423. this._bundle_name = bundle_name;
  424. this._remote_url = remote_url;
  425. }
  426. /**切换bundle*/;
  427. _proto.set_bundle_name = function set_bundle_name(bundle_name) {
  428. this._bundle_name = bundle_name;
  429. }
  430. /**
  431. * 释放通过 [[load]] 或者 [[loadDir]] 加载的声音资源。
  432. * @param sound 声音资源路径
  433. */;
  434. _proto.release = function release(sound) {
  435. if (this._load_type == loadType.none) {
  436. ch_log.warn('音频模块未初始化');
  437. } else if (this._load_type == loadType.bundle) {
  438. var bundle = assetManager.getBundle(this._bundle_name);
  439. if (!sound) {
  440. bundle.releaseAll();
  441. } else {
  442. bundle.release(sound, AudioClip);
  443. }
  444. }
  445. }
  446. /** 保存音乐音效的音量、开关配置数据到本地 */;
  447. _proto.save = function save() {
  448. var local_data = {};
  449. local_data.volume_music = this._volume_music;
  450. local_data.volume_effect = this._volume_effect;
  451. local_data.switch_music = this._switch_music;
  452. local_data.switch_effect = this._switch_effect;
  453. ch_storage.set("ch_audio", local_data);
  454. }
  455. /** 本地加载音乐音效的音量、开关配置数据并设置到游戏中 */;
  456. _proto.load = function load() {
  457. var local_data = ch_storage.getObject("ch_audio");
  458. if (local_data) {
  459. try {
  460. this.setState(local_data);
  461. } catch (e) {
  462. this.setStateDefault();
  463. }
  464. } else {
  465. this.setStateDefault();
  466. }
  467. };
  468. _proto.setState = function setState(local_data) {
  469. this.volumeMusic = local_data.volume_music;
  470. this.volumeEffect = local_data.volume_effect;
  471. this.switchMusic = local_data.switch_music;
  472. this.switchEffect = local_data.switch_effect;
  473. };
  474. _proto.setStateDefault = function setStateDefault() {
  475. this.volumeMusic = 0.8;
  476. this.volumeEffect = 0.8;
  477. this.switchMusic = true;
  478. this.switchEffect = true;
  479. }
  480. /**
  481. * 获取背景音乐音量
  482. */;
  483. /**
  484. * @en
  485. * play short audio, such as strikes,explosions
  486. * @zh
  487. * 播放短音频,比如 打击音效,爆炸音效等
  488. * @param sound clip or url for the audio
  489. * @param interval 同名字音频限制播放间隔(毫秒) (默认:0不限制 特殊系数:>0 <=1 使用音频时间X此系数)
  490. */
  491. _proto.playOneShot = function playOneShot(sound, interval, remote_ext) {
  492. var _this = this;
  493. if (interval === void 0) {
  494. interval = 0;
  495. }
  496. if (remote_ext === void 0) {
  497. remote_ext = '.mp3';
  498. }
  499. if (!this._switch_effect) return;
  500. if (sound instanceof AudioClip) {
  501. this.doPlayOneShot(sound, interval);
  502. } else {
  503. if (this._load_type == loadType.none) {
  504. ch_log.warn('音频模块未初始化');
  505. } else if (this._load_type == loadType.bundle) {
  506. var bundle = assetManager.getBundle(this._bundle_name);
  507. if (!bundle) {
  508. ch_log.warn("\u8BF7\u786E\u4FDD bundle" + this._bundle_name + " \u5DF2\u52A0\u8F7D");
  509. } else {
  510. bundle.load(sound, function (err, clip) {
  511. if (err) {
  512. ch_log.error(err);
  513. } else {
  514. _this.doPlayOneShot(clip, interval);
  515. }
  516. });
  517. }
  518. } else if (this._load_type == loadType.remote) {
  519. assetManager.loadRemote(this._remote_url + sound + remote_ext, function (err, clip) {
  520. if (err) {
  521. ch_log.error(err);
  522. } else {
  523. _this.doPlayOneShot(clip, interval);
  524. }
  525. });
  526. }
  527. }
  528. };
  529. _proto.doPlayOneShot = function doPlayOneShot(clip, interval) {
  530. var _this2 = this;
  531. var name = clip.name;
  532. if (interval > 0) {
  533. if (this._playing_sound.has(name)) return;
  534. this._playing_sound.add(name);
  535. var time = interval <= 1 ? clip.getDuration() * interval * 1000 : interval;
  536. setTimeout(function () {
  537. _this2._playing_sound["delete"](name);
  538. }, time);
  539. this.getNextEffectSource().playOneShot(clip, this._volume_effect);
  540. } else {
  541. this.getNextEffectSource().playOneShot(clip, this._volume_effect);
  542. }
  543. };
  544. _proto.getNextEffectSource = function getNextEffectSource() {
  545. var source = this._effect_source_pool[this._effect_index];
  546. this._effect_index = (this._effect_index + 1) % this._effect_max;
  547. return source;
  548. }
  549. /**
  550. * @en
  551. * play long audio, such as the bg music
  552. * @zh
  553. * 播放长音频,比如 背景音乐
  554. * @param sound clip or url for the sound
  555. */;
  556. _proto.play = function play(sound, remote_ext) {
  557. var _this3 = this;
  558. if (remote_ext === void 0) {
  559. remote_ext = '.mp3';
  560. }
  561. if (!this._switch_music) return;
  562. if (sound instanceof AudioClip) {
  563. this._music_source.loop = true;
  564. this._music_source.stop();
  565. this._music_source.clip = sound;
  566. this._music_source.play();
  567. this._music_source.volume = this._volume_music;
  568. } else {
  569. if (this._load_type == loadType.none) {
  570. ch_log.warn('音频模块未初始化');
  571. } else if (this._load_type == loadType.bundle) {
  572. var bundle = assetManager.getBundle(this._bundle_name);
  573. if (!bundle) {
  574. ch_log.warn("\u8BF7\u786E\u4FDD bundle" + this._bundle_name + " \u5DF2\u52A0\u8F7D");
  575. } else {
  576. bundle.load(sound, function (err, clip) {
  577. if (err) {
  578. ch_log.error(err);
  579. } else {
  580. _this3._music_source.loop = true;
  581. _this3._music_source.stop();
  582. _this3._music_source.clip = clip;
  583. _this3._music_source.play();
  584. _this3._music_source.volume = _this3._volume_music;
  585. }
  586. });
  587. }
  588. } else if (this._load_type == loadType.remote) {
  589. assetManager.loadRemote(this._remote_url + sound + remote_ext, function (err, clip) {
  590. if (err) {
  591. ch_log.error(err);
  592. } else {
  593. _this3._music_source.loop = true;
  594. _this3._music_source.stop();
  595. _this3._music_source.clip = clip;
  596. _this3._music_source.play();
  597. _this3._music_source.volume = _this3._volume_music;
  598. }
  599. });
  600. }
  601. }
  602. }
  603. /**
  604. * stop the audio play
  605. */;
  606. _proto.stop = function stop() {
  607. this._music_source.stop();
  608. for (var i = 0; i < this._effect_source_pool.length; i++) {
  609. this._effect_source_pool[i].stop();
  610. }
  611. }
  612. /**stop and clean */;
  613. _proto.clean = function clean() {
  614. var _this$_music_source$c;
  615. this._music_source.stop();
  616. (_this$_music_source$c = this._music_source.clip) == null || _this$_music_source$c.name;
  617. this._music_source.clip = null;
  618. for (var i = 0; i < this._effect_source_pool.length; i++) {
  619. this._effect_source_pool[i].stop();
  620. this._effect_source_pool[i].clip = null;
  621. }
  622. }
  623. /**
  624. * pause the audio play
  625. */;
  626. _proto.pause = function pause() {
  627. this._music_source.pause();
  628. }
  629. /**
  630. * resume the audio play
  631. */;
  632. _proto.resume = function resume() {
  633. if (!this._switch_music) return;
  634. this._music_source.play();
  635. }
  636. /** 重播当前音乐 */;
  637. _proto.replay_music = function replay_music() {
  638. this._music_source.stop();
  639. this._music_source.play();
  640. };
  641. _createClass(ch_audio, [{
  642. key: "volumeMusic",
  643. get: function get() {
  644. return this._volume_music;
  645. }
  646. /**
  647. * 设置背景音乐音量
  648. * @param value 音乐音量值
  649. */,
  650. set: function set(value) {
  651. this._volume_music = value;
  652. this._music_source.volume = value;
  653. }
  654. /**
  655. * 获取背景音乐开关值
  656. */
  657. }, {
  658. key: "switchMusic",
  659. get: function get() {
  660. return this._switch_music;
  661. }
  662. /**
  663. * 设置背景音乐开关值
  664. * @param value 开关值
  665. */,
  666. set: function set(value) {
  667. this._switch_music = value;
  668. if (value == false) this._music_source.stop();
  669. }
  670. /**
  671. * 获取音效音量
  672. */
  673. }, {
  674. key: "volumeEffect",
  675. get: function get() {
  676. return this._volume_effect;
  677. }
  678. /**
  679. * 设置获取音效音量
  680. * @param value 音效音量值
  681. */,
  682. set: function set(value) {
  683. this._volume_effect = value;
  684. for (var i = 0; i < this._effect_source_pool.length; i++) {
  685. this._effect_source_pool[i].volume = this._volume_effect;
  686. }
  687. }
  688. /**
  689. * 获取音效开关值
  690. */
  691. }, {
  692. key: "switchEffect",
  693. get: function get() {
  694. return this._switch_effect;
  695. }
  696. /**
  697. * 设置音效开关值
  698. * @param value 音效开关值
  699. */,
  700. set: function set(value) {
  701. this._switch_effect = value;
  702. if (value == false) {
  703. for (var i = 0; i < this._effect_source_pool.length; i++) {
  704. this._effect_source_pool[i].stop();
  705. }
  706. }
  707. }
  708. }]);
  709. return ch_audio;
  710. }());
  711. ch_audio._instance = void 0;
  712. cclegacy._RF.pop();
  713. }
  714. };
  715. });
  716. System.register("chunks:///_virtual/ch_pvp.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ch_util.ts'], function (exports) {
  717. var _asyncToGenerator, _regeneratorRuntime, cclegacy, ch_util;
  718. return {
  719. setters: [function (module) {
  720. _asyncToGenerator = module.asyncToGenerator;
  721. _regeneratorRuntime = module.regeneratorRuntime;
  722. }, function (module) {
  723. cclegacy = module.cclegacy;
  724. }, function (module) {
  725. ch_util = module.default;
  726. }],
  727. execute: function () {
  728. cclegacy._RF.push({}, "8b658c6Uk1Jq4HkHx1ctH2P", "ch_pvp", undefined);
  729. /**
  730. * pvp扩展玩法 基于 chsdk
  731. */
  732. var ch_pvp = /*#__PURE__*/function () {
  733. function ch_pvp() {
  734. this._set_url = '/user/setPvpSceneData';
  735. this._match_url = '/user/startPvpMatch';
  736. this._finish_url = '/user/pvpFinishAction';
  737. this._record_url = '/user/pvpChallengeRecord';
  738. this._own = void 0;
  739. //
  740. this._cache_records = null;
  741. this._cache_time = void 0;
  742. }
  743. ch_pvp.getInstance = function getInstance() {
  744. if (!this._instance) this._instance = new ch_pvp();
  745. return this._instance;
  746. }
  747. /**
  748. * 设置自己的 PVP 擂台数据
  749. * 该方法用于更新当前用户在 PVP 擂台上的数据。数据将根据传入的 extend 参数进行更新,
  750. * 并返回一个包含操作状态和可能错误信息的 Promise。
  751. * @param extend - 一个pvp擂台数据对象,包含要更新的具体数据。
  752. * @returns 一个 Promise,解析为一个包含以下属性的对象:
  753. * - code: 操作的结果状态。0 表示成功,其他值表示不同的错误类型。
  754. * - err: 可选字符串,指示错误信息(如果有)。
  755. */;
  756. var _proto = ch_pvp.prototype;
  757. _proto.setSceneData = /*#__PURE__*/
  758. function () {
  759. var _setSceneData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(extend) {
  760. var check, body, ret;
  761. return _regeneratorRuntime().wrap(function _callee$(_context) {
  762. while (1) switch (_context.prev = _context.next) {
  763. case 0:
  764. check = chsdk.check_req_time('setSceneData');
  765. if (!check) {
  766. _context.next = 3;
  767. break;
  768. }
  769. return _context.abrupt("return", check);
  770. case 3:
  771. body = {
  772. "extends": ch_util.stringify(extend)
  773. };
  774. _context.next = 6;
  775. return chsdk.makePostTokenRequest(chsdk.getUrl(this._set_url), body);
  776. case 6:
  777. ret = _context.sent;
  778. if (!(ret.code != chsdk.code.success)) {
  779. _context.next = 11;
  780. break;
  781. }
  782. chsdk.log.warn(ret);
  783. _context.next = 18;
  784. break;
  785. case 11:
  786. chsdk.log.log("PVP\u64C2\u53F0\u6570\u636E\u4E0A\u62A5\u6210\u529F");
  787. if (this._own) {
  788. _context.next = 17;
  789. break;
  790. }
  791. _context.next = 15;
  792. return this.getOwn();
  793. case 15:
  794. _context.next = 18;
  795. break;
  796. case 17:
  797. this._own["extends"] = extend;
  798. case 18:
  799. return _context.abrupt("return", ret);
  800. case 19:
  801. case "end":
  802. return _context.stop();
  803. }
  804. }, _callee, this);
  805. }));
  806. function setSceneData(_x) {
  807. return _setSceneData.apply(this, arguments);
  808. }
  809. return setSceneData;
  810. }()
  811. /**
  812. * 开始匹配
  813. * @param uid (可选)具体好友的uid,默为空
  814. * @returns null 匹配失败
  815. *
  816. * pvp_data<T>
  817. extends PVP 擂台数据
  818. * other 台主信息
  819. * own 自己的信息
  820. * head:头像, nickName:名字, uid:id, hid:省id, province:省名, pvp:pvp排位分值, rank:pvp排行榜名次
  821. */;
  822. _proto.startMatch = /*#__PURE__*/
  823. function () {
  824. var _startMatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(uid) {
  825. var check, ret, data;
  826. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  827. while (1) switch (_context2.prev = _context2.next) {
  828. case 0:
  829. check = chsdk.check_req_time('startMatch');
  830. if (!check) {
  831. _context2.next = 3;
  832. break;
  833. }
  834. return _context2.abrupt("return", null);
  835. case 3:
  836. _context2.next = 5;
  837. return chsdk.makePostTokenRequest(chsdk.getUrl(this._match_url), {
  838. uid: uid ? uid.toString() : ''
  839. });
  840. case 5:
  841. ret = _context2.sent;
  842. if (!(ret.code != chsdk.code.success)) {
  843. _context2.next = 11;
  844. break;
  845. }
  846. chsdk.log.warn(ret);
  847. return _context2.abrupt("return", null);
  848. case 11:
  849. data = ret.data.data;
  850. data.other.uid = Number.parseInt(data.other.uid);
  851. data.other.hid = Number.parseInt(data.other.hid);
  852. data.other.province = chsdk.provinceCode2Name(data.other.hid);
  853. data.own.uid = Number.parseInt(data.own.uid);
  854. data.own.hid = Number.parseInt(data.own.hid);
  855. data.own.province = chsdk.provinceCode2Name(data.own.hid);
  856. return _context2.abrupt("return", {
  857. "extends": ch_util.parse(data["extends"]),
  858. other: data.other,
  859. own: data.own
  860. });
  861. case 19:
  862. case "end":
  863. return _context2.stop();
  864. }
  865. }, _callee2, this);
  866. }));
  867. function startMatch(_x2) {
  868. return _startMatch.apply(this, arguments);
  869. }
  870. return startMatch;
  871. }() /**从一条记录开始匹配,用于复仇*/;
  872. _proto.startMatchRecord = /*#__PURE__*/
  873. function () {
  874. var _startMatchRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(pd) {
  875. var check, pp;
  876. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  877. while (1) switch (_context3.prev = _context3.next) {
  878. case 0:
  879. check = chsdk.check_req_time('startMatch');
  880. if (!check) {
  881. _context3.next = 3;
  882. break;
  883. }
  884. return _context3.abrupt("return", null);
  885. case 3:
  886. _context3.next = 5;
  887. return this.startMatch(pd.other.uid);
  888. case 5:
  889. pp = _context3.sent;
  890. if (pp) {
  891. _context3.next = 8;
  892. break;
  893. }
  894. return _context3.abrupt("return", null);
  895. case 8:
  896. pp["extends"] = pd["extends"];
  897. pp.pvpId = pd.pvpId;
  898. return _context3.abrupt("return", pp);
  899. case 11:
  900. case "end":
  901. return _context3.stop();
  902. }
  903. }, _callee3, this);
  904. }));
  905. function startMatchRecord(_x3) {
  906. return _startMatchRecord.apply(this, arguments);
  907. }
  908. return startMatchRecord;
  909. }()
  910. /**
  911. * 完成pvp上报
  912. * @param otherUid 对方uid
  913. * @param status 0:挑战失败 1:挑战胜利
  914. * @param ext PVP 擂台数据
  915. * @param serverData 服务器处理排行数据,订阅消息
  916. * ..ownValue 增减自己排位分值
  917. * ..otherValue 增减对方排位分值
  918. * ..msg 自定义的订阅消息
  919. * @param pvpId 复仇id
  920. * @returns 对战结果
  921. * other 对方的排名和分数变化
  922. * own 自己的排名和分数变化
  923. * curRank 当前排名(变动后)
  924. curScore 当前分数(变动后)
  925. rank 名数变动
  926. score 分数变动
  927. */;
  928. _proto.finish = /*#__PURE__*/
  929. function () {
  930. var _finish = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(otherUid, status, ext, serverData, pvpId) {
  931. var check, body, ret, data;
  932. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  933. while (1) switch (_context4.prev = _context4.next) {
  934. case 0:
  935. check = chsdk.check_req_time('finish');
  936. if (!check) {
  937. _context4.next = 3;
  938. break;
  939. }
  940. return _context4.abrupt("return", null);
  941. case 3:
  942. body = {
  943. otherUid: otherUid.toString(),
  944. status: status,
  945. "extends": ch_util.stringify(ext),
  946. serverData: ch_util.stringify(serverData),
  947. pvpId: pvpId
  948. };
  949. _context4.next = 6;
  950. return chsdk.makePostTokenRequest(chsdk.getUrl(this._finish_url), body);
  951. case 6:
  952. ret = _context4.sent;
  953. if (!(ret.code != chsdk.code.success)) {
  954. _context4.next = 12;
  955. break;
  956. }
  957. chsdk.log.warn(ret);
  958. return _context4.abrupt("return", null);
  959. case 12:
  960. data = ret.data.data;
  961. chsdk.log.log("pvp\u7ED3\u679C\u6570\u636E\u4E0A\u62A5\u6210\u529F,\u7ED3\u7B97:", data);
  962. return _context4.abrupt("return", data);
  963. case 15:
  964. case "end":
  965. return _context4.stop();
  966. }
  967. }, _callee4, this);
  968. }));
  969. function finish(_x4, _x5, _x6, _x7, _x8) {
  970. return _finish.apply(this, arguments);
  971. }
  972. return finish;
  973. }();
  974. /**获取自己的pvp擂台数据*/
  975. _proto.getOwn = /*#__PURE__*/
  976. function () {
  977. var _getOwn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  978. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  979. while (1) switch (_context5.prev = _context5.next) {
  980. case 0:
  981. if (this._own) {
  982. _context5.next = 3;
  983. break;
  984. }
  985. _context5.next = 3;
  986. return this.getRecords(3, false);
  987. case 3:
  988. return _context5.abrupt("return", this._own);
  989. case 4:
  990. case "end":
  991. return _context5.stop();
  992. }
  993. }, _callee5, this);
  994. }));
  995. function getOwn() {
  996. return _getOwn.apply(this, arguments);
  997. }
  998. return getOwn;
  999. }();
  1000. _proto.get_cache_records = function get_cache_records() {
  1001. if (chsdk.date.now() - this._cache_time > 6e4) return null;
  1002. return this._cache_records;
  1003. }
  1004. /**
  1005. * 获取pvp对战记录
  1006. * @param type 0:全部纪录 1:被挑战的记录信息(默认) 2:挑战别人的记录 3:不需要纪录
  1007. * @param cache 默认为true,优先缓存拿数据,缓存存在一分钟
  1008. * @returns own:自己的PVP 擂台数据
  1009. * list:交互纪录
  1010. * extends PVP 擂台数据
  1011. * reward 奖励惩罚排位分值,由于serverData中得来
  1012. * type 0:自己的数据 1:被挑战的记录信息 2:挑战别人的记录
  1013. * status 0:挑战失败 1:挑战胜利 2:复仇成功
  1014. * time 时间
  1015. * pvpId pvp复仇id
  1016. * other 对方信息
  1017. * own 自己信息
  1018. */;
  1019. _proto.getRecords = /*#__PURE__*/
  1020. function () {
  1021. var _getRecords = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(typeId, cache) {
  1022. var data, check, ret, _data, d, i, _d;
  1023. return _regeneratorRuntime().wrap(function _callee6$(_context6) {
  1024. while (1) switch (_context6.prev = _context6.next) {
  1025. case 0:
  1026. if (typeId === void 0) {
  1027. typeId = 1;
  1028. }
  1029. if (cache === void 0) {
  1030. cache = true;
  1031. }
  1032. if (!cache) {
  1033. _context6.next = 6;
  1034. break;
  1035. }
  1036. data = this.get_cache_records();
  1037. if (!data) {
  1038. _context6.next = 6;
  1039. break;
  1040. }
  1041. return _context6.abrupt("return", data);
  1042. case 6:
  1043. check = chsdk.check_req_time('getRecords');
  1044. if (!check) {
  1045. _context6.next = 9;
  1046. break;
  1047. }
  1048. return _context6.abrupt("return", null);
  1049. case 9:
  1050. _context6.next = 11;
  1051. return chsdk.makePostTokenRequest(chsdk.getUrl(this._record_url), {
  1052. typeId: typeId
  1053. });
  1054. case 11:
  1055. ret = _context6.sent;
  1056. if (!(ret.code != chsdk.code.success)) {
  1057. _context6.next = 17;
  1058. break;
  1059. }
  1060. chsdk.log.warn(ret);
  1061. return _context6.abrupt("return", null);
  1062. case 17:
  1063. _data = ret.data.data;
  1064. if (_data.own) {
  1065. d = _data.own;
  1066. d["extends"] = ch_util.parse(d["extends"]);
  1067. d.own.uid = Number.parseInt(d.own.uid);
  1068. d.own.hid = Number.parseInt(d.own.hid);
  1069. d.own.province = chsdk.provinceCode2Name(d.own.hid);
  1070. } else {
  1071. _data.own = null;
  1072. }
  1073. _data.list || (_data.list = []);
  1074. for (i = 0; i < _data.list.length; i++) {
  1075. _d = _data.list[i];
  1076. _d["extends"] = ch_util.parse(_d["extends"]);
  1077. _d.own.uid = Number.parseInt(_d.own.uid);
  1078. _d.own.hid = Number.parseInt(_d.own.hid);
  1079. _d.own.province = chsdk.provinceCode2Name(_d.own.hid);
  1080. _d.other.uid = Number.parseInt(_d.other.uid);
  1081. _d.other.hid = Number.parseInt(_d.other.hid);
  1082. _d.other.province = chsdk.provinceCode2Name(_d.other.hid);
  1083. }
  1084. this._own = _data.own;
  1085. this._cache_records = _data;
  1086. this._cache_time = chsdk.date.now();
  1087. return _context6.abrupt("return", _data);
  1088. case 25:
  1089. case "end":
  1090. return _context6.stop();
  1091. }
  1092. }, _callee6, this);
  1093. }));
  1094. function getRecords(_x9, _x10) {
  1095. return _getRecords.apply(this, arguments);
  1096. }
  1097. return getRecords;
  1098. }()
  1099. /**
  1100. * 获取pvp排位分值榜单
  1101. * @returns
  1102. */;
  1103. _proto.getRank = /*#__PURE__*/
  1104. function () {
  1105. var _getRank = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
  1106. var d;
  1107. return _regeneratorRuntime().wrap(function _callee7$(_context7) {
  1108. while (1) switch (_context7.prev = _context7.next) {
  1109. case 0:
  1110. _context7.next = 2;
  1111. return chsdk.loadRankData('pvp', 1, 100, true);
  1112. case 2:
  1113. d = _context7.sent;
  1114. return _context7.abrupt("return", {
  1115. list: d.data.list,
  1116. ower: d.data.own
  1117. });
  1118. case 4:
  1119. case "end":
  1120. return _context7.stop();
  1121. }
  1122. }, _callee7);
  1123. }));
  1124. function getRank() {
  1125. return _getRank.apply(this, arguments);
  1126. }
  1127. return getRank;
  1128. }()
  1129. /**
  1130. * 分享pvp数据,邀请对战
  1131. * @param player 玩家自己信息
  1132. * @param extend (可选)pvp关卡等数据
  1133. * @param title 分享显示标题
  1134. * @param imageUrl 分享显示图片
  1135. */;
  1136. _proto.sharePvp = /*#__PURE__*/
  1137. function () {
  1138. var _sharePvp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(player, extend, title, imageUrl) {
  1139. return _regeneratorRuntime().wrap(function _callee8$(_context8) {
  1140. while (1) switch (_context8.prev = _context8.next) {
  1141. case 0:
  1142. chsdk.shareAppMessage(title, '', imageUrl, ch_util.stringify({
  1143. type: 'pvp',
  1144. player: player,
  1145. "extends": extend
  1146. }));
  1147. case 1:
  1148. case "end":
  1149. return _context8.stop();
  1150. }
  1151. }, _callee8);
  1152. }));
  1153. function sharePvp(_x11, _x12, _x13, _x14) {
  1154. return _sharePvp.apply(this, arguments);
  1155. }
  1156. return sharePvp;
  1157. }()
  1158. /**
  1159. *获取从好友分享的pvp数据进入游戏的数据
  1160. */;
  1161. _proto.getSharePvpExtends = function getSharePvpExtends() {
  1162. var query = chsdk.getQuery();
  1163. if (!query) return null;
  1164. var message = query.message;
  1165. if (!message) return null;
  1166. var data = ch_util.parse(message);
  1167. if (!data) return null;
  1168. if (data.type != 'pvp') return null;
  1169. query.message = null;
  1170. return {
  1171. player: data.player,
  1172. extend: data["extends"]
  1173. };
  1174. };
  1175. return ch_pvp;
  1176. }(); //
  1177. ch_pvp._instance = void 0;
  1178. var pvp = exports('default', ch_pvp.getInstance());
  1179. cclegacy._RF.pop();
  1180. }
  1181. };
  1182. });
  1183. System.register("chunks:///_virtual/ch_sdk_comp.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  1184. var _inheritsLoose, cclegacy, _decorator, game, Game, Component;
  1185. return {
  1186. setters: [function (module) {
  1187. _inheritsLoose = module.inheritsLoose;
  1188. }, function (module) {
  1189. cclegacy = module.cclegacy;
  1190. _decorator = module._decorator;
  1191. game = module.game;
  1192. Game = module.Game;
  1193. Component = module.Component;
  1194. }],
  1195. execute: function () {
  1196. var _dec, _class;
  1197. cclegacy._RF.push({}, "9a64dfa1IRPk5UQTCy9WxRi", "ch_sdk_comp", undefined);
  1198. var ccclass = _decorator.ccclass,
  1199. property = _decorator.property;
  1200. var ch_sdk_comp = exports('ch_sdk_comp', (_dec = ccclass('ch_sdk_comp'), _dec(_class = /*#__PURE__*/function (_Component) {
  1201. _inheritsLoose(ch_sdk_comp, _Component);
  1202. function ch_sdk_comp() {
  1203. return _Component.apply(this, arguments) || this;
  1204. }
  1205. var _proto = ch_sdk_comp.prototype;
  1206. _proto.onLoad = function onLoad() {
  1207. game.on(Game.EVENT_SHOW, function () {
  1208. chsdk.sdk_event.emit(chsdk.sdk_event.key.show);
  1209. }, this);
  1210. game.on(Game.EVENT_HIDE, function () {
  1211. chsdk.sdk_event.emit(chsdk.sdk_event.key.hide);
  1212. }, this);
  1213. /*window.addEventListener("blur", () => {
  1214. chsdk.sdk_event.emit(chsdk.sdk_event.key.hide);
  1215. });
  1216. window.addEventListener("focus", () => {
  1217. chsdk.sdk_event.emit(chsdk.sdk_event.key.show);
  1218. });*/
  1219. };
  1220. return ch_sdk_comp;
  1221. }(Component)) || _class));
  1222. cclegacy._RF.pop();
  1223. }
  1224. };
  1225. });
  1226. System.register("chunks:///_virtual/ch_start_pack.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ch.ts', './audio.ts', './ch_sdk_comp.ts'], function (exports) {
  1227. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _createClass, _asyncToGenerator, _regeneratorRuntime, cclegacy, _decorator, Enum, Component, Node, director, ch, loadType, ch_sdk_comp;
  1228. return {
  1229. setters: [function (module) {
  1230. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  1231. _inheritsLoose = module.inheritsLoose;
  1232. _initializerDefineProperty = module.initializerDefineProperty;
  1233. _assertThisInitialized = module.assertThisInitialized;
  1234. _createClass = module.createClass;
  1235. _asyncToGenerator = module.asyncToGenerator;
  1236. _regeneratorRuntime = module.regeneratorRuntime;
  1237. }, function (module) {
  1238. cclegacy = module.cclegacy;
  1239. _decorator = module._decorator;
  1240. Enum = module.Enum;
  1241. Component = module.Component;
  1242. Node = module.Node;
  1243. director = module.director;
  1244. }, function (module) {
  1245. ch = module.ch;
  1246. }, function (module) {
  1247. loadType = module.loadType;
  1248. }, function (module) {
  1249. ch_sdk_comp = module.ch_sdk_comp;
  1250. }],
  1251. execute: function () {
  1252. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _dec28, _dec29, _dec30, _dec31, _dec32, _dec33, _dec34, _dec35, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16, _descriptor17, _descriptor18;
  1253. cclegacy._RF.push({}, "4aa63NubuJJqLakcBFHXiHV", "ch_start_pack", undefined);
  1254. var ccclass = _decorator.ccclass,
  1255. property = _decorator.property;
  1256. /**包id*/
  1257. var pack = exports('pack', /*#__PURE__*/function (pack) {
  1258. pack[pack["id0"] = 0] = "id0";
  1259. pack[pack["id1"] = 1] = "id1";
  1260. pack[pack["id2"] = 2] = "id2";
  1261. pack[pack["id3"] = 3] = "id3";
  1262. pack[pack["id4"] = 4] = "id4";
  1263. pack[pack["id5"] = 5] = "id5";
  1264. pack[pack["id6"] = 6] = "id6";
  1265. pack[pack["id7"] = 7] = "id7";
  1266. pack[pack["id8"] = 8] = "id8";
  1267. pack[pack["id9"] = 9] = "id9";
  1268. return pack;
  1269. }({}));
  1270. var ch_start_pack = exports('ch_start_pack', (_dec = ccclass('ch_start_pack'), _dec2 = property({
  1271. visible: false
  1272. }), _dec3 = property({
  1273. visible: false
  1274. }), _dec4 = property({
  1275. visible: false
  1276. }), _dec5 = property({
  1277. visible: false
  1278. }), _dec6 = property({
  1279. visible: false
  1280. }), _dec7 = property({
  1281. visible: false
  1282. }), _dec8 = property({
  1283. visible: false
  1284. }), _dec9 = property({
  1285. visible: false
  1286. }), _dec10 = property({
  1287. visible: false
  1288. }), _dec11 = property({
  1289. visible: false
  1290. }), _dec12 = property({
  1291. visible: false
  1292. }), _dec13 = property({
  1293. visible: false
  1294. }), _dec14 = property({
  1295. visible: false
  1296. }), _dec15 = property({
  1297. visible: false
  1298. }), _dec16 = property({
  1299. type: Enum(pack),
  1300. displayName: '包id',
  1301. group: {
  1302. name: '选包',
  1303. id: 'pack',
  1304. displayOrder: 0
  1305. }
  1306. }), _dec17 = property({
  1307. displayName: '游戏名',
  1308. group: {
  1309. name: '选包',
  1310. id: 'pack',
  1311. displayOrder: 0
  1312. }
  1313. }), _dec18 = property({
  1314. displayName: '游戏id',
  1315. group: {
  1316. name: '选包',
  1317. id: 'pack',
  1318. displayOrder: 0
  1319. }
  1320. }), _dec19 = property({
  1321. displayName: '是否单机',
  1322. group: {
  1323. name: 'ch.sdk模块',
  1324. id: 'sdk',
  1325. displayOrder: 0
  1326. }
  1327. }), _dec20 = property({
  1328. type: Enum(chsdk.serverType),
  1329. displayName: '服务器地址',
  1330. visible: function visible() {
  1331. return !this.is_local;
  1332. },
  1333. group: {
  1334. name: 'ch.sdk模块',
  1335. id: 'sdk',
  1336. displayOrder: 0
  1337. },
  1338. tooltip: "local 局域网 \n dev 测试服 \n online 正式服"
  1339. }), _dec21 = property({
  1340. displayName: '本地服测试ip',
  1341. visible: function visible() {
  1342. return this.server == chsdk.serverType.test;
  1343. },
  1344. group: {
  1345. name: 'ch.sdk模块',
  1346. id: 'sdk',
  1347. displayOrder: 0
  1348. }
  1349. }), _dec22 = property({
  1350. type: Enum(chsdk.reportType),
  1351. displayName: '上报类型',
  1352. group: {
  1353. name: '基本参数',
  1354. id: 'sdk',
  1355. displayOrder: 0
  1356. },
  1357. tooltip: "off 不上报 \n ch 使用ch服务器(需要在ch后台配置事件) \n platform 使用微信/抖音平台(需要在平台后台设置事件)\nch__platflorm所有平台自定义事件都上报"
  1358. }), _dec23 = property({
  1359. type: Enum(chsdk.loglevel),
  1360. displayName: '日志等级',
  1361. group: {
  1362. name: '基本参数',
  1363. id: 'sdk',
  1364. displayOrder: 0
  1365. }
  1366. }), _dec24 = property({
  1367. displayName: '抖音奖励广告id',
  1368. group: {
  1369. name: '基本参数',
  1370. id: 'sdk',
  1371. displayOrder: 0
  1372. }
  1373. }), _dec25 = property({
  1374. displayName: '抖音插屏广告id',
  1375. group: {
  1376. name: '基本参数',
  1377. id: 'sdk',
  1378. displayOrder: 0
  1379. }
  1380. }), _dec26 = property({
  1381. displayName: '抖音订阅id(,隔开)',
  1382. group: {
  1383. name: '基本参数',
  1384. id: 'sdk',
  1385. displayOrder: 0
  1386. }
  1387. }), _dec27 = property({
  1388. displayName: '微信奖励广告id',
  1389. group: {
  1390. name: '基本参数',
  1391. id: 'sdk',
  1392. displayOrder: 0
  1393. }
  1394. }), _dec28 = property({
  1395. displayName: '微信插屏广告id',
  1396. group: {
  1397. name: '基本参数',
  1398. id: 'sdk',
  1399. displayOrder: 0
  1400. }
  1401. }), _dec29 = property({
  1402. displayName: '微信订阅id(,隔开)',
  1403. group: {
  1404. name: '基本参数',
  1405. id: 'sdk',
  1406. displayOrder: 0
  1407. }
  1408. }), _dec30 = property({
  1409. visible: false
  1410. }), _dec31 = property({
  1411. type: Enum(loadType),
  1412. visible: false
  1413. }), _dec32 = property({
  1414. displayName: '是否使用ch.audio模块',
  1415. group: {
  1416. name: 'ch.audio模块',
  1417. id: 'audio',
  1418. displayOrder: 1
  1419. }
  1420. }), _dec33 = property({
  1421. type: Enum(loadType),
  1422. displayName: '音频资源加载模式',
  1423. group: {
  1424. name: 'ch.audio模块',
  1425. id: 'audio',
  1426. displayOrder: 1
  1427. },
  1428. visible: function visible() {
  1429. return this._use_ch_audio;
  1430. }
  1431. }), _dec34 = property({
  1432. displayName: '音频资源默认bundle名',
  1433. group: {
  1434. name: 'ch.audio模块',
  1435. id: 'audio',
  1436. displayOrder: 1
  1437. },
  1438. visible: function visible() {
  1439. return this._use_ch_audio && this._ch_audio_type == loadType.bundle;
  1440. }
  1441. }), _dec35 = property({
  1442. displayName: '音频资源远程地址',
  1443. group: {
  1444. name: 'ch.audio模块',
  1445. id: 'audio',
  1446. displayOrder: 1
  1447. },
  1448. visible: function visible() {
  1449. return this._use_ch_audio && this._ch_audio_type == loadType.remote;
  1450. }
  1451. }), _dec(_class = (_class2 = /*#__PURE__*/function (_Component) {
  1452. _inheritsLoose(ch_start_pack, _Component);
  1453. function ch_start_pack() {
  1454. var _this;
  1455. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1456. args[_key] = arguments[_key];
  1457. }
  1458. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  1459. _initializerDefineProperty(_this, "_gname", _descriptor, _assertThisInitialized(_this));
  1460. _initializerDefineProperty(_this, "_gid", _descriptor2, _assertThisInitialized(_this));
  1461. _initializerDefineProperty(_this, "_is_local", _descriptor3, _assertThisInitialized(_this));
  1462. _initializerDefineProperty(_this, "_server", _descriptor4, _assertThisInitialized(_this));
  1463. _initializerDefineProperty(_this, "_report", _descriptor5, _assertThisInitialized(_this));
  1464. _initializerDefineProperty(_this, "_log", _descriptor6, _assertThisInitialized(_this));
  1465. _initializerDefineProperty(_this, "_ttad", _descriptor7, _assertThisInitialized(_this));
  1466. _initializerDefineProperty(_this, "_ttiad", _descriptor8, _assertThisInitialized(_this));
  1467. _initializerDefineProperty(_this, "_tttmpid", _descriptor9, _assertThisInitialized(_this));
  1468. _initializerDefineProperty(_this, "_wxad", _descriptor10, _assertThisInitialized(_this));
  1469. _initializerDefineProperty(_this, "_wxiad", _descriptor11, _assertThisInitialized(_this));
  1470. _initializerDefineProperty(_this, "_wxtmpid", _descriptor12, _assertThisInitialized(_this));
  1471. _initializerDefineProperty(_this, "_serverIP", _descriptor13, _assertThisInitialized(_this));
  1472. _initializerDefineProperty(_this, "_pid", _descriptor14, _assertThisInitialized(_this));
  1473. //
  1474. _initializerDefineProperty(_this, "_use_ch_audio", _descriptor15, _assertThisInitialized(_this));
  1475. _initializerDefineProperty(_this, "_ch_audio_type", _descriptor16, _assertThisInitialized(_this));
  1476. _initializerDefineProperty(_this, "sound_bundle", _descriptor17, _assertThisInitialized(_this));
  1477. _initializerDefineProperty(_this, "sound_url", _descriptor18, _assertThisInitialized(_this));
  1478. return _this;
  1479. }
  1480. var _proto = ch_start_pack.prototype;
  1481. _proto.onLoad = function onLoad() {
  1482. console.log('包Id:' + this.pid, '游戏名:' + this.gname, '游戏Id:' + this.gid, '单机:' + this.is_local, '服务器:' + chsdk.serverType[this.server]);
  1483. }
  1484. /**初始化*/;
  1485. _proto.init = /*#__PURE__*/
  1486. function () {
  1487. var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  1488. var ret, sdk;
  1489. return _regeneratorRuntime().wrap(function _callee$(_context) {
  1490. while (1) switch (_context.prev = _context.next) {
  1491. case 0:
  1492. chsdk.setConf(chsdk.pf.tt, {
  1493. adUnitId: this.ttad,
  1494. multiton: false,
  1495. inster_unitId: this.ttiad,
  1496. tmplIds: this.tttmpid ? this.tttmpid.split(',') : null
  1497. });
  1498. chsdk.setConf(chsdk.pf.wx, {
  1499. adUnitId: this.wxad,
  1500. multiton: false,
  1501. inster_unitId: this.wxiad,
  1502. tmplIds: this.wxtmpid ? this.wxtmpid.split(',') : null
  1503. });
  1504. _context.next = 4;
  1505. return chsdk.init_inside(this.gid, this.log, this.server == chsdk.serverType.test ? this.serverIP : this.server, this.is_local, this.report);
  1506. case 4:
  1507. ret = _context.sent;
  1508. if (!(ret.code == chsdk.code.success)) {
  1509. _context.next = 11;
  1510. break;
  1511. }
  1512. if (this.use_ch_audio) {
  1513. ch.audio.init(this.sount_load_type, this.sound_bundle, this.sound_url);
  1514. }
  1515. if (chsdk.get_pf() === chsdk.pf.web) {
  1516. sdk = new Node();
  1517. sdk.name = '__ch_sdk__';
  1518. sdk.addComponent(ch_sdk_comp);
  1519. director.getScene().addChild(sdk);
  1520. director.addPersistRootNode(sdk);
  1521. }
  1522. return _context.abrupt("return", true);
  1523. case 11:
  1524. chsdk.log.error(ret.err);
  1525. return _context.abrupt("return", false);
  1526. case 13:
  1527. case "end":
  1528. return _context.stop();
  1529. }
  1530. }, _callee, this);
  1531. }));
  1532. function init() {
  1533. return _init.apply(this, arguments);
  1534. }
  1535. return init;
  1536. }()
  1537. /**初化始并在遇到问题时以单机模式进入
  1538. * @param try_count 重试次数
  1539. * @param try_interval 重试间隔时间(MS)
  1540. */;
  1541. _proto.try_init = /*#__PURE__*/
  1542. function () {
  1543. var _try_init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(try_count, try_interval) {
  1544. var ret;
  1545. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  1546. while (1) switch (_context2.prev = _context2.next) {
  1547. case 0:
  1548. if (try_count === void 0) {
  1549. try_count = 5;
  1550. }
  1551. if (try_interval === void 0) {
  1552. try_interval = 2000;
  1553. }
  1554. _context2.next = 4;
  1555. return this.init();
  1556. case 4:
  1557. ret = _context2.sent;
  1558. if (!ret) {
  1559. _context2.next = 7;
  1560. break;
  1561. }
  1562. return _context2.abrupt("return");
  1563. case 7:
  1564. try_count--;
  1565. if (!(try_count < 0)) {
  1566. _context2.next = 15;
  1567. break;
  1568. }
  1569. this.is_local = true;
  1570. _context2.next = 12;
  1571. return this.init();
  1572. case 12:
  1573. return _context2.abrupt("return");
  1574. case 15:
  1575. _context2.next = 17;
  1576. return new Promise(function (resolve) {
  1577. return setTimeout(resolve, try_interval);
  1578. });
  1579. case 17:
  1580. return _context2.abrupt("return", this.try_init(try_count, try_interval));
  1581. case 18:
  1582. case "end":
  1583. return _context2.stop();
  1584. }
  1585. }, _callee2, this);
  1586. }));
  1587. function try_init(_x, _x2) {
  1588. return _try_init.apply(this, arguments);
  1589. }
  1590. return try_init;
  1591. }();
  1592. _createClass(ch_start_pack, [{
  1593. key: "pid",
  1594. get: function get() {
  1595. return this._pid;
  1596. },
  1597. set: function set(val) {
  1598. this._pid = val;
  1599. for (var i = 0; i <= this._pid; i++) {
  1600. var _this$_gname, _i, _this$_gname$_i, _this$_is_local, _i2, _this$_is_local$_i, _this$_is_local2, _this$_gid, _i3, _this$_gid$_i, _this$_gid2, _this$_server, _i4, _this$_server$_i, _this$_server2, _this$_report, _i5, _this$_report$_i, _this$_report2, _this$_log, _i6, _this$_log$_i, _this$_log2, _this$_ttad, _i7, _this$_ttad$_i, _this$_ttiad, _i8, _this$_ttiad$_i, _this$_tttmpid, _i9, _this$_tttmpid$_i, _this$_wxad, _i10, _this$_wxad$_i, _this$_wxiad, _i11, _this$_wxiad$_i, _this$_wxtmpid, _i12, _this$_wxtmpid$_i, _this$_serverIP, _i13, _this$_serverIP$_i;
  1601. (_this$_gname$_i = (_this$_gname = this._gname)[_i = i]) != null ? _this$_gname$_i : _this$_gname[_i] = '';
  1602. (_this$_is_local$_i = (_this$_is_local = this._is_local)[_i2 = i]) != null ? _this$_is_local$_i : _this$_is_local[_i2] = (_this$_is_local2 = this._is_local[i - 1]) != null ? _this$_is_local2 : true;
  1603. (_this$_gid$_i = (_this$_gid = this._gid)[_i3 = i]) != null ? _this$_gid$_i : _this$_gid[_i3] = (_this$_gid2 = this._gid[i - 1]) != null ? _this$_gid2 : '0';
  1604. (_this$_server$_i = (_this$_server = this._server)[_i4 = i]) != null ? _this$_server$_i : _this$_server[_i4] = (_this$_server2 = this._server[i - 1]) != null ? _this$_server2 : chsdk.serverType.online;
  1605. (_this$_report$_i = (_this$_report = this._report)[_i5 = i]) != null ? _this$_report$_i : _this$_report[_i5] = (_this$_report2 = this._report[i - 1]) != null ? _this$_report2 : chsdk.reportType.off;
  1606. (_this$_log$_i = (_this$_log = this._log)[_i6 = i]) != null ? _this$_log$_i : _this$_log[_i6] = (_this$_log2 = this._log[i - 1]) != null ? _this$_log2 : chsdk.loglevel.DEBUG;
  1607. (_this$_ttad$_i = (_this$_ttad = this._ttad)[_i7 = i]) != null ? _this$_ttad$_i : _this$_ttad[_i7] = '';
  1608. (_this$_ttiad$_i = (_this$_ttiad = this._ttiad)[_i8 = i]) != null ? _this$_ttiad$_i : _this$_ttiad[_i8] = '';
  1609. (_this$_tttmpid$_i = (_this$_tttmpid = this._tttmpid)[_i9 = i]) != null ? _this$_tttmpid$_i : _this$_tttmpid[_i9] = '';
  1610. (_this$_wxad$_i = (_this$_wxad = this._wxad)[_i10 = i]) != null ? _this$_wxad$_i : _this$_wxad[_i10] = '';
  1611. (_this$_wxiad$_i = (_this$_wxiad = this._wxiad)[_i11 = i]) != null ? _this$_wxiad$_i : _this$_wxiad[_i11] = '';
  1612. (_this$_wxtmpid$_i = (_this$_wxtmpid = this._wxtmpid)[_i12 = i]) != null ? _this$_wxtmpid$_i : _this$_wxtmpid[_i12] = '';
  1613. (_this$_serverIP$_i = (_this$_serverIP = this._serverIP)[_i13 = i]) != null ? _this$_serverIP$_i : _this$_serverIP[_i13] = 'http://192.168.1.120:8787/v1';
  1614. }
  1615. }
  1616. }, {
  1617. key: "gname",
  1618. get: function get() {
  1619. var _this$_gname$this$_pi;
  1620. return (_this$_gname$this$_pi = this._gname[this._pid]) != null ? _this$_gname$this$_pi : '';
  1621. },
  1622. set: function set(val) {
  1623. this._gname[this._pid] = val;
  1624. }
  1625. }, {
  1626. key: "gid",
  1627. get: function get() {
  1628. return this._gid[this._pid];
  1629. },
  1630. set: function set(val) {
  1631. this._gid[this._pid] = val;
  1632. }
  1633. //
  1634. }, {
  1635. key: "is_local",
  1636. get: function get() {
  1637. return this._is_local[this._pid];
  1638. },
  1639. set: function set(val) {
  1640. this._is_local[this._pid] = val;
  1641. }
  1642. //
  1643. }, {
  1644. key: "server",
  1645. get: function get() {
  1646. return this._server[this._pid];
  1647. },
  1648. set: function set(val) {
  1649. this._server[this._pid] = val;
  1650. }
  1651. }, {
  1652. key: "serverIP",
  1653. get: function get() {
  1654. return this._serverIP[this._pid];
  1655. },
  1656. set: function set(val) {
  1657. this._serverIP[this._pid] = val;
  1658. }
  1659. }, {
  1660. key: "report",
  1661. get: function get() {
  1662. return this._report[this._pid];
  1663. },
  1664. set: function set(val) {
  1665. this._report[this._pid] = val;
  1666. }
  1667. }, {
  1668. key: "log",
  1669. get: function get() {
  1670. return this._log[this._pid];
  1671. },
  1672. set: function set(val) {
  1673. this._log[this._pid] = val;
  1674. }
  1675. //
  1676. }, {
  1677. key: "ttad",
  1678. get: function get() {
  1679. return this._ttad[this._pid];
  1680. },
  1681. set: function set(val) {
  1682. this._ttad[this._pid] = val;
  1683. }
  1684. }, {
  1685. key: "ttiad",
  1686. get: function get() {
  1687. return this._ttiad[this._pid];
  1688. },
  1689. set: function set(val) {
  1690. this._ttiad[this._pid] = val;
  1691. }
  1692. }, {
  1693. key: "tttmpid",
  1694. get: function get() {
  1695. return this._tttmpid[this._pid];
  1696. },
  1697. set: function set(val) {
  1698. this._tttmpid[this._pid] = val;
  1699. }
  1700. }, {
  1701. key: "wxad",
  1702. get: function get() {
  1703. return this._wxad[this._pid];
  1704. },
  1705. set: function set(val) {
  1706. this._wxad[this._pid] = val;
  1707. }
  1708. }, {
  1709. key: "wxiad",
  1710. get: function get() {
  1711. return this._wxiad[this._pid];
  1712. },
  1713. set: function set(val) {
  1714. this._wxiad[this._pid] = val;
  1715. }
  1716. }, {
  1717. key: "wxtmpid",
  1718. get: function get() {
  1719. return this._wxtmpid[this._pid];
  1720. },
  1721. set: function set(val) {
  1722. this._wxtmpid[this._pid] = val;
  1723. }
  1724. }, {
  1725. key: "use_ch_audio",
  1726. get: function get() {
  1727. return this._use_ch_audio;
  1728. },
  1729. set: function set(val) {
  1730. this._use_ch_audio = val;
  1731. }
  1732. }, {
  1733. key: "sount_load_type",
  1734. get: function get() {
  1735. return this._ch_audio_type;
  1736. },
  1737. set: function set(val) {
  1738. this._ch_audio_type = val;
  1739. }
  1740. }]);
  1741. return ch_start_pack;
  1742. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "_gname", [_dec2], {
  1743. configurable: true,
  1744. enumerable: true,
  1745. writable: true,
  1746. initializer: function initializer() {
  1747. return [];
  1748. }
  1749. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_gid", [_dec3], {
  1750. configurable: true,
  1751. enumerable: true,
  1752. writable: true,
  1753. initializer: function initializer() {
  1754. return [];
  1755. }
  1756. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_is_local", [_dec4], {
  1757. configurable: true,
  1758. enumerable: true,
  1759. writable: true,
  1760. initializer: function initializer() {
  1761. return [];
  1762. }
  1763. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_server", [_dec5], {
  1764. configurable: true,
  1765. enumerable: true,
  1766. writable: true,
  1767. initializer: function initializer() {
  1768. return [chsdk.serverType.dev];
  1769. }
  1770. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_report", [_dec6], {
  1771. configurable: true,
  1772. enumerable: true,
  1773. writable: true,
  1774. initializer: function initializer() {
  1775. return [chsdk.reportType.off];
  1776. }
  1777. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_log", [_dec7], {
  1778. configurable: true,
  1779. enumerable: true,
  1780. writable: true,
  1781. initializer: function initializer() {
  1782. return [];
  1783. }
  1784. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_ttad", [_dec8], {
  1785. configurable: true,
  1786. enumerable: true,
  1787. writable: true,
  1788. initializer: function initializer() {
  1789. return [];
  1790. }
  1791. }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "_ttiad", [_dec9], {
  1792. configurable: true,
  1793. enumerable: true,
  1794. writable: true,
  1795. initializer: function initializer() {
  1796. return [];
  1797. }
  1798. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "_tttmpid", [_dec10], {
  1799. configurable: true,
  1800. enumerable: true,
  1801. writable: true,
  1802. initializer: function initializer() {
  1803. return [];
  1804. }
  1805. }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "_wxad", [_dec11], {
  1806. configurable: true,
  1807. enumerable: true,
  1808. writable: true,
  1809. initializer: function initializer() {
  1810. return [];
  1811. }
  1812. }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "_wxiad", [_dec12], {
  1813. configurable: true,
  1814. enumerable: true,
  1815. writable: true,
  1816. initializer: function initializer() {
  1817. return [];
  1818. }
  1819. }), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "_wxtmpid", [_dec13], {
  1820. configurable: true,
  1821. enumerable: true,
  1822. writable: true,
  1823. initializer: function initializer() {
  1824. return [];
  1825. }
  1826. }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "_serverIP", [_dec14], {
  1827. configurable: true,
  1828. enumerable: true,
  1829. writable: true,
  1830. initializer: function initializer() {
  1831. return [];
  1832. }
  1833. }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "_pid", [_dec15], {
  1834. configurable: true,
  1835. enumerable: true,
  1836. writable: true,
  1837. initializer: function initializer() {
  1838. return pack.id0;
  1839. }
  1840. }), _applyDecoratedDescriptor(_class2.prototype, "pid", [_dec16], Object.getOwnPropertyDescriptor(_class2.prototype, "pid"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "gname", [_dec17], Object.getOwnPropertyDescriptor(_class2.prototype, "gname"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "gid", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "gid"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "is_local", [_dec19], Object.getOwnPropertyDescriptor(_class2.prototype, "is_local"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "server", [_dec20], Object.getOwnPropertyDescriptor(_class2.prototype, "server"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "serverIP", [_dec21], Object.getOwnPropertyDescriptor(_class2.prototype, "serverIP"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "report", [_dec22], Object.getOwnPropertyDescriptor(_class2.prototype, "report"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "log", [_dec23], Object.getOwnPropertyDescriptor(_class2.prototype, "log"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "ttad", [_dec24], Object.getOwnPropertyDescriptor(_class2.prototype, "ttad"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "ttiad", [_dec25], Object.getOwnPropertyDescriptor(_class2.prototype, "ttiad"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "tttmpid", [_dec26], Object.getOwnPropertyDescriptor(_class2.prototype, "tttmpid"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "wxad", [_dec27], Object.getOwnPropertyDescriptor(_class2.prototype, "wxad"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "wxiad", [_dec28], Object.getOwnPropertyDescriptor(_class2.prototype, "wxiad"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "wxtmpid", [_dec29], Object.getOwnPropertyDescriptor(_class2.prototype, "wxtmpid"), _class2.prototype), _descriptor15 = _applyDecoratedDescriptor(_class2.prototype, "_use_ch_audio", [_dec30], {
  1841. configurable: true,
  1842. enumerable: true,
  1843. writable: true,
  1844. initializer: function initializer() {
  1845. return false;
  1846. }
  1847. }), _descriptor16 = _applyDecoratedDescriptor(_class2.prototype, "_ch_audio_type", [_dec31], {
  1848. configurable: true,
  1849. enumerable: true,
  1850. writable: true,
  1851. initializer: function initializer() {
  1852. return loadType.bundle;
  1853. }
  1854. }), _applyDecoratedDescriptor(_class2.prototype, "use_ch_audio", [_dec32], Object.getOwnPropertyDescriptor(_class2.prototype, "use_ch_audio"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "sount_load_type", [_dec33], Object.getOwnPropertyDescriptor(_class2.prototype, "sount_load_type"), _class2.prototype), _descriptor17 = _applyDecoratedDescriptor(_class2.prototype, "sound_bundle", [_dec34], {
  1855. configurable: true,
  1856. enumerable: true,
  1857. writable: true,
  1858. initializer: function initializer() {
  1859. return 'res';
  1860. }
  1861. }), _descriptor18 = _applyDecoratedDescriptor(_class2.prototype, "sound_url", [_dec35], {
  1862. configurable: true,
  1863. enumerable: true,
  1864. writable: true,
  1865. initializer: function initializer() {
  1866. return '';
  1867. }
  1868. })), _class2)) || _class));
  1869. cclegacy._RF.pop();
  1870. }
  1871. };
  1872. });
  1873. System.register("chunks:///_virtual/ch_util.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  1874. var _asyncToGenerator, _regeneratorRuntime, cclegacy, sys, UITransform, size, screen, view, assetManager, SpriteFrame, Texture2D, ImageAsset;
  1875. return {
  1876. setters: [function (module) {
  1877. _asyncToGenerator = module.asyncToGenerator;
  1878. _regeneratorRuntime = module.regeneratorRuntime;
  1879. }, function (module) {
  1880. cclegacy = module.cclegacy;
  1881. sys = module.sys;
  1882. UITransform = module.UITransform;
  1883. size = module.size;
  1884. screen = module.screen;
  1885. view = module.view;
  1886. assetManager = module.assetManager;
  1887. SpriteFrame = module.SpriteFrame;
  1888. Texture2D = module.Texture2D;
  1889. ImageAsset = module.ImageAsset;
  1890. }],
  1891. execute: function () {
  1892. cclegacy._RF.push({}, "1badftMxAdA7p5/bxrvSF8o", "ch_util", undefined);
  1893. /**工具*/
  1894. var ch_util = /*#__PURE__*/function () {
  1895. function ch_util() {
  1896. this._k = 1000;
  1897. this._k_sizes_en = ['', 'K', 'M', 'G', 'T', 'P', 'E'];
  1898. this._k_sizes_cn = ['', '千', '百万', '十亿', '万亿', '拍(千万亿)', '艾(十亿亿)'];
  1899. this._w = 10000;
  1900. this._w_sizes_en = ['', 'W', 'M', 'B', 'T'];
  1901. this._w_sizes_cn = ['', '万', '亿', '万亿'];
  1902. this._url_data = null;
  1903. }
  1904. ch_util.getInstance = function getInstance() {
  1905. if (!this._instance) this._instance = new ch_util();
  1906. return this._instance;
  1907. }
  1908. /**
  1909. * 随机数 (包含min,不包含max)
  1910. * @param min
  1911. * @param max
  1912. * @param isInt
  1913. * @return {*}
  1914. */;
  1915. var _proto = ch_util.prototype;
  1916. _proto.getRandom = function getRandom(min, max) {
  1917. if (min === void 0) {
  1918. min = 0;
  1919. }
  1920. if (max === void 0) {
  1921. max = 1;
  1922. }
  1923. if (min == null) min = 0;
  1924. if (max == null) max = 1;
  1925. if (min === max) return min;
  1926. return min + Math.random() * (max - min);
  1927. }
  1928. /**
  1929. * 随机整数-不包含最大值
  1930. * @param min
  1931. * @param max
  1932. * @return {*}
  1933. */;
  1934. _proto.getRandomInt = function getRandomInt(min, max) {
  1935. min = Math.ceil(min);
  1936. max = Math.ceil(max);
  1937. return Math.floor(Math.random() * (max - min)) + min;
  1938. }
  1939. /** 生成随机整数 -1 或 1*/;
  1940. _proto.getRandomDir = function getRandomDir() {
  1941. return Math.floor(Math.random() * 2) === 0 ? -1 : 1;
  1942. }
  1943. /**
  1944. * 在指定数组中随机取出N个不重复的数据
  1945. * @param resArr
  1946. * @param ranNum
  1947. * @returns {Array}
  1948. */;
  1949. _proto.getRandomDiffValueFromArr = function getRandomDiffValueFromArr(resArr, ranNum) {
  1950. var arr = new Array();
  1951. var result = new Array();
  1952. if (!resArr || resArr.length <= 0 || ranNum <= 0) {
  1953. return result;
  1954. }
  1955. for (var i = 0; i < resArr.length; i++) {
  1956. arr.push(resArr[i]);
  1957. }
  1958. if (ranNum >= arr.length) return arr;
  1959. ranNum = Math.min(ranNum, arr.length - 1);
  1960. for (var _i = 0; _i < ranNum; _i++) {
  1961. var ran = this.getRandomInt(0, arr.length - 1);
  1962. result.push(arr.splice(ran, 1)[0]);
  1963. }
  1964. return result;
  1965. }
  1966. /**
  1967. * 取小数位
  1968. * @param decimal 小数
  1969. * @param places 位数
  1970. * @return {number}
  1971. */;
  1972. _proto.numberToDecimal = function numberToDecimal(decimal, places) {
  1973. var round = Math.pow(10, places);
  1974. return Math.round(decimal * round) / round;
  1975. };
  1976. _proto.parse = function parse(text, reciver) {
  1977. try {
  1978. return JSON.parse(text, reciver);
  1979. } catch (error) {
  1980. //ch_log.error(error);
  1981. return null;
  1982. }
  1983. };
  1984. _proto.stringify = function stringify(value, replacer, space) {
  1985. try {
  1986. return JSON.stringify(value, replacer, space);
  1987. } catch (error) {
  1988. return null;
  1989. }
  1990. }
  1991. /**
  1992. * 判断字符是否为双字节字符(如中文字符)
  1993. * @param string 原字符串
  1994. */;
  1995. _proto.str_isDoubleWord = function str_isDoubleWord(string) {
  1996. return /[^\x00-\xff]/.test(string);
  1997. }
  1998. /**
  1999. * 是否为空
  2000. * @param str
  2001. */;
  2002. _proto.str_isEmpty = function str_isEmpty(str) {
  2003. if (str == null || str == undefined || str.length == 0) {
  2004. return true;
  2005. }
  2006. return false;
  2007. }
  2008. /**
  2009. * 转美式计数字符串
  2010. * @param value 数字
  2011. * @example
  2012. * 123456789 = 123,456,789
  2013. */;
  2014. _proto.numberTotPermil = function numberTotPermil(value) {
  2015. return value.toLocaleString();
  2016. };
  2017. /**
  2018. * 通用单位转换方法
  2019. */
  2020. _proto.convertNumber = function convertNumber(value, base, sizes, fixed) {
  2021. if (value < base) return value.toString();
  2022. var i = Math.floor(Math.log(value) / Math.log(base));
  2023. var r = value / Math.pow(base, i);
  2024. if (i >= sizes.length) return value.toString();
  2025. return "" + r.toFixed(fixed) + sizes[i];
  2026. }
  2027. /**
  2028. * 转单位计数(默认英文)
  2029. * @param value 数字
  2030. * @param fixed 保留小数位数
  2031. * @param isEn 是否英文
  2032. * @example
  2033. * 12345 = 12.35K
  2034. */;
  2035. _proto.numberToThousand = function numberToThousand(value, fixed, isEn) {
  2036. if (fixed === void 0) {
  2037. fixed = 2;
  2038. }
  2039. if (isEn === void 0) {
  2040. isEn = true;
  2041. }
  2042. var sizes = isEn ? this._k_sizes_en : this._k_sizes_cn;
  2043. return this.convertNumber(value, this._k, sizes, fixed);
  2044. }
  2045. /**
  2046. * 转单位计数(默认中文)
  2047. * @param value 数字
  2048. * @param fixed 保留小数位数
  2049. * @param isEn 是否英文
  2050. * @example
  2051. * 12345 = 1.23万
  2052. */;
  2053. _proto.numberToTenThousand = function numberToTenThousand(value, fixed, isEn) {
  2054. if (fixed === void 0) {
  2055. fixed = 2;
  2056. }
  2057. if (isEn === void 0) {
  2058. isEn = false;
  2059. }
  2060. var sizes = isEn ? this._w_sizes_en : this._w_sizes_cn;
  2061. return this.convertNumber(value, this._w, sizes, fixed);
  2062. }
  2063. /**获取一个唯一标识的字符串 */;
  2064. _proto.guid = function guid() {
  2065. var guid = Math.random().toString(36).substring(2);
  2066. return guid;
  2067. }
  2068. /**排序一个json Object*/;
  2069. _proto.obj_sort = function obj_sort(obj) {
  2070. var sorted_keys = Object.keys(obj).sort();
  2071. var new_obj = {};
  2072. for (var i = 0; i < sorted_keys.length; i++) {
  2073. var _key = sorted_keys[i];
  2074. var _value = obj[_key];
  2075. var t = this.obj_get_value_type(_value);
  2076. new_obj[_key] = t == 'object' ? this.obj_sort(_value) : _value;
  2077. }
  2078. return new_obj;
  2079. }
  2080. /**获取一个josn值的类型*/;
  2081. _proto.obj_get_value_type = function obj_get_value_type(value) {
  2082. var type;
  2083. if (value === null) {
  2084. type = 'null';
  2085. } else {
  2086. type = typeof value;
  2087. }
  2088. // 如果是对象或数组,还可以进一步判断
  2089. if (type === 'object') {
  2090. if (Array.isArray(value)) {
  2091. type = 'array';
  2092. }
  2093. //else if (value instanceof Date) { type = 'date'; }
  2094. }
  2095. return type;
  2096. }
  2097. /**
  2098. * 判断指定的值是否为对象
  2099. * @param value 值
  2100. */;
  2101. _proto.valueIsObject = function valueIsObject(value) {
  2102. return Object.prototype.toString.call(value) === '[object Object]';
  2103. }
  2104. /**
  2105. * 深拷贝
  2106. * @param target 目标
  2107. */
  2108. /** 克隆对象 */;
  2109. _proto.obj_clone = function obj_clone(target_, record_set) {
  2110. if (record_set === void 0) {
  2111. record_set = new Set();
  2112. }
  2113. var result;
  2114. switch (typeof target_) {
  2115. case "object":
  2116. {
  2117. // 数组:遍历拷贝
  2118. if (Array.isArray(target_)) {
  2119. if (record_set.has(target_)) {
  2120. return target_;
  2121. }
  2122. record_set.add(target_);
  2123. result = [];
  2124. for (var k_n = 0; k_n < target_.length; ++k_n) {
  2125. // 递归克隆数组中的每一项
  2126. result.push(this.obj_clone(target_[k_n], record_set));
  2127. }
  2128. }
  2129. // null:直接赋值
  2130. else if (target_ === null) {
  2131. result = null;
  2132. }
  2133. // RegExp:直接赋值
  2134. else if (target_.constructor === RegExp) {
  2135. result = target_;
  2136. }
  2137. // 普通对象:循环递归赋值对象的所有值
  2138. else {
  2139. if (record_set.has(target_)) {
  2140. return target_;
  2141. }
  2142. record_set.add(target_);
  2143. result = {};
  2144. for (var k_s in target_) {
  2145. result[k_s] = this.obj_clone(target_[k_s], record_set);
  2146. }
  2147. }
  2148. break;
  2149. }
  2150. case "function":
  2151. {
  2152. result = target_.bind({});
  2153. break;
  2154. }
  2155. default:
  2156. {
  2157. result = target_;
  2158. }
  2159. }
  2160. return result;
  2161. }
  2162. /**
  2163. * 拷贝对象
  2164. * @param target 目标
  2165. */;
  2166. _proto.copy = function copy(target) {
  2167. return this.parse(this.stringify(target));
  2168. }
  2169. //请求相关--------------------------------------------
  2170. ;
  2171. _proto.getReqId = function getReqId() {
  2172. return Date.now() + "_" + Math.ceil(1e3 * Math.random());
  2173. };
  2174. /**获取链接中传入的某个值*/
  2175. _proto.getUrlData = function getUrlData(key) {
  2176. if (!this._url_data) {
  2177. this._url_data = this.parseUrl();
  2178. }
  2179. var value = this._url_data[key];
  2180. if (value === undefined) return null;
  2181. if (typeof value === 'string') {
  2182. var numberValue = parseFloat(value);
  2183. if (!isNaN(numberValue)) return numberValue;
  2184. return value;
  2185. }
  2186. return null;
  2187. };
  2188. _proto.parseUrl = function parseUrl() {
  2189. if (!sys.isBrowser || typeof window !== "object" || !window.document) return {};
  2190. var url = window.document.location.href;
  2191. var queryString = url.split("?")[1];
  2192. if (!queryString) return {};
  2193. return queryString.split("&").reduce(function (acc, param) {
  2194. var _param$split = param.split("="),
  2195. key = _param$split[0],
  2196. value = _param$split[1];
  2197. if (key) acc[decodeURIComponent(key)] = value ? decodeURIComponent(value) : '';
  2198. return acc;
  2199. }, {});
  2200. }
  2201. /**获到node的坐标和范围用于平台在对应位置创建按纽*/;
  2202. _proto.getBtnOp = function getBtnOp(btnNode) {
  2203. var btnNodeUiTransform = btnNode.getComponent(UITransform);
  2204. var btnSize = size(btnNodeUiTransform.width + 0, btnNodeUiTransform.height + 0);
  2205. //let frameWidth = screen.windowSize.width / screen.devicePixelRatio
  2206. var frameHeight = screen.windowSize.height / screen.devicePixelRatio;
  2207. //const winSize = screen.windowSize;
  2208. //const designSize = view.getDesignResolutionSize();
  2209. //console.log('designSize', designSize);
  2210. //console.log('winSize:', winSize);
  2211. //console.log('frameSize:', frameWidth,frameHeight);
  2212. //适配不同机型来创建微信授权按钮
  2213. var rect = btnNodeUiTransform.getBoundingBoxToWorld();
  2214. var ratio = screen.devicePixelRatio;
  2215. var scale = view.getScaleX();
  2216. var factor = scale / ratio;
  2217. var offsetX = 0;
  2218. var offsetY = 0;
  2219. var top = frameHeight - (rect.y + rect.height) * factor - offsetY;
  2220. var left = rect.x * factor + offsetX;
  2221. var width = btnSize.width * factor;
  2222. var height = btnSize.height * factor;
  2223. return {
  2224. left: left,
  2225. top: top,
  2226. width: width,
  2227. height: height
  2228. };
  2229. }
  2230. /**远程加载图片*/;
  2231. _proto.loadImage = /*#__PURE__*/
  2232. function () {
  2233. var _loadImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
  2234. var idata;
  2235. return _regeneratorRuntime().wrap(function _callee$(_context) {
  2236. while (1) switch (_context.prev = _context.next) {
  2237. case 0:
  2238. if (!(chsdk.get_pf() == chsdk.pf.web)) {
  2239. _context.next = 6;
  2240. break;
  2241. }
  2242. _context.next = 3;
  2243. return this.loadRemoteSprite(url);
  2244. case 3:
  2245. return _context.abrupt("return", _context.sent);
  2246. case 6:
  2247. _context.next = 8;
  2248. return chsdk.loadImage(url);
  2249. case 8:
  2250. idata = _context.sent;
  2251. return _context.abrupt("return", this.getSpriteFrame(idata));
  2252. case 10:
  2253. case "end":
  2254. return _context.stop();
  2255. }
  2256. }, _callee, this);
  2257. }));
  2258. function loadImage(_x) {
  2259. return _loadImage.apply(this, arguments);
  2260. }
  2261. return loadImage;
  2262. }() /**cocos加载远程图片*/;
  2263. _proto.loadRemoteSprite = function loadRemoteSprite(remoteUrl, ext) {
  2264. if (ext === void 0) {
  2265. ext = '.png';
  2266. }
  2267. return new Promise(function (resolve) {
  2268. assetManager.loadRemote(remoteUrl, {
  2269. ext: ext
  2270. }, function (err, imageAsset) {
  2271. var spriteFrame = new SpriteFrame();
  2272. var texture = new Texture2D();
  2273. texture.image = imageAsset;
  2274. spriteFrame.texture = texture;
  2275. resolve(spriteFrame);
  2276. });
  2277. });
  2278. }
  2279. /**远程加载的图片数据转成spriteFrame*/;
  2280. _proto.getSpriteFrame = function getSpriteFrame(img) {
  2281. if (!img) return null;
  2282. try {
  2283. var spriteFrame = new SpriteFrame();
  2284. var texture = new Texture2D();
  2285. texture.image = img instanceof ImageAsset ? img : new ImageAsset(img);
  2286. spriteFrame.texture = texture;
  2287. return spriteFrame;
  2288. } catch (error) {
  2289. //ch_log.warn(error);
  2290. return null;
  2291. }
  2292. };
  2293. return ch_util;
  2294. }();
  2295. ch_util._instance = void 0;
  2296. var ch_util$1 = exports('default', ch_util.getInstance());
  2297. cclegacy._RF.pop();
  2298. }
  2299. };
  2300. });
  2301. System.register("chunks:///_virtual/ch.ts", ['cc', './audio.ts', './ch_pvp.ts', './ch_util.ts', './sign.ts', './net.ts', './NetPlayer.ts', './NetRoom.ts'], function (exports) {
  2302. var cclegacy, ch_audio, pvp, ch_util, ch_sign, ch_net;
  2303. return {
  2304. setters: [function (module) {
  2305. cclegacy = module.cclegacy;
  2306. }, function (module) {
  2307. ch_audio = module.default;
  2308. }, function (module) {
  2309. pvp = module.default;
  2310. }, function (module) {
  2311. ch_util = module.default;
  2312. }, function (module) {
  2313. ch_sign = module.default;
  2314. }, function (module) {
  2315. ch_net = module.ch_net;
  2316. }, function (module) {
  2317. exports('NetPlayer', module.NetPlayer);
  2318. }, function (module) {
  2319. exports('NetRoom', module.NetRoom);
  2320. }],
  2321. execute: function () {
  2322. cclegacy._RF.push({}, "16801Kyc0VO+7VDvNW2CiaJ", "ch", undefined);
  2323. var ch = exports('ch', {
  2324. /**主sdk(需要初始化)*/
  2325. sdk: chsdk,
  2326. /**日志*/
  2327. log: chsdk.log,
  2328. /**本地缓存*/
  2329. storage: chsdk.storage,
  2330. /**日期*/
  2331. date: chsdk.date,
  2332. /**创建一个模块事件*/get_new_event: function get_new_event() {
  2333. return chsdk.get_new_event();
  2334. },
  2335. //---------------------------------------------
  2336. /**交互*/
  2337. pvp: pvp,
  2338. /**创建一个新的网络连接管理*/get_new_net: function get_new_net() {
  2339. return new ch_net();
  2340. },
  2341. /**工具*/
  2342. util: ch_util,
  2343. /**登录签到模块*/
  2344. get sign() {
  2345. return ch_sign.getInstance();
  2346. },
  2347. /**音频播放模块(需要初始化)*/
  2348. get audio() {
  2349. return ch_audio.getInstance();
  2350. }
  2351. });
  2352. cclegacy._RF.pop();
  2353. }
  2354. };
  2355. });
  2356. System.register("chunks:///_virtual/ClickPenetrate.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  2357. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, cclegacy, _decorator, EventHandler, Vec2, Button, Input, Component;
  2358. return {
  2359. setters: [function (module) {
  2360. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  2361. _inheritsLoose = module.inheritsLoose;
  2362. _initializerDefineProperty = module.initializerDefineProperty;
  2363. _assertThisInitialized = module.assertThisInitialized;
  2364. }, function (module) {
  2365. cclegacy = module.cclegacy;
  2366. _decorator = module._decorator;
  2367. EventHandler = module.EventHandler;
  2368. Vec2 = module.Vec2;
  2369. Button = module.Button;
  2370. Input = module.Input;
  2371. Component = module.Component;
  2372. }],
  2373. execute: function () {
  2374. var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
  2375. cclegacy._RF.push({}, "739bfHpcHtB3IXOkilm3JV7", "ClickPenetrate", undefined);
  2376. var ccclass = _decorator.ccclass,
  2377. property = _decorator.property;
  2378. /*** 按钮 点击穿透*/
  2379. var ClickPenetrate = exports('ClickPenetrate', (_dec = ccclass('ClickPenetrate'), _dec2 = property({
  2380. tooltip: "滑动会关闭 end 触摸事件"
  2381. }), _dec3 = property({
  2382. tooltip: "触摸开始",
  2383. type: EventHandler
  2384. }), _dec4 = property({
  2385. tooltip: "触摸移动",
  2386. type: EventHandler
  2387. }), _dec5 = property({
  2388. tooltip: "触摸结束",
  2389. type: EventHandler
  2390. }), _dec(_class = (_class2 = /*#__PURE__*/function (_Component) {
  2391. _inheritsLoose(ClickPenetrate, _Component);
  2392. function ClickPenetrate() {
  2393. var _this;
  2394. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  2395. args[_key] = arguments[_key];
  2396. }
  2397. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  2398. _initializerDefineProperty(_this, "move_began_end", _descriptor, _assertThisInitialized(_this));
  2399. _initializerDefineProperty(_this, "on_touch_began", _descriptor2, _assertThisInitialized(_this));
  2400. _initializerDefineProperty(_this, "on_touch_move", _descriptor3, _assertThisInitialized(_this));
  2401. _initializerDefineProperty(_this, "on_touch_end", _descriptor4, _assertThisInitialized(_this));
  2402. // @property({ tooltip: "触摸关闭", type: cc.EventHandler })
  2403. // private on_touch_cancel: Array<cc.EventHandler> = [];
  2404. _this.has_began = false;
  2405. _this.comp_btn = null;
  2406. /** 是移动状态 */
  2407. _this.is_move = null;
  2408. /** 本次点击所移动的距离 */
  2409. _this.delta = new Vec2(0, 0);
  2410. return _this;
  2411. }
  2412. var _proto = ClickPenetrate.prototype;
  2413. _proto.onLoad = function onLoad() {
  2414. this.comp_btn = this.node.getComponent(Button) || this.node.addComponent(Button);
  2415. this.comp_btn.node.on(Input.EventType.TOUCH_START, this.onTouchBegan, this);
  2416. this.comp_btn.node.on(Input.EventType.TOUCH_MOVE, this.onTouchMoved, this);
  2417. this.comp_btn.node.on(Input.EventType.TOUCH_END, this.onTouchEnded, this);
  2418. this.comp_btn.node.on(Input.EventType.TOUCH_CANCEL, this.onTouchCancelled, this);
  2419. };
  2420. _proto.onTouchBegan = function onTouchBegan(touch, param) {
  2421. var _this2 = this;
  2422. touch.preventSwallow = true;
  2423. this.has_began = true;
  2424. this.is_move = false;
  2425. this.delta = new Vec2(0, 0);
  2426. this.on_touch_began.forEach(function (value, key) {
  2427. value.emit([_this2.comp_btn]);
  2428. });
  2429. };
  2430. _proto.onTouchMoved = function onTouchMoved(touch, param) {
  2431. var _this3 = this;
  2432. touch.preventSwallow = true;
  2433. if (!this.has_began) return;
  2434. this.on_touch_move.forEach(function (value, key) {
  2435. value.emit([_this3.comp_btn]);
  2436. });
  2437. var delta = touch.getDelta();
  2438. this.delta.x += delta.x;
  2439. this.delta.y += delta.y;
  2440. var distance = this.delta.length();
  2441. if (distance >= 20) this.is_move = true;
  2442. // 滑动超过20像素,算作点击
  2443. };
  2444. _proto.onTouchEnded = function onTouchEnded(touch, param) {
  2445. var _this4 = this;
  2446. touch.preventSwallow = true;
  2447. if (!this.has_began) return;
  2448. if (this.move_began_end && this.is_move) return;
  2449. this.on_touch_end.forEach(function (value, key) {
  2450. value.emit([_this4.comp_btn]);
  2451. });
  2452. this.has_began = false;
  2453. this.is_move = false;
  2454. };
  2455. _proto.onTouchCancelled = function onTouchCancelled(touch, param) {
  2456. touch.preventSwallow = true;
  2457. };
  2458. return ClickPenetrate;
  2459. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "move_began_end", [_dec2], {
  2460. configurable: true,
  2461. enumerable: true,
  2462. writable: true,
  2463. initializer: function initializer() {
  2464. return false;
  2465. }
  2466. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_began", [_dec3], {
  2467. configurable: true,
  2468. enumerable: true,
  2469. writable: true,
  2470. initializer: function initializer() {
  2471. return [];
  2472. }
  2473. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_move", [_dec4], {
  2474. configurable: true,
  2475. enumerable: true,
  2476. writable: true,
  2477. initializer: function initializer() {
  2478. return [];
  2479. }
  2480. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "on_touch_end", [_dec5], {
  2481. configurable: true,
  2482. enumerable: true,
  2483. writable: true,
  2484. initializer: function initializer() {
  2485. return [];
  2486. }
  2487. })), _class2)) || _class));
  2488. cclegacy._RF.pop();
  2489. }
  2490. };
  2491. });
  2492. System.register("chunks:///_virtual/Container.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  2493. var _createClass, cclegacy;
  2494. return {
  2495. setters: [function (module) {
  2496. _createClass = module.createClass;
  2497. }, function (module) {
  2498. cclegacy = module.cclegacy;
  2499. }],
  2500. execute: function () {
  2501. cclegacy._RF.push({}, "7b367Ns5DhICaZLmc2yobWd", "Container", undefined);
  2502. var Container = exports('Container', /*#__PURE__*/function () {
  2503. function Container() {
  2504. this._itemList = null;
  2505. this._itemList = new Array();
  2506. }
  2507. var _proto = Container.prototype;
  2508. _proto.addCount = function addCount(type, count) {
  2509. return this.addItem({
  2510. type: type,
  2511. count: count
  2512. });
  2513. };
  2514. _proto.useCount = function useCount(type, count) {
  2515. for (var i = 0; i < this._itemList.length; i++) {
  2516. if (this._itemList[i].type == type) {
  2517. if (this._itemList[i].count >= count) {
  2518. this._itemList[i].count -= count;
  2519. return this._itemList[i];
  2520. }
  2521. }
  2522. }
  2523. return null;
  2524. }
  2525. /**
  2526. * 添加物品
  2527. * @param item
  2528. * @returns
  2529. */;
  2530. _proto.addItem = function addItem(item) {
  2531. for (var i = 0; i < this._itemList.length; i++) {
  2532. if (this._itemList[i].type == item.type) {
  2533. this._itemList[i].count += item.count;
  2534. return this._itemList[i];
  2535. }
  2536. }
  2537. this._itemList.push(item);
  2538. return item;
  2539. };
  2540. _proto.getCount = function getCount(type) {
  2541. for (var i = 0; i < this._itemList.length; i++) {
  2542. if (this._itemList[i].type == type) {
  2543. return this._itemList[i].count;
  2544. }
  2545. }
  2546. return 0;
  2547. };
  2548. /**
  2549. * 序列化(数据库存储)
  2550. */
  2551. _proto.serialize = function serialize() {
  2552. var list = [];
  2553. for (var i = 0; i < this._itemList.length; i++) {
  2554. var item = this._itemList[i];
  2555. list.push({
  2556. type: item.type,
  2557. count: item.count
  2558. });
  2559. }
  2560. var data = {
  2561. "list": list
  2562. };
  2563. return data;
  2564. }
  2565. /**
  2566. * 反序列化(数据库读取)
  2567. * @param data
  2568. */;
  2569. _proto.unserialize = function unserialize(data) {
  2570. if (!data) return;
  2571. var list = data.list;
  2572. this._itemList = [];
  2573. for (var i = 0; i < list.length; i++) {
  2574. this._itemList.push({
  2575. type: list[i].type,
  2576. count: list[i].count
  2577. });
  2578. }
  2579. };
  2580. _createClass(Container, [{
  2581. key: "itemList",
  2582. get: function get() {
  2583. return this._itemList;
  2584. },
  2585. set: function set(arr) {
  2586. this._itemList = arr;
  2587. }
  2588. }]);
  2589. return Container;
  2590. }());
  2591. cclegacy._RF.pop();
  2592. }
  2593. };
  2594. });
  2595. System.register("chunks:///_virtual/DataTimeUtil.ts", ['cc'], function (exports) {
  2596. var cclegacy;
  2597. return {
  2598. setters: [function (module) {
  2599. cclegacy = module.cclegacy;
  2600. }],
  2601. execute: function () {
  2602. cclegacy._RF.push({}, "6aa3eXS6PhBSro7Xyyel0Vs", "DataTimeUtil", undefined);
  2603. var DataTimeUtil = exports('default', /*#__PURE__*/function () {
  2604. function DataTimeUtil() {}
  2605. /**
  2606. * 当前时间戳(毫秒)
  2607. * @returns
  2608. */
  2609. DataTimeUtil.currentTimeMillis = function currentTimeMillis() {
  2610. return new Date().getTime() + this.offset;
  2611. }
  2612. /**
  2613. * 当前时间戳(秒)
  2614. * @returns
  2615. */;
  2616. DataTimeUtil.currentTimeSeconds = function currentTimeSeconds() {
  2617. return Math.floor((new Date().getTime() + this.offset) / 1000);
  2618. }
  2619. /**当前服务器日期*/;
  2620. DataTimeUtil.currentDate = function currentDate() {
  2621. return new Date(this.currentTimeMillis());
  2622. }
  2623. /**将毫秒时间戳转到当天0点时的毫秒时间戳*/;
  2624. DataTimeUtil.timestampToStartOfDay = function timestampToStartOfDay(timestamp) {
  2625. var date = new Date(timestamp); // 将时间戳转换为日期对象
  2626. date.setHours(0, 0, 0, 0); // 将时、分、秒、毫秒部分设置为0
  2627. return date.getTime(); // 将日期转换回时间戳
  2628. }
  2629. /**将秒时间戳转到当天0点时的秒时间戳*/;
  2630. DataTimeUtil.timestampSecondsToStartOfDay = function timestampSecondsToStartOfDay(timestamp) {
  2631. var date = new Date(timestamp * 1000); // 将时间戳转换为日期对象
  2632. date.setHours(0, 0, 0, 0); // 将时、分、秒、毫秒部分设置为0
  2633. return Math.floor(date.getTime() / 1000); // 将日期转换回时间戳
  2634. }
  2635. /**获取服务器到明天0点时长 */;
  2636. DataTimeUtil.longToTomorrow = function longToTomorrow() {
  2637. // 获取当前时间
  2638. var now = this.currentDate();
  2639. // 获取明天的日期
  2640. var tomorrow = new Date(now);
  2641. tomorrow.setDate(now.getDate() + 1);
  2642. tomorrow.setHours(0, 0, 0, 0);
  2643. // 计算时间差
  2644. return tomorrow.getTime() - now.getTime();
  2645. }
  2646. /**当前服务器月份*/;
  2647. DataTimeUtil.currentMonth = function currentMonth() {
  2648. return this.currentDate().getMonth() + 1; // 月份从0开始,所以需要加1
  2649. }
  2650. /**当前服务器日期月有多少天 */;
  2651. DataTimeUtil.daysInCurrentMonth = function daysInCurrentMonth() {
  2652. var currentYear = this.currentDate().getFullYear();
  2653. var daysInCurrentMonth = new Date(currentYear, this.currentMonth(), 0).getDate();
  2654. return daysInCurrentMonth;
  2655. };
  2656. DataTimeUtil.timeMillisToDate = function timeMillisToDate(ms) {
  2657. return new Date(ms);
  2658. };
  2659. DataTimeUtil.stringToStamp = function stringToStamp(dateString) {
  2660. var timestamp = Date.parse(dateString) - new Date().getTimezoneOffset() * 60 * 1000;
  2661. return timestamp;
  2662. };
  2663. DataTimeUtil.stringToDate = function stringToDate(dateString) {
  2664. return new Date(dateString);
  2665. };
  2666. DataTimeUtil.dateToString = function dateToString(date) {
  2667. var year = date.getFullYear();
  2668. var month = date.getMonth() + 1;
  2669. var day = date.getDate();
  2670. var hours = date.getHours();
  2671. var minutes = date.getMinutes();
  2672. var seconds = date.getSeconds();
  2673. // 自定义格式化日期和时间
  2674. var formattedDateTime = year + "-" + month.toString().padStart(2, '0') + "-" + day.toString().padStart(2, '0') + " " + hours.toString().padStart(2, '0') + ":" + minutes.toString().padStart(2, '0') + ":" + seconds.toString().padStart(2, '0');
  2675. return formattedDateTime;
  2676. }
  2677. /**本周一0点的时间戳*/;
  2678. DataTimeUtil.mondayTimestamp = function mondayTimestamp() {
  2679. var currentDate = this.currentDate();
  2680. // 获取当前日期的星期几(星期天为0,星期一为1,以此类推)
  2681. var currentDayOfWeek = currentDate.getDay();
  2682. // 计算当前日期距离周一的天数差值
  2683. var daysUntilMonday = currentDayOfWeek === 0 ? 6 : currentDayOfWeek - 1;
  2684. return currentDate.getTime() - daysUntilMonday * 24 * 60 * 60 * 1000;
  2685. }
  2686. /*private _day_s = 864e5;
  2687. private _diff:number=0;
  2688. private updateServerTime(s:number):void{ this._diff = s - (new Date).getTime()}
  2689. public now():number{return this.getTime()}
  2690. public getTime():number { return (new Date).getTime() + this._diff;}
  2691. public getDayStartTime(s:number):number {return new Date(s).setHours(0, 0, 0, 0)}
  2692. public getDayEndTime(e:number):number { return new Date(e).setHours(23, 59, 59, 999)}
  2693. public getWeekEndTime (e:number):number {
  2694. var t = new Date(e).getDay();
  2695. return this.getDayEndTime(e) + (0 === t ? 0 : (7 - t) * this._day_s)
  2696. }
  2697. public getMonthEndTime(e:number):number {
  2698. var t = new Date(e);
  2699. return 11 === t.getMonth() ? t.setFullYear(t.getFullYear() + 1, 0, 0) : t.setMonth(t.getMonth() + 1, 0), t.setHours(23, 59, 59, 999)
  2700. }
  2701. public getDiffDayNum (e:number, t:number) {
  2702. var r = this.getDayStartTime(e),o = this.getDayStartTime(t);
  2703. return Math.ceil(Math.abs(r - o) / this._day_s)
  2704. }*/
  2705. /**获取时间戳*/;
  2706. DataTimeUtil.getTickCount = function getTickCount() {
  2707. if (window && window.performance) {
  2708. return window.performance.now();
  2709. }
  2710. return new Date().getTime();
  2711. }
  2712. //-----------------------------------------------------------------------------------------------------------------------------
  2713. /**
  2714. * 根据秒数格式化字符串
  2715. * @param second 秒数
  2716. * @param type 1:00:00:00 2:yyyy-mm-dd h:m:s 3:00:00(分:秒) 4:xx天前,xx小时前,xx分钟前 6:00:00(时:分)
  2717. * @return
  2718. *
  2719. */;
  2720. DataTimeUtil.getFormatBySecond = function getFormatBySecond(second, type) {
  2721. if (type === void 0) {
  2722. type = 1;
  2723. }
  2724. var str = "";
  2725. switch (type) {
  2726. case 1:
  2727. str = this.getFormatBySecond1(second);
  2728. break;
  2729. case 2:
  2730. str = this.getFormatBySecond2(second);
  2731. break;
  2732. case 3:
  2733. str = this.getFormatBySecond3(second);
  2734. break;
  2735. case 4:
  2736. str = this.getFormatBySecond4(second);
  2737. break;
  2738. case 5:
  2739. str = this.getFormatBySecond5(second);
  2740. break;
  2741. case 6:
  2742. str = this.getFormatBySecond6(second);
  2743. break;
  2744. }
  2745. return str;
  2746. }
  2747. //1: 00:00:00
  2748. ;
  2749. DataTimeUtil.getFormatBySecond1 = function getFormatBySecond1(t) {
  2750. if (t === void 0) {
  2751. t = 0;
  2752. }
  2753. var hourst = Math.floor(t / 3600);
  2754. var hours;
  2755. if (hourst == 0) {
  2756. hours = "00";
  2757. } else {
  2758. if (hourst < 10) hours = "0" + hourst;else hours = "" + hourst;
  2759. }
  2760. var minst = Math.floor((t - hourst * 3600) / 60);
  2761. var secondt = Math.floor((t - hourst * 3600) % 60);
  2762. var mins;
  2763. var sens;
  2764. if (minst == 0) {
  2765. mins = "00";
  2766. } else if (minst < 10) {
  2767. mins = "0" + minst;
  2768. } else {
  2769. mins = "" + minst;
  2770. }
  2771. if (secondt == 0) {
  2772. sens = "00";
  2773. } else if (secondt < 10) {
  2774. sens = "0" + secondt;
  2775. } else {
  2776. sens = "" + secondt;
  2777. }
  2778. return hours + ":" + mins + ":" + sens;
  2779. }
  2780. //3:00:00(分:秒)
  2781. ;
  2782. DataTimeUtil.getFormatBySecond3 = function getFormatBySecond3(t) {
  2783. if (t === void 0) {
  2784. t = 0;
  2785. }
  2786. var hourst = Math.floor(t / 3600);
  2787. var minst = Math.floor((t - hourst * 3600) / 60);
  2788. var secondt = Math.floor((t - hourst * 3600) % 60);
  2789. var mins;
  2790. var sens;
  2791. if (minst == 0) {
  2792. mins = "00";
  2793. } else if (minst < 10) {
  2794. mins = "0" + minst;
  2795. } else {
  2796. mins = "" + minst;
  2797. }
  2798. if (secondt == 0) {
  2799. sens = "00";
  2800. } else if (secondt < 10) {
  2801. sens = "0" + secondt;
  2802. } else {
  2803. sens = "" + secondt;
  2804. }
  2805. return mins + ":" + sens;
  2806. }
  2807. //2:yyyy-mm-dd h:m:s
  2808. ;
  2809. DataTimeUtil.getFormatBySecond2 = function getFormatBySecond2(time) {
  2810. var date = new Date(time * 1000);
  2811. var year = date.getFullYear();
  2812. var month = date.getMonth() + 1; //返回的月份从0-11;
  2813. var day = date.getDate();
  2814. var hours = date.getHours();
  2815. var minute = date.getMinutes();
  2816. var second = date.getSeconds();
  2817. return year + "-" + month + "-" + day + " " + hours + ":" + minute + ":" + second;
  2818. }
  2819. //4:xx天前,xx小时前,xx分钟前
  2820. ;
  2821. DataTimeUtil.getFormatBySecond4 = function getFormatBySecond4(time) {
  2822. var t = Math.floor(time / 3600);
  2823. if (t > 0) {
  2824. if (t > 24) {
  2825. return Math.floor(t / 24) + "天前";
  2826. } else {
  2827. return t + "小时前";
  2828. }
  2829. } else {
  2830. return Math.floor(time / 60) + "分钟前";
  2831. }
  2832. };
  2833. DataTimeUtil.getFormatBySecond5 = function getFormatBySecond5(time) {
  2834. //每个时间单位所对应的秒数
  2835. var oneDay = 3600 * 24;
  2836. var oneHourst = 3600;
  2837. var oneMinst = 60;
  2838. var days = Math.floor(time / oneDay);
  2839. var hourst = Math.floor(time % oneDay / oneHourst);
  2840. var minst = Math.floor((time - hourst * oneHourst) / oneMinst); //Math.floor(time % oneDay % oneHourst / oneMinst);
  2841. var secondt = Math.floor((time - hourst * oneHourst) % oneMinst); //time;
  2842. var dayss = "";
  2843. var hourss = "";
  2844. var minss = "";
  2845. var secss = "";
  2846. if (time > 0) {
  2847. //天
  2848. if (days == 0) {
  2849. dayss = "";
  2850. //小时
  2851. if (hourst == 0) {
  2852. hourss = "";
  2853. //分
  2854. if (minst == 0) {
  2855. minss = "";
  2856. if (secondt == 0) {
  2857. secss = "";
  2858. } else if (secondt < 10) {
  2859. secss = "0" + secondt + "秒";
  2860. } else {
  2861. secss = "" + secondt + "秒";
  2862. }
  2863. return secss;
  2864. } else {
  2865. minss = "" + minst + "分";
  2866. if (secondt == 0) {
  2867. secss = "";
  2868. } else if (secondt < 10) {
  2869. secss = "0" + secondt + "秒";
  2870. } else {
  2871. secss = "" + secondt + "秒";
  2872. }
  2873. }
  2874. return minss + secss;
  2875. } else {
  2876. hourss = hourst + "小时";
  2877. if (minst == 0) {
  2878. minss = "";
  2879. if (secondt == 0) {
  2880. secss = "";
  2881. } else if (secondt < 10) {
  2882. secss = "0" + secondt + "秒";
  2883. } else {
  2884. secss = "" + secondt + "秒";
  2885. }
  2886. return secss;
  2887. } else if (minst < 10) {
  2888. minss = "0" + minst + "分";
  2889. } else {
  2890. minss = "" + minst + "分";
  2891. }
  2892. return hourss + minss;
  2893. }
  2894. } else {
  2895. dayss = days + "天";
  2896. if (hourst == 0) {
  2897. hourss = "";
  2898. } else {
  2899. if (hourst < 10) hourss = "0" + hourst + "小时";else hourss = "" + hourst + "小时";
  2900. }
  2901. return dayss + hourss;
  2902. }
  2903. }
  2904. return "";
  2905. }
  2906. //6:00:00(时:分)
  2907. ;
  2908. DataTimeUtil.getFormatBySecond6 = function getFormatBySecond6(t) {
  2909. if (t === void 0) {
  2910. t = 0;
  2911. }
  2912. var hourst = Math.floor(t / 3600);
  2913. var minst = Math.floor((t - hourst * 3600) / 60);
  2914. var houers;
  2915. var mins;
  2916. if (hourst == 0) {
  2917. houers = "00";
  2918. } else if (hourst < 10) {
  2919. houers = "0" + hourst;
  2920. } else {
  2921. houers = "" + hourst;
  2922. }
  2923. if (minst == 0) {
  2924. mins = "00";
  2925. } else if (minst < 10) {
  2926. mins = "0" + minst;
  2927. } else {
  2928. mins = "" + minst;
  2929. }
  2930. return houers + ":" + mins;
  2931. }
  2932. /**
  2933. * 获取当前是周几
  2934. * ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
  2935. */;
  2936. DataTimeUtil.getDay = function getDay(timestamp) {
  2937. var date = new Date(timestamp);
  2938. return date.getDay();
  2939. }
  2940. /**
  2941. * 判定两个时间是否是同一天
  2942. */;
  2943. DataTimeUtil.isSameDate = function isSameDate(timestamp1, timestamp2) {
  2944. var date1 = new Date(timestamp1);
  2945. var date2 = new Date(timestamp2);
  2946. return date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate();
  2947. }
  2948. /**
  2949. * 日期格式化
  2950. */;
  2951. DataTimeUtil.format = function format(d, fmt) {
  2952. if (fmt === void 0) {
  2953. fmt = "yyyy-MM-dd hh:mm:ss";
  2954. }
  2955. var o = {
  2956. "M+": d.getMonth() + 1,
  2957. //month
  2958. "d+": d.getDate(),
  2959. //day
  2960. "h+": d.getHours(),
  2961. //hour
  2962. "m+": d.getMinutes(),
  2963. //minute
  2964. "s+": d.getSeconds(),
  2965. //second
  2966. "q+": Math.floor((d.getMonth() + 3) / 3),
  2967. //quarter
  2968. "S": d.getMilliseconds() //millisecond
  2969. };
  2970. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
  2971. for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
  2972. return fmt;
  2973. }
  2974. /**
  2975. * 计算两个时间(秒)相差天数(不满一天算0天)
  2976. */;
  2977. DataTimeUtil.getDayCountSeconds = function getDayCountSeconds(timestamp1, timestamp2) {
  2978. var d_value = Math.abs(timestamp2 - timestamp1);
  2979. return Math.floor(d_value / (24 * 60 * 60));
  2980. }
  2981. /**
  2982. * 计算两个时间相差天数
  2983. */;
  2984. DataTimeUtil.dateDifference = function dateDifference(timestamp1, timestamp2) {
  2985. var d_value = Math.abs(timestamp2 - timestamp1);
  2986. return Math.ceil(d_value / (24 * 60 * 60 * 1000));
  2987. };
  2988. return DataTimeUtil;
  2989. }());
  2990. /**时间偏移*/
  2991. DataTimeUtil.offset = 0;
  2992. cclegacy._RF.pop();
  2993. }
  2994. };
  2995. });
  2996. System.register("chunks:///_virtual/Delay.ts", ['cc'], function (exports) {
  2997. var cclegacy;
  2998. return {
  2999. setters: [function (module) {
  3000. cclegacy = module.cclegacy;
  3001. }],
  3002. execute: function () {
  3003. exports('default', get_new_delay);
  3004. cclegacy._RF.push({}, "8e7b9WCurJPu4fjNX9PZbRY", "Delay", undefined);
  3005. var Delay = /*#__PURE__*/function () {
  3006. function Delay() {
  3007. this.delays = [];
  3008. this.paused = false;
  3009. }
  3010. var _proto = Delay.prototype;
  3011. // 创建一个新的延迟
  3012. _proto.start = function start(seconds) {
  3013. var _this = this;
  3014. var duration = seconds;
  3015. return new Promise(function (resolve) {
  3016. _this.delays.push({
  3017. duration: duration,
  3018. elapsed: 0,
  3019. resolve: resolve
  3020. });
  3021. });
  3022. };
  3023. _proto.pause = function pause() {
  3024. this.paused = true;
  3025. };
  3026. _proto.resume = function resume() {
  3027. this.paused = false;
  3028. }
  3029. //更新所有延迟的状态,传入更新时间间隔(秒)
  3030. ;
  3031. _proto.update = function update(deltaTime) {
  3032. if (this.paused) return;
  3033. for (var i = this.delays.length - 1; i >= 0; i--) {
  3034. var delay = this.delays[i];
  3035. delay.elapsed += deltaTime; // 累加已过时间
  3036. if (delay.elapsed >= delay.duration) {
  3037. if (delay.resolve) {
  3038. delay.resolve(); // 解析 Promise
  3039. delay.resolve = null; // 清空引用
  3040. }
  3041. this.delays.splice(i, 1); // 从数组中移除已完成的延迟对象
  3042. }
  3043. }
  3044. }
  3045. //取消所有延迟
  3046. ;
  3047. _proto.cancelAll = function cancelAll() {
  3048. this.delays.forEach(function (delay) {
  3049. delay.resolve = null;
  3050. });
  3051. this.delays = []; //清空所有延迟
  3052. }
  3053. //检查是否有活动的延迟
  3054. ;
  3055. _proto.isActive = function isActive() {
  3056. return this.delays.length > 0;
  3057. };
  3058. return Delay;
  3059. }();
  3060. function get_new_delay() {
  3061. return new Delay();
  3062. }
  3063. cclegacy._RF.pop();
  3064. }
  3065. };
  3066. });
  3067. System.register("chunks:///_virtual/DirectorUtil.ts", ['cc'], function (exports) {
  3068. var cclegacy, director, AnimationManager, sp, TweenSystem, PhysicsSystem2D, PhysicsSystem, Animation;
  3069. return {
  3070. setters: [function (module) {
  3071. cclegacy = module.cclegacy;
  3072. director = module.director;
  3073. AnimationManager = module.AnimationManager;
  3074. sp = module.sp;
  3075. TweenSystem = module.TweenSystem;
  3076. PhysicsSystem2D = module.PhysicsSystem2D;
  3077. PhysicsSystem = module.PhysicsSystem;
  3078. Animation = module.Animation;
  3079. }],
  3080. execute: function () {
  3081. cclegacy._RF.push({}, "0dd04xSWM1G07cwb9c87Tja", "DirectorUtil", undefined);
  3082. var DirectorUtil = exports('default', /*#__PURE__*/function () {
  3083. function DirectorUtil() {}
  3084. /**暂停游戏 */
  3085. DirectorUtil.pause = function pause(config_) {
  3086. var _this = this;
  3087. if (this.pause_data.state_b) return;
  3088. // 暂停定时器
  3089. this.pause_data.scheduler_as = director.getScheduler().pauseAllTargets();
  3090. // 暂停当前动画
  3091. {
  3092. var _this$pause_data$anim;
  3093. var anim_system = director.getSystem(AnimationManager.ID);
  3094. (_this$pause_data$anim = this.pause_data.anim_as).splice.apply(_this$pause_data$anim, [0, this.pause_data.anim_as.length].concat(anim_system["_anims"].array));
  3095. this.pause_data.anim_as.forEach(function (v1) {
  3096. v1.pause();
  3097. });
  3098. }
  3099. // 暂停spine动画
  3100. {
  3101. this.pause_data.spine_as = director.getScene().getComponentsInChildren(sp.Skeleton);
  3102. this.pause_data.spine_as.forEach(function (v1) {
  3103. v1.timeScale = 0;
  3104. });
  3105. }
  3106. // 暂停龙骨动画
  3107. // {
  3108. //this.pause_data.dragon_bones_as = director.getScene().getComponentsInChildren(dragonBones.ArmatureDisplay);
  3109. //this.pause_data.dragon_bones_as.forEach(v1 => {v1.timeScale = 0;});
  3110. //}
  3111. // 暂停当前缓动
  3112. this.pause_data.tween_target_as = TweenSystem.instance.ActionManager.pauseAllRunningActions();
  3113. // 暂停物理系统
  3114. {
  3115. if (PhysicsSystem2D && PhysicsSystem2D.instance.enable) {
  3116. this.pause_data.physics_2d_b = PhysicsSystem2D.instance.enable;
  3117. PhysicsSystem2D.instance.enable = false;
  3118. }
  3119. if (PhysicsSystem && PhysicsSystem.instance.enable) {
  3120. this.pause_data.physics_3d_b = PhysicsSystem.instance.enable;
  3121. PhysicsSystem.instance.enable = false;
  3122. }
  3123. }
  3124. // 恢复排除节点
  3125. if (config_) {
  3126. var _config_$recu_exclude;
  3127. var exclude_as = [];
  3128. exclude_as.push.apply(exclude_as, config_.exclude_as);
  3129. (_config_$recu_exclude = config_.recu_exclude_as) == null || _config_$recu_exclude.forEach(function (v1) {
  3130. exclude_as.push.apply(exclude_as, _this.recu_node_list(v1));
  3131. });
  3132. exclude_as.forEach(function (v1) {
  3133. _this.resume_node(v1);
  3134. });
  3135. }
  3136. this.pause_data.state_b = true;
  3137. };
  3138. DirectorUtil.recu_node_list = function recu_node_list(node_, result_as) {
  3139. var _this2 = this;
  3140. if (result_as === void 0) {
  3141. result_as = [];
  3142. }
  3143. if (!node_) {
  3144. return result_as;
  3145. }
  3146. result_as.push(node_);
  3147. node_.children.forEach(function (v1) {
  3148. result_as.push(v1);
  3149. _this2.recu_node_list(v1);
  3150. });
  3151. return result_as;
  3152. }
  3153. /**恢复游戏 */;
  3154. DirectorUtil.resume = function resume() {
  3155. // 恢复定时器
  3156. director.getScheduler().resumeTargets(this.pause_data.scheduler_as);
  3157. // 恢复动画
  3158. this.pause_data.anim_as.forEach(function (v1) {
  3159. if (v1.isPlaying && v1.isPaused) {
  3160. v1.play();
  3161. }
  3162. });
  3163. // 恢复龙骨动画
  3164. //this.pause_data.dragon_bones_as.forEach(v1 => {
  3165. //v1.timeScale = 1;
  3166. //});
  3167. this.pause_data.spine_as.forEach(function (v1) {
  3168. v1.timeScale = 1;
  3169. });
  3170. // 恢复缓动
  3171. TweenSystem.instance.ActionManager.resumeTargets(this.pause_data.tween_target_as);
  3172. // 恢复物理系统
  3173. {
  3174. if (this.pause_data.physics_2d_b) {
  3175. PhysicsSystem2D.instance.enable = this.pause_data.physics_2d_b;
  3176. }
  3177. if (this.pause_data.physics_3d_b) {
  3178. PhysicsSystem.instance.enable = this.pause_data.physics_3d_b;
  3179. }
  3180. }
  3181. this.pause_data.state_b = false;
  3182. }
  3183. /**暂停节点
  3184. * -物理系统需手动启用/禁用
  3185. */;
  3186. DirectorUtil.pause_node = function pause_node(args1_) {
  3187. var node_as;
  3188. if (Array.isArray(args1_)) {
  3189. node_as = args1_;
  3190. } else {
  3191. node_as = [args1_];
  3192. }
  3193. node_as.forEach(function (v1) {
  3194. var _v1$getComponent;
  3195. // 暂停定时器
  3196. director.getScheduler().pauseTarget(v1);
  3197. // 暂停动画
  3198. (_v1$getComponent = v1.getComponent(Animation)) == null || _v1$getComponent.pause();
  3199. //暂停spine动画
  3200. if (v1.getComponent(sp.Skeleton)) {
  3201. v1.getComponent(sp.Skeleton).timeScale = 0;
  3202. }
  3203. // 暂停龙骨
  3204. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  3205. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 0;
  3206. //}
  3207. // 暂停缓动
  3208. TweenSystem.instance.ActionManager.pauseTarget(v1);
  3209. });
  3210. }
  3211. /**恢复节点 */;
  3212. DirectorUtil.resume_node = function resume_node(args1_) {
  3213. var node_as;
  3214. if (Array.isArray(args1_)) {
  3215. node_as = args1_;
  3216. } else {
  3217. node_as = [args1_];
  3218. }
  3219. node_as.forEach(function (v1) {
  3220. var _v1$getComponent2;
  3221. // 恢复定时器
  3222. director.getScheduler().resumeTarget(v1);
  3223. // 恢复动画
  3224. (_v1$getComponent2 = v1.getComponent(Animation)) == null || _v1$getComponent2.resume();
  3225. //恢复spine动画
  3226. if (v1.getComponent(sp.Skeleton)) {
  3227. v1.getComponent(sp.Skeleton).timeScale = 1;
  3228. }
  3229. //恢复龙骨
  3230. //if (v1.getComponent(dragonBones.ArmatureDisplay)) {
  3231. //v1.getComponent(dragonBones.ArmatureDisplay).timeScale = 1;
  3232. //}
  3233. // 恢复缓动
  3234. TweenSystem.instance.ActionManager.resumeTarget(v1);
  3235. });
  3236. }
  3237. //
  3238. ;
  3239. return DirectorUtil;
  3240. }());
  3241. //没有用到龙骨 dragon_bones_as:dragonBones.ArmatureDisplay[]
  3242. DirectorUtil.pause_data = {
  3243. /**暂停状态 */
  3244. state_b: false,
  3245. /**2d物理系统状态 */
  3246. physics_2d_b: false,
  3247. /**3d物理系统状态 */
  3248. physics_3d_b: false,
  3249. /**定时器对象列表 */
  3250. scheduler_as: [],
  3251. /**动画列表 */
  3252. anim_as: [],
  3253. /**缓动对象列表 */
  3254. tween_target_as: [],
  3255. /**龙骨组件列表 */
  3256. //dragon_bones_as:[],
  3257. spine_as: []
  3258. };
  3259. cclegacy._RF.pop();
  3260. }
  3261. };
  3262. });
  3263. System.register("chunks:///_virtual/FMS.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  3264. var _createClass, cclegacy;
  3265. return {
  3266. setters: [function (module) {
  3267. _createClass = module.createClass;
  3268. }, function (module) {
  3269. cclegacy = module.cclegacy;
  3270. }],
  3271. execute: function () {
  3272. exports({
  3273. FMSRegister: FMSRegister,
  3274. default: get_new_fms
  3275. });
  3276. cclegacy._RF.push({}, "bbc25Bst09Pm7REKGq+Wn2J", "FMS", undefined);
  3277. /**注册一个继承IFMS的状态类型 */
  3278. function FMSRegister(name) {
  3279. return function (target) {
  3280. var instance = new target();
  3281. instance.type = name;
  3282. FMS.IFMS.set(name, instance);
  3283. };
  3284. }
  3285. /**状态接口*/
  3286. /**全局状态机,游戏流程 (私有有行为机更灵活)*/
  3287. var FMS = /*#__PURE__*/function () {
  3288. function FMS() {
  3289. this._current = void 0;
  3290. }
  3291. var _proto = FMS.prototype;
  3292. /**初始1个状态*/
  3293. _proto.Init = function Init(type) {
  3294. this.Change(type);
  3295. }
  3296. /**切换状态*/;
  3297. _proto.Change = function Change(type) {
  3298. if (this._current) this._current.onExit();
  3299. this._current = FMS.IFMS.get(type);
  3300. if (this._current) this._current.onEntry();
  3301. };
  3302. _createClass(FMS, [{
  3303. key: "Current",
  3304. get: /**当前状态*/
  3305. function get() {
  3306. return this._current;
  3307. }
  3308. }, {
  3309. key: "CurrentTaype",
  3310. get: function get() {
  3311. return this._current ? null : this._current.type;
  3312. }
  3313. }]);
  3314. return FMS;
  3315. }();
  3316. /**例子:
  3317. @FMSRegister("Init")
  3318. export class FMSInit implements IFMS{
  3319. type: string;
  3320. onExit: () => void;
  3321. onEntry():void{
  3322. console.log(this.type,"---------------------");
  3323. }
  3324. }
  3325. */
  3326. FMS.IFMS = new Map();
  3327. function get_new_fms() {
  3328. return new FMS();
  3329. }
  3330. cclegacy._RF.pop();
  3331. }
  3332. };
  3333. });
  3334. System.register("chunks:///_virtual/Game.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './Delay.ts', './FMS.ts', './TimeJobCenter.ts', './Random.ts', './PrefabPool.ts', './DirectorUtil.ts'], function (exports) {
  3335. var _inheritsLoose, _createClass, cclegacy, Component, get_new_delay, get_new_fms, get_new_job, get_new_random, get_new_prefab_pool, DirectorUtil;
  3336. return {
  3337. setters: [function (module) {
  3338. _inheritsLoose = module.inheritsLoose;
  3339. _createClass = module.createClass;
  3340. }, function (module) {
  3341. cclegacy = module.cclegacy;
  3342. Component = module.Component;
  3343. }, function (module) {
  3344. get_new_delay = module.default;
  3345. }, function (module) {
  3346. get_new_fms = module.default;
  3347. }, function (module) {
  3348. get_new_job = module.default;
  3349. }, function (module) {
  3350. get_new_random = module.default;
  3351. }, function (module) {
  3352. get_new_prefab_pool = module.default;
  3353. }, function (module) {
  3354. DirectorUtil = module.default;
  3355. }],
  3356. execute: function () {
  3357. cclegacy._RF.push({}, "c8af7nfrdRHqaACOmm328nQ", "Game", undefined);
  3358. /**
  3359. * 游戏模块
  3360. *
  3361. const { ccclass, property } = _decorator;
  3362. @ccclass('GameStar')
  3363. export class GameStar extends Game<GameStar> {
  3364. public cc:number=99;
  3365. public tcc():void{
  3366. console.log("goaodfjadsofjosadjfo"+this.cc);
  3367. }
  3368. onLoad(): void {
  3369. super.onLoad();
  3370. }
  3371. update(deltaTime: number) {
  3372. super.update(deltaTime);
  3373. }
  3374. async start() {
  3375. console.log("111111111111111111111111111")
  3376. await this.delay.start(3);
  3377. console.log("3333333333333333333333333")
  3378. GameStar.getInst().tcc();
  3379. }
  3380. }
  3381. */
  3382. var Game = exports('Game', /*#__PURE__*/function (_Component) {
  3383. _inheritsLoose(Game, _Component);
  3384. function Game() {
  3385. var _this;
  3386. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  3387. args[_key] = arguments[_key];
  3388. }
  3389. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  3390. /**游戏流程状态*/
  3391. _this.FMS = get_new_fms();
  3392. /**时间任务管理 暂停后不运行*/
  3393. _this.job = get_new_job();
  3394. /**延时管理*/
  3395. _this.delay = get_new_delay();
  3396. /**可设置种子的随机数*/
  3397. _this.ranodm = get_new_random(new Date().getTime());
  3398. /**预制体对象池*/
  3399. _this.prefabPool = get_new_prefab_pool();
  3400. _this._paused = false;
  3401. return _this;
  3402. }
  3403. Game.getInst = function getInst() {
  3404. var _class = this;
  3405. return _class.instance;
  3406. };
  3407. var _proto = Game.prototype;
  3408. _proto.onLoad = function onLoad() {
  3409. Game.instance = this;
  3410. };
  3411. //
  3412. _proto.pause = function pause() {
  3413. this._paused = true;
  3414. DirectorUtil.pause();
  3415. }
  3416. //
  3417. ;
  3418. _proto.resume = function resume() {
  3419. this._paused = false;
  3420. DirectorUtil.resume();
  3421. };
  3422. _proto.update = function update(deltaTime) {
  3423. this.delay.update(deltaTime);
  3424. if (this._paused) return;
  3425. this.job.Run(deltaTime);
  3426. };
  3427. _createClass(Game, [{
  3428. key: "is_paused",
  3429. get: function get() {
  3430. return this._paused;
  3431. }
  3432. }]);
  3433. return Game;
  3434. }(Component));
  3435. Game.instance = void 0;
  3436. cclegacy._RF.pop();
  3437. }
  3438. };
  3439. });
  3440. System.register("chunks:///_virtual/GameData.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ch.ts', './PeriodData.ts'], function (exports) {
  3441. var _createClass, _asyncToGenerator, _regeneratorRuntime, cclegacy, ch, PeriodData, PeriodDataUpdate;
  3442. return {
  3443. setters: [function (module) {
  3444. _createClass = module.createClass;
  3445. _asyncToGenerator = module.asyncToGenerator;
  3446. _regeneratorRuntime = module.regeneratorRuntime;
  3447. }, function (module) {
  3448. cclegacy = module.cclegacy;
  3449. }, function (module) {
  3450. ch = module.ch;
  3451. }, function (module) {
  3452. PeriodData = module.default;
  3453. PeriodDataUpdate = module.PeriodDataUpdate;
  3454. }],
  3455. execute: function () {
  3456. cclegacy._RF.push({}, "c88bd5RDxxIJ7YUSwv6V1cm", "GameData", undefined);
  3457. /**游戏数据
  3458. * 有额外自定义数据可以继承此类
  3459. */
  3460. var GameData = exports('default', /*#__PURE__*/function () {
  3461. function GameData(gid, uid, name, limt, day_limt, week_limt, month_limt) {
  3462. this._key = void 0;
  3463. this._uid = void 0;
  3464. this._gid = void 0;
  3465. this._save_time = void 0;
  3466. this._ver = void 0;
  3467. this._data = void 0;
  3468. this._day_data = void 0;
  3469. this._week_data = void 0;
  3470. this._month_data = void 0;
  3471. //
  3472. this._dirty = false;
  3473. this._key = name;
  3474. this._gid = gid;
  3475. this._uid = uid;
  3476. this._data = new PeriodData(PeriodDataUpdate.none, limt);
  3477. this._day_data = new PeriodData(PeriodDataUpdate.day, day_limt);
  3478. this._week_data = new PeriodData(PeriodDataUpdate.week, week_limt);
  3479. this._month_data = new PeriodData(PeriodDataUpdate.month, month_limt);
  3480. }
  3481. //
  3482. var _proto = GameData.prototype;
  3483. _proto.checkNewDay = function checkNewDay() {
  3484. var _this$_day_data, _this$_week_data, _this$_month_data;
  3485. var now = ch.date.now();
  3486. (_this$_day_data = this._day_data) == null || _this$_day_data.check(now);
  3487. (_this$_week_data = this._week_data) == null || _this$_week_data.check(now);
  3488. (_this$_month_data = this._month_data) == null || _this$_month_data.check(now);
  3489. }
  3490. //
  3491. ;
  3492. _proto.compareVersion = function compareVersion(version1, version2) {
  3493. // 移除前面的 'v' 字符
  3494. var v1 = version1.replace(/^V/, '');
  3495. var v2 = version2.replace(/^V/, '');
  3496. // 分割版本号
  3497. var parts1 = v1.split('.').map(Number); // 将版本号分割并转为数字
  3498. var parts2 = v2.split('.').map(Number);
  3499. // 比较每一部分
  3500. for (var i = 0; i < Math.max(parts1.length, parts2.length); i++) {
  3501. var num1 = parts1[i] || 0; // 如果没有该部分,默认为 0
  3502. var num2 = parts2[i] || 0;
  3503. if (num1 < num2) {
  3504. return -1; // version1 < version2
  3505. }
  3506. if (num1 > num2) {
  3507. return 1; // version1 > version2
  3508. }
  3509. }
  3510. return 0; // 两个版本号相等
  3511. }
  3512. //
  3513. ;
  3514. _proto.loadGameDataWithRetry = /*#__PURE__*/
  3515. function () {
  3516. var _loadGameDataWithRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(maxRetries, delayMs) {
  3517. var attempt, _data;
  3518. return _regeneratorRuntime().wrap(function _callee$(_context) {
  3519. while (1) switch (_context.prev = _context.next) {
  3520. case 0:
  3521. if (maxRetries === void 0) {
  3522. maxRetries = 3;
  3523. }
  3524. if (delayMs === void 0) {
  3525. delayMs = 1000;
  3526. }
  3527. attempt = 0;
  3528. case 3:
  3529. if (!(attempt < maxRetries)) {
  3530. _context.next = 16;
  3531. break;
  3532. }
  3533. _context.next = 6;
  3534. return this.load_data();
  3535. case 6:
  3536. _data = _context.sent;
  3537. if (!(_data != null)) {
  3538. _context.next = 11;
  3539. break;
  3540. }
  3541. return _context.abrupt("return", _data != null ? _data : null);
  3542. case 11:
  3543. attempt++;
  3544. _context.next = 14;
  3545. return new Promise(function (resolve) {
  3546. return setTimeout(resolve, delayMs);
  3547. });
  3548. case 14:
  3549. _context.next = 3;
  3550. break;
  3551. case 16:
  3552. return _context.abrupt("return", null);
  3553. case 17:
  3554. case "end":
  3555. return _context.stop();
  3556. }
  3557. }, _callee, this);
  3558. }));
  3559. function loadGameDataWithRetry(_x, _x2) {
  3560. return _loadGameDataWithRetry.apply(this, arguments);
  3561. }
  3562. return loadGameDataWithRetry;
  3563. }() //
  3564. ;
  3565. _proto.saveGameDataWithRetry = /*#__PURE__*/
  3566. function () {
  3567. var _saveGameDataWithRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(save_data, maxRetries, delayMs) {
  3568. var attempt, ret;
  3569. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  3570. while (1) switch (_context2.prev = _context2.next) {
  3571. case 0:
  3572. if (maxRetries === void 0) {
  3573. maxRetries = 3;
  3574. }
  3575. if (delayMs === void 0) {
  3576. delayMs = 1000;
  3577. }
  3578. attempt = 0;
  3579. case 3:
  3580. if (!(attempt < maxRetries)) {
  3581. _context2.next = 16;
  3582. break;
  3583. }
  3584. _context2.next = 6;
  3585. return this.save_data(save_data);
  3586. case 6:
  3587. ret = _context2.sent;
  3588. if (!ret) {
  3589. _context2.next = 11;
  3590. break;
  3591. }
  3592. return _context2.abrupt("return", true);
  3593. case 11:
  3594. attempt++;
  3595. _context2.next = 14;
  3596. return new Promise(function (resolve) {
  3597. return setTimeout(resolve, delayMs);
  3598. });
  3599. case 14:
  3600. _context2.next = 3;
  3601. break;
  3602. case 16:
  3603. return _context2.abrupt("return", false);
  3604. case 17:
  3605. case "end":
  3606. return _context2.stop();
  3607. }
  3608. }, _callee2, this);
  3609. }));
  3610. function saveGameDataWithRetry(_x3, _x4, _x5) {
  3611. return _saveGameDataWithRetry.apply(this, arguments);
  3612. }
  3613. return saveGameDataWithRetry;
  3614. }() /**加载数据*/;
  3615. _proto.load = /*#__PURE__*/
  3616. function () {
  3617. var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(ver) {
  3618. var load_data, remote_data;
  3619. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  3620. while (1) switch (_context3.prev = _context3.next) {
  3621. case 0:
  3622. this.on_load(0);
  3623. load_data = ch.storage.getObject(this._key, this._gid);
  3624. if (load_data) {
  3625. if (ch.sdk.get_inited() && load_data.uid != this._uid) load_data = null;
  3626. }
  3627. //
  3628. if (load_data) {
  3629. _context3.next = 8;
  3630. break;
  3631. }
  3632. _context3.next = 6;
  3633. return this.loadGameDataWithRetry();
  3634. case 6:
  3635. remote_data = _context3.sent;
  3636. load_data = remote_data;
  3637. case 8:
  3638. // } else if (remote_data && this.on_check(load_data, remote_data)) {
  3639. // load_data = remote_data;
  3640. // }
  3641. //
  3642. if (!load_data) {
  3643. this.on_init();
  3644. console.log("无数据所以初始化");
  3645. } else {
  3646. this.unserialize(load_data);
  3647. console.log("有数据初始化");
  3648. }
  3649. this.checkVer(ver);
  3650. this.checkNewDay();
  3651. this.on_load(1);
  3652. case 12:
  3653. case "end":
  3654. return _context3.stop();
  3655. }
  3656. }, _callee3, this);
  3657. }));
  3658. function load(_x6) {
  3659. return _load.apply(this, arguments);
  3660. }
  3661. return load;
  3662. }() /**远程调用保存,如果不是强制远程保存,必并先设置脏数据*/;
  3663. _proto.save = /*#__PURE__*/
  3664. function () {
  3665. var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(force) {
  3666. var ret;
  3667. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  3668. while (1) switch (_context4.prev = _context4.next) {
  3669. case 0:
  3670. if (force === void 0) {
  3671. force = false;
  3672. }
  3673. this.on_save(0);
  3674. if (!force) {
  3675. _context4.next = 6;
  3676. break;
  3677. }
  3678. this.setDirty();
  3679. _context4.next = 9;
  3680. break;
  3681. case 6:
  3682. if (this._dirty) {
  3683. _context4.next = 9;
  3684. break;
  3685. }
  3686. this.on_save(1);
  3687. return _context4.abrupt("return", false);
  3688. case 9:
  3689. _context4.next = 11;
  3690. return this.saveGameDataWithRetry(this.serialize());
  3691. case 11:
  3692. ret = _context4.sent;
  3693. this.on_save(1);
  3694. if (ret) this._dirty = false;
  3695. return _context4.abrupt("return", ret);
  3696. case 15:
  3697. case "end":
  3698. return _context4.stop();
  3699. }
  3700. }, _callee4, this);
  3701. }));
  3702. function save(_x7) {
  3703. return _save.apply(this, arguments);
  3704. }
  3705. return save;
  3706. }() /**设置脏数据后保存到本地*/;
  3707. _proto.setDirty = function setDirty() {
  3708. this._dirty = true;
  3709. ch.storage.set(this._key, this.serialize(), this._gid);
  3710. };
  3711. _proto.checkVer = function checkVer(new_v) {
  3712. if (!new_v) return;
  3713. if (!this._ver) {
  3714. this.on_ver(true, this._ver, new_v);
  3715. }
  3716. var k = this.compareVersion(this._ver, new_v);
  3717. this.on_ver(k < 0, this._ver, new_v);
  3718. this._ver = new_v;
  3719. }
  3720. /**
  3721. * 序列化(数据库存储)
  3722. */;
  3723. _proto.serialize = function serialize() {
  3724. var save_data = {};
  3725. if (this._data) save_data.data = this._data.serialize();
  3726. if (this._day_data) save_data.day_data = this._day_data.serialize();
  3727. if (this._week_data) save_data.week_data = this._week_data.serialize();
  3728. if (this._month_data) save_data.month_data = this._month_data.serialize();
  3729. save_data.uid = this._uid;
  3730. save_data.gid = this._gid;
  3731. this._save_time = ch.date.now();
  3732. save_data.save_time = this._save_time;
  3733. if (this._ver) save_data.ver = this._ver;
  3734. this.on_serialize(save_data);
  3735. return save_data;
  3736. }
  3737. /**
  3738. * 反序列化
  3739. */;
  3740. _proto.unserialize = function unserialize(load_data) {
  3741. var _this$_data, _this$_day_data2, _this$_week_data2, _this$_month_data2, _load_data$uid, _load_data$gid, _ref;
  3742. if (!load_data) return;
  3743. (_this$_data = this._data) == null || _this$_data.unserialize(load_data.data);
  3744. (_this$_day_data2 = this._day_data) == null || _this$_day_data2.unserialize(load_data.day_data);
  3745. (_this$_week_data2 = this._week_data) == null || _this$_week_data2.unserialize(load_data.week_data);
  3746. (_this$_month_data2 = this._month_data) == null || _this$_month_data2.unserialize(load_data.month_data);
  3747. this._uid = (_load_data$uid = load_data.uid) != null ? _load_data$uid : this._uid;
  3748. this._gid = (_load_data$gid = load_data.gid) != null ? _load_data$gid : this._gid;
  3749. this._save_time = (_ref = load_data.save_time) != null ? _ref : ch.date.now();
  3750. if (load_data.ver) this._ver = load_data.ver;
  3751. this.on_unserialize(load_data);
  3752. }
  3753. /**重写此方法初始自定义数据*/;
  3754. _proto.on_init = function on_init() {}
  3755. /**重写此方法检测是否使用远程数据*/;
  3756. _proto.on_check = function on_check(local, remote) {
  3757. return true;
  3758. }
  3759. /**重写 版本检测数据处理*/;
  3760. _proto.on_ver = function on_ver(is_new, old_v, new_v) {}
  3761. /**重写序列化加入自定义的数据*/;
  3762. _proto.on_serialize = function on_serialize(data) {}
  3763. /**重写反序列化*/;
  3764. _proto.on_unserialize = function on_unserialize(data) {}
  3765. /**保存数据(0开始 1结束)*/;
  3766. _proto.on_save = function on_save(step) {}
  3767. /**加载数据(0开始 1结束)*/;
  3768. _proto.on_load = function on_load(step) {
  3769. if (step == 0) {
  3770. console.log("开始加载数据");
  3771. } else if (step == 1) {
  3772. console.log("加载数据结束");
  3773. }
  3774. }
  3775. /**重写成其它加载方式*/;
  3776. _proto.load_data = /*#__PURE__*/
  3777. function () {
  3778. var _load_data = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  3779. var ret;
  3780. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  3781. while (1) switch (_context5.prev = _context5.next) {
  3782. case 0:
  3783. _context5.next = 2;
  3784. return ch.sdk.loadGameData(this._key);
  3785. case 2:
  3786. ret = _context5.sent;
  3787. if (!(ret.code === 0)) {
  3788. _context5.next = 7;
  3789. break;
  3790. }
  3791. return _context5.abrupt("return", ret.data);
  3792. case 7:
  3793. ch.log.warn("\u5C1D\u8BD5\u52A0\u8F7D\u6570\u636E\u5931\u8D25\uFF0C\u9519\u8BEF\u4EE3\u7801: " + ret.code + " " + ret.err);
  3794. case 8:
  3795. return _context5.abrupt("return", null);
  3796. case 9:
  3797. case "end":
  3798. return _context5.stop();
  3799. }
  3800. }, _callee5, this);
  3801. }));
  3802. function load_data() {
  3803. return _load_data.apply(this, arguments);
  3804. }
  3805. return load_data;
  3806. }() /**重写成其它保存方式*/;
  3807. _proto.save_data = /*#__PURE__*/
  3808. function () {
  3809. var _save_data2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_save_data) {
  3810. var ret;
  3811. return _regeneratorRuntime().wrap(function _callee6$(_context6) {
  3812. while (1) switch (_context6.prev = _context6.next) {
  3813. case 0:
  3814. _context6.next = 2;
  3815. return ch.sdk.saveGameData(this._key, _save_data);
  3816. case 2:
  3817. ret = _context6.sent;
  3818. if (!(ret.code == 0)) {
  3819. _context6.next = 7;
  3820. break;
  3821. }
  3822. return _context6.abrupt("return", true);
  3823. case 7:
  3824. ch.log.warn("\u5C1D\u8BD5\u4FDD\u5B58\u6570\u636E\u5931\u8D25\uFF0C\u9519\u8BEF\u4EE3\u7801: " + ret.code + " " + ret.err);
  3825. return _context6.abrupt("return", false);
  3826. case 9:
  3827. case "end":
  3828. return _context6.stop();
  3829. }
  3830. }, _callee6, this);
  3831. }));
  3832. function save_data(_x8) {
  3833. return _save_data2.apply(this, arguments);
  3834. }
  3835. return save_data;
  3836. }();
  3837. _createClass(GameData, [{
  3838. key: "data",
  3839. get: function get() {
  3840. return this._data;
  3841. }
  3842. }, {
  3843. key: "day_data",
  3844. get: function get() {
  3845. return this._day_data;
  3846. }
  3847. }, {
  3848. key: "week_data",
  3849. get: function get() {
  3850. return this._week_data;
  3851. }
  3852. }, {
  3853. key: "month_data",
  3854. get: function get() {
  3855. return this._month_data;
  3856. }
  3857. }, {
  3858. key: "uid",
  3859. get: function get() {
  3860. return this._uid;
  3861. }
  3862. }]);
  3863. return GameData;
  3864. }());
  3865. cclegacy._RF.pop();
  3866. }
  3867. };
  3868. });
  3869. System.register("chunks:///_virtual/HeadIcon.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ch.ts'], function (exports) {
  3870. var _asyncToGenerator, _regeneratorRuntime, cclegacy, ch;
  3871. return {
  3872. setters: [function (module) {
  3873. _asyncToGenerator = module.asyncToGenerator;
  3874. _regeneratorRuntime = module.regeneratorRuntime;
  3875. }, function (module) {
  3876. cclegacy = module.cclegacy;
  3877. }, function (module) {
  3878. ch = module.ch;
  3879. }],
  3880. execute: function () {
  3881. exports('default', get_new_head_icon);
  3882. cclegacy._RF.push({}, "e8ef1bG3LhBg7/PvloyUrDD", "HeadIcon", undefined);
  3883. var HeadIcon = /*#__PURE__*/function () {
  3884. function HeadIcon() {
  3885. this._map = new Map();
  3886. this._map_uid = new Map();
  3887. }
  3888. var _proto = HeadIcon.prototype;
  3889. _proto.showIcon = /*#__PURE__*/function () {
  3890. var _showIcon = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(uid, remoteUrl, sp, def) {
  3891. var spr, map, map_uid, spriteFrame;
  3892. return _regeneratorRuntime().wrap(function _callee$(_context) {
  3893. while (1) switch (_context.prev = _context.next) {
  3894. case 0:
  3895. if (sp === void 0) {
  3896. sp = null;
  3897. }
  3898. if (!(!remoteUrl || remoteUrl == "image")) {
  3899. _context.next = 4;
  3900. break;
  3901. }
  3902. if (sp) sp.spriteFrame = def;
  3903. return _context.abrupt("return");
  3904. case 4:
  3905. if (!this._map.has(uid)) {
  3906. _context.next = 10;
  3907. break;
  3908. }
  3909. spr = this._map.get(uid);
  3910. if (sp) sp.spriteFrame = spr;
  3911. return _context.abrupt("return", spr);
  3912. case 10:
  3913. map = this._map;
  3914. map_uid = this._map_uid;
  3915. if (sp && sp.isValid) map_uid.set(sp, uid);
  3916. _context.next = 15;
  3917. return ch.util.loadImage(remoteUrl);
  3918. case 15:
  3919. spriteFrame = _context.sent;
  3920. if (sp && sp.isValid) if (map_uid.get(sp) == uid) sp.spriteFrame = spriteFrame;
  3921. map.set(uid, spriteFrame);
  3922. return _context.abrupt("return", spriteFrame);
  3923. case 19:
  3924. case "end":
  3925. return _context.stop();
  3926. }
  3927. }, _callee, this);
  3928. }));
  3929. function showIcon(_x, _x2, _x3, _x4) {
  3930. return _showIcon.apply(this, arguments);
  3931. }
  3932. return showIcon;
  3933. }();
  3934. _proto.clean = function clean() {
  3935. this._map.clear();
  3936. this._map_uid.clear();
  3937. };
  3938. return HeadIcon;
  3939. }();
  3940. function get_new_head_icon() {
  3941. return new HeadIcon();
  3942. }
  3943. cclegacy._RF.pop();
  3944. }
  3945. };
  3946. });
  3947. System.register("chunks:///_virtual/Instance.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  3948. var _construct, cclegacy;
  3949. return {
  3950. setters: [function (module) {
  3951. _construct = module.construct;
  3952. }, function (module) {
  3953. cclegacy = module.cclegacy;
  3954. }],
  3955. execute: function () {
  3956. cclegacy._RF.push({}, "f298auxhOZIcJjqKwn1kGP+", "Instance", undefined);
  3957. /**单例
  3958. * 加方法型
  3959. * public static getInstance(): XXX{
  3960. return Instance.get(XXX);
  3961. }
  3962. */
  3963. var Instance = exports('default', /*#__PURE__*/function () {
  3964. function Instance() {}
  3965. Instance.get = function get(clazz) {
  3966. for (var _len = arguments.length, param = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  3967. param[_key - 1] = arguments[_key];
  3968. }
  3969. if (clazz["__Instance__"] == null) {
  3970. clazz["__Instance__"] = _construct(clazz, param);
  3971. }
  3972. return clazz["__Instance__"];
  3973. };
  3974. return Instance;
  3975. }());
  3976. var Singleton = exports('Singleton', /*#__PURE__*/function () {
  3977. /**
  3978. * 获取实例
  3979. */
  3980. Singleton.getInstance = function getInstance() {
  3981. var _class = this;
  3982. if (!_class._instance) {
  3983. _class._instantiateByGetInstance = true;
  3984. _class._instance = new _class();
  3985. _class._instantiateByGetInstance = false;
  3986. }
  3987. return _class._instance;
  3988. }
  3989. /**
  3990. * 构造函数
  3991. * @protected
  3992. */;
  3993. function Singleton() {
  3994. if (!this.constructor._instantiateByGetInstance) {
  3995. throw new Error("Singleton class can't be instantiated more than once.");
  3996. }
  3997. }
  3998. return Singleton;
  3999. }());
  4000. // 实例
  4001. Singleton._instance = void 0;
  4002. // 是否是通过getInstance实例化
  4003. Singleton._instantiateByGetInstance = false;
  4004. cclegacy._RF.pop();
  4005. }
  4006. };
  4007. });
  4008. System.register("chunks:///_virtual/Line2DMove.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  4009. var _createClass, cclegacy, Vec2;
  4010. return {
  4011. setters: [function (module) {
  4012. _createClass = module.createClass;
  4013. }, function (module) {
  4014. cclegacy = module.cclegacy;
  4015. Vec2 = module.Vec2;
  4016. }],
  4017. execute: function () {
  4018. cclegacy._RF.push({}, "24592yMfD9O6qsVldhDD3Pb", "Line2DMove", undefined);
  4019. //直线移动
  4020. var Line2DMove = exports('Line2DMove', /*#__PURE__*/function () {
  4021. /**
  4022. * @param start_x 起始点
  4023. * @param start_y
  4024. * @param end_x 终点
  4025. * @param end_y
  4026. * @param speed 速度
  4027. * @param addSpeed 加速度
  4028. * 起点终点一致时没有速度将不起作用
  4029. */
  4030. function Line2DMove(start_x, start_y, end_x, end_y, speed, addSpeed) {
  4031. this._s = void 0;
  4032. //起始点
  4033. this._e = void 0;
  4034. //终点
  4035. this._percentSpeed = void 0;
  4036. this._percentAddSpeed = void 0;
  4037. this._percent = void 0;
  4038. //进度
  4039. this._current = void 0;
  4040. this._currentDir = void 0;
  4041. /**
  4042. * 获取进度位置
  4043. * @param t 当前时间进度 0-1
  4044. * @param a 起点
  4045. * @param b 控制点
  4046. * @param c 终点
  4047. */
  4048. this._ab = new Vec2();
  4049. this._s = new Vec2(start_x, start_y);
  4050. this._e = new Vec2(end_x, end_y);
  4051. this._current = new Vec2(start_x, start_y);
  4052. this._currentDir = new Vec2(this._e.x - this._s.x, this._e.y - this._s.y).normalize();
  4053. var dis = new Vec2(end_x, end_y).subtract2f(start_x, start_y).length();
  4054. if (dis <= 0) {
  4055. this._percent = 1;
  4056. this._percentSpeed = 0;
  4057. this._percentAddSpeed = 0;
  4058. } else {
  4059. this._percent = 0;
  4060. this._percentSpeed = speed / dis;
  4061. this._percentAddSpeed = addSpeed / dis;
  4062. }
  4063. }
  4064. var _proto = Line2DMove.prototype;
  4065. /**
  4066. * 向目标运动
  4067. * @param dt 帧时间
  4068. * @param mb 目标点,没有的话为初始定义的点
  4069. * @returns
  4070. */
  4071. _proto.MoveTo = function MoveTo(dt, mb) {
  4072. if (mb === void 0) {
  4073. mb = null;
  4074. }
  4075. if (this._percentSpeed == 0 && this._percentAddSpeed == 0) return this._current;
  4076. this._percentSpeed += this._percentAddSpeed * dt;
  4077. this._percent += this._percentSpeed * dt;
  4078. var nextpos = this.getPos(this._percent, this._s, mb == null ? this._e : mb);
  4079. this._current.x = nextpos.x;
  4080. this._current.y = nextpos.y;
  4081. return this._current;
  4082. };
  4083. _proto.getPos = function getPos(t, a, b) {
  4084. Vec2.lerp(this._ab, a, b, t);
  4085. return this._ab;
  4086. };
  4087. _createClass(Line2DMove, [{
  4088. key: "target_pos_x",
  4089. get: function get() {
  4090. return this._e.x;
  4091. }
  4092. }, {
  4093. key: "target_pos_y",
  4094. get: function get() {
  4095. return this._e.y;
  4096. }
  4097. }, {
  4098. key: "current_dir",
  4099. get: function get() {
  4100. return this._currentDir;
  4101. }
  4102. }, {
  4103. key: "isEnd",
  4104. get: function get() {
  4105. return this._percent >= 1;
  4106. }
  4107. }, {
  4108. key: "percent",
  4109. get: function get() {
  4110. return this._percent;
  4111. }
  4112. }]);
  4113. return Line2DMove;
  4114. }());
  4115. cclegacy._RF.pop();
  4116. }
  4117. };
  4118. });
  4119. System.register("chunks:///_virtual/List.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './env', './ListItem.ts'], function (exports) {
  4120. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _createClass, cclegacy, _decorator, ScrollView, Enum, Node, Prefab, CCFloat, EventHandler, CCBoolean, CCInteger, isValid, UITransform, Layout, instantiate, NodePool, Vec3, Size, Widget, tween, Component, DEV, ListItem;
  4121. return {
  4122. setters: [function (module) {
  4123. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  4124. _inheritsLoose = module.inheritsLoose;
  4125. _initializerDefineProperty = module.initializerDefineProperty;
  4126. _assertThisInitialized = module.assertThisInitialized;
  4127. _createClass = module.createClass;
  4128. }, function (module) {
  4129. cclegacy = module.cclegacy;
  4130. _decorator = module._decorator;
  4131. ScrollView = module.ScrollView;
  4132. Enum = module.Enum;
  4133. Node = module.Node;
  4134. Prefab = module.Prefab;
  4135. CCFloat = module.CCFloat;
  4136. EventHandler = module.EventHandler;
  4137. CCBoolean = module.CCBoolean;
  4138. CCInteger = module.CCInteger;
  4139. isValid = module.isValid;
  4140. UITransform = module.UITransform;
  4141. Layout = module.Layout;
  4142. instantiate = module.instantiate;
  4143. NodePool = module.NodePool;
  4144. Vec3 = module.Vec3;
  4145. Size = module.Size;
  4146. Widget = module.Widget;
  4147. tween = module.tween;
  4148. Component = module.Component;
  4149. }, function (module) {
  4150. DEV = module.DEV;
  4151. }, function (module) {
  4152. ListItem = module.default;
  4153. }],
  4154. execute: function () {
  4155. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16, _descriptor17;
  4156. cclegacy._RF.push({}, "30e50g9bStDgYX3Y3vvH6ye", "List", undefined);
  4157. /******************************************
  4158. * @author kL <klk0@qq.com>
  4159. * @date 2020/12/9
  4160. * @doc 列表组件.
  4161. * @end
  4162. ******************************************/
  4163. var ccclass = _decorator.ccclass,
  4164. property = _decorator.property,
  4165. disallowMultiple = _decorator.disallowMultiple,
  4166. menu = _decorator.menu,
  4167. executionOrder = _decorator.executionOrder,
  4168. requireComponent = _decorator.requireComponent;
  4169. var TemplateType = /*#__PURE__*/function (TemplateType) {
  4170. TemplateType[TemplateType["NODE"] = 1] = "NODE";
  4171. TemplateType[TemplateType["PREFAB"] = 2] = "PREFAB";
  4172. return TemplateType;
  4173. }(TemplateType || {});
  4174. var SlideType = /*#__PURE__*/function (SlideType) {
  4175. SlideType[SlideType["NORMAL"] = 1] = "NORMAL";
  4176. SlideType[SlideType["ADHERING"] = 2] = "ADHERING";
  4177. SlideType[SlideType["PAGE"] = 3] = "PAGE";
  4178. return SlideType;
  4179. }(SlideType || {}); //页面模式,将强制关闭滚动惯性
  4180. var SelectedType = /*#__PURE__*/function (SelectedType) {
  4181. SelectedType[SelectedType["NONE"] = 0] = "NONE";
  4182. SelectedType[SelectedType["SINGLE"] = 1] = "SINGLE";
  4183. SelectedType[SelectedType["MULT"] = 2] = "MULT";
  4184. return SelectedType;
  4185. }(SelectedType || {}); //多选
  4186. var List = exports('default', (_dec = disallowMultiple(), _dec2 = menu('List'), _dec3 = requireComponent(ScrollView), _dec4 = executionOrder(-5000), _dec5 = property({
  4187. type: Enum(TemplateType),
  4188. tooltip: DEV
  4189. }), _dec6 = property({
  4190. type: Node,
  4191. tooltip: DEV,
  4192. visible: function visible() {
  4193. return this.templateType == TemplateType.NODE;
  4194. }
  4195. }), _dec7 = property({
  4196. type: Prefab,
  4197. tooltip: DEV,
  4198. visible: function visible() {
  4199. return this.templateType == TemplateType.PREFAB;
  4200. }
  4201. }), _dec8 = property({}), _dec9 = property({
  4202. type: Enum(SlideType),
  4203. tooltip: DEV
  4204. }), _dec10 = property({
  4205. type: CCFloat,
  4206. range: [0, 1, .1],
  4207. tooltip: DEV,
  4208. slide: true,
  4209. visible: function visible() {
  4210. return this._slideMode == SlideType.PAGE;
  4211. }
  4212. }), _dec11 = property({
  4213. type: EventHandler,
  4214. tooltip: DEV,
  4215. visible: function visible() {
  4216. return this._slideMode == SlideType.PAGE;
  4217. }
  4218. }), _dec12 = property({}), _dec13 = property({
  4219. type: CCBoolean,
  4220. tooltip: DEV
  4221. }), _dec14 = property({
  4222. tooltip: DEV,
  4223. visible: function visible() {
  4224. var val = /*this.virtual &&*/this.slideMode == SlideType.NORMAL;
  4225. if (!val) this.cyclic = false;
  4226. return val;
  4227. }
  4228. }), _dec15 = property({
  4229. tooltip: DEV,
  4230. visible: function visible() {
  4231. return this.virtual;
  4232. }
  4233. }), _dec16 = property({
  4234. tooltip: DEV,
  4235. visible: function visible() {
  4236. var val = this.virtual && !this.lackCenter;
  4237. if (!val) this.lackSlide = false;
  4238. return val;
  4239. }
  4240. }), _dec17 = property({
  4241. type: CCInteger
  4242. }), _dec18 = property({
  4243. type: CCInteger,
  4244. range: [0, 6, 1],
  4245. tooltip: DEV,
  4246. slide: true
  4247. }), _dec19 = property({
  4248. type: CCInteger,
  4249. range: [0, 12, 1],
  4250. tooltip: DEV,
  4251. slide: true
  4252. }), _dec20 = property({
  4253. type: EventHandler,
  4254. tooltip: DEV
  4255. }), _dec21 = property({
  4256. type: Enum(SelectedType),
  4257. tooltip: DEV
  4258. }), _dec22 = property({
  4259. type: EventHandler,
  4260. tooltip: DEV,
  4261. visible: function visible() {
  4262. return this.selectedMode > SelectedType.NONE;
  4263. }
  4264. }), _dec23 = property({
  4265. tooltip: DEV,
  4266. visible: function visible() {
  4267. return this.selectedMode == SelectedType.SINGLE;
  4268. }
  4269. }), _dec24 = property({
  4270. serializable: false
  4271. }), ccclass(_class = _dec(_class = _dec2(_class = _dec3(_class = _dec4(_class = (_class2 = /*#__PURE__*/function (_Component) {
  4272. _inheritsLoose(List, _Component);
  4273. function List() {
  4274. var _this;
  4275. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  4276. args[_key] = arguments[_key];
  4277. }
  4278. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  4279. //模板类型
  4280. _initializerDefineProperty(_this, "templateType", _descriptor, _assertThisInitialized(_this));
  4281. //模板Item(Node)
  4282. _initializerDefineProperty(_this, "tmpNode", _descriptor2, _assertThisInitialized(_this));
  4283. //模板Item(Prefab)
  4284. _initializerDefineProperty(_this, "tmpPrefab", _descriptor3, _assertThisInitialized(_this));
  4285. //滑动模式
  4286. _initializerDefineProperty(_this, "_slideMode", _descriptor4, _assertThisInitialized(_this));
  4287. //翻页作用距离
  4288. _initializerDefineProperty(_this, "pageDistance", _descriptor5, _assertThisInitialized(_this));
  4289. //页面改变事件
  4290. _initializerDefineProperty(_this, "pageChangeEvent", _descriptor6, _assertThisInitialized(_this));
  4291. //是否为虚拟列表(动态列表)
  4292. _initializerDefineProperty(_this, "_virtual", _descriptor7, _assertThisInitialized(_this));
  4293. //是否为循环列表
  4294. _initializerDefineProperty(_this, "cyclic", _descriptor8, _assertThisInitialized(_this));
  4295. //缺省居中
  4296. _initializerDefineProperty(_this, "lackCenter", _descriptor9, _assertThisInitialized(_this));
  4297. //缺省可滑动
  4298. _initializerDefineProperty(_this, "lackSlide", _descriptor10, _assertThisInitialized(_this));
  4299. //刷新频率
  4300. _initializerDefineProperty(_this, "_updateRate", _descriptor11, _assertThisInitialized(_this));
  4301. //分帧渲染(每帧渲染的Item数量(<=0时关闭分帧渲染))
  4302. _initializerDefineProperty(_this, "frameByFrameRenderNum", _descriptor12, _assertThisInitialized(_this));
  4303. //渲染事件(渲染器)
  4304. _initializerDefineProperty(_this, "renderEvent", _descriptor13, _assertThisInitialized(_this));
  4305. //选择模式
  4306. _initializerDefineProperty(_this, "selectedMode", _descriptor14, _assertThisInitialized(_this));
  4307. //触发选择事件
  4308. _initializerDefineProperty(_this, "selectedEvent", _descriptor15, _assertThisInitialized(_this));
  4309. _initializerDefineProperty(_this, "repeatEventSingle", _descriptor16, _assertThisInitialized(_this));
  4310. //当前选择id
  4311. _this._selectedId = -1;
  4312. _this._lastSelectedId = void 0;
  4313. _this.multSelected = void 0;
  4314. _this._forceUpdate = false;
  4315. _this._align = void 0;
  4316. _this._horizontalDir = void 0;
  4317. _this._verticalDir = void 0;
  4318. _this._startAxis = void 0;
  4319. _this._alignCalcType = void 0;
  4320. _this.content = void 0;
  4321. _this._contentUt = void 0;
  4322. _this.firstListId = void 0;
  4323. _this.displayItemNum = void 0;
  4324. _this._updateDone = true;
  4325. _this._updateCounter = void 0;
  4326. _this._actualNumItems = void 0;
  4327. _this._cyclicNum = void 0;
  4328. _this._cyclicPos1 = void 0;
  4329. _this._cyclicPos2 = void 0;
  4330. //列表数量
  4331. _initializerDefineProperty(_this, "_numItems", _descriptor17, _assertThisInitialized(_this));
  4332. _this._inited = false;
  4333. _this._scrollView = void 0;
  4334. _this._layout = void 0;
  4335. _this._resizeMode = void 0;
  4336. _this._topGap = void 0;
  4337. _this._rightGap = void 0;
  4338. _this._bottomGap = void 0;
  4339. _this._leftGap = void 0;
  4340. _this._columnGap = void 0;
  4341. _this._lineGap = void 0;
  4342. _this._colLineNum = void 0;
  4343. _this._lastDisplayData = void 0;
  4344. _this.displayData = void 0;
  4345. _this._pool = void 0;
  4346. _this._itemTmp = void 0;
  4347. _this._itemTmpUt = void 0;
  4348. _this._needUpdateWidget = false;
  4349. _this._itemSize = void 0;
  4350. _this._sizeType = void 0;
  4351. _this._customSize = void 0;
  4352. _this.frameCount = void 0;
  4353. _this._aniDelRuning = false;
  4354. _this._aniDelCB = void 0;
  4355. _this._aniDelItem = void 0;
  4356. _this._aniDelBeforePos = void 0;
  4357. _this._aniDelBeforeScale = void 0;
  4358. _this.viewTop = void 0;
  4359. _this.viewRight = void 0;
  4360. _this.viewBottom = void 0;
  4361. _this.viewLeft = void 0;
  4362. _this._doneAfterUpdate = false;
  4363. _this.elasticTop = void 0;
  4364. _this.elasticRight = void 0;
  4365. _this.elasticBottom = void 0;
  4366. _this.elasticLeft = void 0;
  4367. _this.scrollToListId = void 0;
  4368. _this.adhering = false;
  4369. _this._adheringBarrier = false;
  4370. _this.nearestListId = void 0;
  4371. _this.curPageNum = 0;
  4372. _this._beganPos = void 0;
  4373. _this._scrollPos = void 0;
  4374. _this._curScrollIsTouch = void 0;
  4375. //当前滑动是否为手动
  4376. _this._scrollToListId = void 0;
  4377. _this._scrollToEndTime = void 0;
  4378. _this._scrollToSo = void 0;
  4379. _this._lack = void 0;
  4380. _this._allItemSize = void 0;
  4381. _this._allItemSizeNoEdge = void 0;
  4382. _this._scrollItem = void 0;
  4383. //当前控制 ScrollView 滚动的 Item
  4384. _this._thisNodeUt = void 0;
  4385. return _this;
  4386. }
  4387. var _proto = List.prototype;
  4388. //----------------------------------------------------------------------------
  4389. _proto.onLoad = function onLoad() {
  4390. this._init();
  4391. };
  4392. _proto.onDestroy = function onDestroy() {
  4393. var t = this;
  4394. if (isValid(t._itemTmp)) t._itemTmp.destroy();
  4395. if (isValid(t.tmpNode)) t.tmpNode.destroy();
  4396. t._pool && t._pool.clear();
  4397. };
  4398. _proto.onEnable = function onEnable() {
  4399. // if (!EDITOR)
  4400. this._registerEvent();
  4401. this._init();
  4402. // 处理重新显示后,有可能上一次的动画移除还未播放完毕,导致动画卡住的问题
  4403. if (this._aniDelRuning) {
  4404. this._aniDelRuning = false;
  4405. if (this._aniDelItem) {
  4406. if (this._aniDelBeforePos) {
  4407. this._aniDelItem.position = this._aniDelBeforePos;
  4408. delete this._aniDelBeforePos;
  4409. }
  4410. if (this._aniDelBeforeScale) {
  4411. this._aniDelItem.scale = this._aniDelBeforeScale;
  4412. delete this._aniDelBeforeScale;
  4413. }
  4414. delete this._aniDelItem;
  4415. }
  4416. if (this._aniDelCB) {
  4417. this._aniDelCB();
  4418. delete this._aniDelCB;
  4419. }
  4420. }
  4421. };
  4422. _proto.onDisable = function onDisable() {
  4423. // if (!EDITOR)
  4424. this._unregisterEvent();
  4425. }
  4426. //注册事件
  4427. ;
  4428. _proto._registerEvent = function _registerEvent() {
  4429. var t = this;
  4430. t.node.on(Node.EventType.TOUCH_START, t._onTouchStart, t);
  4431. t.node.on('touch-up', t._onTouchUp, t);
  4432. t.node.on(Node.EventType.TOUCH_CANCEL, t._onTouchCancelled, t);
  4433. t.node.on('scroll-began', t._onScrollBegan, t);
  4434. t.node.on('scroll-ended', t._onScrollEnded, t);
  4435. t.node.on('scrolling', t._onScrolling, t);
  4436. t.node.on(Node.EventType.SIZE_CHANGED, t._onSizeChanged, t);
  4437. }
  4438. //卸载事件
  4439. ;
  4440. _proto._unregisterEvent = function _unregisterEvent() {
  4441. var t = this;
  4442. t.node.off(Node.EventType.TOUCH_START, t._onTouchStart, t);
  4443. t.node.off('touch-up', t._onTouchUp, t);
  4444. t.node.off(Node.EventType.TOUCH_CANCEL, t._onTouchCancelled, t);
  4445. t.node.off('scroll-began', t._onScrollBegan, t);
  4446. t.node.off('scroll-ended', t._onScrollEnded, t);
  4447. t.node.off('scrolling', t._onScrolling, t);
  4448. t.node.off(Node.EventType.SIZE_CHANGED, t._onSizeChanged, t);
  4449. }
  4450. //初始化各种..
  4451. ;
  4452. _proto._init = function _init() {
  4453. var t = this;
  4454. if (t._inited) return;
  4455. t._thisNodeUt = t.node.getComponent(UITransform);
  4456. t._scrollView = t.node.getComponent(ScrollView);
  4457. t.content = t._scrollView.content;
  4458. t._contentUt = t.content.getComponent(UITransform);
  4459. if (!t.content) {
  4460. console.error(t.node.name + "'s ScrollView unset content!");
  4461. return;
  4462. }
  4463. t._layout = t.content.getComponent(Layout);
  4464. t._align = t._layout.type; //排列模式
  4465. t._resizeMode = t._layout.resizeMode; //自适应模式
  4466. t._startAxis = t._layout.startAxis;
  4467. t._topGap = t._layout.paddingTop; //顶边距
  4468. t._rightGap = t._layout.paddingRight; //右边距
  4469. t._bottomGap = t._layout.paddingBottom; //底边距
  4470. t._leftGap = t._layout.paddingLeft; //左边距
  4471. t._columnGap = t._layout.spacingX; //列距
  4472. t._lineGap = t._layout.spacingY; //行距
  4473. t._colLineNum; //列数或行数(非GRID模式则=1,表示单列或单行);
  4474. t._verticalDir = t._layout.verticalDirection; //垂直排列子节点的方向
  4475. t._horizontalDir = t._layout.horizontalDirection; //水平排列子节点的方向
  4476. t.setTemplateItem(instantiate(t.templateType == TemplateType.PREFAB ? t.tmpPrefab : t.tmpNode));
  4477. // 特定的滑动模式处理
  4478. if (t._slideMode == SlideType.ADHERING || t._slideMode == SlideType.PAGE) {
  4479. t._scrollView.inertia = false;
  4480. t._scrollView._onMouseWheel = function () {
  4481. return;
  4482. };
  4483. }
  4484. if (!t.virtual)
  4485. // lackCenter 仅支持 Virtual 模式
  4486. t.lackCenter = false;
  4487. t._lastDisplayData = []; //最后一次刷新的数据
  4488. t.displayData = []; //当前数据
  4489. t._pool = new NodePool(); //这是个池子..
  4490. t._forceUpdate = false; //是否强制更新
  4491. t._updateCounter = 0; //当前分帧渲染帧数
  4492. t._updateDone = true; //分帧渲染是否完成
  4493. t.curPageNum = 0; //当前页数
  4494. if (t.cyclic || 0) {
  4495. t._scrollView._processAutoScrolling = this._processAutoScrolling.bind(t);
  4496. t._scrollView._startBounceBackIfNeeded = function () {
  4497. return false;
  4498. };
  4499. }
  4500. switch (t._align) {
  4501. case Layout.Type.HORIZONTAL:
  4502. {
  4503. switch (t._horizontalDir) {
  4504. case Layout.HorizontalDirection.LEFT_TO_RIGHT:
  4505. t._alignCalcType = 1;
  4506. break;
  4507. case Layout.HorizontalDirection.RIGHT_TO_LEFT:
  4508. t._alignCalcType = 2;
  4509. break;
  4510. }
  4511. break;
  4512. }
  4513. case Layout.Type.VERTICAL:
  4514. {
  4515. switch (t._verticalDir) {
  4516. case Layout.VerticalDirection.TOP_TO_BOTTOM:
  4517. t._alignCalcType = 3;
  4518. break;
  4519. case Layout.VerticalDirection.BOTTOM_TO_TOP:
  4520. t._alignCalcType = 4;
  4521. break;
  4522. }
  4523. break;
  4524. }
  4525. case Layout.Type.GRID:
  4526. {
  4527. switch (t._startAxis) {
  4528. case Layout.AxisDirection.HORIZONTAL:
  4529. switch (t._verticalDir) {
  4530. case Layout.VerticalDirection.TOP_TO_BOTTOM:
  4531. t._alignCalcType = 3;
  4532. break;
  4533. case Layout.VerticalDirection.BOTTOM_TO_TOP:
  4534. t._alignCalcType = 4;
  4535. break;
  4536. }
  4537. break;
  4538. case Layout.AxisDirection.VERTICAL:
  4539. switch (t._horizontalDir) {
  4540. case Layout.HorizontalDirection.LEFT_TO_RIGHT:
  4541. t._alignCalcType = 1;
  4542. break;
  4543. case Layout.HorizontalDirection.RIGHT_TO_LEFT:
  4544. t._alignCalcType = 2;
  4545. break;
  4546. }
  4547. break;
  4548. }
  4549. break;
  4550. }
  4551. }
  4552. // 清空 content
  4553. // t.content.children.forEach((child: Node) => {
  4554. // child.removeFromParent();
  4555. // if (child != t.tmpNode && child.isValid)
  4556. // child.destroy();
  4557. // });
  4558. t.content.removeAllChildren();
  4559. t._inited = true;
  4560. }
  4561. /**
  4562. * 为了实现循环列表,必须覆写cc.ScrollView的某些函数
  4563. * @param {Number} dt
  4564. */;
  4565. _proto._processAutoScrolling = function _processAutoScrolling(dt) {
  4566. // ------------- scroll-view 里定义的一些常量 -------------
  4567. var OUT_OF_BOUNDARY_BREAKING_FACTOR = 0.05;
  4568. var EPSILON = 1e-4;
  4569. var ZERO = new Vec3();
  4570. var quintEaseOut = function quintEaseOut(time) {
  4571. time -= 1;
  4572. return time * time * time * time * time + 1;
  4573. };
  4574. // ------------- scroll-view 里定义的一些常量 -------------
  4575. var sv = this._scrollView;
  4576. var isAutoScrollBrake = sv['_isNecessaryAutoScrollBrake']();
  4577. var brakingFactor = isAutoScrollBrake ? OUT_OF_BOUNDARY_BREAKING_FACTOR : 1;
  4578. sv['_autoScrollAccumulatedTime'] += dt * (1 / brakingFactor);
  4579. var percentage = Math.min(1, sv['_autoScrollAccumulatedTime'] / sv['_autoScrollTotalTime']);
  4580. if (sv['_autoScrollAttenuate']) {
  4581. percentage = quintEaseOut(percentage);
  4582. }
  4583. var clonedAutoScrollTargetDelta = sv['_autoScrollTargetDelta'].clone();
  4584. clonedAutoScrollTargetDelta.multiplyScalar(percentage);
  4585. var clonedAutoScrollStartPosition = sv['_autoScrollStartPosition'].clone();
  4586. clonedAutoScrollStartPosition.add(clonedAutoScrollTargetDelta);
  4587. var reachedEnd = Math.abs(percentage - 1) <= EPSILON;
  4588. var fireEvent = Math.abs(percentage - 1) <= sv['getScrollEndedEventTiming']();
  4589. if (fireEvent && !sv['_isScrollEndedWithThresholdEventFired']) {
  4590. sv['_dispatchEvent'](ScrollView.EventType.SCROLL_ENG_WITH_THRESHOLD);
  4591. sv['_isScrollEndedWithThresholdEventFired'] = true;
  4592. }
  4593. if (sv['elastic']) {
  4594. var brakeOffsetPosition = clonedAutoScrollStartPosition.clone();
  4595. brakeOffsetPosition.subtract(sv['_autoScrollBrakingStartPosition']);
  4596. if (isAutoScrollBrake) {
  4597. brakeOffsetPosition.multiplyScalar(brakingFactor);
  4598. }
  4599. clonedAutoScrollStartPosition.set(sv['_autoScrollBrakingStartPosition']);
  4600. clonedAutoScrollStartPosition.add(brakeOffsetPosition);
  4601. } else {
  4602. var moveDelta = clonedAutoScrollStartPosition.clone();
  4603. moveDelta.subtract(sv['_getContentPosition']());
  4604. var outOfBoundary = sv['_getHowMuchOutOfBoundary'](moveDelta);
  4605. if (!outOfBoundary.equals(ZERO, EPSILON)) {
  4606. clonedAutoScrollStartPosition.add(outOfBoundary);
  4607. reachedEnd = true;
  4608. }
  4609. }
  4610. if (reachedEnd) {
  4611. sv['_autoScrolling'] = false;
  4612. }
  4613. var deltaMove = new Vec3(clonedAutoScrollStartPosition);
  4614. deltaMove.subtract(sv['_getContentPosition']());
  4615. sv['_clampDelta'](deltaMove);
  4616. sv['_moveContent'](deltaMove, reachedEnd);
  4617. sv['_dispatchEvent'](ScrollView.EventType.SCROLLING);
  4618. if (!sv['_autoScrolling']) {
  4619. sv['_isBouncing'] = false;
  4620. sv['_scrolling'] = false;
  4621. sv['_dispatchEvent'](ScrollView.EventType.SCROLL_ENDED);
  4622. }
  4623. }
  4624. //设置模板Item
  4625. ;
  4626. _proto.setTemplateItem = function setTemplateItem(item) {
  4627. if (!item) return;
  4628. var t = this;
  4629. t._itemTmp = item;
  4630. t._itemTmpUt = item.getComponent(UITransform);
  4631. if (t._resizeMode == Layout.ResizeMode.CHILDREN) t._itemSize = t._layout.cellSize;else {
  4632. var itemUt = item.getComponent(UITransform);
  4633. t._itemSize = new Size(itemUt.width, itemUt.height);
  4634. }
  4635. //获取ListItem,如果没有就取消选择模式
  4636. var com = item.getComponent(ListItem);
  4637. var remove = false;
  4638. if (!com) remove = true;
  4639. // if (com) {
  4640. // if (!com._btnCom && !item.getComponent(cc.Button)) {
  4641. // remove = true;
  4642. // }
  4643. // }
  4644. if (remove) {
  4645. t.selectedMode = SelectedType.NONE;
  4646. }
  4647. com = item.getComponent(Widget);
  4648. if (com && com.enabled) {
  4649. t._needUpdateWidget = true;
  4650. }
  4651. if (t.selectedMode == SelectedType.MULT) t.multSelected = [];
  4652. switch (t._align) {
  4653. case Layout.Type.HORIZONTAL:
  4654. t._colLineNum = 1;
  4655. t._sizeType = false;
  4656. break;
  4657. case Layout.Type.VERTICAL:
  4658. t._colLineNum = 1;
  4659. t._sizeType = true;
  4660. break;
  4661. case Layout.Type.GRID:
  4662. switch (t._startAxis) {
  4663. case Layout.AxisDirection.HORIZONTAL:
  4664. //计算列数
  4665. var trimW = t._contentUt.width - t._leftGap - t._rightGap;
  4666. t._colLineNum = Math.floor((trimW + t._columnGap) / (t._itemSize.width + t._columnGap));
  4667. t._sizeType = true;
  4668. break;
  4669. case Layout.AxisDirection.VERTICAL:
  4670. //计算行数
  4671. var trimH = t._contentUt.height - t._topGap - t._bottomGap;
  4672. t._colLineNum = Math.floor((trimH + t._lineGap) / (t._itemSize.height + t._lineGap));
  4673. t._sizeType = false;
  4674. break;
  4675. }
  4676. break;
  4677. }
  4678. }
  4679. /**
  4680. * 检查是否初始化
  4681. * @param {Boolean} printLog 是否打印错误信息
  4682. * @returns
  4683. */;
  4684. _proto.checkInited = function checkInited(printLog) {
  4685. if (printLog === void 0) {
  4686. printLog = true;
  4687. }
  4688. if (!this._inited) {
  4689. if (printLog) console.error('List initialization not completed!');
  4690. return false;
  4691. }
  4692. return true;
  4693. }
  4694. //禁用 Layout 组件,自行计算 Content Size
  4695. ;
  4696. _proto._resizeContent = function _resizeContent() {
  4697. var t = this;
  4698. var result;
  4699. switch (t._align) {
  4700. case Layout.Type.HORIZONTAL:
  4701. {
  4702. if (t._customSize) {
  4703. var fixed = t._getFixedSize(null);
  4704. result = t._leftGap + fixed.val + t._itemSize.width * (t._numItems - fixed.count) + t._columnGap * (t._numItems - 1) + t._rightGap;
  4705. } else {
  4706. result = t._leftGap + t._itemSize.width * t._numItems + t._columnGap * (t._numItems - 1) + t._rightGap;
  4707. }
  4708. break;
  4709. }
  4710. case Layout.Type.VERTICAL:
  4711. {
  4712. if (t._customSize) {
  4713. var _fixed = t._getFixedSize(null);
  4714. result = t._topGap + _fixed.val + t._itemSize.height * (t._numItems - _fixed.count) + t._lineGap * (t._numItems - 1) + t._bottomGap;
  4715. } else {
  4716. result = t._topGap + t._itemSize.height * t._numItems + t._lineGap * (t._numItems - 1) + t._bottomGap;
  4717. }
  4718. break;
  4719. }
  4720. case Layout.Type.GRID:
  4721. {
  4722. //网格模式不支持居中
  4723. if (t.lackCenter) t.lackCenter = false;
  4724. switch (t._startAxis) {
  4725. case Layout.AxisDirection.HORIZONTAL:
  4726. var lineNum = Math.ceil(t._numItems / t._colLineNum);
  4727. result = t._topGap + t._itemSize.height * lineNum + t._lineGap * (lineNum - 1) + t._bottomGap;
  4728. break;
  4729. case Layout.AxisDirection.VERTICAL:
  4730. var colNum = Math.ceil(t._numItems / t._colLineNum);
  4731. result = t._leftGap + t._itemSize.width * colNum + t._columnGap * (colNum - 1) + t._rightGap;
  4732. break;
  4733. }
  4734. break;
  4735. }
  4736. }
  4737. var layout = t.content.getComponent(Layout);
  4738. if (layout) layout.enabled = false;
  4739. t._allItemSize = result;
  4740. t._allItemSizeNoEdge = t._allItemSize - (t._sizeType ? t._topGap + t._bottomGap : t._leftGap + t._rightGap);
  4741. if (t.cyclic) {
  4742. var totalSize = t._sizeType ? t._thisNodeUt.height : t._thisNodeUt.width;
  4743. t._cyclicPos1 = 0;
  4744. totalSize -= t._cyclicPos1;
  4745. t._cyclicNum = Math.ceil(totalSize / t._allItemSizeNoEdge) + 1;
  4746. var spacing = t._sizeType ? t._lineGap : t._columnGap;
  4747. t._cyclicPos2 = t._cyclicPos1 + t._allItemSizeNoEdge + spacing;
  4748. t._cyclicAllItemSize = t._allItemSize + t._allItemSizeNoEdge * (t._cyclicNum - 1) + spacing * (t._cyclicNum - 1);
  4749. t._cycilcAllItemSizeNoEdge = t._allItemSizeNoEdge * t._cyclicNum;
  4750. t._cycilcAllItemSizeNoEdge += spacing * (t._cyclicNum - 1);
  4751. // cc.log('_cyclicNum ->', t._cyclicNum, t._allItemSizeNoEdge, t._allItemSize, t._cyclicPos1, t._cyclicPos2);
  4752. }
  4753. t._lack = !t.cyclic && t._allItemSize < (t._sizeType ? t._thisNodeUt.height : t._thisNodeUt.width);
  4754. var slideOffset = (!t._lack || !t.lackCenter) && t.lackSlide ? 0 : .1;
  4755. var targetWH = t._lack ? (t._sizeType ? t._thisNodeUt.height : t._thisNodeUt.width) - slideOffset : t.cyclic ? t._cyclicAllItemSize : t._allItemSize;
  4756. if (targetWH < 0) targetWH = 0;
  4757. if (t._sizeType) {
  4758. t._contentUt.height = targetWH;
  4759. } else {
  4760. t._contentUt.width = targetWH;
  4761. }
  4762. // cc.log('_resizeContent() numItems =', t._numItems, ',content =', t.content);
  4763. }
  4764. //滚动进行时...
  4765. ;
  4766. _proto._onScrolling = function _onScrolling(ev) {
  4767. if (ev === void 0) {
  4768. ev = null;
  4769. }
  4770. if (this.frameCount == null) this.frameCount = this._updateRate;
  4771. if (!this._forceUpdate && ev && ev.type != 'scroll-ended' && this.frameCount > 0) {
  4772. this.frameCount--;
  4773. return;
  4774. } else this.frameCount = this._updateRate;
  4775. if (this._aniDelRuning) return;
  4776. //循环列表处理
  4777. if (this.cyclic) {
  4778. var scrollPos = this.content.getPosition();
  4779. scrollPos = this._sizeType ? scrollPos.y : scrollPos.x;
  4780. var addVal = this._allItemSizeNoEdge + (this._sizeType ? this._lineGap : this._columnGap);
  4781. var add = this._sizeType ? new Vec3(0, addVal, 0) : new Vec3(addVal, 0, 0);
  4782. var contentPos = this.content.getPosition();
  4783. switch (this._alignCalcType) {
  4784. case 1:
  4785. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  4786. if (scrollPos > -this._cyclicPos1) {
  4787. contentPos.set(-this._cyclicPos2, contentPos.y, contentPos.z);
  4788. this.content.setPosition(contentPos);
  4789. if (this._scrollView.isAutoScrolling()) {
  4790. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].subtract(add);
  4791. }
  4792. // if (this._beganPos) {
  4793. // this._beganPos += add;
  4794. // }
  4795. } else if (scrollPos < -this._cyclicPos2) {
  4796. contentPos.set(-this._cyclicPos1, contentPos.y, contentPos.z);
  4797. this.content.setPosition(contentPos);
  4798. if (this._scrollView.isAutoScrolling()) {
  4799. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].add(add);
  4800. }
  4801. // if (this._beganPos) {
  4802. // this._beganPos -= add;
  4803. // }
  4804. }
  4805. break;
  4806. case 2:
  4807. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  4808. if (scrollPos < this._cyclicPos1) {
  4809. contentPos.set(this._cyclicPos2, contentPos.y, contentPos.z);
  4810. this.content.setPosition(contentPos);
  4811. if (this._scrollView.isAutoScrolling()) {
  4812. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].add(add);
  4813. }
  4814. } else if (scrollPos > this._cyclicPos2) {
  4815. contentPos.set(this._cyclicPos1, contentPos.y, contentPos.z);
  4816. this.content.setPosition(contentPos);
  4817. if (this._scrollView.isAutoScrolling()) {
  4818. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].subtract(add);
  4819. }
  4820. }
  4821. break;
  4822. case 3:
  4823. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  4824. if (scrollPos < this._cyclicPos1) {
  4825. contentPos.set(contentPos.x, this._cyclicPos2, contentPos.z);
  4826. this.content.setPosition(contentPos);
  4827. if (this._scrollView.isAutoScrolling()) {
  4828. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].add(add);
  4829. }
  4830. } else if (scrollPos > this._cyclicPos2) {
  4831. contentPos.set(contentPos.x, this._cyclicPos1, contentPos.z);
  4832. this.content.setPosition(contentPos);
  4833. if (this._scrollView.isAutoScrolling()) {
  4834. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].subtract(add);
  4835. }
  4836. }
  4837. break;
  4838. case 4:
  4839. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  4840. if (scrollPos > -this._cyclicPos1) {
  4841. contentPos.set(contentPos.x, -this._cyclicPos2, contentPos.z);
  4842. this.content.setPosition(contentPos);
  4843. if (this._scrollView.isAutoScrolling()) {
  4844. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].subtract(add);
  4845. }
  4846. } else if (scrollPos < -this._cyclicPos2) {
  4847. contentPos.set(contentPos.x, -this._cyclicPos1, contentPos.z);
  4848. this.content.setPosition(contentPos);
  4849. if (this._scrollView.isAutoScrolling()) {
  4850. this._scrollView['_autoScrollStartPosition'] = this._scrollView['_autoScrollStartPosition'].add(add);
  4851. }
  4852. }
  4853. break;
  4854. }
  4855. }
  4856. this._calcViewPos();
  4857. var vTop, vRight, vBottom, vLeft;
  4858. if (this._sizeType) {
  4859. vTop = this.viewTop;
  4860. vBottom = this.viewBottom;
  4861. } else {
  4862. vRight = this.viewRight;
  4863. vLeft = this.viewLeft;
  4864. }
  4865. if (this._virtual) {
  4866. this.displayData = [];
  4867. var itemPos;
  4868. var curId = 0;
  4869. var endId = this._numItems - 1;
  4870. if (this._customSize) {
  4871. var breakFor = false;
  4872. //如果该item的位置在可视区域内,就推入displayData
  4873. for (; curId <= endId && !breakFor; curId++) {
  4874. itemPos = this._calcItemPos(curId);
  4875. switch (this._align) {
  4876. case Layout.Type.HORIZONTAL:
  4877. if (itemPos.right >= vLeft && itemPos.left <= vRight) {
  4878. this.displayData.push(itemPos);
  4879. } else if (curId != 0 && this.displayData.length > 0) {
  4880. breakFor = true;
  4881. }
  4882. break;
  4883. case Layout.Type.VERTICAL:
  4884. if (itemPos.bottom <= vTop && itemPos.top >= vBottom) {
  4885. this.displayData.push(itemPos);
  4886. } else if (curId != 0 && this.displayData.length > 0) {
  4887. breakFor = true;
  4888. }
  4889. break;
  4890. case Layout.Type.GRID:
  4891. switch (this._startAxis) {
  4892. case Layout.AxisDirection.HORIZONTAL:
  4893. if (itemPos.bottom <= vTop && itemPos.top >= vBottom) {
  4894. this.displayData.push(itemPos);
  4895. } else if (curId != 0 && this.displayData.length > 0) {
  4896. breakFor = true;
  4897. }
  4898. break;
  4899. case Layout.AxisDirection.VERTICAL:
  4900. if (itemPos.right >= vLeft && itemPos.left <= vRight) {
  4901. this.displayData.push(itemPos);
  4902. } else if (curId != 0 && this.displayData.length > 0) {
  4903. breakFor = true;
  4904. }
  4905. break;
  4906. }
  4907. break;
  4908. }
  4909. }
  4910. } else {
  4911. var ww = this._itemSize.width + this._columnGap;
  4912. var hh = this._itemSize.height + this._lineGap;
  4913. switch (this._alignCalcType) {
  4914. case 1:
  4915. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  4916. curId = (vLeft - this._leftGap) / ww;
  4917. endId = (vRight - this._leftGap) / ww;
  4918. break;
  4919. case 2:
  4920. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  4921. curId = (-vRight - this._rightGap) / ww;
  4922. endId = (-vLeft - this._rightGap) / ww;
  4923. break;
  4924. case 3:
  4925. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  4926. curId = (-vTop - this._topGap) / hh;
  4927. endId = (-vBottom - this._topGap) / hh;
  4928. break;
  4929. case 4:
  4930. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  4931. curId = (vBottom - this._bottomGap) / hh;
  4932. endId = (vTop - this._bottomGap) / hh;
  4933. break;
  4934. }
  4935. curId = Math.floor(curId) * this._colLineNum;
  4936. endId = Math.ceil(endId) * this._colLineNum;
  4937. endId--;
  4938. if (curId < 0) curId = 0;
  4939. if (endId >= this._numItems) endId = this._numItems - 1;
  4940. for (; curId <= endId; curId++) {
  4941. this.displayData.push(this._calcItemPos(curId));
  4942. }
  4943. }
  4944. this._delRedundantItem();
  4945. if (this.displayData.length <= 0 || !this._numItems) {
  4946. //if none, delete all.
  4947. this._lastDisplayData = [];
  4948. return;
  4949. }
  4950. this.firstListId = this.displayData[0].id;
  4951. this.displayItemNum = this.displayData.length;
  4952. var len = this._lastDisplayData.length;
  4953. var haveDataChange = this.displayItemNum != len;
  4954. if (haveDataChange) {
  4955. // 如果是逐帧渲染,需要排序
  4956. if (this.frameByFrameRenderNum > 0) {
  4957. this._lastDisplayData.sort(function (a, b) {
  4958. return a - b;
  4959. });
  4960. }
  4961. // 因List的显示数据是有序的,所以只需要判断数组长度是否相等,以及头、尾两个元素是否相等即可。
  4962. haveDataChange = this.firstListId != this._lastDisplayData[0] || this.displayData[this.displayItemNum - 1].id != this._lastDisplayData[len - 1];
  4963. }
  4964. if (this._forceUpdate || haveDataChange) {
  4965. //如果是强制更新
  4966. if (this.frameByFrameRenderNum > 0) {
  4967. // if (this._updateDone) {
  4968. // this._lastDisplayData = [];
  4969. //逐帧渲染
  4970. if (this._numItems > 0) {
  4971. if (!this._updateDone) {
  4972. this._doneAfterUpdate = true;
  4973. } else {
  4974. this._updateCounter = 0;
  4975. }
  4976. this._updateDone = false;
  4977. } else {
  4978. this._updateCounter = 0;
  4979. this._updateDone = true;
  4980. }
  4981. // }
  4982. } else {
  4983. //直接渲染
  4984. this._lastDisplayData = [];
  4985. // cc.log('List Display Data II::', this.displayData);
  4986. for (var c = 0; c < this.displayItemNum; c++) {
  4987. this._createOrUpdateItem(this.displayData[c]);
  4988. }
  4989. this._forceUpdate = false;
  4990. }
  4991. }
  4992. this._calcNearestItem();
  4993. }
  4994. }
  4995. //计算可视范围
  4996. ;
  4997. _proto._calcViewPos = function _calcViewPos() {
  4998. var scrollPos = this.content.getPosition();
  4999. switch (this._alignCalcType) {
  5000. case 1:
  5001. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  5002. this.elasticLeft = scrollPos.x > 0 ? scrollPos.x : 0;
  5003. this.viewLeft = (scrollPos.x < 0 ? -scrollPos.x : 0) - this.elasticLeft;
  5004. this.viewRight = this.viewLeft + this._thisNodeUt.width;
  5005. this.elasticRight = this.viewRight > this._contentUt.width ? Math.abs(this.viewRight - this._contentUt.width) : 0;
  5006. this.viewRight += this.elasticRight;
  5007. // cc.log(this.elasticLeft, this.elasticRight, this.viewLeft, this.viewRight);
  5008. break;
  5009. case 2:
  5010. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  5011. this.elasticRight = scrollPos.x < 0 ? -scrollPos.x : 0;
  5012. this.viewRight = (scrollPos.x > 0 ? -scrollPos.x : 0) + this.elasticRight;
  5013. this.viewLeft = this.viewRight - this._thisNodeUt.width;
  5014. this.elasticLeft = this.viewLeft < -this._contentUt.width ? Math.abs(this.viewLeft + this._contentUt.width) : 0;
  5015. this.viewLeft -= this.elasticLeft;
  5016. // cc.log(this.elasticLeft, this.elasticRight, this.viewLeft, this.viewRight);
  5017. break;
  5018. case 3:
  5019. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  5020. this.elasticTop = scrollPos.y < 0 ? Math.abs(scrollPos.y) : 0;
  5021. this.viewTop = (scrollPos.y > 0 ? -scrollPos.y : 0) + this.elasticTop;
  5022. this.viewBottom = this.viewTop - this._thisNodeUt.height;
  5023. this.elasticBottom = this.viewBottom < -this._contentUt.height ? Math.abs(this.viewBottom + this._contentUt.height) : 0;
  5024. this.viewBottom += this.elasticBottom;
  5025. // cc.log(this.elasticTop, this.elasticBottom, this.viewTop, this.viewBottom);
  5026. break;
  5027. case 4:
  5028. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  5029. this.elasticBottom = scrollPos.y > 0 ? Math.abs(scrollPos.y) : 0;
  5030. this.viewBottom = (scrollPos.y < 0 ? -scrollPos.y : 0) - this.elasticBottom;
  5031. this.viewTop = this.viewBottom + this._thisNodeUt.height;
  5032. this.elasticTop = this.viewTop > this._contentUt.height ? Math.abs(this.viewTop - this._contentUt.height) : 0;
  5033. this.viewTop -= this.elasticTop;
  5034. // cc.log(this.elasticTop, this.elasticBottom, this.viewTop, this.viewBottom);
  5035. break;
  5036. }
  5037. }
  5038. //计算位置 根据id
  5039. ;
  5040. _proto._calcItemPos = function _calcItemPos(id) {
  5041. var width, height, top, bottom, left, right, itemX, itemY;
  5042. switch (this._align) {
  5043. case Layout.Type.HORIZONTAL:
  5044. switch (this._horizontalDir) {
  5045. case Layout.HorizontalDirection.LEFT_TO_RIGHT:
  5046. {
  5047. if (this._customSize) {
  5048. var fixed = this._getFixedSize(id);
  5049. left = this._leftGap + (this._itemSize.width + this._columnGap) * (id - fixed.count) + (fixed.val + this._columnGap * fixed.count);
  5050. var cs = this._customSize[id];
  5051. width = cs > 0 ? cs : this._itemSize.width;
  5052. } else {
  5053. left = this._leftGap + (this._itemSize.width + this._columnGap) * id;
  5054. width = this._itemSize.width;
  5055. }
  5056. if (this.lackCenter) {
  5057. left -= this._leftGap;
  5058. var offset = this._contentUt.width / 2 - this._allItemSizeNoEdge / 2;
  5059. left += offset;
  5060. }
  5061. right = left + width;
  5062. return {
  5063. id: id,
  5064. left: left,
  5065. right: right,
  5066. x: left + this._itemTmpUt.anchorX * width,
  5067. y: this._itemTmp.y
  5068. };
  5069. }
  5070. case Layout.HorizontalDirection.RIGHT_TO_LEFT:
  5071. {
  5072. if (this._customSize) {
  5073. var _fixed2 = this._getFixedSize(id);
  5074. right = -this._rightGap - (this._itemSize.width + this._columnGap) * (id - _fixed2.count) - (_fixed2.val + this._columnGap * _fixed2.count);
  5075. var _cs = this._customSize[id];
  5076. width = _cs > 0 ? _cs : this._itemSize.width;
  5077. } else {
  5078. right = -this._rightGap - (this._itemSize.width + this._columnGap) * id;
  5079. width = this._itemSize.width;
  5080. }
  5081. if (this.lackCenter) {
  5082. right += this._rightGap;
  5083. var _offset = this._contentUt.width / 2 - this._allItemSizeNoEdge / 2;
  5084. right -= _offset;
  5085. }
  5086. left = right - width;
  5087. return {
  5088. id: id,
  5089. right: right,
  5090. left: left,
  5091. x: left + this._itemTmpUt.anchorX * width,
  5092. y: this._itemTmp.y
  5093. };
  5094. }
  5095. }
  5096. break;
  5097. case Layout.Type.VERTICAL:
  5098. {
  5099. switch (this._verticalDir) {
  5100. case Layout.VerticalDirection.TOP_TO_BOTTOM:
  5101. {
  5102. if (this._customSize) {
  5103. var _fixed3 = this._getFixedSize(id);
  5104. top = -this._topGap - (this._itemSize.height + this._lineGap) * (id - _fixed3.count) - (_fixed3.val + this._lineGap * _fixed3.count);
  5105. var _cs2 = this._customSize[id];
  5106. height = _cs2 > 0 ? _cs2 : this._itemSize.height;
  5107. } else {
  5108. top = -this._topGap - (this._itemSize.height + this._lineGap) * id;
  5109. height = this._itemSize.height;
  5110. }
  5111. if (this.lackCenter) {
  5112. top += this._topGap;
  5113. var _offset2 = this._contentUt.height / 2 - this._allItemSizeNoEdge / 2;
  5114. top -= _offset2;
  5115. }
  5116. bottom = top - height;
  5117. return {
  5118. id: id,
  5119. top: top,
  5120. bottom: bottom,
  5121. x: this._itemTmp.x,
  5122. y: bottom + this._itemTmpUt.anchorY * height
  5123. };
  5124. }
  5125. case Layout.VerticalDirection.BOTTOM_TO_TOP:
  5126. {
  5127. if (this._customSize) {
  5128. var _fixed4 = this._getFixedSize(id);
  5129. bottom = this._bottomGap + (this._itemSize.height + this._lineGap) * (id - _fixed4.count) + (_fixed4.val + this._lineGap * _fixed4.count);
  5130. var _cs3 = this._customSize[id];
  5131. height = _cs3 > 0 ? _cs3 : this._itemSize.height;
  5132. } else {
  5133. bottom = this._bottomGap + (this._itemSize.height + this._lineGap) * id;
  5134. height = this._itemSize.height;
  5135. }
  5136. if (this.lackCenter) {
  5137. bottom -= this._bottomGap;
  5138. var _offset3 = this._contentUt.height / 2 - this._allItemSizeNoEdge / 2;
  5139. bottom += _offset3;
  5140. }
  5141. top = bottom + height;
  5142. return {
  5143. id: id,
  5144. top: top,
  5145. bottom: bottom,
  5146. x: this._itemTmp.x,
  5147. y: bottom + this._itemTmpUt.anchorY * height
  5148. };
  5149. }
  5150. }
  5151. }
  5152. case Layout.Type.GRID:
  5153. {
  5154. var colLine = Math.floor(id / this._colLineNum);
  5155. switch (this._startAxis) {
  5156. case Layout.AxisDirection.HORIZONTAL:
  5157. {
  5158. switch (this._verticalDir) {
  5159. case Layout.VerticalDirection.TOP_TO_BOTTOM:
  5160. {
  5161. top = -this._topGap - (this._itemSize.height + this._lineGap) * colLine;
  5162. bottom = top - this._itemSize.height;
  5163. itemY = bottom + this._itemTmpUt.anchorY * this._itemSize.height;
  5164. break;
  5165. }
  5166. case Layout.VerticalDirection.BOTTOM_TO_TOP:
  5167. {
  5168. bottom = this._bottomGap + (this._itemSize.height + this._lineGap) * colLine;
  5169. top = bottom + this._itemSize.height;
  5170. itemY = bottom + this._itemTmpUt.anchorY * this._itemSize.height;
  5171. break;
  5172. }
  5173. }
  5174. itemX = this._leftGap + id % this._colLineNum * (this._itemSize.width + this._columnGap);
  5175. switch (this._horizontalDir) {
  5176. case Layout.HorizontalDirection.LEFT_TO_RIGHT:
  5177. {
  5178. itemX += this._itemTmpUt.anchorX * this._itemSize.width;
  5179. itemX -= this._contentUt.anchorX * this._contentUt.width;
  5180. break;
  5181. }
  5182. case Layout.HorizontalDirection.RIGHT_TO_LEFT:
  5183. {
  5184. itemX += (1 - this._itemTmpUt.anchorX) * this._itemSize.width;
  5185. itemX -= (1 - this._contentUt.anchorX) * this._contentUt.width;
  5186. itemX *= -1;
  5187. break;
  5188. }
  5189. }
  5190. return {
  5191. id: id,
  5192. top: top,
  5193. bottom: bottom,
  5194. x: itemX,
  5195. y: itemY
  5196. };
  5197. }
  5198. case Layout.AxisDirection.VERTICAL:
  5199. {
  5200. switch (this._horizontalDir) {
  5201. case Layout.HorizontalDirection.LEFT_TO_RIGHT:
  5202. {
  5203. left = this._leftGap + (this._itemSize.width + this._columnGap) * colLine;
  5204. right = left + this._itemSize.width;
  5205. itemX = left + this._itemTmpUt.anchorX * this._itemSize.width;
  5206. itemX -= this._contentUt.anchorX * this._contentUt.width;
  5207. break;
  5208. }
  5209. case Layout.HorizontalDirection.RIGHT_TO_LEFT:
  5210. {
  5211. right = -this._rightGap - (this._itemSize.width + this._columnGap) * colLine;
  5212. left = right - this._itemSize.width;
  5213. itemX = left + this._itemTmpUt.anchorX * this._itemSize.width;
  5214. itemX += (1 - this._contentUt.anchorX) * this._contentUt.width;
  5215. break;
  5216. }
  5217. }
  5218. itemY = -this._topGap - id % this._colLineNum * (this._itemSize.height + this._lineGap);
  5219. switch (this._verticalDir) {
  5220. case Layout.VerticalDirection.TOP_TO_BOTTOM:
  5221. {
  5222. itemY -= (1 - this._itemTmpUt.anchorY) * this._itemSize.height;
  5223. itemY += (1 - this._contentUt.anchorY) * this._contentUt.height;
  5224. break;
  5225. }
  5226. case Layout.VerticalDirection.BOTTOM_TO_TOP:
  5227. {
  5228. itemY -= this._itemTmpUt.anchorY * this._itemSize.height;
  5229. itemY += this._contentUt.anchorY * this._contentUt.height;
  5230. itemY *= -1;
  5231. break;
  5232. }
  5233. }
  5234. return {
  5235. id: id,
  5236. left: left,
  5237. right: right,
  5238. x: itemX,
  5239. y: itemY
  5240. };
  5241. }
  5242. }
  5243. break;
  5244. }
  5245. }
  5246. }
  5247. //计算已存在的Item的位置
  5248. ;
  5249. _proto._calcExistItemPos = function _calcExistItemPos(id) {
  5250. var item = this.getItemByListId(id);
  5251. if (!item) return null;
  5252. var ut = item.getComponent(UITransform);
  5253. var pos = item.getPosition();
  5254. var data = {
  5255. id: id,
  5256. x: pos.x,
  5257. y: pos.y
  5258. };
  5259. if (this._sizeType) {
  5260. data.top = pos.y + ut.height * (1 - ut.anchorY);
  5261. data.bottom = pos.y - ut.height * ut.anchorY;
  5262. } else {
  5263. data.left = pos.x - ut.width * ut.anchorX;
  5264. data.right = pos.x + ut.width * (1 - ut.anchorX);
  5265. }
  5266. return data;
  5267. }
  5268. //获取Item位置
  5269. ;
  5270. _proto.getItemPos = function getItemPos(id) {
  5271. if (this._virtual) return this._calcItemPos(id);else {
  5272. if (this.frameByFrameRenderNum) return this._calcItemPos(id);else return this._calcExistItemPos(id);
  5273. }
  5274. }
  5275. //获取固定尺寸
  5276. ;
  5277. _proto._getFixedSize = function _getFixedSize(listId) {
  5278. if (!this._customSize) return null;
  5279. if (listId == null) listId = this._numItems;
  5280. var fixed = 0;
  5281. var count = 0;
  5282. for (var id in this._customSize) {
  5283. if (parseInt(id) < listId) {
  5284. fixed += this._customSize[id];
  5285. count++;
  5286. }
  5287. }
  5288. return {
  5289. val: fixed,
  5290. count: count
  5291. };
  5292. }
  5293. //滚动结束时..
  5294. ;
  5295. _proto._onScrollBegan = function _onScrollBegan() {
  5296. this._beganPos = this._sizeType ? this.viewTop : this.viewLeft;
  5297. }
  5298. //滚动结束时..
  5299. ;
  5300. _proto._onScrollEnded = function _onScrollEnded() {
  5301. var t = this;
  5302. t._curScrollIsTouch = false;
  5303. if (t.scrollToListId != null) {
  5304. var item = t.getItemByListId(t.scrollToListId);
  5305. t.scrollToListId = null;
  5306. if (item) {
  5307. tween(item).to(.1, {
  5308. scale: 1.06
  5309. }).to(.1, {
  5310. scale: 1
  5311. }).start();
  5312. }
  5313. }
  5314. t._onScrolling();
  5315. if (t._slideMode == SlideType.ADHERING && !t.adhering) {
  5316. //cc.log(t.adhering, t._scrollView.isAutoScrolling(), t._scrollView.isScrolling());
  5317. t.adhere();
  5318. } else if (t._slideMode == SlideType.PAGE) {
  5319. if (t._beganPos != null && t._curScrollIsTouch) {
  5320. this._pageAdhere();
  5321. } else {
  5322. t.adhere();
  5323. }
  5324. }
  5325. }
  5326. // 触摸时
  5327. ;
  5328. _proto._onTouchStart = function _onTouchStart(ev, captureListeners) {
  5329. if (this._scrollView['_hasNestedViewGroup'](ev, captureListeners)) return;
  5330. this._curScrollIsTouch = true;
  5331. var isMe = ev.eventPhase === 2 && ev.target === this.node;
  5332. if (!isMe) {
  5333. var itemNode = ev.target;
  5334. while (itemNode._listId == null && itemNode.parent) itemNode = itemNode.parent;
  5335. this._scrollItem = itemNode._listId != null ? itemNode : ev.target;
  5336. }
  5337. }
  5338. //触摸抬起时..
  5339. ;
  5340. _proto._onTouchUp = function _onTouchUp() {
  5341. var t = this;
  5342. t._scrollPos = null;
  5343. if (t._slideMode == SlideType.ADHERING) {
  5344. if (this.adhering) this._adheringBarrier = true;
  5345. t.adhere();
  5346. } else if (t._slideMode == SlideType.PAGE) {
  5347. if (t._beganPos != null) {
  5348. this._pageAdhere();
  5349. } else {
  5350. t.adhere();
  5351. }
  5352. }
  5353. this._scrollItem = null;
  5354. };
  5355. _proto._onTouchCancelled = function _onTouchCancelled(ev, captureListeners) {
  5356. var t = this;
  5357. if (t._scrollView['_hasNestedViewGroup'](ev, captureListeners) || ev.simulate) return;
  5358. t._scrollPos = null;
  5359. if (t._slideMode == SlideType.ADHERING) {
  5360. if (t.adhering) t._adheringBarrier = true;
  5361. t.adhere();
  5362. } else if (t._slideMode == SlideType.PAGE) {
  5363. if (t._beganPos != null) {
  5364. t._pageAdhere();
  5365. } else {
  5366. t.adhere();
  5367. }
  5368. }
  5369. this._scrollItem = null;
  5370. }
  5371. //当尺寸改变
  5372. ;
  5373. _proto._onSizeChanged = function _onSizeChanged() {
  5374. if (this.checkInited(false)) this._onScrolling();
  5375. }
  5376. //当Item自适应
  5377. ;
  5378. _proto._onItemAdaptive = function _onItemAdaptive(item) {
  5379. var ut = item.getComponent(UITransform);
  5380. // if (this.checkInited(false)) {
  5381. if (!this._sizeType && ut.width != this._itemSize.width || this._sizeType && ut.height != this._itemSize.height) {
  5382. if (!this._customSize) this._customSize = {};
  5383. var val = this._sizeType ? ut.height : ut.width;
  5384. if (this._customSize[item._listId] != val) {
  5385. this._customSize[item._listId] = val;
  5386. this._resizeContent();
  5387. // this.content.children.forEach((child: Node) => {
  5388. // this._updateItemPos(child);
  5389. // });
  5390. this.updateAll();
  5391. // 如果当前正在运行 scrollTo,肯定会不准确,在这里做修正
  5392. if (this._scrollToListId != null) {
  5393. this._scrollPos = null;
  5394. this.unschedule(this._scrollToSo);
  5395. this.scrollTo(this._scrollToListId, Math.max(0, this._scrollToEndTime - new Date().getTime() / 1000));
  5396. }
  5397. }
  5398. }
  5399. // }
  5400. }
  5401. //PAGE粘附
  5402. ;
  5403. _proto._pageAdhere = function _pageAdhere() {
  5404. var t = this;
  5405. if (!t.cyclic && (t.elasticTop > 0 || t.elasticRight > 0 || t.elasticBottom > 0 || t.elasticLeft > 0)) return;
  5406. var curPos = t._sizeType ? t.viewTop : t.viewLeft;
  5407. var dis = (t._sizeType ? t._thisNodeUt.height : t._thisNodeUt.width) * t.pageDistance;
  5408. var canSkip = Math.abs(t._beganPos - curPos) > dis;
  5409. if (canSkip) {
  5410. var timeInSecond = .5;
  5411. switch (t._alignCalcType) {
  5412. case 1: //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  5413. case 4:
  5414. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  5415. if (t._beganPos > curPos) {
  5416. t.prePage(timeInSecond);
  5417. // cc.log('_pageAdhere PPPPPPPPPPPPPPP');
  5418. } else {
  5419. t.nextPage(timeInSecond);
  5420. // cc.log('_pageAdhere NNNNNNNNNNNNNNN');
  5421. }
  5422. break;
  5423. case 2: //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  5424. case 3:
  5425. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  5426. if (t._beganPos < curPos) {
  5427. t.prePage(timeInSecond);
  5428. } else {
  5429. t.nextPage(timeInSecond);
  5430. }
  5431. break;
  5432. }
  5433. } else if (t.elasticTop <= 0 && t.elasticRight <= 0 && t.elasticBottom <= 0 && t.elasticLeft <= 0) {
  5434. t.adhere();
  5435. }
  5436. t._beganPos = null;
  5437. }
  5438. //粘附
  5439. ;
  5440. _proto.adhere = function adhere() {
  5441. var t = this;
  5442. if (!t.checkInited()) return;
  5443. if (t.elasticTop > 0 || t.elasticRight > 0 || t.elasticBottom > 0 || t.elasticLeft > 0) return;
  5444. t.adhering = true;
  5445. t._calcNearestItem();
  5446. var offset = (t._sizeType ? t._topGap : t._leftGap) / (t._sizeType ? t._thisNodeUt.height : t._thisNodeUt.width);
  5447. var timeInSecond = .7;
  5448. t.scrollTo(t.nearestListId, timeInSecond, offset);
  5449. }
  5450. //Update..
  5451. ;
  5452. _proto.update = function update() {
  5453. if (this.frameByFrameRenderNum <= 0 || this._updateDone) return;
  5454. // cc.log(this.displayData.length, this._updateCounter, this.displayData[this._updateCounter]);
  5455. if (this._virtual) {
  5456. var len = this._updateCounter + this.frameByFrameRenderNum > this.displayItemNum ? this.displayItemNum : this._updateCounter + this.frameByFrameRenderNum;
  5457. for (var n = this._updateCounter; n < len; n++) {
  5458. var data = this.displayData[n];
  5459. if (data) {
  5460. this._createOrUpdateItem(data);
  5461. }
  5462. }
  5463. if (this._updateCounter >= this.displayItemNum - 1) {
  5464. //最后一个
  5465. if (this._doneAfterUpdate) {
  5466. this._updateCounter = 0;
  5467. this._updateDone = false;
  5468. // if (!this._scrollView.isScrolling())
  5469. this._doneAfterUpdate = false;
  5470. } else {
  5471. this._updateDone = true;
  5472. this._delRedundantItem();
  5473. this._forceUpdate = false;
  5474. this._calcNearestItem();
  5475. if (this.slideMode == SlideType.PAGE) this.curPageNum = this.nearestListId;
  5476. }
  5477. } else {
  5478. this._updateCounter += this.frameByFrameRenderNum;
  5479. }
  5480. } else {
  5481. if (this._updateCounter < this._numItems) {
  5482. var _len2 = this._updateCounter + this.frameByFrameRenderNum > this._numItems ? this._numItems : this._updateCounter + this.frameByFrameRenderNum;
  5483. for (var _n = this._updateCounter; _n < _len2; _n++) {
  5484. this._createOrUpdateItem2(_n);
  5485. }
  5486. this._updateCounter += this.frameByFrameRenderNum;
  5487. } else {
  5488. this._updateDone = true;
  5489. this._calcNearestItem();
  5490. if (this.slideMode == SlideType.PAGE) this.curPageNum = this.nearestListId;
  5491. }
  5492. }
  5493. }
  5494. /**
  5495. * 创建或更新Item(虚拟列表用)
  5496. * @param {Object} data 数据
  5497. */;
  5498. _proto._createOrUpdateItem = function _createOrUpdateItem(data) {
  5499. var item = this.getItemByListId(data.id);
  5500. if (!item) {
  5501. //如果不存在
  5502. var canGet = this._pool.size() > 0;
  5503. if (canGet) {
  5504. item = this._pool.get();
  5505. // cc.log('从池中取出:: 旧id =', item['_listId'], ',新id =', data.id, item);
  5506. } else {
  5507. item = instantiate(this._itemTmp);
  5508. // cc.log('新建::', data.id, item);
  5509. }
  5510. if (!canGet || !isValid(item)) {
  5511. item = instantiate(this._itemTmp);
  5512. canGet = false;
  5513. }
  5514. if (item._listId != data.id) {
  5515. item._listId = data.id;
  5516. var ut = item.getComponent(UITransform);
  5517. ut.setContentSize(this._itemSize);
  5518. }
  5519. item.setPosition(new Vec3(data.x, data.y, 0));
  5520. this._resetItemSize(item);
  5521. this.content.addChild(item);
  5522. if (canGet && this._needUpdateWidget) {
  5523. var widget = item.getComponent(Widget);
  5524. if (widget) widget.updateAlignment();
  5525. }
  5526. item.setSiblingIndex(this.content.children.length - 1);
  5527. var listItem = item.getComponent(ListItem);
  5528. item['listItem'] = listItem;
  5529. if (listItem) {
  5530. listItem.listId = data.id;
  5531. listItem.list = this;
  5532. listItem._registerEvent();
  5533. }
  5534. if (this.renderEvent) {
  5535. EventHandler.emitEvents([this.renderEvent], item, data.id % this._actualNumItems);
  5536. }
  5537. } else if (this._forceUpdate && this.renderEvent) {
  5538. //强制更新
  5539. item.setPosition(new Vec3(data.x, data.y, 0));
  5540. this._resetItemSize(item);
  5541. // cc.log('ADD::', data.id, item);
  5542. if (this.renderEvent) {
  5543. EventHandler.emitEvents([this.renderEvent], item, data.id % this._actualNumItems);
  5544. }
  5545. }
  5546. this._resetItemSize(item);
  5547. this._updateListItem(item['listItem']);
  5548. if (this._lastDisplayData.indexOf(data.id) < 0) {
  5549. this._lastDisplayData.push(data.id);
  5550. }
  5551. }
  5552. //创建或更新Item(非虚拟列表用)
  5553. ;
  5554. _proto._createOrUpdateItem2 = function _createOrUpdateItem2(listId) {
  5555. var item = this.content.children[listId];
  5556. var listItem;
  5557. if (!item) {
  5558. //如果不存在
  5559. item = instantiate(this._itemTmp);
  5560. item._listId = listId;
  5561. this.content.addChild(item);
  5562. listItem = item.getComponent(ListItem);
  5563. item['listItem'] = listItem;
  5564. if (listItem) {
  5565. listItem.listId = listId;
  5566. listItem.list = this;
  5567. listItem._registerEvent();
  5568. }
  5569. if (this.renderEvent) {
  5570. EventHandler.emitEvents([this.renderEvent], item, listId % this._actualNumItems);
  5571. }
  5572. } else if (this._forceUpdate && this.renderEvent) {
  5573. //强制更新
  5574. item._listId = listId;
  5575. if (listItem) listItem.listId = listId;
  5576. if (this.renderEvent) {
  5577. EventHandler.emitEvents([this.renderEvent], item, listId % this._actualNumItems);
  5578. }
  5579. }
  5580. this._updateListItem(listItem);
  5581. if (this._lastDisplayData.indexOf(listId) < 0) {
  5582. this._lastDisplayData.push(listId);
  5583. }
  5584. };
  5585. _proto._updateListItem = function _updateListItem(listItem) {
  5586. if (!listItem) return;
  5587. if (this.selectedMode > SelectedType.NONE) {
  5588. var item = listItem.node;
  5589. switch (this.selectedMode) {
  5590. case SelectedType.SINGLE:
  5591. listItem.selected = this.selectedId == item._listId;
  5592. break;
  5593. case SelectedType.MULT:
  5594. listItem.selected = this.multSelected.indexOf(item._listId) >= 0;
  5595. break;
  5596. }
  5597. }
  5598. }
  5599. //仅虚拟列表用
  5600. ;
  5601. _proto._resetItemSize = function _resetItemSize(item) {
  5602. return;
  5603. }
  5604. /**
  5605. * 更新Item位置
  5606. * @param {Number||Node} listIdOrItem
  5607. */;
  5608. _proto._updateItemPos = function _updateItemPos(listIdOrItem) {
  5609. var item = isNaN(listIdOrItem) ? listIdOrItem : this.getItemByListId(listIdOrItem);
  5610. var pos = this.getItemPos(item._listId);
  5611. item.setPosition(pos.x, pos.y);
  5612. }
  5613. /**
  5614. * 设置多选
  5615. * @param {Array} args 可以是单个listId,也可是个listId数组
  5616. * @param {Boolean} bool 值,如果为null的话,则直接用args覆盖
  5617. */;
  5618. _proto.setMultSelected = function setMultSelected(args, bool) {
  5619. var t = this;
  5620. if (!t.checkInited()) return;
  5621. if (!Array.isArray(args)) {
  5622. args = [args];
  5623. }
  5624. if (bool == null) {
  5625. t.multSelected = args;
  5626. } else {
  5627. var listId, sub;
  5628. if (bool) {
  5629. for (var n = args.length - 1; n >= 0; n--) {
  5630. listId = args[n];
  5631. sub = t.multSelected.indexOf(listId);
  5632. if (sub < 0) {
  5633. t.multSelected.push(listId);
  5634. }
  5635. }
  5636. } else {
  5637. for (var _n2 = args.length - 1; _n2 >= 0; _n2--) {
  5638. listId = args[_n2];
  5639. sub = t.multSelected.indexOf(listId);
  5640. if (sub >= 0) {
  5641. t.multSelected.splice(sub, 1);
  5642. }
  5643. }
  5644. }
  5645. }
  5646. t._forceUpdate = true;
  5647. t._onScrolling();
  5648. }
  5649. /**
  5650. * 获取多选数据
  5651. * @returns
  5652. */;
  5653. _proto.getMultSelected = function getMultSelected() {
  5654. return this.multSelected;
  5655. }
  5656. /**
  5657. * 多选是否有选择
  5658. * @param {number} listId 索引
  5659. * @returns
  5660. */;
  5661. _proto.hasMultSelected = function hasMultSelected(listId) {
  5662. return this.multSelected && this.multSelected.indexOf(listId) >= 0;
  5663. }
  5664. /**
  5665. * 更新指定的Item
  5666. * @param {Array} args 单个listId,或者数组
  5667. * @returns
  5668. */;
  5669. _proto.updateItem = function updateItem(args) {
  5670. if (!this.checkInited()) return;
  5671. if (!Array.isArray(args)) {
  5672. args = [args];
  5673. }
  5674. for (var n = 0, len = args.length; n < len; n++) {
  5675. var listId = args[n];
  5676. var item = this.getItemByListId(listId);
  5677. if (item) EventHandler.emitEvents([this.renderEvent], item, listId % this._actualNumItems);
  5678. }
  5679. }
  5680. /**
  5681. * 更新全部
  5682. */;
  5683. _proto.updateAll = function updateAll() {
  5684. if (!this.checkInited()) return;
  5685. this.numItems = this.numItems;
  5686. }
  5687. /**
  5688. * 根据ListID获取Item
  5689. * @param {Number} listId
  5690. * @returns
  5691. */;
  5692. _proto.getItemByListId = function getItemByListId(listId) {
  5693. if (this.content) {
  5694. for (var n = this.content.children.length - 1; n >= 0; n--) {
  5695. var item = this.content.children[n];
  5696. if (item._listId == listId) return item;
  5697. }
  5698. }
  5699. }
  5700. /**
  5701. * 获取在显示区域外的Item
  5702. * @returns
  5703. */;
  5704. _proto._getOutsideItem = function _getOutsideItem() {
  5705. var item;
  5706. var result = [];
  5707. for (var n = this.content.children.length - 1; n >= 0; n--) {
  5708. item = this.content.children[n];
  5709. if (!this.displayData.find(function (d) {
  5710. return d.id == item._listId;
  5711. })) {
  5712. result.push(item);
  5713. }
  5714. }
  5715. return result;
  5716. }
  5717. //删除显示区域以外的Item
  5718. ;
  5719. _proto._delRedundantItem = function _delRedundantItem() {
  5720. if (this._virtual) {
  5721. var arr = this._getOutsideItem();
  5722. for (var n = arr.length - 1; n >= 0; n--) {
  5723. var item = arr[n];
  5724. if (this._scrollItem && item._listId == this._scrollItem._listId) continue;
  5725. item.isCached = true;
  5726. this._pool.put(item);
  5727. for (var m = this._lastDisplayData.length - 1; m >= 0; m--) {
  5728. if (this._lastDisplayData[m] == item._listId) {
  5729. this._lastDisplayData.splice(m, 1);
  5730. break;
  5731. }
  5732. }
  5733. }
  5734. // cc.log('存入::', str, ' pool.length =', this._pool.length);
  5735. } else {
  5736. while (this.content.children.length > this._numItems) {
  5737. this._delSingleItem(this.content.children[this.content.children.length - 1]);
  5738. }
  5739. }
  5740. }
  5741. //删除单个Item
  5742. ;
  5743. _proto._delSingleItem = function _delSingleItem(item) {
  5744. // cc.log('DEL::', item['_listId'], item);
  5745. item.removeFromParent();
  5746. if (item.destroy) item.destroy();
  5747. item = null;
  5748. }
  5749. /**
  5750. * 动效删除Item(此方法只适用于虚拟列表,即_virtual=true)
  5751. * 一定要在回调函数里重新设置新的numItems进行刷新,毕竟本List是靠数据驱动的。
  5752. */;
  5753. _proto.aniDelItem = function aniDelItem(listId, callFunc, aniType) {
  5754. var t = this;
  5755. if (!t.checkInited() || t.cyclic || !t._virtual) return console.error('This function is not allowed to be called!');
  5756. if (!callFunc) return console.error('CallFunc are not allowed to be NULL, You need to delete the corresponding index in the data array in the CallFunc!');
  5757. if (t._aniDelRuning) return console.warn('Please wait for the current deletion to finish!');
  5758. var item = t.getItemByListId(listId);
  5759. var listItem;
  5760. if (!item) {
  5761. callFunc(listId);
  5762. return;
  5763. } else {
  5764. listItem = item.getComponent(ListItem);
  5765. }
  5766. t._aniDelRuning = true;
  5767. t._aniDelCB = callFunc;
  5768. t._aniDelItem = item;
  5769. t._aniDelBeforePos = item.position;
  5770. t._aniDelBeforeScale = item.scale;
  5771. var curLastId = t.displayData[t.displayData.length - 1].id;
  5772. var resetSelectedId = listItem.selected;
  5773. listItem.showAni(aniType, function () {
  5774. //判断有没有下一个,如果有的话,创建粗来
  5775. var newId;
  5776. if (curLastId < t._numItems - 2) {
  5777. newId = curLastId + 1;
  5778. }
  5779. if (newId != null) {
  5780. var newData = t._calcItemPos(newId);
  5781. t.displayData.push(newData);
  5782. if (t._virtual) t._createOrUpdateItem(newData);else t._createOrUpdateItem2(newId);
  5783. } else t._numItems--;
  5784. if (t.selectedMode == SelectedType.SINGLE) {
  5785. if (resetSelectedId) {
  5786. t._selectedId = -1;
  5787. } else if (t._selectedId - 1 >= 0) {
  5788. t._selectedId--;
  5789. }
  5790. } else if (t.selectedMode == SelectedType.MULT && t.multSelected.length) {
  5791. var sub = t.multSelected.indexOf(listId);
  5792. if (sub >= 0) {
  5793. t.multSelected.splice(sub, 1);
  5794. }
  5795. //多选的数据,在其后的全部减一
  5796. for (var n = t.multSelected.length - 1; n >= 0; n--) {
  5797. var id = t.multSelected[n];
  5798. if (id >= listId) t.multSelected[n]--;
  5799. }
  5800. }
  5801. if (t._customSize) {
  5802. if (t._customSize[listId]) delete t._customSize[listId];
  5803. var newCustomSize = {};
  5804. var size;
  5805. for (var _id in t._customSize) {
  5806. size = t._customSize[_id];
  5807. var idNumber = parseInt(_id);
  5808. newCustomSize[idNumber - (idNumber >= listId ? 1 : 0)] = size;
  5809. }
  5810. t._customSize = newCustomSize;
  5811. }
  5812. //后面的Item向前怼的动效
  5813. var sec = .2333;
  5814. var twe, haveCB;
  5815. for (var _n3 = newId != null ? newId : curLastId; _n3 >= listId + 1; _n3--) {
  5816. item = t.getItemByListId(_n3);
  5817. if (item) {
  5818. var posData = t._calcItemPos(_n3 - 1);
  5819. twe = tween(item).to(sec, {
  5820. position: new Vec3(posData.x, posData.y, 0)
  5821. });
  5822. if (_n3 <= listId + 1) {
  5823. haveCB = true;
  5824. twe.call(function () {
  5825. t._aniDelRuning = false;
  5826. callFunc(listId);
  5827. delete t._aniDelCB;
  5828. });
  5829. }
  5830. twe.start();
  5831. }
  5832. }
  5833. if (!haveCB) {
  5834. t._aniDelRuning = false;
  5835. callFunc(listId);
  5836. t._aniDelCB = null;
  5837. }
  5838. }, true);
  5839. }
  5840. /**
  5841. * 滚动到..
  5842. * @param {Number} listId 索引(如果<0,则滚到首个Item位置,如果>=_numItems,则滚到最末Item位置)
  5843. * @param {Number} timeInSecond 时间
  5844. * @param {Number} offset 索引目标位置偏移,0-1
  5845. * @param {Boolean} overStress 滚动后是否强调该Item(这只是个实验功能)
  5846. */;
  5847. _proto.scrollTo = function scrollTo(listId, timeInSecond, offset, overStress) {
  5848. if (timeInSecond === void 0) {
  5849. timeInSecond = .5;
  5850. }
  5851. if (offset === void 0) {
  5852. offset = null;
  5853. }
  5854. if (overStress === void 0) {
  5855. overStress = false;
  5856. }
  5857. var t = this;
  5858. if (!t.checkInited(false)) return;
  5859. // t._scrollView.stopAutoScroll();
  5860. if (timeInSecond == null)
  5861. //默认0.5
  5862. timeInSecond = .5;else if (timeInSecond < 0) timeInSecond = 0;
  5863. if (listId < 0) listId = 0;else if (listId >= t._numItems) listId = t._numItems - 1;
  5864. // 以防设置了numItems之后layout的尺寸还未更新
  5865. if (!t._virtual && t._layout && t._layout.enabled) t._layout.updateLayout();
  5866. var pos = t.getItemPos(listId);
  5867. if (!pos) {
  5868. return DEV;
  5869. }
  5870. var targetX, targetY;
  5871. switch (t._alignCalcType) {
  5872. case 1:
  5873. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  5874. targetX = pos.left;
  5875. if (offset != null) targetX -= t._thisNodeUt.width * offset;else targetX -= t._leftGap;
  5876. pos = new Vec3(targetX, 0, 0);
  5877. break;
  5878. case 2:
  5879. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  5880. targetX = pos.right - t._thisNodeUt.width;
  5881. if (offset != null) targetX += t._thisNodeUt.width * offset;else targetX += t._rightGap;
  5882. pos = new Vec3(targetX + t._contentUt.width, 0, 0);
  5883. break;
  5884. case 3:
  5885. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  5886. targetY = pos.top;
  5887. if (offset != null) targetY += t._thisNodeUt.height * offset;else targetY += t._topGap;
  5888. pos = new Vec3(0, -targetY, 0);
  5889. break;
  5890. case 4:
  5891. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  5892. targetY = pos.bottom + t._thisNodeUt.height;
  5893. if (offset != null) targetY -= t._thisNodeUt.height * offset;else targetY -= t._bottomGap;
  5894. pos = new Vec3(0, -targetY + t._contentUt.height, 0);
  5895. break;
  5896. }
  5897. var viewPos = t.content.getPosition();
  5898. viewPos = Math.abs(t._sizeType ? viewPos.y : viewPos.x);
  5899. var comparePos = t._sizeType ? pos.y : pos.x;
  5900. var runScroll = Math.abs((t._scrollPos != null ? t._scrollPos : viewPos) - comparePos) > .5;
  5901. // cc.log(runScroll, t._scrollPos, viewPos, comparePos)
  5902. // t._scrollView.stopAutoScroll();
  5903. if (runScroll) {
  5904. t._scrollView.scrollToOffset(pos, timeInSecond);
  5905. t._scrollToListId = listId;
  5906. t._scrollToEndTime = new Date().getTime() / 1000 + timeInSecond;
  5907. // cc.log(listId, t.content.width, t.content.getPosition(), pos);
  5908. t._scrollToSo = t.scheduleOnce(function () {
  5909. if (!t._adheringBarrier) {
  5910. t.adhering = t._adheringBarrier = false;
  5911. }
  5912. t._scrollPos = t._scrollToListId = t._scrollToEndTime = t._scrollToSo = null;
  5913. //cc.log('2222222222', t._adheringBarrier)
  5914. if (overStress) {
  5915. // t.scrollToListId = listId;
  5916. var item = t.getItemByListId(listId);
  5917. if (item) {
  5918. tween(item).to(.1, {
  5919. scale: 1.05
  5920. }).to(.1, {
  5921. scale: 1
  5922. }).start();
  5923. }
  5924. }
  5925. }, timeInSecond + .1);
  5926. if (timeInSecond <= 0) {
  5927. t._onScrolling();
  5928. }
  5929. }
  5930. }
  5931. /**
  5932. * 计算当前滚动窗最近的Item
  5933. */;
  5934. _proto._calcNearestItem = function _calcNearestItem() {
  5935. var t = this;
  5936. t.nearestListId = null;
  5937. var data, center;
  5938. if (t._virtual) t._calcViewPos();
  5939. var vTop, vRight, vBottom, vLeft;
  5940. vTop = t.viewTop;
  5941. vRight = t.viewRight;
  5942. vBottom = t.viewBottom;
  5943. vLeft = t.viewLeft;
  5944. var breakFor = false;
  5945. for (var n = 0; n < t.content.children.length && !breakFor; n += t._colLineNum) {
  5946. data = t._virtual ? t.displayData[n] : t._calcExistItemPos(n);
  5947. if (data) {
  5948. center = t._sizeType ? (data.top + data.bottom) / 2 : center = (data.left + data.right) / 2;
  5949. switch (t._alignCalcType) {
  5950. case 1:
  5951. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  5952. if (data.right >= vLeft) {
  5953. t.nearestListId = data.id;
  5954. if (vLeft > center) t.nearestListId += t._colLineNum;
  5955. breakFor = true;
  5956. }
  5957. break;
  5958. case 2:
  5959. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  5960. if (data.left <= vRight) {
  5961. t.nearestListId = data.id;
  5962. if (vRight < center) t.nearestListId += t._colLineNum;
  5963. breakFor = true;
  5964. }
  5965. break;
  5966. case 3:
  5967. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  5968. if (data.bottom <= vTop) {
  5969. t.nearestListId = data.id;
  5970. if (vTop < center) t.nearestListId += t._colLineNum;
  5971. breakFor = true;
  5972. }
  5973. break;
  5974. case 4:
  5975. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  5976. if (data.top >= vBottom) {
  5977. t.nearestListId = data.id;
  5978. if (vBottom > center) t.nearestListId += t._colLineNum;
  5979. breakFor = true;
  5980. }
  5981. break;
  5982. }
  5983. }
  5984. }
  5985. //判断最后一个Item。。。(哎,这些判断真心恶心,判断了前面的还要判断最后一个。。。一开始呢,就只有一个布局(单列布局),那时候代码才三百行,后来就想着完善啊,艹..这坑真深,现在这行数都一千五了= =||)
  5986. data = t._virtual ? t.displayData[t.displayItemNum - 1] : t._calcExistItemPos(t._numItems - 1);
  5987. if (data && data.id == t._numItems - 1) {
  5988. center = t._sizeType ? (data.top + data.bottom) / 2 : center = (data.left + data.right) / 2;
  5989. switch (t._alignCalcType) {
  5990. case 1:
  5991. //单行HORIZONTAL(LEFT_TO_RIGHT)、网格VERTICAL(LEFT_TO_RIGHT)
  5992. if (vRight > center) t.nearestListId = data.id;
  5993. break;
  5994. case 2:
  5995. //单行HORIZONTAL(RIGHT_TO_LEFT)、网格VERTICAL(RIGHT_TO_LEFT)
  5996. if (vLeft < center) t.nearestListId = data.id;
  5997. break;
  5998. case 3:
  5999. //单列VERTICAL(TOP_TO_BOTTOM)、网格HORIZONTAL(TOP_TO_BOTTOM)
  6000. if (vBottom < center) t.nearestListId = data.id;
  6001. break;
  6002. case 4:
  6003. //单列VERTICAL(BOTTOM_TO_TOP)、网格HORIZONTAL(BOTTOM_TO_TOP)
  6004. if (vTop > center) t.nearestListId = data.id;
  6005. break;
  6006. }
  6007. }
  6008. // cc.log('t.nearestListId =', t.nearestListId);
  6009. }
  6010. //上一页
  6011. ;
  6012. _proto.prePage = function prePage(timeInSecond) {
  6013. if (timeInSecond === void 0) {
  6014. timeInSecond = .5;
  6015. }
  6016. // cc.log('👈');
  6017. if (!this.checkInited()) return;
  6018. this.skipPage(this.curPageNum - 1, timeInSecond);
  6019. }
  6020. //下一页
  6021. ;
  6022. _proto.nextPage = function nextPage(timeInSecond) {
  6023. if (timeInSecond === void 0) {
  6024. timeInSecond = .5;
  6025. }
  6026. // cc.log('👉');
  6027. if (!this.checkInited()) return;
  6028. this.skipPage(this.curPageNum + 1, timeInSecond);
  6029. }
  6030. //跳转到第几页
  6031. ;
  6032. _proto.skipPage = function skipPage(pageNum, timeInSecond) {
  6033. var t = this;
  6034. if (!t.checkInited()) return;
  6035. if (t._slideMode != SlideType.PAGE) return console.error('This function is not allowed to be called, Must SlideMode = PAGE!');
  6036. if (pageNum < 0 || pageNum >= t._numItems) return;
  6037. if (t.curPageNum == pageNum) return;
  6038. // cc.log(pageNum);
  6039. t.curPageNum = pageNum;
  6040. if (t.pageChangeEvent) {
  6041. EventHandler.emitEvents([t.pageChangeEvent], pageNum);
  6042. }
  6043. t.scrollTo(pageNum, timeInSecond);
  6044. }
  6045. //计算 CustomSize(这个函数还是保留吧,某些罕见的情况的确还是需要手动计算customSize的)
  6046. ;
  6047. _proto.calcCustomSize = function calcCustomSize(numItems) {
  6048. var t = this;
  6049. if (!t.checkInited()) return;
  6050. if (!t._itemTmp) return console.error('Unset template item!');
  6051. if (!t.renderEvent) return console.error('Unset Render-Event!');
  6052. t._customSize = {};
  6053. var temp = instantiate(t._itemTmp);
  6054. var ut = temp.getComponent(UITransform);
  6055. t.content.addChild(temp);
  6056. for (var n = 0; n < numItems; n++) {
  6057. EventHandler.emitEvents([t.renderEvent], temp, n);
  6058. if (ut.height != t._itemSize.height || ut.width != t._itemSize.width) {
  6059. t._customSize[n] = t._sizeType ? ut.height : ut.width;
  6060. }
  6061. }
  6062. if (!Object.keys(t._customSize).length) t._customSize = null;
  6063. temp.removeFromParent();
  6064. if (temp.destroy) temp.destroy();
  6065. return t._customSize;
  6066. };
  6067. _createClass(List, [{
  6068. key: "slideMode",
  6069. get: function get() {
  6070. return this._slideMode;
  6071. },
  6072. set: function set(val) {
  6073. this._slideMode = val;
  6074. }
  6075. }, {
  6076. key: "virtual",
  6077. get: function get() {
  6078. return this._virtual;
  6079. },
  6080. set: function set(val) {
  6081. if (val != null) this._virtual = val;
  6082. if (this._numItems != 0) {
  6083. this._onScrolling();
  6084. }
  6085. }
  6086. }, {
  6087. key: "updateRate",
  6088. get: function get() {
  6089. return this._updateRate;
  6090. },
  6091. set: function set(val) {
  6092. if (val >= 0 && val <= 6) {
  6093. this._updateRate = val;
  6094. }
  6095. }
  6096. }, {
  6097. key: "selectedId",
  6098. get: function get() {
  6099. return this._selectedId;
  6100. },
  6101. set: function set(val) {
  6102. var t = this;
  6103. var item;
  6104. switch (t.selectedMode) {
  6105. case SelectedType.SINGLE:
  6106. {
  6107. if (!t.repeatEventSingle && val == t._selectedId) return;
  6108. item = t.getItemByListId(val);
  6109. // if (!item && val >= 0)
  6110. // return;
  6111. var listItem;
  6112. if (t._selectedId >= 0) t._lastSelectedId = t._selectedId;else
  6113. //如果<0则取消选择,把_lastSelectedId也置空吧,如果以后有特殊需求再改吧。
  6114. t._lastSelectedId = null;
  6115. t._selectedId = val;
  6116. if (item) {
  6117. listItem = item.getComponent(ListItem);
  6118. listItem.selected = true;
  6119. }
  6120. if (t._lastSelectedId >= 0 && t._lastSelectedId != t._selectedId) {
  6121. var lastItem = t.getItemByListId(t._lastSelectedId);
  6122. if (lastItem) {
  6123. lastItem.getComponent(ListItem).selected = false;
  6124. }
  6125. }
  6126. if (t.selectedEvent) {
  6127. EventHandler.emitEvents([t.selectedEvent], item, val % this._actualNumItems, t._lastSelectedId == null ? null : t._lastSelectedId % this._actualNumItems);
  6128. }
  6129. break;
  6130. }
  6131. case SelectedType.MULT:
  6132. {
  6133. item = t.getItemByListId(val);
  6134. if (!item) return;
  6135. var _listItem = item.getComponent(ListItem);
  6136. if (t._selectedId >= 0) t._lastSelectedId = t._selectedId;
  6137. t._selectedId = val;
  6138. var bool = !_listItem.selected;
  6139. _listItem.selected = bool;
  6140. var sub = t.multSelected.indexOf(val);
  6141. if (bool && sub < 0) {
  6142. t.multSelected.push(val);
  6143. } else if (!bool && sub >= 0) {
  6144. t.multSelected.splice(sub, 1);
  6145. }
  6146. if (t.selectedEvent) {
  6147. EventHandler.emitEvents([t.selectedEvent], item, val % this._actualNumItems, t._lastSelectedId == null ? null : t._lastSelectedId % this._actualNumItems, bool);
  6148. }
  6149. break;
  6150. }
  6151. }
  6152. }
  6153. }, {
  6154. key: "numItems",
  6155. get: function get() {
  6156. return this._actualNumItems;
  6157. },
  6158. set: function set(val) {
  6159. var t = this;
  6160. if (!t.checkInited(false)) return;
  6161. if (val == null || val < 0) {
  6162. console.error('numItems set the wrong::', val);
  6163. return;
  6164. }
  6165. t._actualNumItems = t._numItems = val;
  6166. t._forceUpdate = true;
  6167. if (t._virtual) {
  6168. t._resizeContent();
  6169. if (t.cyclic) {
  6170. t._numItems = t._cyclicNum * t._numItems;
  6171. }
  6172. t._onScrolling();
  6173. if (!t.frameByFrameRenderNum && t.slideMode == SlideType.PAGE) t.curPageNum = t.nearestListId;
  6174. } else {
  6175. if (t.cyclic) {
  6176. t._resizeContent();
  6177. t._numItems = t._cyclicNum * t._numItems;
  6178. }
  6179. var layout = t.content.getComponent(Layout);
  6180. if (layout) {
  6181. layout.enabled = true;
  6182. }
  6183. t._delRedundantItem();
  6184. t.firstListId = 0;
  6185. if (t.frameByFrameRenderNum > 0) {
  6186. //先渲染几个出来
  6187. var len = t.frameByFrameRenderNum > t._numItems ? t._numItems : t.frameByFrameRenderNum;
  6188. for (var n = 0; n < len; n++) {
  6189. t._createOrUpdateItem2(n);
  6190. }
  6191. if (t.frameByFrameRenderNum < t._numItems) {
  6192. t._updateCounter = t.frameByFrameRenderNum;
  6193. t._updateDone = false;
  6194. }
  6195. } else {
  6196. for (var _n4 = 0; _n4 < t._numItems; _n4++) {
  6197. t._createOrUpdateItem2(_n4);
  6198. }
  6199. t.displayItemNum = t._numItems;
  6200. }
  6201. }
  6202. }
  6203. }, {
  6204. key: "scrollView",
  6205. get: function get() {
  6206. return this._scrollView;
  6207. }
  6208. }]);
  6209. return List;
  6210. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "templateType", [_dec5], {
  6211. configurable: true,
  6212. enumerable: true,
  6213. writable: true,
  6214. initializer: function initializer() {
  6215. return TemplateType.NODE;
  6216. }
  6217. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "tmpNode", [_dec6], {
  6218. configurable: true,
  6219. enumerable: true,
  6220. writable: true,
  6221. initializer: function initializer() {
  6222. return null;
  6223. }
  6224. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "tmpPrefab", [_dec7], {
  6225. configurable: true,
  6226. enumerable: true,
  6227. writable: true,
  6228. initializer: function initializer() {
  6229. return null;
  6230. }
  6231. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_slideMode", [_dec8], {
  6232. configurable: true,
  6233. enumerable: true,
  6234. writable: true,
  6235. initializer: function initializer() {
  6236. return SlideType.NORMAL;
  6237. }
  6238. }), _applyDecoratedDescriptor(_class2.prototype, "slideMode", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "slideMode"), _class2.prototype), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "pageDistance", [_dec10], {
  6239. configurable: true,
  6240. enumerable: true,
  6241. writable: true,
  6242. initializer: function initializer() {
  6243. return .3;
  6244. }
  6245. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "pageChangeEvent", [_dec11], {
  6246. configurable: true,
  6247. enumerable: true,
  6248. writable: true,
  6249. initializer: function initializer() {
  6250. return new EventHandler();
  6251. }
  6252. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "_virtual", [_dec12], {
  6253. configurable: true,
  6254. enumerable: true,
  6255. writable: true,
  6256. initializer: function initializer() {
  6257. return true;
  6258. }
  6259. }), _applyDecoratedDescriptor(_class2.prototype, "virtual", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "virtual"), _class2.prototype), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "cyclic", [_dec14], {
  6260. configurable: true,
  6261. enumerable: true,
  6262. writable: true,
  6263. initializer: function initializer() {
  6264. return false;
  6265. }
  6266. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "lackCenter", [_dec15], {
  6267. configurable: true,
  6268. enumerable: true,
  6269. writable: true,
  6270. initializer: function initializer() {
  6271. return false;
  6272. }
  6273. }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "lackSlide", [_dec16], {
  6274. configurable: true,
  6275. enumerable: true,
  6276. writable: true,
  6277. initializer: function initializer() {
  6278. return false;
  6279. }
  6280. }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "_updateRate", [_dec17], {
  6281. configurable: true,
  6282. enumerable: true,
  6283. writable: true,
  6284. initializer: function initializer() {
  6285. return 0;
  6286. }
  6287. }), _applyDecoratedDescriptor(_class2.prototype, "updateRate", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "updateRate"), _class2.prototype), _descriptor12 = _applyDecoratedDescriptor(_class2.prototype, "frameByFrameRenderNum", [_dec19], {
  6288. configurable: true,
  6289. enumerable: true,
  6290. writable: true,
  6291. initializer: function initializer() {
  6292. return 0;
  6293. }
  6294. }), _descriptor13 = _applyDecoratedDescriptor(_class2.prototype, "renderEvent", [_dec20], {
  6295. configurable: true,
  6296. enumerable: true,
  6297. writable: true,
  6298. initializer: function initializer() {
  6299. return new EventHandler();
  6300. }
  6301. }), _descriptor14 = _applyDecoratedDescriptor(_class2.prototype, "selectedMode", [_dec21], {
  6302. configurable: true,
  6303. enumerable: true,
  6304. writable: true,
  6305. initializer: function initializer() {
  6306. return SelectedType.NONE;
  6307. }
  6308. }), _descriptor15 = _applyDecoratedDescriptor(_class2.prototype, "selectedEvent", [_dec22], {
  6309. configurable: true,
  6310. enumerable: true,
  6311. writable: true,
  6312. initializer: function initializer() {
  6313. return new EventHandler();
  6314. }
  6315. }), _descriptor16 = _applyDecoratedDescriptor(_class2.prototype, "repeatEventSingle", [_dec23], {
  6316. configurable: true,
  6317. enumerable: true,
  6318. writable: true,
  6319. initializer: function initializer() {
  6320. return false;
  6321. }
  6322. }), _descriptor17 = _applyDecoratedDescriptor(_class2.prototype, "_numItems", [_dec24], {
  6323. configurable: true,
  6324. enumerable: true,
  6325. writable: true,
  6326. initializer: function initializer() {
  6327. return 0;
  6328. }
  6329. })), _class2)) || _class) || _class) || _class) || _class) || _class));
  6330. cclegacy._RF.pop();
  6331. }
  6332. };
  6333. });
  6334. System.register("chunks:///_virtual/ListItem.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './env'], function (exports) {
  6335. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _createClass, cclegacy, _decorator, Sprite, Node, Enum, SpriteFrame, EventHandler, UITransform, tween, Vec3, Button, Component, DEV;
  6336. return {
  6337. setters: [function (module) {
  6338. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  6339. _inheritsLoose = module.inheritsLoose;
  6340. _initializerDefineProperty = module.initializerDefineProperty;
  6341. _assertThisInitialized = module.assertThisInitialized;
  6342. _createClass = module.createClass;
  6343. }, function (module) {
  6344. cclegacy = module.cclegacy;
  6345. _decorator = module._decorator;
  6346. Sprite = module.Sprite;
  6347. Node = module.Node;
  6348. Enum = module.Enum;
  6349. SpriteFrame = module.SpriteFrame;
  6350. EventHandler = module.EventHandler;
  6351. UITransform = module.UITransform;
  6352. tween = module.tween;
  6353. Vec3 = module.Vec3;
  6354. Button = module.Button;
  6355. Component = module.Component;
  6356. }, function (module) {
  6357. DEV = module.DEV;
  6358. }],
  6359. execute: function () {
  6360. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
  6361. cclegacy._RF.push({}, "d2ed4KwTq5JtZePzUbNaDYC", "ListItem", undefined);
  6362. /******************************************
  6363. * @author kL <klk0@qq.com>
  6364. * @date 2019/12/9
  6365. * @doc 列表Item组件.
  6366. * 说明:
  6367. * 1、此组件须配合List组件使用。(配套的配套的..)
  6368. * @end
  6369. ******************************************/
  6370. var ccclass = _decorator.ccclass,
  6371. property = _decorator.property,
  6372. disallowMultiple = _decorator.disallowMultiple,
  6373. menu = _decorator.menu,
  6374. executionOrder = _decorator.executionOrder;
  6375. var SelectedType = /*#__PURE__*/function (SelectedType) {
  6376. SelectedType[SelectedType["NONE"] = 0] = "NONE";
  6377. SelectedType[SelectedType["TOGGLE"] = 1] = "TOGGLE";
  6378. SelectedType[SelectedType["SWITCH"] = 2] = "SWITCH";
  6379. return SelectedType;
  6380. }(SelectedType || {});
  6381. var ListItem = exports('default', (_dec = disallowMultiple(), _dec2 = menu('List Item'), _dec3 = executionOrder(-5001), _dec4 = property({
  6382. type: Sprite,
  6383. tooltip: DEV
  6384. }), _dec5 = property({
  6385. type: Node,
  6386. tooltip: DEV
  6387. }), _dec6 = property({
  6388. type: Enum(SelectedType),
  6389. tooltip: DEV
  6390. }), _dec7 = property({
  6391. type: Node,
  6392. tooltip: DEV,
  6393. visible: function visible() {
  6394. return this.selectedMode > SelectedType.NONE;
  6395. }
  6396. }), _dec8 = property({
  6397. type: SpriteFrame,
  6398. tooltip: DEV,
  6399. visible: function visible() {
  6400. return this.selectedMode == SelectedType.SWITCH;
  6401. }
  6402. }), _dec9 = property({
  6403. tooltip: DEV
  6404. }), ccclass(_class = _dec(_class = _dec2(_class = _dec3(_class = (_class2 = /*#__PURE__*/function (_Component) {
  6405. _inheritsLoose(ListItem, _Component);
  6406. function ListItem() {
  6407. var _this;
  6408. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  6409. args[_key] = arguments[_key];
  6410. }
  6411. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  6412. //图标
  6413. _initializerDefineProperty(_this, "icon", _descriptor, _assertThisInitialized(_this));
  6414. //标题
  6415. _initializerDefineProperty(_this, "title", _descriptor2, _assertThisInitialized(_this));
  6416. //选择模式
  6417. _initializerDefineProperty(_this, "selectedMode", _descriptor3, _assertThisInitialized(_this));
  6418. //被选标志
  6419. _initializerDefineProperty(_this, "selectedFlag", _descriptor4, _assertThisInitialized(_this));
  6420. //被选择的SpriteFrame
  6421. _initializerDefineProperty(_this, "selectedSpriteFrame", _descriptor5, _assertThisInitialized(_this));
  6422. //未被选择的SpriteFrame
  6423. _this._unselectedSpriteFrame = null;
  6424. //自适应尺寸
  6425. _initializerDefineProperty(_this, "adaptiveSize", _descriptor6, _assertThisInitialized(_this));
  6426. //选择
  6427. _this._selected = false;
  6428. //按钮组件
  6429. _this._btnCom = void 0;
  6430. //依赖的List组件
  6431. _this.list = void 0;
  6432. //是否已经注册过事件
  6433. _this._eventReg = false;
  6434. //序列id
  6435. _this.listId = void 0;
  6436. return _this;
  6437. }
  6438. var _proto = ListItem.prototype;
  6439. _proto.onLoad = function onLoad() {
  6440. // //没有按钮组件的话,selectedFlag无效
  6441. // if (!this.btnCom)
  6442. // this.selectedMode == SelectedType.NONE;
  6443. //有选择模式时,保存相应的东西
  6444. if (this.selectedMode == SelectedType.SWITCH) {
  6445. var com = this.selectedFlag.getComponent(Sprite);
  6446. this._unselectedSpriteFrame = com.spriteFrame;
  6447. }
  6448. };
  6449. _proto.onDestroy = function onDestroy() {
  6450. this.node.off(Node.EventType.SIZE_CHANGED, this._onSizeChange, this);
  6451. };
  6452. _proto._registerEvent = function _registerEvent() {
  6453. if (!this._eventReg) {
  6454. if (this.btnCom && this.list.selectedMode > 0) {
  6455. this.btnCom.clickEvents.unshift(this.createEvt(this, 'onClickThis'));
  6456. }
  6457. if (this.adaptiveSize) {
  6458. this.node.on(Node.EventType.SIZE_CHANGED, this._onSizeChange, this);
  6459. }
  6460. this._eventReg = true;
  6461. }
  6462. };
  6463. _proto._onSizeChange = function _onSizeChange() {
  6464. this.list._onItemAdaptive(this.node);
  6465. }
  6466. /**
  6467. * 创建事件
  6468. * @param {cc.Component} component 组件脚本
  6469. * @param {string} handlerName 触发函数名称
  6470. * @param {cc.Node} node 组件所在node(不传的情况下取component.node)
  6471. * @returns cc.Component.EventHandler
  6472. */;
  6473. _proto.createEvt = function createEvt(component, handlerName, node) {
  6474. if (node === void 0) {
  6475. node = null;
  6476. }
  6477. if (!component.isValid) return; //有些异步加载的,节点以及销毁了。
  6478. component['comName'] = component['comName'] || component.name.match(/\<(.*?)\>/g).pop().replace(/\<|>/g, '');
  6479. var evt = new EventHandler();
  6480. evt.target = node || component.node;
  6481. evt.component = component['comName'];
  6482. evt.handler = handlerName;
  6483. return evt;
  6484. };
  6485. _proto.showAni = function showAni(aniType, callFunc, del) {
  6486. var t = this;
  6487. var twe;
  6488. var ut = t.node.getComponent(UITransform);
  6489. switch (aniType) {
  6490. case 0:
  6491. //向上消失
  6492. twe = tween(t.node).to(.2, {
  6493. scale: new Vec3(.7, .7)
  6494. }).by(.3, {
  6495. position: new Vec3(0, ut.height * 2)
  6496. });
  6497. break;
  6498. case 1:
  6499. //向右消失
  6500. twe = tween(t.node).to(.2, {
  6501. scale: new Vec3(.7, .7)
  6502. }).by(.3, {
  6503. position: new Vec3(ut.width * 2, 0)
  6504. });
  6505. break;
  6506. case 2:
  6507. //向下消失
  6508. twe = tween(t.node).to(.2, {
  6509. scale: new Vec3(.7, .7)
  6510. }).by(.3, {
  6511. position: new Vec3(0, ut.height * -2)
  6512. });
  6513. break;
  6514. case 3:
  6515. //向左消失
  6516. twe = tween(t.node).to(.2, {
  6517. scale: new Vec3(.7, .7)
  6518. }).by(.3, {
  6519. position: new Vec3(ut.width * -2, 0)
  6520. });
  6521. break;
  6522. default:
  6523. //默认:缩小消失
  6524. twe = tween(t.node).to(.3, {
  6525. scale: new Vec3(.1, .1)
  6526. });
  6527. break;
  6528. }
  6529. if (callFunc || del) {
  6530. twe.call(function () {
  6531. if (del) {
  6532. t.list._delSingleItem(t.node);
  6533. for (var n = t.list.displayData.length - 1; n >= 0; n--) {
  6534. if (t.list.displayData[n].id == t.listId) {
  6535. t.list.displayData.splice(n, 1);
  6536. break;
  6537. }
  6538. }
  6539. }
  6540. callFunc();
  6541. });
  6542. }
  6543. twe.start();
  6544. };
  6545. _proto.onClickThis = function onClickThis() {
  6546. this.list.selectedId = this.listId;
  6547. };
  6548. _createClass(ListItem, [{
  6549. key: "selected",
  6550. get: function get() {
  6551. return this._selected;
  6552. },
  6553. set: function set(val) {
  6554. this._selected = val;
  6555. if (!this.selectedFlag) return;
  6556. switch (this.selectedMode) {
  6557. case SelectedType.TOGGLE:
  6558. this.selectedFlag.active = val;
  6559. break;
  6560. case SelectedType.SWITCH:
  6561. var sp = this.selectedFlag.getComponent(Sprite);
  6562. if (sp) {
  6563. sp.spriteFrame = val ? this.selectedSpriteFrame : this._unselectedSpriteFrame;
  6564. }
  6565. break;
  6566. }
  6567. }
  6568. }, {
  6569. key: "btnCom",
  6570. get: function get() {
  6571. if (!this._btnCom) this._btnCom = this.node.getComponent(Button);
  6572. return this._btnCom;
  6573. }
  6574. }]);
  6575. return ListItem;
  6576. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "icon", [_dec4], {
  6577. configurable: true,
  6578. enumerable: true,
  6579. writable: true,
  6580. initializer: function initializer() {
  6581. return null;
  6582. }
  6583. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "title", [_dec5], {
  6584. configurable: true,
  6585. enumerable: true,
  6586. writable: true,
  6587. initializer: function initializer() {
  6588. return null;
  6589. }
  6590. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "selectedMode", [_dec6], {
  6591. configurable: true,
  6592. enumerable: true,
  6593. writable: true,
  6594. initializer: function initializer() {
  6595. return SelectedType.NONE;
  6596. }
  6597. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "selectedFlag", [_dec7], {
  6598. configurable: true,
  6599. enumerable: true,
  6600. writable: true,
  6601. initializer: function initializer() {
  6602. return null;
  6603. }
  6604. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "selectedSpriteFrame", [_dec8], {
  6605. configurable: true,
  6606. enumerable: true,
  6607. writable: true,
  6608. initializer: function initializer() {
  6609. return null;
  6610. }
  6611. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "adaptiveSize", [_dec9], {
  6612. configurable: true,
  6613. enumerable: true,
  6614. writable: true,
  6615. initializer: function initializer() {
  6616. return false;
  6617. }
  6618. })), _class2)) || _class) || _class) || _class) || _class));
  6619. cclegacy._RF.pop();
  6620. }
  6621. };
  6622. });
  6623. System.register("chunks:///_virtual/LocalStorageUtil.ts", ['cc'], function (exports) {
  6624. var cclegacy, sys;
  6625. return {
  6626. setters: [function (module) {
  6627. cclegacy = module.cclegacy;
  6628. sys = module.sys;
  6629. }],
  6630. execute: function () {
  6631. cclegacy._RF.push({}, "d8e88J+Q9RPtY3fFaop4Z7i", "LocalStorageUtil", undefined);
  6632. var LocalStorageUtil = exports('LocalStorageUtil', /*#__PURE__*/function () {
  6633. LocalStorageUtil.getInstance = function getInstance() {
  6634. if (!this._inst) this._inst = new LocalStorageUtil();
  6635. return this._inst;
  6636. }
  6637. //缓存
  6638. ;
  6639. function LocalStorageUtil() {
  6640. this.temporary = void 0;
  6641. this._user_id = void 0;
  6642. this.temporary = new Map();
  6643. }
  6644. var _proto = LocalStorageUtil.prototype;
  6645. _proto.setUserId = function setUserId(uk) {
  6646. this._user_id = uk;
  6647. }
  6648. /**
  6649. * 缓存变量存储区别用户
  6650. * @param {*} key
  6651. * @param {*} value
  6652. */;
  6653. _proto.set = function set(key, value) {
  6654. if (typeof value === 'object') {
  6655. try {
  6656. value = JSON.stringify(value);
  6657. } catch (e) {
  6658. console.error("\u89E3\u6790\u5931\u8D25\uFF0Cstr = " + value);
  6659. return;
  6660. }
  6661. } else if (typeof value === 'number') {
  6662. value = value + "";
  6663. }
  6664. if (this._user_id) sys.localStorage.setItem(this._user_id + "_" + key, value);else sys.localStorage.setItem(key, value);
  6665. return value;
  6666. }
  6667. /**
  6668. * 获取缓存变量区别用户
  6669. * @param {*} key
  6670. * @returns
  6671. */;
  6672. _proto.get = function get(key) {
  6673. if (null == key) {
  6674. console.error("存储的key不能为空");
  6675. return null;
  6676. }
  6677. var data;
  6678. if (this._user_id) data = sys.localStorage.getItem(this._user_id + "_" + key);else data = sys.localStorage.getItem(key);
  6679. if (!data) return undefined;
  6680. return data;
  6681. }
  6682. /** 获取指定关键字的数值 */;
  6683. _proto.getNumber = function getNumber(key, defaultValue) {
  6684. if (defaultValue === void 0) {
  6685. defaultValue = 0;
  6686. }
  6687. var r = this.get(key);
  6688. if (r == "0") {
  6689. return Number(r);
  6690. }
  6691. return Number(r) || defaultValue;
  6692. }
  6693. /** 获取指定关键字的布尔值 */;
  6694. _proto.getBoolean = function getBoolean(key) {
  6695. var r = this.get(key);
  6696. return Boolean(r) || false;
  6697. }
  6698. /** 获取指定关键字的JSON对象 */;
  6699. _proto.getJson = function getJson(key, defaultValue) {
  6700. var r = this.get(key);
  6701. return r && JSON.parse(r) || defaultValue;
  6702. }
  6703. /** 获取指定关键字的JSON对象 */;
  6704. _proto.getObject = function getObject(key) {
  6705. var data = this.get(key);
  6706. try {
  6707. var jsonObj = JSON.parse(data);
  6708. return jsonObj;
  6709. } catch (error) {
  6710. return data;
  6711. }
  6712. }
  6713. /**
  6714. * 删除缓存变量
  6715. * @param {*} key
  6716. */;
  6717. _proto.removeNormalObject = function removeNormalObject(key) {
  6718. sys.localStorage.removeItem(key);
  6719. }
  6720. /**
  6721. * 缓存变量存储
  6722. * @param {*} key
  6723. * @param {*} value
  6724. */;
  6725. _proto.setNormalObject = function setNormalObject(key, value) {
  6726. sys.localStorage.setItem(key, JSON.stringify(value));
  6727. return value;
  6728. }
  6729. /**
  6730. * 获取缓存变量
  6731. * @param {*} key
  6732. * @returns
  6733. */;
  6734. _proto.getNormalObject = function getNormalObject(key) {
  6735. var data;
  6736. data = sys.localStorage.getItem(key);
  6737. if (!data) return undefined;
  6738. try {
  6739. var jsonObj = JSON.parse(data);
  6740. return jsonObj;
  6741. } catch (error) {
  6742. return data;
  6743. }
  6744. }
  6745. /**
  6746. * 删除缓存变量
  6747. * @param {*} key
  6748. */;
  6749. _proto.removeObject = function removeObject(key) {
  6750. sys.localStorage.removeItem(key);
  6751. }
  6752. /**
  6753. * 临时变量存储
  6754. * @param {*} key
  6755. * @param {*} value
  6756. */;
  6757. _proto.setTempObject = function setTempObject(key, value) {
  6758. this.temporary.set(key, value);
  6759. }
  6760. /**
  6761. * 获取临时变量
  6762. * @param {*} key
  6763. * @returns
  6764. */;
  6765. _proto.getTempObject = function getTempObject(key) {
  6766. return this.temporary.get(key);
  6767. }
  6768. /**
  6769. * 删除临时变量
  6770. * @param {*} key
  6771. */;
  6772. _proto.removeTempObject = function removeTempObject(key) {
  6773. this.temporary["delete"](key);
  6774. };
  6775. return LocalStorageUtil;
  6776. }());
  6777. LocalStorageUtil._inst = void 0;
  6778. cclegacy._RF.pop();
  6779. }
  6780. };
  6781. });
  6782. System.register("chunks:///_virtual/main", ['./ModuleDef.ts', './SceneDef.ts', './audio.ts', './ch.ts', './ch_util.ts', './NetBase.ts', './NetPlayer.ts', './NetRoom.ts', './NetTeam.ts', './WsClient.ts', './net.ts', './ch_pvp.ts', './sign.ts', './ch_sdk_comp.ts', './ch_start_pack.ts', './ui.ts', './ui_ResolutionAutoFit.ts', './ui_base.ts', './ArrayUtil.ts', './DataTimeUtil.ts', './DirectorUtil.ts', './Instance.ts', './LocalStorageUtil.ts', './MathUtil.ts', './PathUtil.ts', './ProjectileMathUtil.ts', './ResUtil.ts', './StringUtil.ts', './TableLoadUtil.ts', './UrlUtil.ts', './Utils.ts', './Action.ts', './Container.ts', './Delay.ts', './FMS.ts', './GameData.ts', './HeadIcon.ts', './Line2DMove.ts', './PeriodData.ts', './PrefabPool.ts', './Queue.ts', './Random.ts', './SafeNumber.ts', './Shake.ts', './State.ts', './TimeJobCenter.ts', './Timer.ts', './Toast.ts', './Wait.ts', './ClickPenetrate.ts', './Game.ts', './List.ts', './ListItem.ts', './MotionTrail.ts', './MovieClip.ts', './RewardFly.ts', './SpineView.ts', './UISpineMovie.ts', './Start.ts'], function () {
  6783. return {
  6784. setters: [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null],
  6785. execute: function () {}
  6786. };
  6787. });
  6788. System.register("chunks:///_virtual/MathUtil.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  6789. var _createClass, cclegacy, Vec3, Vec2, misc;
  6790. return {
  6791. setters: [function (module) {
  6792. _createClass = module.createClass;
  6793. }, function (module) {
  6794. cclegacy = module.cclegacy;
  6795. Vec3 = module.Vec3;
  6796. Vec2 = module.Vec2;
  6797. misc = module.misc;
  6798. }],
  6799. execute: function () {
  6800. cclegacy._RF.push({}, "5df23qNkJ5Jco4b72bZLJJf", "MathUtil", undefined);
  6801. /** 用于计算的临时工 */
  6802. var tempVec3 = new Vec3();
  6803. /** 用于弧度转角度 */
  6804. var rad2Deg = 180 / Math.PI;
  6805. /** 用于角度转弧度 */
  6806. var deg2Rad = Math.PI / 180;
  6807. var MathUtil = exports('MathUtil', /*#__PURE__*/function () {
  6808. function MathUtil() {}
  6809. /**
  6810. * 弧度转角度
  6811. * @param radians
  6812. */
  6813. MathUtil.radiansToDegrees = function radiansToDegrees(radians) {
  6814. return radians * rad2Deg;
  6815. }
  6816. /**
  6817. * 角度转弧度
  6818. * @param degree
  6819. */;
  6820. MathUtil.degreesToRadians = function degreesToRadians(degree) {
  6821. return degree * deg2Rad;
  6822. }
  6823. /**限制数大小 */;
  6824. MathUtil.Clamp = function Clamp(value, min, max) {
  6825. if (value < min) {
  6826. value = min;
  6827. } else if (value > max) {
  6828. value = max;
  6829. }
  6830. return value;
  6831. };
  6832. MathUtil.Clamp01 = function Clamp01(value) {
  6833. return this.Clamp(value, 0, 1);
  6834. };
  6835. MathUtil.PingPong = function PingPong(t, length) {
  6836. t = this.Repeat(t, length * 2);
  6837. return length - Math.abs(t - length);
  6838. };
  6839. MathUtil.Repeat = function Repeat(t, length) {
  6840. return t - Math.floor(t / length) * length;
  6841. };
  6842. MathUtil.Round = function Round(num) {
  6843. return Math.floor(num + 0.5);
  6844. };
  6845. MathUtil.Sign = function Sign(num) {
  6846. if (num > 0) {
  6847. num = 1;
  6848. } else if (num < 0) {
  6849. num = -1;
  6850. } else {
  6851. num = 0;
  6852. }
  6853. return num;
  6854. };
  6855. MathUtil.InverseLerp = function InverseLerp(from, to, value) {
  6856. if (from < to) {
  6857. if (value < from) return 0;
  6858. if (value > to) return 1;
  6859. value = value - from;
  6860. value = value / (to - from);
  6861. return value;
  6862. }
  6863. if (from <= to) return 0;
  6864. if (value < to) return 1;
  6865. if (value > from) return 0;
  6866. return 1 - (value - to) / (from - to);
  6867. };
  6868. MathUtil.Lerp = function Lerp(from, to, t) {
  6869. return from + (to - from) * this.Clamp01(t);
  6870. };
  6871. MathUtil.LerpUnclamped = function LerpUnclamped(a, b, t) {
  6872. return a + (b - a) * t;
  6873. };
  6874. MathUtil.DeltaAngle = function DeltaAngle(current, target) {
  6875. var num = this.Repeat(target - current, 360);
  6876. if (num > 180) num = num - 360;
  6877. return num;
  6878. };
  6879. MathUtil.LerpAngle = function LerpAngle(a, b, t) {
  6880. var num = this.Repeat(b - a, 360);
  6881. if (num > 180) num = num - 360;
  6882. return a + num * this.Clamp01(t);
  6883. }
  6884. /**
  6885. * 在最小值和最大值之间进行插值,并在极限处进行平滑处理
  6886. * @param from
  6887. * @param to
  6888. * @param t
  6889. */;
  6890. MathUtil.smoothStep = function smoothStep(from, to, t) {
  6891. t = this.Clamp01(t);
  6892. t = -2.0 * t * t * t + 3.0 * t * t;
  6893. return to * t + from * (1.0 - t);
  6894. }
  6895. /**
  6896. * 平滑控制
  6897. * @param current 当前值
  6898. * @param target 目标值
  6899. * @param currentVelocity 当前速度
  6900. * @param smoothTime 平滑时间
  6901. * @param maxSpeed 最大速度
  6902. * @param deltaTime 时间增量
  6903. */;
  6904. MathUtil.smoothDamp = function smoothDamp(current, target, currentVelocity, smoothTime, deltaTime, maxSpeed) {
  6905. if (maxSpeed === void 0) {
  6906. maxSpeed = Number.POSITIVE_INFINITY;
  6907. }
  6908. smoothTime = Math.max(0.0001, smoothTime);
  6909. var num1 = 2 / smoothTime;
  6910. var num2 = num1 * deltaTime;
  6911. var num3 = 1 / (1 + num2 + 0.47999998927116394 * num2 * num2 + 0.23499999940395355 * num2 * num2 * num2);
  6912. var num4 = current - target;
  6913. var num5 = target;
  6914. var max = maxSpeed * smoothTime;
  6915. var num6 = this.Clamp(num4, -max, max);
  6916. target = current - num6;
  6917. var num7 = (currentVelocity + num1 * num6) * deltaTime;
  6918. var velocity = (currentVelocity - num1 * num7) * num3;
  6919. var num8 = target + (num6 + num7) * num3;
  6920. if (num5 - current > 0 === num8 > num5) {
  6921. num8 = num5;
  6922. velocity = (num8 - num5) / deltaTime;
  6923. }
  6924. return {
  6925. value: num8,
  6926. velocity: velocity
  6927. };
  6928. }
  6929. /**
  6930. * 垂直于原向量V的单位向量
  6931. * @param v 一个向量
  6932. * @returns
  6933. */;
  6934. MathUtil.getPerpendicular = function getPerpendicular(v) {
  6935. var perpendicular = new Vec2(-v.y, v.x); //计算垂直向量
  6936. var normal = perpendicular.normalize(); //归一化
  6937. return normal;
  6938. }
  6939. //角度转向量
  6940. ;
  6941. MathUtil.angleToVector = function angleToVector(angle) {
  6942. return this.zore.clone().rotate(-misc.degreesToRadians(angle));
  6943. }
  6944. // 向量转角度
  6945. ;
  6946. MathUtil.vectorToAngle = function vectorToAngle(dir) {
  6947. return -misc.radiansToDegrees(dir.signAngle(this.zore));
  6948. }
  6949. // 角度转向量
  6950. ;
  6951. MathUtil.angle_to_vector = function angle_to_vector(angle) {
  6952. // tan = sin / cos
  6953. // 将传入的角度转为弧度
  6954. var radian = this.degreesToRadians(angle);
  6955. // 算出cos,sin和tan
  6956. var cos = Math.cos(radian); // 邻边 / 斜边
  6957. var sin = Math.sin(radian); // 对边 / 斜边
  6958. // 结合在一起并归一化
  6959. var vec = new Vec2(cos, sin).normalize();
  6960. // 返回向量
  6961. return vec;
  6962. }
  6963. // !!!!!!!!其实使用Math.atan2求出弧度再转角度一样的效果
  6964. // 向量转角度
  6965. ;
  6966. MathUtil.vector_to_angle = function vector_to_angle(dir) {
  6967. // 将传入的向量归一化 一般已经归一化了
  6968. //dir.normalize();
  6969. // 计算出目标角度的弧度
  6970. var radian = dir.signAngle(this.zore);
  6971. // 把弧度计算成角度
  6972. var angle = -this.radiansToDegrees(radian);
  6973. // 返回角度
  6974. return angle;
  6975. }
  6976. //向量转弧度
  6977. ;
  6978. MathUtil.vector_to_radian = function vector_to_radian(dir) {
  6979. return dir.signAngle(this.zore);
  6980. }
  6981. /// <summary>
  6982. /// 旋转向量,使其方向改变,大小不变
  6983. /// </summary>
  6984. /// <param name="v">需要旋转的向量</param>
  6985. /// <param name="angle">旋转的角度</param>
  6986. /// <returns>旋转后的向量</returns>
  6987. ;
  6988. MathUtil.RotationMatrix = function RotationMatrix(x, y, angle) {
  6989. var radian = this.degreesToRadians(angle);
  6990. var sin = Math.sin(radian);
  6991. var cos = Math.cos(radian);
  6992. var newX = x * cos + y * sin;
  6993. var newY = x * -sin + y * cos;
  6994. //var newX = x * cos - y * sin;
  6995. //var newY = x * sin + y * cos;
  6996. return new Vec2(newX, newY);
  6997. };
  6998. MathUtil.RotationDir = function RotationDir(dir, angle) {
  6999. var radian = this.radiansToDegrees(angle);
  7000. var sin = Math.sin(radian);
  7001. var cos = Math.cos(radian);
  7002. var newX = dir.x * cos + dir.y * sin;
  7003. var newY = dir.x * -sin + dir.y * cos;
  7004. dir.x = newX;
  7005. dir.y = newY;
  7006. return dir;
  7007. }
  7008. //扇形范围
  7009. ;
  7010. MathUtil.CheckInView = function CheckInView(mPos, faceDir, tPos, dis, angle) {
  7011. //let t = tPos.subtract(mPos);
  7012. //let distance = Vec2.lengthSqr(t);
  7013. //if(distance<dis*dis)
  7014. var distance = Vec2.distance(mPos, tPos);
  7015. if (distance < dis) {
  7016. if (angle >= 360) return true;
  7017. var dir = tPos.subtract(mPos).normalize();
  7018. var ang = this.radiansToDegrees(Vec2.angle(faceDir, dir));
  7019. if (ang <= angle * 0.5) {
  7020. return true;
  7021. }
  7022. }
  7023. return false;
  7024. }
  7025. //检测点是否在一个凸四边形内
  7026. ;
  7027. MathUtil.InConvexQuad = function InConvexQuad(point, pointA, pointB, pointC, pointD) {
  7028. var vec1, vec2;
  7029. vec1.x = pointB.x - pointA.x;
  7030. vec1.y = pointB.y - pointA.y;
  7031. vec2.x = point.x - pointA.x;
  7032. vec2.y = point.y - pointA.y;
  7033. if (this.cross2DPoint(vec2.x, vec2.y, vec1.x, vec1.y)) return false;
  7034. vec1.x = pointC.x - pointB.x;
  7035. vec1.y = pointC.y - pointB.y;
  7036. vec2.x = point.x - pointB.x;
  7037. vec2.y = point.y - pointB.y;
  7038. if (this.cross2DPoint(vec2.x, vec2.y, vec1.x, vec1.y)) return false;
  7039. vec1.x = pointD.x - pointC.x;
  7040. vec1.y = pointD.y - pointC.y;
  7041. vec2.x = point.x - pointC.x;
  7042. vec2.y = point.y - pointC.y;
  7043. if (this.cross2DPoint(vec2.x, vec2.y, vec1.x, vec1.y)) return false;
  7044. vec1.x = pointA.x - pointD.x;
  7045. vec1.y = pointA.y - pointD.y;
  7046. vec2.x = point.x - pointD.x;
  7047. vec2.y = point.y - pointD.y;
  7048. if (this.cross2DPoint(vec2.x, vec2.y, vec1.x, vec1.y)) return false;
  7049. return true;
  7050. }
  7051. /**等同于Vec2.cross */;
  7052. MathUtil.cross2DPoint = function cross2DPoint(x1, y1, x2, y2) {
  7053. return x1 * y2 - x2 * y1;
  7054. }
  7055. /**检测两个2D包围盒(xy为中心点 wh分别为x轴半径宽 y轴半径宽) 是否相交*/;
  7056. MathUtil.AABBAABB2D = function AABBAABB2D(pointX1, pointY1, w1, h1, pointX2, pointY2, w2, h2) {
  7057. if (Math.abs(pointX1 - pointX2) > w1 + w2) return false;
  7058. if (Math.abs(pointY1 - pointY2) > h1 + h2) return false;
  7059. return true;
  7060. }
  7061. /**检测两个3D包围盒 是否相交*/;
  7062. MathUtil.AABBAABB3D = function AABBAABB3D(pointX1, pointY1, pointZ1, w1, h1, t1, pointX2, pointY2, pointZ2, w2, h2, t2) {
  7063. if (Math.abs(pointX1 - pointX2) > w1 + w2) return false;
  7064. if (Math.abs(pointY1 - pointY2) > h1 + h2) return false;
  7065. if (Math.abs(pointZ1 - pointZ2) > t1 + t2) return false;
  7066. return true;
  7067. }
  7068. /**点与点*/;
  7069. MathUtil.pointPoint = function pointPoint(point1, point2) {
  7070. if (point1.x == point2.x && point1.y == point2.y) {
  7071. return true;
  7072. }
  7073. return false;
  7074. }
  7075. //判断点是否在线上,在返回1,不在返回0
  7076. ;
  7077. MathUtil.onSegement = function onSegement(Q, p1, p2) {
  7078. var maxx, minx, maxy, miny;
  7079. maxx = p1.x > p2.x ? p1.x : p2.x; //矩形的右边长
  7080. minx = p1.x > p2.x ? p2.x : p1.x; //矩形的左边长
  7081. maxy = p1.y > p2.y ? p1.y : p2.y; //矩形的上边长
  7082. miny = p1.y > p2.y ? p2.y : p1.y; //矩形的下边长
  7083. if ((Q.x - p1.x) * (p2.y - p1.y) == (p2.x - p1.x) * (Q.y - p1.y) && Q.x >= minx && Q.x <= maxx && Q.y >= miny && Q.y <= maxy) {
  7084. return true;
  7085. }
  7086. return false;
  7087. }
  7088. //点与圆的碰撞
  7089. //通过计算点到圆心的距离与半径比较判断circle(由中心点和半径构成)
  7090. ;
  7091. MathUtil.pointInCircle = function pointInCircle(point, center, radius) {
  7092. return Vec2.squaredDistance(point, center) <= radius * radius;
  7093. }
  7094. //点与矩形的碰撞
  7095. //通过判断点坐标是否在矩形四个顶点围成的坐标区域内
  7096. ;
  7097. MathUtil.pointInRect = function pointInRect(point, rect) {
  7098. if (point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height) return true;
  7099. return false;
  7100. }
  7101. //线与矩形的碰撞
  7102. ;
  7103. MathUtil.lineInRect = function lineInRect(p1, p2, rect) {
  7104. var height = p1.y - p2.y;
  7105. var width = p2.x - p1.x;
  7106. var c = p1.x * p2.y - p2.x - p1.y; //计算叉乘
  7107. if (height * rect.xMin + width * rect.yMin + c >= 0 && height * rect.xMax + width * rect.yMax + c <= 0 || height * rect.xMin + width * rect.yMin + c <= 0 && height * rect.xMax + width * rect.yMax + c >= 0 || height * rect.xMin + width * rect.yMax + c >= 0 && height * rect.xMax + width * rect.yMin + c <= 0 || height * rect.xMin + width * rect.yMax + c <= 0 && height * rect.xMax + width * rect.yMin + c >= 0) {
  7108. if (p1.x < rect.xMin && p2.x < rect.xMin || p1.x > rect.xMax && p2.x > rect.xMax || p1.y > rect.yMin && p2.y > rect.yMin || p1.y < rect.yMax && p2.y < rect.yMax) {
  7109. return false;
  7110. } else {
  7111. return true;
  7112. }
  7113. } else {
  7114. return false;
  7115. }
  7116. }
  7117. //两个rect是否相交
  7118. ;
  7119. MathUtil.collisionRectWithRect = function collisionRectWithRect(rect1, rect2) {
  7120. //计算相交部分的矩形
  7121. //左下角坐标:( lx , ly ) //右上角坐标:( rx , ry )
  7122. var lx = Math.max(rect1.xMin, rect2.xMin);
  7123. var ly = Math.max(rect1.yMin, rect2.yMin);
  7124. var rx = Math.min(rect1.xMax, rect2.xMax);
  7125. var ry = Math.min(rect1.yMax, rect2.yMax);
  7126. //判断是否能构成小矩形
  7127. if (lx > rx || ly > ry) return false; //矩形不相交
  7128. return true; //发生碰撞
  7129. }
  7130. //圆与矩形是否相交
  7131. ;
  7132. MathUtil.collisionRectWithCircle = function collisionRectWithCircle(rect, p, r) {
  7133. //获取矩形信息
  7134. //左下角坐标:( lx , ly )
  7135. //右上角坐标:( rx , ry )
  7136. var lx = rect.xMin;
  7137. var ly = rect.yMin;
  7138. var rx = rect.xMax;
  7139. var ry = rect.yMax;
  7140. //计算圆心到四个顶点的距离
  7141. var d1 = Vec2.distance(p, new Vec2(lx, ly));
  7142. var d2 = Vec2.distance(p, new Vec2(lx, ry));
  7143. var d3 = Vec2.distance(p, new Vec2(rx, ly));
  7144. var d4 = Vec2.distance(p, new Vec2(rx, ry));
  7145. //判断是否碰撞//判断距离是否小于半径
  7146. if (d1 < r || d2 < r || d3 < r || d4 < r) return true;
  7147. //是否在圆角矩形的,横向矩形内
  7148. if (p.x > lx - r && p.x < rx + r && p.y > ly && p.y < ry) return true;
  7149. //是否在圆角矩形的,纵向矩形内
  7150. if (p.x > lx && p.x < rx && p.y > ly - r && p.y < ry + r) return true;
  7151. //不发生碰撞
  7152. return false;
  7153. }
  7154. /**
  7155. * 计算向量在指定平面上的投影
  7156. * @param vector 被投影的向量
  7157. * @param planeNormal 平面法线
  7158. */;
  7159. MathUtil.projectOnPlane = function projectOnPlane(vector, planeNormal) {
  7160. // 也可以直接用 Vec3 自带的平面投影函数
  7161. // return Vec3.projectOnPlane(new Vec3, targetDir, planeNormal);
  7162. // 使用点乘计算方向矢量在平面法线上的投影长度
  7163. var projectionLength = Vec3.dot(vector, planeNormal);
  7164. // 平面法线与长度相乘得到方向矢量在平面法线上的投影矢量
  7165. var vectorOnPlane = tempVec3.set(planeNormal).multiplyScalar(projectionLength);
  7166. // 方向矢量减去其在平面法线上的投影矢量即是其在平面上的投影矢量
  7167. return Vec3.subtract(new Vec3(), vector, vectorOnPlane);
  7168. }
  7169. /**
  7170. * 计算两个向量基于指定轴的夹角(逆时针方向为正方向,值范围 -180 ~ 180)
  7171. * @param a 向量 a
  7172. * @param b 向量 b
  7173. * @param axis 参照轴向量(请确保是归一化的)
  7174. */;
  7175. MathUtil.signedAngle = function signedAngle(a, b, axis) {
  7176. // 将向量 a 和 b 分别投影到以 axis 为法线的平面上
  7177. var aOnAxisPlane = this.projectOnPlane(a, axis);
  7178. var bOnAxisPlane = this.projectOnPlane(b, axis);
  7179. // 归一化处理
  7180. var aNormalized = aOnAxisPlane.normalize();
  7181. var bNormalized = bOnAxisPlane.normalize();
  7182. // 求出同时垂直于 a 和 b 的法向量
  7183. var abNormal = Vec3.cross(new Vec3(), aNormalized, bNormalized).normalize();
  7184. // 将法向量到 axis 上的投影长度
  7185. // 若投影长度为正值(+1)则表示法向量与 axis 同向(向量叉乘的右手法则)
  7186. var sign = Vec3.dot(abNormal, axis);
  7187. // 求出向量 a 和 b 的夹角
  7188. var radian = Math.acos(Vec3.dot(aNormalized, bNormalized));
  7189. // 混合在一起!
  7190. return radian * sign * this.rad2Deg;
  7191. }
  7192. //获取某点到某点的Y轴方向
  7193. ;
  7194. MathUtil.GetYDir = function GetYDir(from, to) {
  7195. var dir = to.subtract(from);
  7196. dir.y = from.y;
  7197. return dir.normalize();
  7198. }
  7199. //向量绕Y轴转一个角度
  7200. ;
  7201. MathUtil.RotateAroundAxisY = function RotateAroundAxisY(dir, angle) {
  7202. dir = dir.clone();
  7203. var rad = this.degreesToRadians(angle);
  7204. var cos = Math.cos(rad);
  7205. var sin = Math.sin(rad);
  7206. dir.x = dir.x * cos + dir.z * sin;
  7207. dir.z = dir.x * -sin + dir.z * cos;
  7208. return dir;
  7209. }
  7210. //将一个向量围绕X轴旋转angle个角度
  7211. ;
  7212. MathUtil.RotateAroundAxisX = function RotateAroundAxisX(dir, angle) {
  7213. dir = dir.clone();
  7214. var rad = this.degreesToRadians(angle);
  7215. var cos = Math.cos(rad);
  7216. var sin = Math.sin(rad);
  7217. dir.y = dir.y * cos - dir.z * sin;
  7218. dir.z = dir.y * sin + dir.z * cos;
  7219. return dir;
  7220. }
  7221. //将一个向量围绕Z轴旋转angle个角度
  7222. ;
  7223. MathUtil.RotateAroundAxisZ = function RotateAroundAxisZ(dir, angle) {
  7224. dir = dir.clone();
  7225. var rad = this.degreesToRadians(angle);
  7226. var cos = Math.cos(rad);
  7227. var sin = Math.sin(rad);
  7228. dir.x = dir.x * cos - dir.y * sin;
  7229. dir.y = dir.x * sin + dir.y * cos;
  7230. return dir;
  7231. }
  7232. //线段是否与矩形相交
  7233. ;
  7234. MathUtil.LineRectIntersection = function LineRectIntersection(lineStartPoint, lineEndPoint, rectMinX, rectMaxX, rectMinY, rectMaxY) {
  7235. //针对四种不同的情况,进行碰撞检测
  7236. var minXLinePoint = lineEndPoint;
  7237. if (lineStartPoint.x <= lineEndPoint.x) {
  7238. minXLinePoint = lineStartPoint;
  7239. }
  7240. var maxXLinePoint = lineStartPoint;
  7241. if (lineStartPoint.x <= lineEndPoint.x) {
  7242. maxXLinePoint = lineEndPoint;
  7243. }
  7244. var minYLinePoint = lineEndPoint;
  7245. if (lineStartPoint.y <= lineEndPoint.y) {
  7246. minYLinePoint = lineStartPoint;
  7247. }
  7248. var maxYLinePoint = lineStartPoint;
  7249. if (lineStartPoint.y <= lineEndPoint.y) {
  7250. maxYLinePoint = lineEndPoint;
  7251. }
  7252. if (minXLinePoint.x <= rectMinX && rectMinX <= maxXLinePoint.x) {
  7253. var m = (maxXLinePoint.y - minXLinePoint.y) / (maxXLinePoint.x - minXLinePoint.x);
  7254. var intersectionY = (rectMinX - minXLinePoint.x) * m + minXLinePoint.y;
  7255. if (minYLinePoint.y <= intersectionY && intersectionY <= maxYLinePoint.y && rectMinY <= intersectionY && intersectionY <= rectMaxY) {
  7256. return true; //new Vec2(rectMinX, intersectionY)
  7257. }
  7258. }
  7259. if (minXLinePoint.x <= rectMaxX && rectMaxX <= maxXLinePoint.x) {
  7260. var _m = (maxXLinePoint.y - minXLinePoint.y) / (maxXLinePoint.x - minXLinePoint.x);
  7261. var _intersectionY = (rectMaxX - minXLinePoint.x) * _m + minXLinePoint.y;
  7262. if (minYLinePoint.y <= _intersectionY && _intersectionY <= maxYLinePoint.y && rectMinY <= _intersectionY && _intersectionY <= rectMaxY) {
  7263. return true; //new Vec2(rectMaxX, intersectionY)
  7264. }
  7265. }
  7266. if (minYLinePoint.y <= rectMaxY && rectMaxY <= maxYLinePoint.y) {
  7267. var rm = (maxYLinePoint.x - minYLinePoint.x) / (maxYLinePoint.y - minYLinePoint.y);
  7268. var intersectionX = (rectMaxY - minYLinePoint.y) * rm + minYLinePoint.x;
  7269. if (minXLinePoint.x <= intersectionX && intersectionX <= maxXLinePoint.x && rectMinX <= intersectionX && intersectionX <= rectMaxX) {
  7270. return true; //new Vec2(intersectionX, rectMaxY)
  7271. }
  7272. }
  7273. if (minYLinePoint.y <= rectMinY && rectMinY <= maxYLinePoint.y) {
  7274. var _rm = (maxYLinePoint.x - minYLinePoint.x) / (maxYLinePoint.y - minYLinePoint.y);
  7275. var _intersectionX = (rectMinY - minYLinePoint.y) * _rm + minYLinePoint.x;
  7276. if (minXLinePoint.x <= _intersectionX && _intersectionX <= maxXLinePoint.x && rectMinX <= _intersectionX && _intersectionX <= rectMaxX) {
  7277. return true; //new Vec2(intersectionX, rectMinY)
  7278. }
  7279. }
  7280. return false;
  7281. };
  7282. _createClass(MathUtil, null, [{
  7283. key: "rad2Deg",
  7284. get:
  7285. /**
  7286. * 用于弧度转角度
  7287. */
  7288. function get() {
  7289. return rad2Deg;
  7290. }
  7291. /**
  7292. * 用于角度转弧度
  7293. */
  7294. }, {
  7295. key: "deg2Rad",
  7296. get: function get() {
  7297. return deg2Rad;
  7298. }
  7299. }]);
  7300. return MathUtil;
  7301. }());
  7302. MathUtil.zore = new Vec2(1, 0);
  7303. cclegacy._RF.pop();
  7304. }
  7305. };
  7306. });
  7307. System.register("chunks:///_virtual/ModuleDef.ts", ['cc'], function (exports) {
  7308. var cclegacy;
  7309. return {
  7310. setters: [function (module) {
  7311. cclegacy = module.cclegacy;
  7312. }],
  7313. execute: function () {
  7314. cclegacy._RF.push({}, "755bdpf6lRIfLHpmBltN1fn", "ModuleDef", undefined);
  7315. var ModuleDef = exports('ModuleDef', function ModuleDef() {});
  7316. ModuleDef.BASIC = 'module_basic';
  7317. ModuleDef.EXTRA = 'module_extra';
  7318. ModuleDef.GAME = 'module_game';
  7319. cclegacy._RF.pop();
  7320. }
  7321. };
  7322. });
  7323. System.register("chunks:///_virtual/MotionTrail.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  7324. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _createClass, cclegacy, _decorator, SpriteFrame, CCInteger, CurveRange, GradientRange, UITransform, director, Director, UIRenderer, v2, DynamicAtlasManager;
  7325. return {
  7326. setters: [function (module) {
  7327. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  7328. _inheritsLoose = module.inheritsLoose;
  7329. _initializerDefineProperty = module.initializerDefineProperty;
  7330. _assertThisInitialized = module.assertThisInitialized;
  7331. _createClass = module.createClass;
  7332. }, function (module) {
  7333. cclegacy = module.cclegacy;
  7334. _decorator = module._decorator;
  7335. SpriteFrame = module.SpriteFrame;
  7336. CCInteger = module.CCInteger;
  7337. CurveRange = module.CurveRange;
  7338. GradientRange = module.GradientRange;
  7339. UITransform = module.UITransform;
  7340. director = module.director;
  7341. Director = module.Director;
  7342. UIRenderer = module.UIRenderer;
  7343. v2 = module.v2;
  7344. DynamicAtlasManager = module.DynamicAtlasManager;
  7345. }],
  7346. execute: function () {
  7347. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6;
  7348. cclegacy._RF.push({}, "bb8ffN3AwpEqJr3cZDOVdXJ", "MotionTrail", undefined);
  7349. var TrailData = function TrailData() {
  7350. this.x = 0;
  7351. this.y = 0;
  7352. this.dis = 0;
  7353. this.cos = 0;
  7354. this.sin = 0;
  7355. };
  7356. var ccclass = _decorator.ccclass,
  7357. property = _decorator.property,
  7358. executeInEditMode = _decorator.executeInEditMode,
  7359. menu = _decorator.menu;
  7360. var MotionTrail = exports('default', (_dec = menu('Comp/MotionTrail'), _dec2 = executeInEditMode(), _dec3 = property({
  7361. visible: false
  7362. }), _dec4 = property({
  7363. type: SpriteFrame,
  7364. displayName: 'SpriteFrame'
  7365. }), _dec5 = property({
  7366. displayName: '世界坐标',
  7367. tooltip: '顶点坐标是世界坐标还是本地坐标'
  7368. }), _dec6 = property({
  7369. displayName: '偏移'
  7370. }), _dec7 = property({
  7371. type: CCInteger,
  7372. displayName: '拖尾长度'
  7373. }), _dec8 = property({
  7374. type: CurveRange,
  7375. displayName: '宽度变化',
  7376. range: [0, 1]
  7377. }), _dec9 = property({
  7378. type: CurveRange,
  7379. displayName: '宽度变化',
  7380. range: [0, 1]
  7381. }), _dec10 = property({
  7382. type: GradientRange,
  7383. displayName: '颜色变化'
  7384. }), _dec11 = property({
  7385. type: GradientRange,
  7386. displayName: '颜色变化'
  7387. }), ccclass(_class = _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_UIRenderer) {
  7388. _inheritsLoose(MotionTrail, _UIRenderer);
  7389. function MotionTrail() {
  7390. var _this;
  7391. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  7392. args[_key] = arguments[_key];
  7393. }
  7394. _this = _UIRenderer.call.apply(_UIRenderer, [this].concat(args)) || this;
  7395. _initializerDefineProperty(_this, "_spriteFrame", _descriptor, _assertThisInitialized(_this));
  7396. _initializerDefineProperty(_this, "_isWorldXY", _descriptor2, _assertThisInitialized(_this));
  7397. _initializerDefineProperty(_this, "offset", _descriptor3, _assertThisInitialized(_this));
  7398. _initializerDefineProperty(_this, "_length", _descriptor4, _assertThisInitialized(_this));
  7399. _this.trailData = [];
  7400. _initializerDefineProperty(_this, "_sizeCurveRange", _descriptor5, _assertThisInitialized(_this));
  7401. _initializerDefineProperty(_this, "_colorCurveRange", _descriptor6, _assertThisInitialized(_this));
  7402. _this._useVertexOpacity = true;
  7403. return _this;
  7404. }
  7405. var _proto = MotionTrail.prototype;
  7406. _proto._render = function _render(render) {
  7407. render.commitComp(this, this.renderData, this._spriteFrame, this._assembler, null);
  7408. };
  7409. _proto._flushAssembler = function _flushAssembler() {
  7410. this._assembler = simple;
  7411. if (!this._renderData) {
  7412. this._renderData = this.requestRenderData();
  7413. this._renderData.material = this.getRenderMaterial(0);
  7414. this.freshBuffer();
  7415. this.markForUpdateRenderData();
  7416. if (this._spriteFrame) {
  7417. this._assembler.updateUVs(this);
  7418. }
  7419. this._updateColor();
  7420. }
  7421. }
  7422. //更新buffer
  7423. ;
  7424. _proto.freshBuffer = function freshBuffer() {
  7425. var len = this.length;
  7426. var count = 4 + (len - 2) * 2;
  7427. this._renderData.dataLength = count;
  7428. this._renderData.resize(count, (count - 2) * 3);
  7429. };
  7430. _proto.updateLength = function updateLength() {
  7431. var trailLen = this.length;
  7432. var sub = trailLen - this.trailData.length;
  7433. if (sub > 0) {
  7434. for (var i = 0; i < sub; ++i) {
  7435. this.trailData.push(new TrailData());
  7436. }
  7437. } else if (sub < 0) {
  7438. this.trailData.splice(trailLen);
  7439. }
  7440. };
  7441. _proto.updateWidth = function updateWidth() {
  7442. var data = this.trailData;
  7443. var trailLen = this.length;
  7444. var width = this.getComponent(UITransform).width / 2;
  7445. for (var i = 0; i < trailLen; ++i) {
  7446. data[i].dis = this.sizeCurveRange.evaluate(i / (trailLen - 1), 0) * width;
  7447. }
  7448. };
  7449. _proto.resetPos = function resetPos() {
  7450. var data = this.trailData;
  7451. var tx = this.offset.x;
  7452. var ty = this.offset.y;
  7453. if (this.isWorldXY) {
  7454. tx += this.node.worldPosition.x;
  7455. ty += this.node.worldPosition.y;
  7456. } else {
  7457. tx += this.node.position.x;
  7458. ty += this.node.position.y;
  7459. }
  7460. for (var i = 0, len = this.length; i < len; i++) {
  7461. data[i].x = tx;
  7462. data[i].y = ty;
  7463. }
  7464. };
  7465. _proto.onLoad = function onLoad() {
  7466. this.length = this._length;
  7467. };
  7468. _proto.onEnable = function onEnable() {
  7469. _UIRenderer.prototype.onEnable.call(this);
  7470. director.once(Director.EVENT_BEFORE_DRAW, this.resetPos, this);
  7471. };
  7472. _createClass(MotionTrail, [{
  7473. key: "color",
  7474. get: function get() {
  7475. return this._color;
  7476. }
  7477. }, {
  7478. key: "spriteFrame",
  7479. get: function get() {
  7480. return this._spriteFrame;
  7481. },
  7482. set: function set(value) {
  7483. this._spriteFrame = value;
  7484. }
  7485. }, {
  7486. key: "isWorldXY",
  7487. get: function get() {
  7488. return this._isWorldXY;
  7489. },
  7490. set: function set(value) {
  7491. this._isWorldXY = value;
  7492. }
  7493. }, {
  7494. key: "length",
  7495. get: function get() {
  7496. return this._length;
  7497. },
  7498. set: function set(value) {
  7499. this._length = Math.max(value, 0);
  7500. this.updateLength();
  7501. this.updateWidth();
  7502. this.resetPos();
  7503. this.freshBuffer();
  7504. }
  7505. }, {
  7506. key: "sizeCurveRange",
  7507. get: function get() {
  7508. return this._sizeCurveRange;
  7509. },
  7510. set: function set(value) {
  7511. this._sizeCurveRange = value;
  7512. this.updateWidth();
  7513. }
  7514. }, {
  7515. key: "colorCurveRange",
  7516. get: function get() {
  7517. return this._colorCurveRange;
  7518. },
  7519. set: function set(value) {
  7520. this._colorCurveRange = value;
  7521. this._updateColor();
  7522. }
  7523. }]);
  7524. return MotionTrail;
  7525. }(UIRenderer), (_applyDecoratedDescriptor(_class2.prototype, "color", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "color"), _class2.prototype), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "_spriteFrame", [property], {
  7526. configurable: true,
  7527. enumerable: true,
  7528. writable: true,
  7529. initializer: function initializer() {
  7530. return null;
  7531. }
  7532. }), _applyDecoratedDescriptor(_class2.prototype, "spriteFrame", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "spriteFrame"), _class2.prototype), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_isWorldXY", [property], {
  7533. configurable: true,
  7534. enumerable: true,
  7535. writable: true,
  7536. initializer: function initializer() {
  7537. return true;
  7538. }
  7539. }), _applyDecoratedDescriptor(_class2.prototype, "isWorldXY", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "isWorldXY"), _class2.prototype), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "offset", [_dec6], {
  7540. configurable: true,
  7541. enumerable: true,
  7542. writable: true,
  7543. initializer: function initializer() {
  7544. return v2(0, 0);
  7545. }
  7546. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_length", [property], {
  7547. configurable: true,
  7548. enumerable: true,
  7549. writable: true,
  7550. initializer: function initializer() {
  7551. return 20;
  7552. }
  7553. }), _applyDecoratedDescriptor(_class2.prototype, "length", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "length"), _class2.prototype), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "_sizeCurveRange", [_dec8], {
  7554. configurable: true,
  7555. enumerable: true,
  7556. writable: true,
  7557. initializer: function initializer() {
  7558. return new CurveRange();
  7559. }
  7560. }), _applyDecoratedDescriptor(_class2.prototype, "sizeCurveRange", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "sizeCurveRange"), _class2.prototype), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "_colorCurveRange", [_dec10], {
  7561. configurable: true,
  7562. enumerable: true,
  7563. writable: true,
  7564. initializer: function initializer() {
  7565. return new GradientRange();
  7566. }
  7567. }), _applyDecoratedDescriptor(_class2.prototype, "colorCurveRange", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "colorCurveRange"), _class2.prototype)), _class2)) || _class) || _class) || _class));
  7568. var simple = {
  7569. updateRenderData: function updateRenderData(trail) {
  7570. var frame = trail.spriteFrame;
  7571. DynamicAtlasManager.instance.packToDynamicAtlas(trail, frame);
  7572. this.updateUVs(trail); // dirty need
  7573. //this.updateColor(sprite);// dirty need
  7574. var renderData = trail.renderData;
  7575. if (renderData && frame) {
  7576. if (renderData.vertDirty) {
  7577. this.updateVertexData(trail);
  7578. }
  7579. renderData.updateRenderData(trail, frame);
  7580. }
  7581. },
  7582. updateWorldVerts: function updateWorldVerts(trail) {
  7583. var renderData = trail.renderData;
  7584. var vData = renderData.chunk.vb;
  7585. var len = trail.length;
  7586. if (len < 1) return;
  7587. var tx = 0,
  7588. ty = 0;
  7589. var data = trail.trailData;
  7590. if (!trail.isWorldXY) {
  7591. tx = trail.node.position.x;
  7592. ty = trail.node.position.y;
  7593. }
  7594. var ax = 0,
  7595. ay = 0;
  7596. var curIdx = 0;
  7597. var tempData = null;
  7598. var tempNextData = null;
  7599. //
  7600. for (var i = 0; i < len; ++i) {
  7601. tempData = data[i];
  7602. var sameIdx = i;
  7603. for (; sameIdx < len; ++sameIdx) {
  7604. tempNextData = data[sameIdx];
  7605. if (tempNextData.x != tempData.x || tempNextData.y != tempData.y) {
  7606. break;
  7607. }
  7608. }
  7609. sameIdx -= 1;
  7610. if (sameIdx == i) {
  7611. ax = tempData.x - tx;
  7612. ay = tempData.y - ty;
  7613. vData[curIdx] = ax + tempData.dis * tempData.sin;
  7614. vData[curIdx + 1] = ay - tempData.dis * tempData.cos;
  7615. vData[curIdx + 2] = 0;
  7616. curIdx += renderData.floatStride;
  7617. vData[curIdx] = ax - tempData.dis * tempData.sin;
  7618. vData[curIdx + 1] = ay + tempData.dis * tempData.cos;
  7619. vData[curIdx + 2] = 0;
  7620. curIdx += renderData.floatStride;
  7621. } else {
  7622. tempData = data[sameIdx];
  7623. ax = tempData.x - tx;
  7624. ay = tempData.y - ty;
  7625. vData[curIdx] = ax + tempData.dis * tempData.sin;
  7626. vData[curIdx + 1] = ay - tempData.dis * tempData.cos;
  7627. vData[curIdx + 2] = 0;
  7628. curIdx += renderData.floatStride;
  7629. vData[curIdx] = ax - tempData.dis * tempData.sin;
  7630. vData[curIdx + 1] = ay + tempData.dis * tempData.cos;
  7631. vData[curIdx + 2] = 0;
  7632. curIdx += renderData.floatStride;
  7633. for (; i < sameIdx; ++i) {
  7634. vData[curIdx] = vData[curIdx - renderData.floatStride * 2];
  7635. vData[curIdx + 1] = vData[curIdx - renderData.floatStride * 2 + 1];
  7636. vData[curIdx + 2] = 0;
  7637. curIdx += renderData.floatStride;
  7638. vData[curIdx] = vData[curIdx - renderData.floatStride * 2];
  7639. vData[curIdx + 1] = vData[curIdx - renderData.floatStride * 2 + 1];
  7640. vData[curIdx + 2] = 0;
  7641. curIdx += renderData.floatStride;
  7642. }
  7643. }
  7644. }
  7645. },
  7646. fillBuffers: function fillBuffers(trail) {
  7647. if (trail.spriteFrame == null) return;
  7648. var renderData = trail.renderData;
  7649. var chunk = renderData.chunk;
  7650. this.update(trail);
  7651. this.updateWorldVerts(trail, chunk);
  7652. // quick version
  7653. var vidOrigin = chunk.vertexOffset;
  7654. var meshBuffer = chunk.meshBuffer;
  7655. var ib = chunk.meshBuffer.iData;
  7656. var indexOffset = meshBuffer.indexOffset;
  7657. var vid = vidOrigin;
  7658. var len = trail.length - 1;
  7659. for (var i = 0; i < len; i++) {
  7660. ib[indexOffset++] = vid + 0;
  7661. ib[indexOffset++] = vid + 1;
  7662. ib[indexOffset++] = vid + 2;
  7663. ib[indexOffset++] = vid + 1;
  7664. ib[indexOffset++] = vid + 3;
  7665. ib[indexOffset++] = vid + 2;
  7666. vid += 2;
  7667. }
  7668. meshBuffer.indexOffset += len * 6;
  7669. },
  7670. updateVertexData: function updateVertexData(trail) {
  7671. var renderData = trail.renderData;
  7672. renderData.vertDirty = true;
  7673. },
  7674. updateUVs: function updateUVs(trail) {
  7675. if (trail.spriteFrame == null) return;
  7676. var renderData = trail.renderData;
  7677. var vData = renderData.chunk.vb;
  7678. var uv = trail.spriteFrame.uv;
  7679. var length = trail.length - 1;
  7680. var uvStep = length == 0 ? 0 : 1 / length;
  7681. var curIdx = 3;
  7682. var subV = uv[7] - uv[1];
  7683. for (var i = 0; i < length; i++) {
  7684. vData[curIdx] = uv[0];
  7685. vData[curIdx + 1] = uv[1] + subV * i * uvStep;
  7686. curIdx += renderData.floatStride;
  7687. vData[curIdx] = uv[0];
  7688. vData[curIdx + 1] = uv[3] + subV * i * uvStep;
  7689. curIdx += renderData.floatStride;
  7690. }
  7691. vData[curIdx] = uv[0];
  7692. vData[curIdx + 1] = uv[7];
  7693. curIdx += renderData.floatStride;
  7694. vData[curIdx] = uv[0];
  7695. vData[curIdx + 1] = uv[5];
  7696. curIdx += renderData.floatStride;
  7697. },
  7698. updateColor: function updateColor(trail) {
  7699. var renderData = trail.renderData;
  7700. var vData = renderData.chunk.vb;
  7701. var total = 4 + (trail.length - 2) * 2;
  7702. var stepTotal = trail.length;
  7703. var stepIdx = -1;
  7704. var colorOffset = 5;
  7705. var curC, random;
  7706. for (var i = 0; i < total; i++) {
  7707. if (i % 2 == 0) {
  7708. random = trail.colorCurveRange.mode === GradientRange.Mode.TwoGradients || trail.colorCurveRange.mode === GradientRange.Mode.TwoColors ? Math.random() : 0;
  7709. curC = trail.colorCurveRange.evaluate(stepIdx / stepTotal, random);
  7710. stepIdx++;
  7711. }
  7712. vData[colorOffset] = curC.r / 255;
  7713. vData[colorOffset + 1] = curC.g / 255;
  7714. vData[colorOffset + 2] = curC.b / 255;
  7715. vData[colorOffset + 3] = curC.a / 255;
  7716. colorOffset += renderData.floatStride;
  7717. }
  7718. },
  7719. update: function update(trail) {
  7720. if (trail.length === 0) return;
  7721. var data = trail.trailData;
  7722. for (var i = trail.length - 1; i > 0; --i) {
  7723. var cur = data[i],
  7724. prev = data[i - 1];
  7725. cur.x = prev.x;
  7726. cur.y = prev.y;
  7727. cur.sin = prev.sin;
  7728. cur.cos = prev.cos;
  7729. }
  7730. var pos = null;
  7731. if (trail.isWorldXY) {
  7732. pos = trail.node.worldPosition;
  7733. } else {
  7734. pos = trail.node.position;
  7735. }
  7736. var fristData = data[0];
  7737. fristData.x = trail.offset.x + pos.x;
  7738. fristData.y = trail.offset.y + pos.y;
  7739. var secondData = data[1];
  7740. var radian = Math.atan2(secondData.y - fristData.y, secondData.x - fristData.x);
  7741. fristData.sin = Math.sin(radian);
  7742. fristData.cos = Math.cos(radian);
  7743. },
  7744. updateOpacity: function updateOpacity(trail, alpha) {
  7745. var renderData = trail.renderData;
  7746. var vData = renderData.chunk.vb;
  7747. var total = 4 + (trail.length - 2) * 2;
  7748. var stepTotal = trail.length;
  7749. var stepIdx = -1;
  7750. var colorOffset = 5;
  7751. var curC, random;
  7752. for (var i = 0; i < total; i++) {
  7753. if (i % 2 == 0) {
  7754. random = trail.colorCurveRange.mode === GradientRange.Mode.TwoGradients || trail.colorCurveRange.mode === GradientRange.Mode.TwoColors ? Math.random() : 0;
  7755. curC = trail.colorCurveRange.evaluate(stepIdx / stepTotal, random);
  7756. stepIdx++;
  7757. }
  7758. vData[colorOffset + 3] = curC.a / 255 * alpha;
  7759. colorOffset += renderData.floatStride;
  7760. }
  7761. }
  7762. };
  7763. cclegacy._RF.pop();
  7764. }
  7765. };
  7766. });
  7767. System.register("chunks:///_virtual/MovieClip.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  7768. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, cclegacy, _decorator, CCFloat, Texture2D, CCInteger, CCBoolean, Sprite, SpriteFrame, Rect, Vec2, Size, UITransform, Component;
  7769. return {
  7770. setters: [function (module) {
  7771. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  7772. _inheritsLoose = module.inheritsLoose;
  7773. _initializerDefineProperty = module.initializerDefineProperty;
  7774. _assertThisInitialized = module.assertThisInitialized;
  7775. }, function (module) {
  7776. cclegacy = module.cclegacy;
  7777. _decorator = module._decorator;
  7778. CCFloat = module.CCFloat;
  7779. Texture2D = module.Texture2D;
  7780. CCInteger = module.CCInteger;
  7781. CCBoolean = module.CCBoolean;
  7782. Sprite = module.Sprite;
  7783. SpriteFrame = module.SpriteFrame;
  7784. Rect = module.Rect;
  7785. Vec2 = module.Vec2;
  7786. Size = module.Size;
  7787. UITransform = module.UITransform;
  7788. Component = module.Component;
  7789. }],
  7790. execute: function () {
  7791. var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
  7792. cclegacy._RF.push({}, "008df+Vqs9NT7+AfYBNY6bw", "MovieClip", undefined);
  7793. var ccclass = _decorator.ccclass,
  7794. property = _decorator.property;
  7795. /**
  7796. * 动画播放器
  7797. * @author
  7798. *
  7799. */
  7800. var MovieClip = exports('default', (_dec = ccclass('MovieClip'), _dec2 = property({
  7801. type: CCFloat
  7802. }), _dec3 = property({
  7803. type: Texture2D
  7804. }), _dec4 = property({
  7805. type: CCInteger
  7806. }), _dec5 = property({
  7807. type: CCInteger
  7808. }), _dec6 = property({
  7809. type: CCInteger
  7810. }), _dec7 = property({
  7811. type: CCInteger
  7812. }), _dec8 = property(CCBoolean), _dec9 = property(CCBoolean), _dec10 = property(CCBoolean), _dec11 = property(CCFloat), _dec12 = property(CCFloat), _dec(_class = (_class2 = /*#__PURE__*/function (_Component) {
  7813. _inheritsLoose(MovieClip, _Component);
  7814. function MovieClip() {
  7815. var _this;
  7816. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  7817. args[_key] = arguments[_key];
  7818. }
  7819. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  7820. /** Sprite渲染器 */
  7821. _this.m_sprite = null;
  7822. /** 动画计时间隔 每隔0.1s更新一帧 */
  7823. _this.timer = 0.1;
  7824. /** 播放 时间 间隔 */
  7825. _initializerDefineProperty(_this, "interval", _descriptor, _assertThisInitialized(_this));
  7826. /** 贴图文件名 */
  7827. _initializerDefineProperty(_this, "texture", _descriptor2, _assertThisInitialized(_this));
  7828. /** 播放次数 */
  7829. _initializerDefineProperty(_this, "playTimes", _descriptor3, _assertThisInitialized(_this));
  7830. _initializerDefineProperty(_this, "row", _descriptor4, _assertThisInitialized(_this));
  7831. /** 图片切割成几列 */
  7832. _initializerDefineProperty(_this, "col", _descriptor5, _assertThisInitialized(_this));
  7833. _initializerDefineProperty(_this, "rowIndex", _descriptor6, _assertThisInitialized(_this));
  7834. _initializerDefineProperty(_this, "isAll", _descriptor7, _assertThisInitialized(_this));
  7835. _initializerDefineProperty(_this, "autoPlayOnLoad", _descriptor8, _assertThisInitialized(_this));
  7836. /** 播放完自动销毁 */
  7837. _initializerDefineProperty(_this, "autoDestroy", _descriptor9, _assertThisInitialized(_this));
  7838. _initializerDefineProperty(_this, "begin", _descriptor10, _assertThisInitialized(_this));
  7839. _initializerDefineProperty(_this, "end", _descriptor11, _assertThisInitialized(_this));
  7840. /** 动画帧数 */
  7841. _this.totalFrame = 8;
  7842. /** 当前帧数 */
  7843. _this.currentFrame = 0;
  7844. /** 当前播放了第几次 */
  7845. _this.currentTimes = 0;
  7846. /** 影片是否在跑动中 */
  7847. _this.running = true;
  7848. //private _direction:number = 1;
  7849. _this._playIndex = 0;
  7850. _this._pieceWidth = 0;
  7851. _this._pieceHeight = 0;
  7852. _this._bitmapArr = [];
  7853. return _this;
  7854. }
  7855. var _proto = MovieClip.prototype;
  7856. _proto.onLoad = function onLoad() {
  7857. //this. m_clips = new SpriteFrame[this.row][this.col];
  7858. //Texture2D tex = Resources.Load<Texture2D>("Image/Avatar/" + m_sprite_name);
  7859. //this.begin = 0;
  7860. if (this.end == 0) {
  7861. this.end = this.col;
  7862. }
  7863. this.rowIndex = this.clamp(this.rowIndex, 0, this.row - 1);
  7864. this._pieceWidth = this.texture.width / this.col;
  7865. this._pieceHeight = this.texture.height / this.row;
  7866. this.m_sprite = this.getComponent(Sprite);
  7867. if (!this.m_sprite) {
  7868. this.m_sprite = this.addComponent(Sprite);
  7869. }
  7870. for (var i = 0; i < this.row; i++) {
  7871. this._bitmapArr[i] = [];
  7872. for (var j = 0; j < this.col; j++) {
  7873. var spriteFrame = new SpriteFrame();
  7874. spriteFrame.texture = this.texture;
  7875. spriteFrame.rect = new Rect(j * this._pieceWidth, i * this._pieceHeight, this._pieceWidth, this._pieceHeight);
  7876. spriteFrame.rotated = false;
  7877. spriteFrame.offset = new Vec2(0, 0);
  7878. spriteFrame.originalSize = new Size(this._pieceWidth, this._pieceHeight);
  7879. this._bitmapArr[i][j] = spriteFrame;
  7880. }
  7881. }
  7882. this.m_sprite.spriteFrame = this._bitmapArr[this.rowIndex][0];
  7883. this.m_sprite.spriteFrame.width;
  7884. var uiTransform = this.getComponent(UITransform);
  7885. if (uiTransform) {
  7886. uiTransform.width = this._pieceWidth;
  7887. uiTransform.height = this._pieceHeight;
  7888. }
  7889. this.timer = 0;
  7890. this.running = this.autoPlayOnLoad;
  7891. };
  7892. _proto.update = function update(dt) {
  7893. if (!this.running) return;
  7894. if (this.playTimes != 0 && this.currentTimes == this.playTimes) {
  7895. this.running = false;
  7896. return;
  7897. }
  7898. this.timer -= dt;
  7899. if (this.timer <= 0) {
  7900. this.timer = this.interval;
  7901. this.currentFrame = this.currentFrame % this.col;
  7902. this.playAction();
  7903. this.currentFrame++;
  7904. if (this.currentFrame == this.col) {
  7905. if (this.isAll) {
  7906. this.rowIndex++;
  7907. if (this.rowIndex == this.row) {
  7908. this.currentTimes++;
  7909. this.node.emit("completeTimes");
  7910. if (this.playTimes != 0 && this.currentTimes == this.playTimes) {
  7911. this.node.emit("complete");
  7912. if (this.autoDestroy) {
  7913. this.node.destroy();
  7914. }
  7915. }
  7916. }
  7917. this.rowIndex %= this.row;
  7918. } else {
  7919. this.currentTimes++;
  7920. this.node.emit("completeTimes");
  7921. if (this.playTimes != 0 && this.currentTimes == this.playTimes) {
  7922. this.node.emit("complete");
  7923. if (this.autoDestroy) {
  7924. this.node.destroy();
  7925. }
  7926. }
  7927. }
  7928. }
  7929. }
  7930. };
  7931. _proto.playAction = function playAction() {
  7932. this.rowIndex = this.clamp(this.rowIndex, 0, this.row - 1);
  7933. this._playIndex = this._playIndex % (this.end - this.begin) + this.begin;
  7934. this.m_sprite.spriteFrame = this._bitmapArr[this.rowIndex][this._playIndex];
  7935. //this.m_sprite.spriteFrame.setRect(this.rect);
  7936. this._playIndex++;
  7937. }
  7938. /** 播放影片 */;
  7939. _proto.play = function play() {
  7940. this.running = true;
  7941. }
  7942. /** 停止播放影片 */;
  7943. _proto.stop = function stop() {
  7944. this.running = false;
  7945. }
  7946. /**
  7947. * 跳帧播放
  7948. * @param frame 帧
  7949. */;
  7950. _proto.gotoAndPlay = function gotoAndPlay(frame) {
  7951. this.running = true;
  7952. this._playIndex = frame;
  7953. this._playIndex = this.clamp(this._playIndex, 0, this.col - 1);
  7954. }
  7955. /**
  7956. * 跳帧停止
  7957. * @param frame 帧
  7958. */;
  7959. _proto.gotoAndStop = function gotoAndStop(frame) {
  7960. this.running = false;
  7961. this._playIndex = frame;
  7962. this._playIndex = this.clamp(this._playIndex, 0, this.col - 1);
  7963. this.m_sprite.spriteFrame = this._bitmapArr[this.rowIndex][this._playIndex];
  7964. };
  7965. _proto.clamp = function clamp(value, minLimit, maxLimit) {
  7966. if (value < minLimit) {
  7967. return minLimit;
  7968. }
  7969. if (value > maxLimit) {
  7970. return maxLimit;
  7971. }
  7972. return value;
  7973. };
  7974. return MovieClip;
  7975. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "interval", [_dec2], {
  7976. configurable: true,
  7977. enumerable: true,
  7978. writable: true,
  7979. initializer: function initializer() {
  7980. return 0.1;
  7981. }
  7982. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "texture", [_dec3], {
  7983. configurable: true,
  7984. enumerable: true,
  7985. writable: true,
  7986. initializer: function initializer() {
  7987. return null;
  7988. }
  7989. }), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "playTimes", [_dec4], {
  7990. configurable: true,
  7991. enumerable: true,
  7992. writable: true,
  7993. initializer: function initializer() {
  7994. return 0;
  7995. }
  7996. }), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "row", [_dec5], {
  7997. configurable: true,
  7998. enumerable: true,
  7999. writable: true,
  8000. initializer: function initializer() {
  8001. return 4;
  8002. }
  8003. }), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "col", [_dec6], {
  8004. configurable: true,
  8005. enumerable: true,
  8006. writable: true,
  8007. initializer: function initializer() {
  8008. return 4;
  8009. }
  8010. }), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "rowIndex", [_dec7], {
  8011. configurable: true,
  8012. enumerable: true,
  8013. writable: true,
  8014. initializer: function initializer() {
  8015. return 0;
  8016. }
  8017. }), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "isAll", [_dec8], {
  8018. configurable: true,
  8019. enumerable: true,
  8020. writable: true,
  8021. initializer: function initializer() {
  8022. return false;
  8023. }
  8024. }), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "autoPlayOnLoad", [_dec9], {
  8025. configurable: true,
  8026. enumerable: true,
  8027. writable: true,
  8028. initializer: function initializer() {
  8029. return true;
  8030. }
  8031. }), _descriptor9 = _applyDecoratedDescriptor(_class2.prototype, "autoDestroy", [_dec10], {
  8032. configurable: true,
  8033. enumerable: true,
  8034. writable: true,
  8035. initializer: function initializer() {
  8036. return false;
  8037. }
  8038. }), _descriptor10 = _applyDecoratedDescriptor(_class2.prototype, "begin", [_dec11], {
  8039. configurable: true,
  8040. enumerable: true,
  8041. writable: true,
  8042. initializer: function initializer() {
  8043. return 0;
  8044. }
  8045. }), _descriptor11 = _applyDecoratedDescriptor(_class2.prototype, "end", [_dec12], {
  8046. configurable: true,
  8047. enumerable: true,
  8048. writable: true,
  8049. initializer: function initializer() {
  8050. return 0;
  8051. }
  8052. })), _class2)) || _class));
  8053. cclegacy._RF.pop();
  8054. }
  8055. };
  8056. });
  8057. System.register("chunks:///_virtual/net.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './NetRoom.ts', './NetTeam.ts', './WsClient.ts'], function (exports) {
  8058. var _createClass, _asyncToGenerator, _regeneratorRuntime, cclegacy, NetRoom, NetTeam, WsClient;
  8059. return {
  8060. setters: [function (module) {
  8061. _createClass = module.createClass;
  8062. _asyncToGenerator = module.asyncToGenerator;
  8063. _regeneratorRuntime = module.regeneratorRuntime;
  8064. }, function (module) {
  8065. cclegacy = module.cclegacy;
  8066. }, function (module) {
  8067. NetRoom = module.NetRoom;
  8068. }, function (module) {
  8069. NetTeam = module.NetTeam;
  8070. }, function (module) {
  8071. WsClient = module.WsClient;
  8072. }],
  8073. execute: function () {
  8074. cclegacy._RF.push({}, "3f10au8XnFG2b0ZjXy1nl0i", "net", undefined);
  8075. /**自定义同步游戏变量(只能以r_或p_开头,按帧率同步,重新进入会收到最新的数据)
  8076. * 只有第一个参数有效,可加上第一个参数跟第一个参数同类型,用于接收改变前的数据
  8077. * t_开头为队伍事件
  8078. * r_开头 主机游戏数据 主机权限
  8079. * revt_ 开头房间事件
  8080. * p_ 开头玩家数据 玩家权限和主机ai权限
  8081. * online 玩家在线下线状态
  8082. * 尽量拆分数据类型,不要设置过于复杂的数据类型*/
  8083. /**网络状态*/
  8084. function isArrayBuffer(it) {
  8085. try {
  8086. return it instanceof ArrayBuffer;
  8087. } catch (_) {
  8088. return false;
  8089. }
  8090. }
  8091. var HEARTBEAT_INTERVAL = 1000; //每秒发送一次 Ping
  8092. var HEARTBEAT_TIMEOUT = 30000; //30 秒的断线超时
  8093. var DIRTYDATACHECK_INTERVAL = 200; //每200毫秒同步一次自定义游戏变量
  8094. var EVTCHECK_INTERVAL = 66; //每66毫秒同步一次自定义游戏事件
  8095. var RECONNECT_COUNT = 10; //默认重连次数
  8096. var RECONNECT_INTERVAL = 2000; //默认重连间隔
  8097. var PING = 'ping';
  8098. var PONG = 'pong';
  8099. //
  8100. var S2C_LOGIN_SUCCESS = 's2c_login_success';
  8101. var S2C_TEAM_SUCCESS = 's2c_team_success';
  8102. var S2C_JOIN_TEAM_FAIL = 's2c_join_team_fail';
  8103. var S2C_TEAM_USER_JOIN = 's2c_team_user_join';
  8104. var S2C_TEAM_USER_EXIT = 's2c_team_user_exit';
  8105. var S2C_TEAM_CHANGE_HOST = 's2c_team_change_host';
  8106. var S2C_USER_RECONNECT = 's2c_user_reconnect';
  8107. var S2C_USER_DISCONNECT = 's2c_user_disconnect';
  8108. var S2C_MATCH = 's2c_match';
  8109. var S2C_MATCH_SUCCESS = 's2c_match_success';
  8110. var S2C_MATCH_CANCEL = 's2c_match_cancel';
  8111. var S2C_ROOM_GAMEDATA_CHANGE = 's2c_room_gameData_change';
  8112. var S2C_USER_GAMEDATA_CHANGE = 's2c_user_gameData_change';
  8113. var S2C_ROOM_CHANGE_HOST = 's2c_room_change_host';
  8114. var S2C_ROOM_CLOSED = 's2c_room_closed';
  8115. var S2C_TALK = 's2c_talk';
  8116. var S2C_FINISH = 's2c_finish';
  8117. var S2C_SETTLEMENT = 's2c_settlement';
  8118. var S2C_READY = 's2c_ready';
  8119. var S2C_NOT_READY = 's2c_not_ready';
  8120. //
  8121. var C2S_UPDATE_USER_GAMEDATA = 'c2s_update_user_gameData';
  8122. var C2S_UPDATE_ROOM_GAMEDATA = 'c2s_update_room_gameData';
  8123. var C2S_SET_TEAM = 'c2s_set_team';
  8124. var C2S_JOIN_TEAM = 'c2s_join_team';
  8125. var C2S_EXIT_TEAM = 'c2s_exit_team';
  8126. var C2S_CLOSE_ROOM = 'c2s_close_room';
  8127. var C2S_ROOM_EXIT = 'c2s_room_exit';
  8128. var C2S_MESSAGE = 'c2s_message';
  8129. var C2S_MESSAGE_TO_HOST = 'c2s_message_to_host';
  8130. var C2S_MESSAGE_TO_OTHER = 'c2s_message_without_self';
  8131. var C2S_TALK = 'c2s_talk';
  8132. var C2S_BACKED_RETURN = 'c2s_backed_return';
  8133. var C2S_BACKED = 'c2s_to_backed';
  8134. var C2S_FINISH = 'c2s_finish';
  8135. //
  8136. var Ver = '0.1.8';
  8137. /**客户端*/
  8138. var ch_net = exports('ch_net', /*#__PURE__*/function () {
  8139. var _proto = ch_net.prototype;
  8140. _proto._new_resolve = function _new_resolve(id) {
  8141. var _this = this;
  8142. return new Promise(function (resolve) {
  8143. return _this._callbacks[id] = resolve;
  8144. });
  8145. };
  8146. _proto._do_resolve = function _do_resolve(id, data) {
  8147. var resolveCallback = this._callbacks[id];
  8148. if (!resolveCallback) return false;
  8149. resolveCallback(data);
  8150. delete this._callbacks[id];
  8151. return true;
  8152. };
  8153. /**
  8154. * 创建一个客户端
  8155. */
  8156. function ch_net() {
  8157. /**连接状态事件*/
  8158. this.state = chsdk.get_new_event();
  8159. this._ws = null;
  8160. this._url = void 0;
  8161. this._ca = void 0;
  8162. this.reconnection = void 0;
  8163. this.reconnectCount = void 0;
  8164. this.reconnectInterval = void 0;
  8165. this.timeoutInterval = void 0;
  8166. this.gameDataInterval = void 0;
  8167. this.gameEvtInterval = void 0;
  8168. this.timeout = null;
  8169. this.json = false;
  8170. this.heartbeatInterval = null;
  8171. // 心跳定时器
  8172. this.dirtyDataCheckInterval = null;
  8173. //变量同步定时器
  8174. this.evtCheckInterval = null;
  8175. //事件同步定时器
  8176. this._currentReconnectCount = 0;
  8177. this._pingTime = 0;
  8178. this._ping = 0;
  8179. //ping值
  8180. this._callbacks = {};
  8181. this._waitSends = [];
  8182. this._lv = {
  8183. LowerRank: 0,
  8184. Rank: 0,
  8185. Star: 0
  8186. };
  8187. this._team = void 0;
  8188. this._room = void 0;
  8189. this._waitSends = [];
  8190. this._callbacks = {};
  8191. }
  8192. /**初始化
  8193. * @param url - 连接的地址 'ws://localhost:3000'
  8194. * @param options - 可选的配置选项对象,支持以下属性:
  8195. * - **ca**: (可选) CA 证书字符串,用于 SSL 连接的验证。
  8196. * - **reconnection**: (可选) 指示是否启用重连机制,默认为 `true`。
  8197. * - **reconnectCount**: (可选) 在连接失败后重连的最大次数,默认值为 `10`。
  8198. * - **reconnectInterval**: (可选) 每次重连之间的间隔时间,以毫秒为单位,默认值为 `2000` (2 秒)。
  8199. * - **timeoutInterval**: (可选) 心跳断线时间,以毫秒为单位,默认值为 `30000` (30 秒)。
  8200. * - **gameEvtInterval**:(可选) 游戏事件同步间隔,默认值为 `66` (0.06秒 1秒钟15次)。
  8201. * - **gameDataInterval**:(可选) 游戏变量同步间隔,默认值为 `200` (0.2秒 1秒钟5次)。
  8202. * - **json**: (可选) 是否用json序列化否则用messagepck 默认为 `false`。
  8203. * @example
  8204. * 自定义消息
  8205. interface message extends message_protocol {
  8206. useItem(userId: string, otherId: string, itemId: number): void//使用道具
  8207. }
  8208. 自定义数据
  8209. export interface gd extends game_data {
  8210. r_lv(lv: number);//关卡信息
  8211. r_time(time: number);//关卡时间
  8212. }
  8213. export const net = ch.get_new_net<gd, message>();
  8214. const url = chsdk.getUrl('/handle').replace(chsdk.getUrl('/handle').split(':')[0], 'ws');
  8215. const token = chsdk.getToken();
  8216. net.init(url,{query: `token=${token}`});
  8217. */
  8218. _proto.init = function init(url, options) {
  8219. var _options$query, _options$reconnection, _options$reconnectCou, _options$reconnectInt, _options$timeoutInter, _options$gameDataInte, _options$gameEvtInter, _options$json;
  8220. this._url = url;
  8221. this._url = "" + this._url + (options != null && (_options$query = options.query) != null && _options$query.length ? '?' + options.query : '');
  8222. this._ca = options == null ? void 0 : options.ca;
  8223. this.reconnection = (_options$reconnection = options == null ? void 0 : options.reconnection) != null ? _options$reconnection : true;
  8224. this.reconnectCount = (_options$reconnectCou = options == null ? void 0 : options.reconnectCount) != null ? _options$reconnectCou : RECONNECT_COUNT;
  8225. this.reconnectInterval = (_options$reconnectInt = options == null ? void 0 : options.reconnectInterval) != null ? _options$reconnectInt : RECONNECT_INTERVAL;
  8226. this.timeoutInterval = (_options$timeoutInter = options == null ? void 0 : options.timeoutInterval) != null ? _options$timeoutInter : HEARTBEAT_TIMEOUT;
  8227. this.gameDataInterval = (_options$gameDataInte = options == null ? void 0 : options.gameDataInterval) != null ? _options$gameDataInte : DIRTYDATACHECK_INTERVAL;
  8228. this.gameEvtInterval = (_options$gameEvtInter = options == null ? void 0 : options.gameEvtInterval) != null ? _options$gameEvtInter : EVTCHECK_INTERVAL;
  8229. this.json = (_options$json = options == null ? void 0 : options.json) != null ? _options$json : false;
  8230. this._ws = new WsClient(this._url, this._ca);
  8231. this._ws.onConnected = this._onConnected.bind(this);
  8232. this._ws.onError = this._onError.bind(this);
  8233. this._ws.onClosing = this._onClosing.bind(this);
  8234. this._ws.onClosed = this._onClosed.bind(this);
  8235. this._ws.onMessage = this._onMessage.bind(this);
  8236. var isbuffer = typeof ArrayBuffer !== 'undefined';
  8237. console.log('ch_net 初始化 ver:', Ver, isbuffer, this.json, this._url);
  8238. //
  8239. chsdk.sdk_event.on('hide', this.on_hide, this);
  8240. chsdk.sdk_event.on('show', this.on_show, this);
  8241. }
  8242. /**主动断开连接*/;
  8243. _proto.dispose = function dispose() {
  8244. this.state.clearAll();
  8245. this._clear_team();
  8246. this._clear_room();
  8247. this._callbacks = {};
  8248. this._waitSends.length = 0;
  8249. this._ws.close(5000, 'client disconnect');
  8250. chsdk.sdk_event.off('hide', this.on_hide, this);
  8251. chsdk.sdk_event.off('show', this.on_show, this);
  8252. };
  8253. _proto.on_hide = function on_hide() {
  8254. if (!this.inRoom) return;
  8255. this.send_data(C2S_BACKED);
  8256. };
  8257. _proto.on_show = function on_show() {
  8258. if (!this.inRoom) return;
  8259. this.send_data(C2S_BACKED_RETURN);
  8260. };
  8261. _proto.encode = function encode(msg) {
  8262. return this.json ? JSON.stringify(msg) : msgpack.encode(msg);
  8263. };
  8264. _proto.decode = function decode(medata) {
  8265. return isArrayBuffer(medata) ? msgpack.decode(new Uint8Array(medata)) : JSON.parse(medata);
  8266. };
  8267. _proto.send_data = function send_data(type, data) {
  8268. this._send(this.encode(data ? {
  8269. type: type,
  8270. data: data
  8271. } : {
  8272. type: type
  8273. }));
  8274. }
  8275. /**开始连接,返回null为成功,否则为错误提示*/;
  8276. _proto.connect = /*#__PURE__*/
  8277. function () {
  8278. var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  8279. return _regeneratorRuntime().wrap(function _callee$(_context) {
  8280. while (1) switch (_context.prev = _context.next) {
  8281. case 0:
  8282. if (this._ws) {
  8283. _context.next = 3;
  8284. break;
  8285. }
  8286. chsdk.log.error('not init');
  8287. return _context.abrupt("return", 'not init');
  8288. case 3:
  8289. if (this._ws.connect()) {
  8290. _context.next = 5;
  8291. break;
  8292. }
  8293. return _context.abrupt("return", 'no netconnect');
  8294. case 5:
  8295. this.state.emit(this.state.key.Connecting);
  8296. return _context.abrupt("return", this._new_resolve('connect'));
  8297. case 7:
  8298. case "end":
  8299. return _context.stop();
  8300. }
  8301. }, _callee, this);
  8302. }));
  8303. function connect() {
  8304. return _connect.apply(this, arguments);
  8305. }
  8306. return connect;
  8307. }() /**主动重新连接*/;
  8308. _proto.reconnect = function reconnect() {
  8309. if (!this._ws) {
  8310. chsdk.log.error('not init');
  8311. return 'not init';
  8312. }
  8313. this._currentReconnectCount = 1;
  8314. this.do_reconnect();
  8315. };
  8316. _proto.do_reconnect = function do_reconnect() {
  8317. if (!this._ws.connect()) return;
  8318. this.state.emit(this.state.key.Reconnecting, this._currentReconnectCount);
  8319. }
  8320. /**玩家创建队伍,返回null为成功,否则为错误提示*/;
  8321. _proto.creat_team = /*#__PURE__*/
  8322. function () {
  8323. var _creat_team = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(player_count) {
  8324. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  8325. while (1) switch (_context2.prev = _context2.next) {
  8326. case 0:
  8327. if (player_count === void 0) {
  8328. player_count = 4;
  8329. }
  8330. if (this._ws) {
  8331. _context2.next = 3;
  8332. break;
  8333. }
  8334. return _context2.abrupt("return", 'no netconnect');
  8335. case 3:
  8336. if (!this.inTeam) {
  8337. _context2.next = 5;
  8338. break;
  8339. }
  8340. return _context2.abrupt("return", null);
  8341. case 5:
  8342. this.send_data(C2S_SET_TEAM, player_count);
  8343. return _context2.abrupt("return", this._new_resolve('creat_team'));
  8344. case 7:
  8345. case "end":
  8346. return _context2.stop();
  8347. }
  8348. }, _callee2, this);
  8349. }));
  8350. function creat_team(_x) {
  8351. return _creat_team.apply(this, arguments);
  8352. }
  8353. return creat_team;
  8354. }() /**玩家进入队伍,返回null为成功,否则为错误提示*/;
  8355. _proto.join_team = /*#__PURE__*/
  8356. function () {
  8357. var _join_team = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(password) {
  8358. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  8359. while (1) switch (_context3.prev = _context3.next) {
  8360. case 0:
  8361. if (this._ws) {
  8362. _context3.next = 2;
  8363. break;
  8364. }
  8365. return _context3.abrupt("return", 'no netconnect');
  8366. case 2:
  8367. if (!this.inTeam) {
  8368. _context3.next = 4;
  8369. break;
  8370. }
  8371. return _context3.abrupt("return", null);
  8372. case 4:
  8373. this.send_data(C2S_JOIN_TEAM, {
  8374. password: password
  8375. });
  8376. return _context3.abrupt("return", this._new_resolve('join_team'));
  8377. case 6:
  8378. case "end":
  8379. return _context3.stop();
  8380. }
  8381. }, _callee3, this);
  8382. }));
  8383. function join_team(_x2) {
  8384. return _join_team.apply(this, arguments);
  8385. }
  8386. return join_team;
  8387. }() /**玩家退出队伍,返回null为成功,否则为错误提示*/;
  8388. _proto.exit_team = /*#__PURE__*/
  8389. function () {
  8390. var _exit_team = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  8391. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  8392. while (1) switch (_context4.prev = _context4.next) {
  8393. case 0:
  8394. if (this._ws) {
  8395. _context4.next = 2;
  8396. break;
  8397. }
  8398. return _context4.abrupt("return", 'no netconnect');
  8399. case 2:
  8400. if (this.inTeam) {
  8401. _context4.next = 4;
  8402. break;
  8403. }
  8404. return _context4.abrupt("return", 'not in team');
  8405. case 4:
  8406. if (!this.inRoom) {
  8407. _context4.next = 6;
  8408. break;
  8409. }
  8410. return _context4.abrupt("return", 'in game');
  8411. case 6:
  8412. this.send_data(C2S_EXIT_TEAM);
  8413. return _context4.abrupt("return", this._new_resolve('exit_team'));
  8414. case 8:
  8415. case "end":
  8416. return _context4.stop();
  8417. }
  8418. }, _callee4, this);
  8419. }));
  8420. function exit_team() {
  8421. return _exit_team.apply(this, arguments);
  8422. }
  8423. return exit_team;
  8424. }() /**主机结束游戏关闭房间,成功后收到房间关闭事件*/;
  8425. _proto.close_room = function close_room() {
  8426. if (!this._ws) return;
  8427. if (!this.inRoom) return;
  8428. if (!this.room.isHost) return;
  8429. this.send_data(C2S_CLOSE_ROOM);
  8430. }
  8431. /**玩家退出房间 ,返回null为成功,否则为错误提示,退出成功后收到房间关闭事件*/;
  8432. _proto.exit_room = /*#__PURE__*/
  8433. function () {
  8434. var _exit_room = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
  8435. return _regeneratorRuntime().wrap(function _callee5$(_context5) {
  8436. while (1) switch (_context5.prev = _context5.next) {
  8437. case 0:
  8438. if (this._ws) {
  8439. _context5.next = 2;
  8440. break;
  8441. }
  8442. return _context5.abrupt("return", 'no netconnect');
  8443. case 2:
  8444. if (this.inRoom) {
  8445. _context5.next = 4;
  8446. break;
  8447. }
  8448. return _context5.abrupt("return", 'not in room');
  8449. case 4:
  8450. this.send_data(C2S_ROOM_EXIT);
  8451. return _context5.abrupt("return", this._new_resolve('exit_room'));
  8452. case 6:
  8453. case "end":
  8454. return _context5.stop();
  8455. }
  8456. }, _callee5, this);
  8457. }));
  8458. function exit_room() {
  8459. return _exit_room.apply(this, arguments);
  8460. }
  8461. return exit_room;
  8462. }();
  8463. _proto._clear_team = function _clear_team() {
  8464. var _this$_team;
  8465. (_this$_team = this._team) == null || _this$_team.dispose();
  8466. this._team = null;
  8467. };
  8468. _proto._clear_room = function _clear_room() {
  8469. var _this$_room;
  8470. if (!this._room) return;
  8471. (_this$_room = this._room) == null || _this$_room.dispose();
  8472. this._room = null;
  8473. };
  8474. _proto._send = function _send(data) {
  8475. if (!this._ws) return;
  8476. if (this._ws.isActive) {
  8477. this._ws.send(data);
  8478. } else {
  8479. this._waitSends.push(data);
  8480. }
  8481. };
  8482. _proto._updatePlayerStatus = function _updatePlayerStatus(id, online) {
  8483. if (this.inTeam) this._team.updatePlayerStatus(id, online);
  8484. if (this.inRoom) this._room.updatePlayerStatus(id, online);
  8485. }
  8486. //
  8487. ;
  8488. _proto._onMessage = function _onMessage(msg) {
  8489. this.resetHeartbeat();
  8490. try {
  8491. var medata = msg.data;
  8492. var _data = this.decode(medata);
  8493. if (_data.type !== PONG) chsdk.log.log('receive', JSON.stringify(_data));
  8494. switch (_data.type) {
  8495. case PONG:
  8496. this._ping = chsdk.date.now() - this._pingTime;
  8497. chsdk.date.updateServerTime(_data.data);
  8498. //chsdk.log.log("pong:", this._ping, data.data, chsdk.date.now());
  8499. break;
  8500. case S2C_LOGIN_SUCCESS:
  8501. this._lv = _data.data;
  8502. if (this._do_resolve('connect', null)) {
  8503. this.state.emit(this.state.key.Connected);
  8504. } else {
  8505. this.state.emit(this.state.key.Reconnected);
  8506. }
  8507. this._callbacks = {};
  8508. this.startHeartbeat();
  8509. while (this._waitSends.length) {
  8510. if (!this._ws) break;
  8511. var _data2 = this._waitSends.shift();
  8512. if (_data2) this._ws.send(_data2);
  8513. }
  8514. break;
  8515. case S2C_TEAM_SUCCESS:
  8516. if (this._team) this._clear_team();
  8517. this._team = new NetTeam(_data.data, this.send_data.bind(this));
  8518. if (!this._do_resolve('creat_team', null)) this._do_resolve('join_team', null);
  8519. break;
  8520. case S2C_JOIN_TEAM_FAIL:
  8521. this._do_resolve('join_team', _data.data);
  8522. break;
  8523. case S2C_TEAM_USER_JOIN:
  8524. var join_user = _data.data;
  8525. join_user.status = true;
  8526. this._team.addPlayer({
  8527. key: join_user.userKey,
  8528. data: join_user
  8529. }, true);
  8530. break;
  8531. case S2C_TEAM_USER_EXIT:
  8532. var esit_id = _data.data;
  8533. if (esit_id === this._team.own.Id) {
  8534. this._team.closed();
  8535. this._clear_team();
  8536. this._do_resolve('exit_team', null);
  8537. } else {
  8538. this._team.removePlayer(esit_id);
  8539. }
  8540. break;
  8541. case S2C_TEAM_CHANGE_HOST:
  8542. this._team.changeHost(_data.data);
  8543. break;
  8544. case S2C_ROOM_CHANGE_HOST:
  8545. this._room.changeHost(_data.data);
  8546. break;
  8547. case S2C_USER_RECONNECT:
  8548. this._updatePlayerStatus(_data.data, true);
  8549. break;
  8550. case S2C_USER_DISCONNECT:
  8551. this._updatePlayerStatus(_data.data, false);
  8552. break;
  8553. case S2C_MATCH:
  8554. this._team.match_start();
  8555. break;
  8556. case S2C_MATCH_CANCEL:
  8557. this._team.match_cancel();
  8558. break;
  8559. case S2C_NOT_READY:
  8560. this._team.not_ready();
  8561. break;
  8562. case S2C_READY:
  8563. this._team.updatePlayerReady(_data.data, true);
  8564. break;
  8565. case S2C_MATCH_SUCCESS:
  8566. this._clear_room();
  8567. var roomData = _data.data.roomData;
  8568. var pData = _data.data.playerData;
  8569. this._room = new NetRoom(roomData, pData);
  8570. if (this._team) this._team.match_success();
  8571. break;
  8572. case S2C_ROOM_GAMEDATA_CHANGE:
  8573. this._room.server_change(_data.data);
  8574. break;
  8575. case S2C_USER_GAMEDATA_CHANGE:
  8576. var p = this._room.getPlayer(_data.data.userKey);
  8577. if (!p) break;
  8578. p.server_change(_data.data.data);
  8579. break;
  8580. case S2C_ROOM_CLOSED:
  8581. this._room.closed(_data.data);
  8582. if (this.inTeam) {
  8583. var list = this.room.all;
  8584. for (var i = 0; i < list.length; i++) {
  8585. var rp = list[i];
  8586. if (rp.isAI) continue;
  8587. var _p = this.team.getPlayer(rp.Id);
  8588. if (!_p) continue;
  8589. _p.set_level(rp.level, rp.rank, rp.score, rp.totalRank);
  8590. }
  8591. }
  8592. this._do_resolve('exit_room', null);
  8593. break;
  8594. case S2C_TALK:
  8595. if (this.inRoom) {
  8596. this._room.onChat(_data.data.userKey, _data.data.msg);
  8597. } else if (this.inTeam) {
  8598. this._team.onChat(_data.data.userKey, _data.data.msg);
  8599. }
  8600. break;
  8601. case S2C_FINISH:
  8602. this._room.finish(_data.data.userKey, _data.data.rank);
  8603. break;
  8604. case S2C_SETTLEMENT:
  8605. this._room.settlement(_data.data);
  8606. break;
  8607. case C2S_MESSAGE:
  8608. if (Array.isArray(_data.data)) {
  8609. for (var _i = 0; _i < _data.data.length; _i++) {
  8610. var d = _data.data[_i];
  8611. this._room._onEvt(d.type, d.data);
  8612. }
  8613. } else {
  8614. chsdk.log.log('no def type:', _data.data);
  8615. //(this.receive as any)._emit(data.type, data.data);
  8616. }
  8617. break;
  8618. default:
  8619. break;
  8620. }
  8621. } catch (error) {
  8622. chsdk.log.warn(error);
  8623. this.state.emit(this.state.key.Error, error);
  8624. }
  8625. };
  8626. _proto._onConnected = function _onConnected(evt) {
  8627. var _this2 = this;
  8628. if (this.timeout) clearTimeout(this.timeout);
  8629. this._currentReconnectCount = 0;
  8630. this.timeout = setTimeout(function () {
  8631. _this2._ws.close();
  8632. chsdk.log.error("Closing connection.");
  8633. }, 3000);
  8634. };
  8635. _proto._onError = function _onError(err) {
  8636. chsdk.log.log('err', err);
  8637. this.state.emit(this.state.key.Error, err);
  8638. };
  8639. _proto._onClosing = function _onClosing() {
  8640. chsdk.log.log('closing');
  8641. this.state.emit(this.state.key.Connecting);
  8642. };
  8643. _proto._onClosed = function _onClosed(event) {
  8644. var _this3 = this;
  8645. chsdk.log.log("WebSocket connection closed", event);
  8646. this.stopHeartbeat();
  8647. if (!this.reconnection || event.reason && event.code > 4000) {
  8648. this.state.emit(this.state.key.Closed, event);
  8649. this._do_resolve('connect', event);
  8650. chsdk.log.log("WebSocket connection closed", event);
  8651. return;
  8652. }
  8653. if (this._currentReconnectCount < this.reconnectCount) {
  8654. this._currentReconnectCount += 1;
  8655. chsdk.log.log("Reconnecting... Attempt " + this._currentReconnectCount);
  8656. setTimeout(function () {
  8657. _this3.do_reconnect();
  8658. }, this.reconnectInterval);
  8659. } else {
  8660. chsdk.log.error("Max reconnect attempts reached. Giving up.");
  8661. this.state.emit(this.state.key.Closed, event);
  8662. this._do_resolve('connect', event);
  8663. }
  8664. };
  8665. _proto.startHeartbeat = function startHeartbeat() {
  8666. var _this4 = this;
  8667. this.heartbeatInterval = setInterval(function () {
  8668. _this4.sendHeartbeat();
  8669. }, HEARTBEAT_INTERVAL);
  8670. this.dirtyDataCheckInterval = setInterval(function () {
  8671. _this4.dirtyDataCheck();
  8672. }, this.gameDataInterval);
  8673. this.evtCheckInterval = setInterval(function () {
  8674. _this4.evtCheck();
  8675. }, this.gameEvtInterval);
  8676. };
  8677. _proto.resetHeartbeat = function resetHeartbeat() {
  8678. var _this5 = this;
  8679. if (this.timeout) clearTimeout(this.timeout);
  8680. this.timeout = setTimeout(function () {
  8681. chsdk.log.error("Heartbeat timeout. Closing connection.");
  8682. _this5._ws.close();
  8683. }, this.timeoutInterval);
  8684. };
  8685. _proto.sendHeartbeat = function sendHeartbeat() {
  8686. this._pingTime = chsdk.date.now();
  8687. this.send_data(PING, this._ping);
  8688. };
  8689. _proto.stopHeartbeat = function stopHeartbeat() {
  8690. if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
  8691. if (this.timeout) clearTimeout(this.timeout);
  8692. if (this.dirtyDataCheckInterval) clearInterval(this.dirtyDataCheckInterval);
  8693. if (this.evtCheckInterval) clearInterval(this.evtCheckInterval);
  8694. };
  8695. _proto.evtCheck = function evtCheck() {
  8696. var _this6 = this;
  8697. if (this.inRoom) {
  8698. this.room.doSendChat(function (msg) {
  8699. if (!msg) return;
  8700. _this6.send_data(C2S_TALK, msg);
  8701. });
  8702. this.room.doSendMode(function (mode0, mode1, mode2) {
  8703. if (mode0.length > 0) _this6.send_data(C2S_MESSAGE, mode0);
  8704. if (mode1.length > 0) _this6.send_data(C2S_MESSAGE_TO_HOST, mode1);
  8705. if (mode2.length > 0) _this6.send_data(C2S_MESSAGE_TO_OTHER, mode2);
  8706. });
  8707. var ps = this.room.all;
  8708. var _loop = function _loop() {
  8709. var p = ps[i];
  8710. p.doFinishGame(function () {
  8711. _this6.send_data(C2S_FINISH, p.Id);
  8712. });
  8713. };
  8714. for (var i = 0; i < ps.length; i++) {
  8715. _loop();
  8716. }
  8717. } else if (this.inTeam) {
  8718. this.team.doSendChat(function (msg) {
  8719. if (!msg) return;
  8720. _this6.send_data(C2S_TALK, msg);
  8721. });
  8722. }
  8723. };
  8724. _proto.dirtyDataCheck = function dirtyDataCheck() {
  8725. var _this7 = this;
  8726. if (!this.inRoom) return;
  8727. this.room.own.doDirtyData(function (dirty) {
  8728. _this7.send_data(C2S_UPDATE_USER_GAMEDATA, {
  8729. userKey: _this7.room.own.Id,
  8730. data: dirty
  8731. });
  8732. });
  8733. if (!this.room.isHost) return;
  8734. this._room.doDirtyData(function (dirty) {
  8735. _this7.send_data(C2S_UPDATE_ROOM_GAMEDATA, dirty);
  8736. });
  8737. var ais = this.room.all;
  8738. var _loop2 = function _loop2() {
  8739. var ai = ais[i];
  8740. ai.doDirtyData(function (dirty) {
  8741. _this7.send_data(C2S_UPDATE_USER_GAMEDATA, {
  8742. userKey: ai.Id,
  8743. data: dirty
  8744. });
  8745. });
  8746. };
  8747. for (var i = 0; i < ais.length; i++) {
  8748. _loop2();
  8749. }
  8750. }
  8751. /**
  8752. * 分享队伍信息,邀请进队
  8753. * @param extend (可选)分享数据
  8754. * @param title 分享显示标题
  8755. * @param imageUrl 分享显示图片
  8756. */;
  8757. _proto.shareNetTeam = function shareNetTeam(title, imageUrl, extend) {
  8758. if (!this.inTeam) return;
  8759. chsdk.shareAppMessage(title, '', imageUrl, JSON.stringify({
  8760. type: 'NetTeam',
  8761. pw: this.team.Password,
  8762. "extends": extend
  8763. }));
  8764. }
  8765. /**
  8766. *获取从好友分享的net数据进入游戏的数据
  8767. */;
  8768. _proto.getShareNetTeam = function getShareNetTeam() {
  8769. var query = chsdk.getQuery();
  8770. if (!query) return null;
  8771. var message = query.message;
  8772. if (!message) return null;
  8773. var data = JSON.parse(message);
  8774. if (!data) return null;
  8775. if (data.type != 'NetTeam') return null;
  8776. query.message = null;
  8777. return {
  8778. password: data.pw,
  8779. extend: data["extends"]
  8780. };
  8781. };
  8782. _createClass(ch_net, [{
  8783. key: "ownLevel",
  8784. get: function get() {
  8785. return this._lv;
  8786. }
  8787. }, {
  8788. key: "dataInterval",
  8789. get: function get() {
  8790. return this.gameDataInterval * 0.001;
  8791. }
  8792. }, {
  8793. key: "evtInterval",
  8794. get: function get() {
  8795. return this.gameEvtInterval * 0.001;
  8796. }
  8797. }, {
  8798. key: "isActive",
  8799. get: function get() {
  8800. return this._ws && this._ws.isActive;
  8801. }
  8802. }, {
  8803. key: "team",
  8804. get: /**队伍信息*/
  8805. function get() {
  8806. return this._team;
  8807. }
  8808. /**是否在队伍中*/
  8809. }, {
  8810. key: "inTeam",
  8811. get: function get() {
  8812. return this._team != null && this._team.own != null;
  8813. }
  8814. /**房间信息*/
  8815. }, {
  8816. key: "room",
  8817. get: function get() {
  8818. return this._room;
  8819. }
  8820. /**是否在房间中*/
  8821. }, {
  8822. key: "inRoom",
  8823. get: function get() {
  8824. return this._room != null && !this._room.cloosed;
  8825. }
  8826. }]);
  8827. return ch_net;
  8828. }());
  8829. cclegacy._RF.pop();
  8830. }
  8831. };
  8832. });
  8833. System.register("chunks:///_virtual/NetBase.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  8834. var _createClass, cclegacy;
  8835. return {
  8836. setters: [function (module) {
  8837. _createClass = module.createClass;
  8838. }, function (module) {
  8839. cclegacy = module.cclegacy;
  8840. }],
  8841. execute: function () {
  8842. cclegacy._RF.push({}, "ee4ceP8Y6tOb7rdImpQdJVo", "NetBase", undefined);
  8843. /**网络变量基类*/
  8844. var NetBase = exports('NetBase', /*#__PURE__*/function () {
  8845. function NetBase(id) {
  8846. this._id = void 0;
  8847. this.dataMap = {};
  8848. this.dirtyMap = {};
  8849. this._id = id;
  8850. this.dataMap = {};
  8851. }
  8852. /**初始变量值*/
  8853. var _proto = NetBase.prototype;
  8854. _proto.initValue = function initValue(data) {
  8855. this.dataMap = data != null ? data : {};
  8856. }
  8857. /**修改某个键的值*/;
  8858. _proto.setValue = function setValue(key, value) {
  8859. this.dataMap[key] = value;
  8860. };
  8861. _proto.setValueDirty = function setValueDirty(key, value) {
  8862. this.dirtyMap[key] = value;
  8863. }
  8864. /**获取数据的值*/;
  8865. _proto.getValue = function getValue(key) {
  8866. return this.dataMap[key];
  8867. }
  8868. /**处理脏数据*/;
  8869. _proto.doDirtyData = function doDirtyData(f) {
  8870. if (Object.keys(this.dirtyMap).length === 0) return null;
  8871. f(this.dirtyMap);
  8872. this.dirtyMap = {};
  8873. };
  8874. _proto.dispose = function dispose() {
  8875. this.dataMap = {};
  8876. this.dirtyMap = {};
  8877. };
  8878. _createClass(NetBase, [{
  8879. key: "Id",
  8880. get: function get() {
  8881. return this._id;
  8882. }
  8883. }]);
  8884. return NetBase;
  8885. }());
  8886. cclegacy._RF.pop();
  8887. }
  8888. };
  8889. });
  8890. System.register("chunks:///_virtual/NetPlayer.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './NetBase.ts'], function (exports) {
  8891. var _inheritsLoose, _createClass, cclegacy, NetBase;
  8892. return {
  8893. setters: [function (module) {
  8894. _inheritsLoose = module.inheritsLoose;
  8895. _createClass = module.createClass;
  8896. }, function (module) {
  8897. cclegacy = module.cclegacy;
  8898. }, function (module) {
  8899. NetBase = module.NetBase;
  8900. }],
  8901. execute: function () {
  8902. cclegacy._RF.push({}, "6fc05FzfGNCnJsa3eEcsw94", "NetPlayer", undefined);
  8903. /**网络玩家*/
  8904. var NetPlayer = exports('NetPlayer', /*#__PURE__*/function (_NetBase) {
  8905. _inheritsLoose(NetPlayer, _NetBase);
  8906. function NetPlayer() {
  8907. var _this;
  8908. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  8909. args[_key] = arguments[_key];
  8910. }
  8911. _this = _NetBase.call.apply(_NetBase, [this].concat(args)) || this;
  8912. _this.evt = chsdk.get_new_event();
  8913. _this._location = 0;
  8914. _this._online = true;
  8915. _this._ready = false;
  8916. _this._score = 0;
  8917. _this._rank = 0;
  8918. _this._totalRank = 0;
  8919. _this._ishost = true;
  8920. _this._userData = void 0;
  8921. _this._rankInfo = void 0;
  8922. _this._canAI = false;
  8923. _this._finsh_tag = false;
  8924. return _this;
  8925. }
  8926. var _proto = NetPlayer.prototype;
  8927. _proto.init = function init(pd) {
  8928. var _pd$status;
  8929. this._location = pd.location;
  8930. this._online = (_pd$status = pd.status) != null ? _pd$status : true;
  8931. this._ready = pd.teamReady;
  8932. this._score = pd.score;
  8933. this._rank = pd.rank;
  8934. this._totalRank = pd.TotalRank;
  8935. this._userData = pd.userData;
  8936. this._userData.hid = Number.parseInt(pd.userData.hid);
  8937. this._userData.loginTime = Number.parseInt(pd.userData.loginTime);
  8938. this._userData.registerTime = Number.parseInt(pd.userData.registerTime);
  8939. this._userData.userId = Number.parseInt(pd.userData.userId);
  8940. this._rankInfo = pd.userRank;
  8941. if (pd.gameData) this.initValue(pd.gameData);
  8942. };
  8943. _proto.set_level = function set_level(level, rank, score, totalRank) {
  8944. this._rankInfo = level;
  8945. this._rank = rank;
  8946. this._totalRank = totalRank;
  8947. this._score = score;
  8948. };
  8949. _proto.set_host = function set_host(isHost, ownHost) {
  8950. this._ishost = isHost;
  8951. this._canAI = this.isAI && ownHost;
  8952. };
  8953. _proto.change_online = function change_online(ol) {
  8954. this._online = ol;
  8955. this.evt._emit('online', this._online);
  8956. };
  8957. _proto.change_ready = function change_ready(ready) {
  8958. this._ready = ready;
  8959. this.evt._emit('ready', this._ready);
  8960. }
  8961. /**修改某个键的值*/;
  8962. _proto.setValue = function setValue(key, data) {
  8963. if (!this.isPermission) return;
  8964. var old = _NetBase.prototype.getValue.call(this, key);
  8965. if (old) {
  8966. if (typeof old === "object") ;else if (data === old) {
  8967. return;
  8968. }
  8969. }
  8970. _NetBase.prototype.setValue.call(this, key, data);
  8971. _NetBase.prototype.setValueDirty.call(this, key, data);
  8972. this.evt._emit(key, data, old);
  8973. }
  8974. /**获取数据的值*/;
  8975. _proto.getValue = function getValue(key) {
  8976. return _NetBase.prototype.getValue.call(this, key);
  8977. }
  8978. //服务器发送过来的数据
  8979. ;
  8980. _proto.server_change = function server_change(data) {
  8981. var _this2 = this;
  8982. if (this.isPermission) return;
  8983. Object.keys(data).forEach(function (key) {
  8984. var old = _NetBase.prototype.getValue.call(_this2, key);
  8985. _NetBase.prototype.setValue.call(_this2, key, data[key]);
  8986. _this2.evt._emit(key, data[key], old);
  8987. });
  8988. };
  8989. _proto.setFinish = function setFinish(rank) {
  8990. this._rank = rank;
  8991. this.evt._emit('finish', this._rank);
  8992. };
  8993. /**玩家完成游戏 不是自己或主机没有权限*/
  8994. _proto.finishGame = function finishGame() {
  8995. if (!this.isPermission) return;
  8996. this._finsh_tag = true;
  8997. };
  8998. _proto.doFinishGame = function doFinishGame(f) {
  8999. if (this._finsh_tag) f(this.Id);
  9000. this._finsh_tag = false;
  9001. };
  9002. _proto.dispose = function dispose() {
  9003. _NetBase.prototype.dispose.call(this);
  9004. this.evt.clearAll();
  9005. };
  9006. _createClass(NetPlayer, [{
  9007. key: "score",
  9008. get: function get() {
  9009. return this._score;
  9010. }
  9011. }, {
  9012. key: "rank",
  9013. get: function get() {
  9014. return this._rank;
  9015. }
  9016. }, {
  9017. key: "totalRank",
  9018. get: function get() {
  9019. return this._totalRank;
  9020. }
  9021. }, {
  9022. key: "location",
  9023. get: /**房间位置0开头*/
  9024. function get() {
  9025. return this._location;
  9026. }
  9027. }, {
  9028. key: "gid",
  9029. get: function get() {
  9030. return this._userData.gid;
  9031. }
  9032. }, {
  9033. key: "head",
  9034. get: function get() {
  9035. return this._userData.head;
  9036. }
  9037. }, {
  9038. key: "hid",
  9039. get: function get() {
  9040. return this._userData.hid;
  9041. }
  9042. }, {
  9043. key: "province",
  9044. get: function get() {
  9045. var _chsdk$provinceCode2N;
  9046. return (_chsdk$provinceCode2N = chsdk.provinceCode2Name(this._userData.hid)) != null ? _chsdk$provinceCode2N : '其它';
  9047. }
  9048. }, {
  9049. key: "ip",
  9050. get: function get() {
  9051. return this._userData.ip;
  9052. }
  9053. }, {
  9054. key: "loginTime",
  9055. get: function get() {
  9056. return this._userData.loginTime;
  9057. }
  9058. }, {
  9059. key: "nickName",
  9060. get: function get() {
  9061. return this._userData.nickName || '玩家' + this._userData.userId;
  9062. }
  9063. }, {
  9064. key: "openId",
  9065. get: function get() {
  9066. return this._userData.openId;
  9067. }
  9068. }, {
  9069. key: "option",
  9070. get: function get() {
  9071. return this._userData.option;
  9072. }
  9073. }, {
  9074. key: "pf",
  9075. get: function get() {
  9076. return this._userData.pf;
  9077. }
  9078. }, {
  9079. key: "userId",
  9080. get: function get() {
  9081. return this._userData.userId;
  9082. }
  9083. }, {
  9084. key: "registerTime",
  9085. get: function get() {
  9086. return this._userData.registerTime;
  9087. }
  9088. }, {
  9089. key: "isHost",
  9090. get: /**是否是主机*/
  9091. function get() {
  9092. return this._ishost;
  9093. }
  9094. }, {
  9095. key: "ready",
  9096. get: /**是否准备*/
  9097. function get() {
  9098. return this._ready;
  9099. }
  9100. }, {
  9101. key: "online",
  9102. get: /**是否在线*/
  9103. function get() {
  9104. return this._online;
  9105. }
  9106. }, {
  9107. key: "canMatch",
  9108. get: /**是否能开启匹配*/
  9109. function get() {
  9110. return this.online && this.ready;
  9111. }
  9112. }, {
  9113. key: "level",
  9114. get: /**段位信息*/
  9115. function get() {
  9116. return this._rankInfo;
  9117. }
  9118. }, {
  9119. key: "isOwn",
  9120. get: /**是否是当前玩家自己 */
  9121. function get() {
  9122. return chsdk.get_uid() === this.userId;
  9123. }
  9124. /**是否是AI */
  9125. }, {
  9126. key: "isAI",
  9127. get: function get() {
  9128. return this._userData.userId < 8888;
  9129. }
  9130. }, {
  9131. key: "canAI",
  9132. get: /**是否有控制当前AI权限*/
  9133. function get() {
  9134. return this._canAI;
  9135. }
  9136. }, {
  9137. key: "isPermission",
  9138. get: /**是否有此玩家数据权限*/
  9139. function get() {
  9140. return this.isOwn || this._canAI;
  9141. }
  9142. }]);
  9143. return NetPlayer;
  9144. }(NetBase));
  9145. cclegacy._RF.pop();
  9146. }
  9147. };
  9148. });
  9149. System.register("chunks:///_virtual/NetRoom.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './NetBase.ts', './NetPlayer.ts'], function (exports) {
  9150. var _inheritsLoose, _createClass, cclegacy, NetBase, NetPlayer;
  9151. return {
  9152. setters: [function (module) {
  9153. _inheritsLoose = module.inheritsLoose;
  9154. _createClass = module.createClass;
  9155. }, function (module) {
  9156. cclegacy = module.cclegacy;
  9157. }, function (module) {
  9158. NetBase = module.NetBase;
  9159. }, function (module) {
  9160. NetPlayer = module.NetPlayer;
  9161. }],
  9162. execute: function () {
  9163. cclegacy._RF.push({}, "577dcgqDHFNgZms65V5Rprz", "NetRoom", undefined);
  9164. /**网络房间*/
  9165. var NetRoom = exports('NetRoom', /*#__PURE__*/function (_NetBase) {
  9166. _inheritsLoose(NetRoom, _NetBase);
  9167. //
  9168. function NetRoom(roomData, playerData) {
  9169. var _this;
  9170. _this = _NetBase.call(this, roomData.roomId) || this;
  9171. _this.evt = chsdk.get_new_event();
  9172. _this._hostId = void 0;
  9173. _this._status = true;
  9174. _this._own_id = void 0;
  9175. _this._players = new Map();
  9176. //
  9177. _this._waitSends_mode0 = [];
  9178. _this._waitSends_mode1 = [];
  9179. _this._waitSends_mode2 = [];
  9180. _this._results = [];
  9181. _this._chat_msg = null;
  9182. _this._last_chat_time = 0;
  9183. _this._status = roomData.status;
  9184. _this._hostId = roomData.hostInfo;
  9185. var ps = Object.keys(playerData).map(function (key) {
  9186. return {
  9187. key: key,
  9188. data: playerData[key]
  9189. };
  9190. });
  9191. for (var i = 0; i < ps.length; i++) _this.addPlayer(ps[i]);
  9192. _this._players.forEach(function (v, _) {
  9193. v.set_host(v.Id === _this._hostId, _this.isHost);
  9194. });
  9195. _this.initValue(roomData.gameData);
  9196. return _this;
  9197. }
  9198. var _proto = NetRoom.prototype;
  9199. _proto.addPlayer = function addPlayer(p) {
  9200. var id = p.key;
  9201. var pd = p.data;
  9202. var player = this._players.get(id);
  9203. if (!player) {
  9204. player = new NetPlayer(id);
  9205. this._players.set(id, player);
  9206. }
  9207. player.init(pd);
  9208. if (player.isOwn) this._own_id = id;
  9209. };
  9210. _proto.updatePlayerStatus = function updatePlayerStatus(id, online) {
  9211. var p = this.getPlayer(id);
  9212. if (p) {
  9213. p.change_online(online);
  9214. var location = p.location;
  9215. var nickName = p.nickName;
  9216. this.evt._emit('r_online', id, online, location, nickName);
  9217. }
  9218. };
  9219. _proto.changeHost = function changeHost(id) {
  9220. var _this2 = this;
  9221. this._hostId = id;
  9222. this._players.forEach(function (v, _) {
  9223. v.set_host(v.Id === _this2._hostId, _this2.isHost);
  9224. });
  9225. var p = this.getPlayer(this._hostId);
  9226. this.evt._emit('r_host', id, p.location, p.nickName);
  9227. }
  9228. /**自己是否是主机*/;
  9229. /**所有玩家*/
  9230. _proto.getAllPlayer = function getAllPlayer() {
  9231. return Array.from(this._players.values());
  9232. }
  9233. /**将玩家按 location 放到一个数组中,并自定义数组长度*/;
  9234. _proto.getAllPlayersAtLocations = function getAllPlayersAtLocations(customLength) {
  9235. var locationArray = Array(customLength).fill(null);
  9236. this._players.forEach(function (player) {
  9237. if (player.location >= 0 && player.location < customLength) locationArray[player.location] = player;
  9238. });
  9239. return locationArray;
  9240. }
  9241. /**中某个玩家的所有信息*/;
  9242. _proto.getPlayer = function getPlayer(id) {
  9243. return this._players.get(id);
  9244. }
  9245. /**获取除了某个id的所有玩家*/;
  9246. _proto.getExPlayer = function getExPlayer(id) {
  9247. return Array.from(this._players.values()).filter(function (player) {
  9248. return player.Id != id;
  9249. });
  9250. }
  9251. /**获在线或不在线的所有玩家*/;
  9252. _proto.getOnlinePlayer = function getOnlinePlayer(isOnline) {
  9253. return isOnline ? this.onlines : this.outlines;
  9254. }
  9255. /**是否有AI权限*/;
  9256. _proto.canAiPlayer = function canAiPlayer(player) {
  9257. if (!this._status) return false;
  9258. if (!this.isHost) return false;
  9259. if (!player || !player.isAI) return false;
  9260. return true;
  9261. }
  9262. /**是否有AI权限Id,返回可以控制的player*/;
  9263. _proto.canAiPlayerId = function canAiPlayerId(id) {
  9264. if (!this._status) return null;
  9265. if (!this.isHost) return null;
  9266. var player = this._players.get(id);
  9267. if (!player) return null;
  9268. if (!player.isAI) return null;
  9269. return player;
  9270. }
  9271. /**是否拥有权限(包括,自己和自己是主机时的ai)*/;
  9272. _proto.hasPermission = function hasPermission(player) {
  9273. return player.isOwn || this.canAiPlayer(player);
  9274. }
  9275. /**创建obj数据*/;
  9276. _proto.creatObj = function creatObj(data) {
  9277. var _NetBase$prototype$ge;
  9278. if (!this._status) return;
  9279. if (!this.isHost) return;
  9280. var oid = (_NetBase$prototype$ge = _NetBase.prototype.getValue.call(this, 'oid')) != null ? _NetBase$prototype$ge : 0;
  9281. oid++;
  9282. var key = 'obj_' + oid;
  9283. _NetBase.prototype.setValue.call(this, 'oid', oid);
  9284. _NetBase.prototype.setValueDirty.call(this, 'oid', oid);
  9285. _NetBase.prototype.setValue.call(this, key, data);
  9286. _NetBase.prototype.setValueDirty.call(this, key, data);
  9287. this.evt._emit('r_obj', key, data);
  9288. return key;
  9289. }
  9290. /**删除obj数据*/;
  9291. _proto.getObj = function getObj(key) {
  9292. return _NetBase.prototype.getValue.call(this, key);
  9293. }
  9294. /**不建议经常更改obj */;
  9295. _proto.changeObj = function changeObj(key, data) {
  9296. if (!this.isHost) return;
  9297. var old = _NetBase.prototype.getValue.call(this, key);
  9298. if (old) {
  9299. _NetBase.prototype.setValue.call(this, key, data);
  9300. _NetBase.prototype.setValueDirty.call(this, key, data);
  9301. this.evt._emit('r_obj', key, data, old);
  9302. }
  9303. }
  9304. //
  9305. ;
  9306. _proto.deleteObj = function deleteObj(key) {
  9307. if (!this.isHost) return;
  9308. _NetBase.prototype.setValue.call(this, key, null);
  9309. _NetBase.prototype.setValueDirty.call(this, key, null);
  9310. }
  9311. /**修改某个键的值*/;
  9312. _proto.setValue = function setValue(key, data) {
  9313. if (!this._status) return;
  9314. if (!this.isHost) return; //不是主机没有权限
  9315. var old = _NetBase.prototype.getValue.call(this, key);
  9316. if (old) {
  9317. if (typeof data === "object") ;else if (data === old) {
  9318. return;
  9319. }
  9320. }
  9321. _NetBase.prototype.setValue.call(this, key, data);
  9322. _NetBase.prototype.setValueDirty.call(this, key, data);
  9323. this.evt._emit(key, data, old);
  9324. }
  9325. /**获取数据的值*/;
  9326. _proto.getValue = function getValue(key) {
  9327. return _NetBase.prototype.getValue.call(this, key);
  9328. };
  9329. _proto.server_change = function server_change(data) {
  9330. var _this3 = this;
  9331. if (!this._status) return;
  9332. if (this.isHost) return;
  9333. Object.keys(data).forEach(function (key) {
  9334. _this3.change(key, data[key]);
  9335. });
  9336. };
  9337. _proto.change = function change(key, data) {
  9338. var old = _NetBase.prototype.getValue.call(this, key);
  9339. _NetBase.prototype.setValue.call(this, key, data);
  9340. if (typeof data !== "object" && data === old) return;
  9341. if (key === 'oid') {
  9342. return;
  9343. } else if (key.startsWith('obj_')) {
  9344. this.evt._emit('r_obj', key, data, old);
  9345. } else {
  9346. this.evt._emit(key, data, old);
  9347. }
  9348. };
  9349. _proto.closed = function closed(data) {
  9350. this._status = false;
  9351. this._results.length = 0;
  9352. var ps = Object.keys(data).map(function (key) {
  9353. return {
  9354. key: key,
  9355. data: data[key]
  9356. };
  9357. });
  9358. for (var i = 0; i < ps.length; i++) {
  9359. var _key = ps[i].key;
  9360. var user = ps[i].data;
  9361. user.Id = _key;
  9362. var player = this.getPlayer(_key);
  9363. player.set_level(user.Level, user.Rank, user.Score, user.TotalRank);
  9364. user.UserData = {
  9365. gid: player.gid,
  9366. head: player.head,
  9367. hid: player.hid,
  9368. ip: player.ip,
  9369. loginTime: player.loginTime,
  9370. nickName: player.nickName,
  9371. openId: player.openId,
  9372. option: player.option,
  9373. pf: player.pf,
  9374. registerTime: player.registerTime,
  9375. userId: player.userId,
  9376. province: player.province
  9377. };
  9378. var elements = user.Elements;
  9379. if (elements) {
  9380. for (var _i = 0; _i < elements.length; _i++) {
  9381. var _chsdk$provinceCode2N;
  9382. var o = elements[_i];
  9383. o.nickName = o.nickName || '玩家' + o.userId;
  9384. o.hid = Number.parseInt(o.hid);
  9385. o.loginTime = Number.parseInt(o.loginTime);
  9386. o.registerTime = Number.parseInt(o.registerTime);
  9387. o.userId = Number.parseInt(o.userId);
  9388. o.province = (_chsdk$provinceCode2N = chsdk.provinceCode2Name(o.hid)) != null ? _chsdk$provinceCode2N : '其它';
  9389. }
  9390. }
  9391. this._results.push(user);
  9392. }
  9393. if (this._results.length > 1) {
  9394. this._results.sort(function (a, b) {
  9395. if (a.Rank === 0 && b.Rank === 0) {
  9396. return 0;
  9397. } else if (a.Rank === 0) {
  9398. return 1;
  9399. } else if (b.Rank === 0) {
  9400. return -1;
  9401. } else {
  9402. return a.Rank - b.Rank;
  9403. }
  9404. });
  9405. }
  9406. //
  9407. this.evt._emit('r_closed');
  9408. };
  9409. _proto.finish = function finish(pid, rank) {
  9410. var player = this.getPlayer(pid);
  9411. if (!player) return;
  9412. player.setFinish(rank);
  9413. this.evt._emit('r_finish', pid, rank);
  9414. }
  9415. /**向房间所有玩家发消息*/;
  9416. _proto.sendEvt = function sendEvt(key) {
  9417. if (!this._status) return;
  9418. for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key2 = 1; _key2 < _len; _key2++) {
  9419. data[_key2 - 1] = arguments[_key2];
  9420. }
  9421. this._waitSends_mode0.push({
  9422. type: key,
  9423. data: data
  9424. });
  9425. }
  9426. /**向房间主机发消息*/;
  9427. _proto.sendToHost = function sendToHost(key) {
  9428. if (!this._status) return;
  9429. for (var _len2 = arguments.length, data = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
  9430. data[_key3 - 1] = arguments[_key3];
  9431. }
  9432. this._waitSends_mode1.push({
  9433. type: key,
  9434. data: data
  9435. });
  9436. }
  9437. /**向房间其它玩家*/;
  9438. _proto.sendToOther = function sendToOther(key) {
  9439. if (!this._status) return;
  9440. for (var _len3 = arguments.length, data = new Array(_len3 > 1 ? _len3 - 1 : 0), _key4 = 1; _key4 < _len3; _key4++) {
  9441. data[_key4 - 1] = arguments[_key4];
  9442. }
  9443. this._waitSends_mode2.push({
  9444. type: key,
  9445. data: data
  9446. });
  9447. }
  9448. /**处理发送事件*/;
  9449. _proto.doSendMode = function doSendMode(f) {
  9450. f(this._waitSends_mode0, this._waitSends_mode1, this._waitSends_mode2);
  9451. this._waitSends_mode0.length = 0;
  9452. this._waitSends_mode1.length = 0;
  9453. this._waitSends_mode2.length = 0;
  9454. };
  9455. /**房间里聊天 ,成功返回true,发送频率过快返回false*/
  9456. _proto.chat = function chat(msg) {
  9457. var now = chsdk.date.now();
  9458. if (now - this._last_chat_time < 1000) return false;
  9459. this._last_chat_time = now;
  9460. this._chat_msg = msg;
  9461. return true;
  9462. };
  9463. _proto.onChat = function onChat(id, msg) {
  9464. var p = this.getPlayer(id);
  9465. this.evt._emit('r_chat', id, msg, p.location, p.nickName);
  9466. };
  9467. _proto.doSendChat = function doSendChat(f) {
  9468. f(this._chat_msg);
  9469. this._chat_msg = null;
  9470. }
  9471. //
  9472. ;
  9473. _proto._onEvt = function _onEvt(key, data) {
  9474. var _ref;
  9475. (_ref = this.evt)._emit.apply(_ref, [key].concat(data));
  9476. }
  9477. //
  9478. ;
  9479. _proto.dispose = function dispose() {
  9480. _NetBase.prototype.dispose.call(this);
  9481. this._players.forEach(function (v, _) {
  9482. v.dispose();
  9483. });
  9484. this._players.clear();
  9485. this._status = false;
  9486. this.evt.clearAll();
  9487. };
  9488. _createClass(NetRoom, [{
  9489. key: "HostId",
  9490. get: /**游戏主机ID*/function get() {
  9491. return this._hostId;
  9492. }
  9493. }, {
  9494. key: "cloosed",
  9495. get: /**游戏是否关闭*/function get() {
  9496. return !this._status;
  9497. }
  9498. }, {
  9499. key: "isHost",
  9500. get: function get() {
  9501. return this._own_id === this._hostId;
  9502. }
  9503. /**自己的所有信息*/
  9504. }, {
  9505. key: "own",
  9506. get: function get() {
  9507. return this._players.get(this._own_id);
  9508. }
  9509. /**其它玩家信息*/
  9510. }, {
  9511. key: "others",
  9512. get: function get() {
  9513. return Array.from(this._players.values()).filter(function (player) {
  9514. return !player.isOwn;
  9515. });
  9516. }
  9517. /**所有ai信息*/
  9518. }, {
  9519. key: "ais",
  9520. get: function get() {
  9521. return Array.from(this._players.values()).filter(function (player) {
  9522. return player.isAI;
  9523. });
  9524. }
  9525. /**所有玩家*/
  9526. }, {
  9527. key: "all",
  9528. get: function get() {
  9529. return this.getAllPlayer();
  9530. }
  9531. /**在线玩家信息*/
  9532. }, {
  9533. key: "onlines",
  9534. get: function get() {
  9535. return Array.from(this._players.values()).filter(function (player) {
  9536. return player.online;
  9537. });
  9538. }
  9539. /**不在线玩家信息*/
  9540. }, {
  9541. key: "outlines",
  9542. get: function get() {
  9543. return Array.from(this._players.values()).filter(function (player) {
  9544. return !player.online;
  9545. });
  9546. }
  9547. }, {
  9548. key: "results",
  9549. get:
  9550. /**
  9551. * 游戏结算数据
  9552. *
  9553. * @returns {Array} results - 包含游戏结算信息的数组。
  9554. * 每个元素表示一个玩家的结算数据,结构如下:
  9555. *
  9556. * - Id: {string} 玩家唯一标识符
  9557. * - AddScore: {number} 本局游戏中增加的星星数
  9558. * - IsFinish: {boolean} 游戏是否已完成
  9559. * - Rank: {number} 玩家在当前游戏中的排名
  9560. * - Score: {number} 玩家在最后星星数
  9561. * - TotalRank: {number} 玩家的总排名
  9562. * - Level: {Object} 玩家当前等级的信息
  9563. * - LowerRank: {number} 当前段位的等级
  9564. * - Rank: {number} 段位
  9565. * - Star: {number} 当前段位的等级的星级
  9566. * - UserData: {Object} 玩家个人信息
  9567. * - gid: {string} 游戏全局唯一标识符
  9568. * - head: {string} 玩家头像的 URL
  9569. * - hid: {number} 玩家省份id
  9570. * - ip: {string} 玩家 IP 地址
  9571. * - loginTime: {number} 玩家登录时间的时间戳
  9572. * - nickName: {string} 玩家昵称
  9573. * - openId: {string} 玩家在平台上的唯一标识符
  9574. * - option: {string} 玩家选择的选项或设置
  9575. * - pf: {string} 平台信息
  9576. * - registerTime: {number} 玩家注册时间的时间戳
  9577. * - userId: {number} 玩家在系统中的用户 ID
  9578. * - province: {string} 玩家所在的省份
  9579. * - Elements: {Array} 包含其他玩家的结算数据
  9580. * - Rank: {number} 其他玩家的排名
  9581. * - Level: {Object} 其他玩家的等级信息
  9582. * - LowerRank: {number} 其他玩家当前段位的等级
  9583. * - Rank: {number} 其他玩家的段位
  9584. * - Star: {number} 其他玩家段位的等级的星级
  9585. * - UserData: {Object} 其他玩家的个人信息(与上面的 UserData 结构相同)
  9586. */
  9587. function get() {
  9588. return this._results;
  9589. }
  9590. /**获取自己本局获得星星*/
  9591. }, {
  9592. key: "own_results_addScore",
  9593. get: function get() {
  9594. var rs = this.results;
  9595. if (!rs) return 0;
  9596. for (var i = 0; i < rs.length; i++) {
  9597. if (rs[i].Id === this._own_id) {
  9598. return rs[i].AddScore;
  9599. }
  9600. }
  9601. return 0;
  9602. }
  9603. }]);
  9604. return NetRoom;
  9605. }(NetBase));
  9606. cclegacy._RF.pop();
  9607. }
  9608. };
  9609. });
  9610. System.register("chunks:///_virtual/NetTeam.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './NetPlayer.ts'], function (exports) {
  9611. var _createClass, cclegacy, NetPlayer;
  9612. return {
  9613. setters: [function (module) {
  9614. _createClass = module.createClass;
  9615. }, function (module) {
  9616. cclegacy = module.cclegacy;
  9617. }, function (module) {
  9618. NetPlayer = module.NetPlayer;
  9619. }],
  9620. execute: function () {
  9621. cclegacy._RF.push({}, "33caeCu1CZJPaCD2lrLn4Gv", "NetTeam", undefined);
  9622. var C2S_MATCH = 'c2s_match';
  9623. var C2S_MATCH_CANCEL = 'c2s_match_cancel';
  9624. var C2S_READY = 'c2s_ready';
  9625. var C2S_KICK_OUT = 'c2s_kick_out';
  9626. /**网络队伍*/
  9627. var NetTeam = exports('NetTeam', /*#__PURE__*/function () {
  9628. function NetTeam(data, send) {
  9629. /**队伍事件*/
  9630. this.evt = chsdk.get_new_event();
  9631. this._status = true;
  9632. this._hostId = void 0;
  9633. this._password = void 0;
  9634. this._limit = void 0;
  9635. this._id = void 0;
  9636. this._inCollect = false;
  9637. this._own_id = void 0;
  9638. this._players = new Map();
  9639. this._send = void 0;
  9640. this._chat_msg = null;
  9641. this._last_chat_time = 0;
  9642. var team = data.teamData;
  9643. var playerData = data.playerData;
  9644. this._hostId = team.hostInfo;
  9645. this._status = team.status;
  9646. this._inCollect = team.inCollect;
  9647. this._password = team.password;
  9648. this._limit = team.limit;
  9649. this._id = team.roomId;
  9650. this._players.clear();
  9651. var ps = Object.keys(playerData).map(function (key) {
  9652. return {
  9653. key: key,
  9654. data: playerData[key]
  9655. };
  9656. });
  9657. for (var i = 0; i < ps.length; i++) this.addPlayer(ps[i]);
  9658. this._send = send;
  9659. }
  9660. /**主机开始匹配*/
  9661. var _proto = NetTeam.prototype;
  9662. _proto.match = function match() {
  9663. if (!this.isHost) return;
  9664. this._send(C2S_MATCH);
  9665. }
  9666. /**主机退出匹配*/;
  9667. _proto.exit_match = function exit_match() {
  9668. if (!this.isHost) return;
  9669. this._send(C2S_MATCH_CANCEL);
  9670. }
  9671. /**主机踢出某个玩家出小队 */;
  9672. _proto.kick_out = function kick_out(arg) {
  9673. if (!this.isHost) return;
  9674. if (typeof arg === 'string') {
  9675. this._send(C2S_KICK_OUT, arg);
  9676. } else if (typeof arg === 'number') {
  9677. var playerToKick = this.all.find(function (player) {
  9678. return player.location === arg;
  9679. });
  9680. if (playerToKick) this._send(C2S_KICK_OUT, playerToKick.Id); // 踢出找到的玩家
  9681. }
  9682. }
  9683. /**主机踢出所有没有准备的玩家 */;
  9684. _proto.kick_out_no_readys = function kick_out_no_readys() {
  9685. if (!this.isHost) return;
  9686. var list = this.notreadys;
  9687. for (var i = 0; i < list.length; i++) this._send(C2S_KICK_OUT, list[i].Id);
  9688. }
  9689. /**主机踢出所有不在线玩家*/;
  9690. _proto.kick_out_outlines = function kick_out_outlines() {
  9691. if (!this.isHost) return;
  9692. var list = this.outlines;
  9693. for (var i = 0; i < list.length; i++) this._send(C2S_KICK_OUT, list[i].Id);
  9694. }
  9695. /**主机踢出所有不在线或没有准备的玩家*/;
  9696. _proto.kick_out_badplayers = function kick_out_badplayers() {
  9697. if (!this.isHost) return;
  9698. var list = this.badplayers;
  9699. for (var i = 0; i < list.length; i++) this._send(C2S_KICK_OUT, list[i].Id);
  9700. }
  9701. /**准备*/;
  9702. _proto.ready = function ready() {
  9703. this._send(C2S_READY);
  9704. };
  9705. _proto.addPlayer = function addPlayer(p, isevt) {
  9706. if (isevt === void 0) {
  9707. isevt = false;
  9708. }
  9709. var id = p.key;
  9710. var pd = p.data;
  9711. var player = this._players.get(id);
  9712. if (!player) {
  9713. player = new NetPlayer(id);
  9714. this._players.set(id, player);
  9715. }
  9716. player.init(pd);
  9717. player.set_host(player.Id === this._hostId);
  9718. if (player.isOwn) this._own_id = id;
  9719. if (isevt) this.evt._emit('t_entry', id, player.location, player.nickName);
  9720. }
  9721. /**玩家离开*/;
  9722. _proto.removePlayer = function removePlayer(id) {
  9723. var p = this._players.get(id);
  9724. if (p) {
  9725. var _location = p.location;
  9726. var nickName = p.nickName;
  9727. this._players["delete"](id);
  9728. this.evt._emit('t_exit', id, _location, nickName);
  9729. }
  9730. }
  9731. /**队伍解散*/;
  9732. _proto.closed = function closed() {
  9733. this.evt._emit('t_closed');
  9734. };
  9735. _proto.updatePlayerStatus = function updatePlayerStatus(id, online) {
  9736. var p = this.getPlayer(id);
  9737. if (p) {
  9738. p.change_online(online);
  9739. var _location2 = p.location;
  9740. var nickName = p.nickName;
  9741. this.evt._emit('t_online', id, online, _location2, nickName);
  9742. }
  9743. };
  9744. _proto.updatePlayerReady = function updatePlayerReady(id, ready) {
  9745. var p = this.getPlayer(id);
  9746. if (p) {
  9747. p.change_ready(ready);
  9748. var _location3 = p.location;
  9749. var nickName = p.nickName;
  9750. this.evt._emit('t_ready', id, ready, _location3, nickName);
  9751. }
  9752. };
  9753. _proto.match_start = function match_start() {
  9754. this._inCollect = true;
  9755. this.evt._emit('t_matchStart');
  9756. };
  9757. _proto.match_cancel = function match_cancel() {
  9758. this._inCollect = false;
  9759. this.evt._emit('t_matchCancel');
  9760. };
  9761. _proto.match_success = function match_success() {
  9762. this._inCollect = false;
  9763. this.evt._emit('t_matchSuccess');
  9764. var ps = this.getAllPlayer();
  9765. for (var i = 0; i < ps.length; i++) {
  9766. ps[i].change_ready(false);
  9767. }
  9768. };
  9769. _proto.not_ready = function not_ready() {
  9770. this.evt._emit('t_no_ready');
  9771. };
  9772. _proto.changeHost = function changeHost(id) {
  9773. var _this = this;
  9774. this._hostId = id;
  9775. this._players.forEach(function (v, _) {
  9776. v.set_host(v.Id === _this._hostId);
  9777. });
  9778. var p = this.getPlayer(this._hostId);
  9779. this.evt._emit('t_host', id, p.location, p.nickName);
  9780. };
  9781. /*队伍里聊天,成功返回true,发送频率过快返回false*/
  9782. _proto.chat = function chat(msg) {
  9783. var now = chsdk.date.now();
  9784. if (now - this._last_chat_time < 1000) return false;
  9785. this._last_chat_time = now;
  9786. this._chat_msg = msg;
  9787. return true;
  9788. };
  9789. _proto.onChat = function onChat(id, msg) {
  9790. var p = this.getPlayer(id);
  9791. this.evt._emit('t_chat', id, msg, p.location, p.nickName);
  9792. };
  9793. _proto.doSendChat = function doSendChat(f) {
  9794. f(this._chat_msg);
  9795. this._chat_msg = null;
  9796. }
  9797. /**自己是否是主机*/;
  9798. /**某个玩家的所有信息*/
  9799. _proto.getPlayer = function getPlayer(id) {
  9800. return this._players.get(id);
  9801. }
  9802. /**所有玩家*/;
  9803. _proto.getAllPlayer = function getAllPlayer() {
  9804. return this.all;
  9805. }
  9806. /**将玩家按 location 放到一个数组中,并自定义数组长度*/;
  9807. _proto.getAllPlayersAtLocations = function getAllPlayersAtLocations(customLength) {
  9808. var locationArray = Array(customLength).fill(null);
  9809. this._players.forEach(function (player) {
  9810. if (player.location >= 0 && player.location < customLength) locationArray[player.location] = player;
  9811. });
  9812. return locationArray;
  9813. }
  9814. /**获取除了某个id的所有玩家*/;
  9815. _proto.getExPlayer = function getExPlayer(id) {
  9816. return Array.from(this._players.values()).filter(function (player) {
  9817. return player.Id != id;
  9818. });
  9819. }
  9820. /**获在线或不在线的所有玩家*/;
  9821. _proto.getOnlinePlayer = function getOnlinePlayer(isOnline) {
  9822. return isOnline ? this.onlines : this.outlines;
  9823. }
  9824. /**获准备或没有准备的所有玩家*/;
  9825. _proto.getReadyPlayer = function getReadyPlayer(ready) {
  9826. return ready ? this.readys : this.notreadys;
  9827. };
  9828. _proto.dispose = function dispose() {
  9829. this._send = null;
  9830. this._players.forEach(function (v, _) {
  9831. v.dispose();
  9832. });
  9833. this._players.clear();
  9834. };
  9835. _createClass(NetTeam, [{
  9836. key: "status",
  9837. get: /**队伍是否能进*/function get() {
  9838. return this._status;
  9839. }
  9840. }, {
  9841. key: "HostId",
  9842. get: /**队伍队长ID*/function get() {
  9843. return this._hostId;
  9844. }
  9845. }, {
  9846. key: "Password",
  9847. get: /**队伍进入口令*/function get() {
  9848. return this._password;
  9849. }
  9850. }, {
  9851. key: "Limit",
  9852. get: /**队伍上限*/function get() {
  9853. return this._limit;
  9854. }
  9855. }, {
  9856. key: "Id",
  9857. get: /**队伍标识id*/function get() {
  9858. return this._id;
  9859. }
  9860. }, {
  9861. key: "inCollect",
  9862. get: /**是否在匹配中*/function get() {
  9863. return this._inCollect;
  9864. }
  9865. }, {
  9866. key: "isHost",
  9867. get: function get() {
  9868. return this._own_id === this._hostId;
  9869. }
  9870. /**自己的所有信息*/
  9871. }, {
  9872. key: "own",
  9873. get: function get() {
  9874. return this._players.get(this._own_id);
  9875. }
  9876. /**所有玩家*/
  9877. }, {
  9878. key: "all",
  9879. get: function get() {
  9880. return Array.from(this._players.values());
  9881. }
  9882. /**其它玩家信息*/
  9883. }, {
  9884. key: "others",
  9885. get: function get() {
  9886. return Array.from(this._players.values()).filter(function (player) {
  9887. return !player.isOwn;
  9888. });
  9889. }
  9890. /**在线玩家信息*/
  9891. }, {
  9892. key: "onlines",
  9893. get: function get() {
  9894. return Array.from(this._players.values()).filter(function (player) {
  9895. return player.online;
  9896. });
  9897. }
  9898. /**不在线玩家信息*/
  9899. }, {
  9900. key: "outlines",
  9901. get: function get() {
  9902. return Array.from(this._players.values()).filter(function (player) {
  9903. return !player.online;
  9904. });
  9905. }
  9906. /**没有准备或不在线玩家*/
  9907. }, {
  9908. key: "badplayers",
  9909. get: function get() {
  9910. return Array.from(this._players.values()).filter(function (player) {
  9911. return !player.ready || !player.online;
  9912. });
  9913. }
  9914. /**准备好的玩家信息*/
  9915. }, {
  9916. key: "readys",
  9917. get: function get() {
  9918. return Array.from(this._players.values()).filter(function (player) {
  9919. return player.ready;
  9920. });
  9921. }
  9922. /**没有准备的玩家信息*/
  9923. }, {
  9924. key: "notreadys",
  9925. get: function get() {
  9926. return Array.from(this._players.values()).filter(function (player) {
  9927. return !player.ready;
  9928. });
  9929. }
  9930. }]);
  9931. return NetTeam;
  9932. }());
  9933. cclegacy._RF.pop();
  9934. }
  9935. };
  9936. });
  9937. System.register("chunks:///_virtual/PathUtil.ts", ['cc'], function (exports) {
  9938. var cclegacy;
  9939. return {
  9940. setters: [function (module) {
  9941. cclegacy = module.cclegacy;
  9942. }],
  9943. execute: function () {
  9944. cclegacy._RF.push({}, "599009CYiRPSbP+6MJkFWLY", "PathUtil", undefined);
  9945. var PathUtil = exports('default', /*#__PURE__*/function () {
  9946. function PathUtil() {}
  9947. /**
  9948. * 返回 Path 的扩展名
  9949. * @param path 路径
  9950. * @returns {string}
  9951. */
  9952. PathUtil.extname = function extname(path) {
  9953. var temp = /(\.[^\.\/\?\\]*)(\?.*)?$/.exec(path);
  9954. return temp ? temp[1] : '';
  9955. }
  9956. /**
  9957. * 获取文件路径的文件名。
  9958. * @param path 路径
  9959. * @param extname 扩展名
  9960. * @returns {string}
  9961. */;
  9962. PathUtil.basename = function basename(path, extname) {
  9963. var index = path.indexOf("?");
  9964. if (index > 0) path = path.substring(0, index);
  9965. var reg = /(\/|\\)([^\/\\]+)$/g;
  9966. var result = reg.exec(path.replace(/(\/|\\)$/, ""));
  9967. if (!result) return path;
  9968. var baseName = result[2];
  9969. if (extname && path.substring(path.length - extname.length).toLowerCase() === extname.toLowerCase()) return baseName.substring(0, baseName.length - extname.length);
  9970. return baseName;
  9971. }
  9972. /**
  9973. * 获取文件路径的目录名
  9974. * @param path 路径
  9975. * @returns {string}
  9976. */;
  9977. PathUtil.dirname = function dirname(path) {
  9978. var temp = /((.*)(\/|\\|\\\\))?(.*?\..*$)?/.exec(path);
  9979. return temp ? temp[2] : '';
  9980. };
  9981. return PathUtil;
  9982. }());
  9983. cclegacy._RF.pop();
  9984. }
  9985. };
  9986. });
  9987. System.register("chunks:///_virtual/PeriodData.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  9988. var _createForOfIteratorHelperLoose, cclegacy;
  9989. return {
  9990. setters: [function (module) {
  9991. _createForOfIteratorHelperLoose = module.createForOfIteratorHelperLoose;
  9992. }, function (module) {
  9993. cclegacy = module.cclegacy;
  9994. }],
  9995. execute: function () {
  9996. cclegacy._RF.push({}, "6e040Hgcc1C2r4oXdDQnwvy", "PeriodData", undefined);
  9997. var PeriodDataUpdate = exports('PeriodDataUpdate', /*#__PURE__*/function (PeriodDataUpdate) {
  9998. PeriodDataUpdate[PeriodDataUpdate["none"] = 0] = "none";
  9999. PeriodDataUpdate[PeriodDataUpdate["day"] = 1] = "day";
  10000. PeriodDataUpdate[PeriodDataUpdate["week"] = 2] = "week";
  10001. PeriodDataUpdate[PeriodDataUpdate["month"] = 3] = "month";
  10002. return PeriodDataUpdate;
  10003. }({}));
  10004. /**周期数据
  10005. * @param T 为一个枚举类型
  10006. * @param update PeriodDataUpdate 更新周期
  10007. * @param limt 限制值最大,最小
  10008. * 调用check检测更新
  10009. * @exampl
  10010. 定义数据枚举 字段名和字段key需要一致
  10011. export enum day_type{
  10012. score ="score",
  10013. level ="level",
  10014. relive="relive",
  10015. }
  10016. 初始所有定义数据
  10017. day_data = new PeriodData<day_type>(PeriodDataUpdate.day,
  10018. Object.keys(day_type) as day_type[],
  10019. new Map([
  10020. [day_type.relive,{min:0,max:3}],//限制每日复活3次
  10021. ])
  10022. );
  10023. day_data.get(day_type.score)...
  10024. */
  10025. var PeriodData = exports('default', /*#__PURE__*/function () {
  10026. function PeriodData(update, limt) {
  10027. var _this = this;
  10028. this._data = new Map();
  10029. this._data_Array = new Map();
  10030. this._last = 0;
  10031. this._update = void 0;
  10032. this._update = update;
  10033. if (!limt) return;
  10034. //遍历所有键进行初始化
  10035. limt.forEach(function (v, key) {
  10036. var _v$min;
  10037. _this._data.set(key, {
  10038. v: (_v$min = v.min) != null ? _v$min : 0,
  10039. min: v.min,
  10040. max: v.max
  10041. });
  10042. }, this);
  10043. }
  10044. /**
  10045. * 序列化(数据库存储)
  10046. */
  10047. var _proto = PeriodData.prototype;
  10048. _proto.serialize = function serialize() {
  10049. var obj = {};
  10050. this._data.forEach(function (value, key) {
  10051. obj[String(key)] = value.v;
  10052. });
  10053. var obj1 = {};
  10054. this._data_Array.forEach(function (value, key) {
  10055. obj1[String(key)] = value;
  10056. });
  10057. var data = {
  10058. "last": this._last,
  10059. "data": obj,
  10060. "data_Array": obj1
  10061. };
  10062. return data;
  10063. }
  10064. /**
  10065. * 反序列化
  10066. */;
  10067. _proto.unserialize = function unserialize(data) {
  10068. var _data$last;
  10069. if (!data) return;
  10070. this._last = (_data$last = data.last) != null ? _data$last : 0;
  10071. var obj = data.data;
  10072. if (obj) {
  10073. for (var _key in obj) {
  10074. var value = obj[_key];
  10075. this._get(_key).v = value;
  10076. }
  10077. }
  10078. var obj1 = data.data_Array;
  10079. if (obj1) {
  10080. for (var _key2 in obj1) {
  10081. var _value = obj1[_key2];
  10082. this.set_Array(_key2, _value);
  10083. }
  10084. }
  10085. };
  10086. _proto._get = function _get(key) {
  10087. var data = this._data.get(key);
  10088. if (!data) {
  10089. data = {
  10090. v: 0,
  10091. min: 0,
  10092. max: null
  10093. };
  10094. this._data.set(key, data);
  10095. }
  10096. return data;
  10097. };
  10098. _proto._get_Array = function _get_Array(key) {
  10099. var data = this._data_Array.get(key);
  10100. console.log("_get_Array called with key: " + String(key) + "data:", data); // 输出存储的数据
  10101. if (!data) {
  10102. data = new Array(5).fill(false);
  10103. this._data_Array.set(key, data);
  10104. }
  10105. return data;
  10106. }
  10107. /**如果有必要,重新设置数据的min,max*/;
  10108. _proto.set = function set(key, value, min, max) {
  10109. var d = this._get(key);
  10110. d.v = value;
  10111. d.min = min;
  10112. d.max = max;
  10113. }
  10114. /**获取数据*/;
  10115. _proto.get = function get(key) {
  10116. return this._get(key).v;
  10117. };
  10118. _proto.set_Array = function set_Array(key, value) {
  10119. this._data_Array.set(key, value);
  10120. }
  10121. /**获取数据*/;
  10122. _proto.get_Array = function get_Array(key) {
  10123. return this._get_Array(key);
  10124. }
  10125. /**有大最值的话,获取数据为剩余可用次数*/;
  10126. _proto.get_available = function get_available(key) {
  10127. var d = this._get(key);
  10128. if (d.max) return d.max - d.v;
  10129. return d.v;
  10130. };
  10131. _proto.isEnble = function isEnble(key) {
  10132. var d = this._get(key);
  10133. return d.v > 0;
  10134. };
  10135. _proto.enble = function enble(key) {
  10136. this._get(key).v = 1;
  10137. };
  10138. _proto.disEnble = function disEnble(key) {
  10139. this._get(key).v = 0;
  10140. }
  10141. /**增加数据的值*/;
  10142. _proto.add = function add(key, n) {
  10143. if (n === void 0) {
  10144. n = 1;
  10145. }
  10146. return this.change(key, n);
  10147. }
  10148. /**减小数据的值*/;
  10149. _proto.sub = function sub(key, n) {
  10150. if (n === void 0) {
  10151. n = 1;
  10152. }
  10153. return this.change(key, -n);
  10154. }
  10155. /**改变数据 n>0增加 小于0减少*/;
  10156. _proto.change = function change(key, n) {
  10157. var d = this._get(key);
  10158. if (!d) return null;
  10159. d.v += n;
  10160. if (d.min && d.v < d.min) d.v = d.min;
  10161. if (d.max && d.v > d.max) d.v = d.max;
  10162. return d.v;
  10163. }
  10164. /**改变数据,比原本值大直接替换,没有改变返回null*/;
  10165. _proto.change_big = function change_big(key, n) {
  10166. var d = this._get(key);
  10167. if (!d) return null;
  10168. if (n > d.v) {
  10169. d.v = n;
  10170. if (d.min && d.v < d.min) d.v = d.min;
  10171. if (d.max && d.v > d.max) d.v = d.max;
  10172. return d.v;
  10173. }
  10174. return null;
  10175. }
  10176. /**改变数据,比原本值小直接替换,没有改变返回null*/;
  10177. _proto.change_sm = function change_sm(key, n) {
  10178. var d = this._get(key);
  10179. if (!d) return null;
  10180. if (n < d.v) {
  10181. d.v = n;
  10182. if (d.min && d.v < d.min) d.v = d.min;
  10183. if (d.max && d.v > d.max) d.v = d.max;
  10184. return d.v;
  10185. }
  10186. return null;
  10187. }
  10188. /**检测更新now当前时间戳(ms)*/;
  10189. _proto.check = function check(now) {
  10190. if (this._update == PeriodDataUpdate.none) return false;
  10191. if (this._update == PeriodDataUpdate.day) {
  10192. if (!this.isSameDate(now, this._last)) {
  10193. this._last = now;
  10194. this.reset();
  10195. return true;
  10196. }
  10197. }
  10198. if (this._update == PeriodDataUpdate.week) {
  10199. if (!this.areDatesInSameWeek(now, this._last)) {
  10200. this._last = now;
  10201. this.reset();
  10202. this._data_Array = new Map();
  10203. return true;
  10204. }
  10205. }
  10206. if (this._update == PeriodDataUpdate.month) {
  10207. if (!this.areDatesInSameMonth(now, this._last)) {
  10208. this._last = now;
  10209. this.reset();
  10210. return true;
  10211. }
  10212. }
  10213. return false;
  10214. };
  10215. _proto.reset = function reset() {
  10216. for (var _iterator = _createForOfIteratorHelperLoose(this._data.keys()), _step; !(_step = _iterator()).done;) {
  10217. var _data$min;
  10218. var _key3 = _step.value;
  10219. var data = this._get(_key3);
  10220. data.v = (_data$min = data.min) != null ? _data$min : 0;
  10221. }
  10222. for (var _iterator2 = _createForOfIteratorHelperLoose(this._data_Array.keys()), _step2; !(_step2 = _iterator2()).done;) {
  10223. var _key4 = _step2.value;
  10224. this._data_Array.set(_key4, new Array(5).fill(false));
  10225. }
  10226. }
  10227. /**判定两个时间是否是同一天*/;
  10228. _proto.isSameDate = function isSameDate(timestamp1, timestamp2) {
  10229. var date1 = new Date(timestamp1);
  10230. var date2 = new Date(timestamp2);
  10231. return date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate();
  10232. }
  10233. /**判定两个时间是否是同一周*/;
  10234. _proto.areDatesInSameWeek = function areDatesInSameWeek(date1, date2) {
  10235. var startOfWeek1 = this.getStartOfWeek(new Date(date1));
  10236. var startOfWeek2 = this.getStartOfWeek(new Date(date2));
  10237. return startOfWeek1.getTime() === startOfWeek2.getTime();
  10238. };
  10239. _proto.getStartOfWeek = function getStartOfWeek(date) {
  10240. var startOfWeek = new Date(date);
  10241. var day = startOfWeek.getDay(); // 星期日是 0,星期一是 1,依此类推
  10242. var diff = startOfWeek.getDate() - day; // 计算当前日期所在周的第一天
  10243. startOfWeek.setDate(diff); // 设置为该周的第一天
  10244. startOfWeek.setHours(0, 0, 0, 0); // 设置时间为 00:00:00
  10245. return startOfWeek;
  10246. };
  10247. _proto.areDatesInSameMonth = function areDatesInSameMonth(date1, date2) {
  10248. var d1 = new Date(date1);
  10249. var d2 = new Date(date2);
  10250. return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth();
  10251. };
  10252. return PeriodData;
  10253. }());
  10254. cclegacy._RF.pop();
  10255. }
  10256. };
  10257. });
  10258. System.register("chunks:///_virtual/PrefabPool.ts", ['cc'], function (exports) {
  10259. var cclegacy, Node, NodePool, instantiate;
  10260. return {
  10261. setters: [function (module) {
  10262. cclegacy = module.cclegacy;
  10263. Node = module.Node;
  10264. NodePool = module.NodePool;
  10265. instantiate = module.instantiate;
  10266. }],
  10267. execute: function () {
  10268. exports('default', get_new_prefab_pool);
  10269. cclegacy._RF.push({}, "12f30kX+ltO4JZlGRue34gE", "PrefabPool", undefined);
  10270. /** node对象池 */
  10271. var PrefabPool = /*#__PURE__*/function () {
  10272. function PrefabPool() {
  10273. this._pools = new Map();
  10274. this._node = void 0;
  10275. if (this._node == null) {
  10276. this._node = new Node();
  10277. this._node.active = false;
  10278. }
  10279. }
  10280. var _proto = PrefabPool.prototype;
  10281. _proto.getPool = function getPool(path) {
  10282. var pool = this._pools.get(path);
  10283. if (pool == null) {
  10284. pool = new NodePool();
  10285. this._pools.set(path, pool);
  10286. }
  10287. return pool;
  10288. };
  10289. _proto.GetNode = function GetNode(p) {
  10290. var pool = this.getPool(p.name);
  10291. var node = pool.get();
  10292. if (!node) {
  10293. node = instantiate(p);
  10294. node.name = p.name;
  10295. }
  10296. return node;
  10297. };
  10298. _proto.RecNode = function RecNode(node) {
  10299. node.parent = this._node;
  10300. this.getPool(node.name).put(node);
  10301. };
  10302. _proto.InitPool = function InitPool(p, n) {
  10303. if (n === void 0) {
  10304. n = 10;
  10305. }
  10306. var pool = this.getPool(p.name);
  10307. for (var i = 0; i < n; i++) {
  10308. var node = instantiate(p);
  10309. node.name = p.name;
  10310. node.parent = this._node;
  10311. pool.put(node);
  10312. }
  10313. };
  10314. _proto.Clear = function Clear() {
  10315. if (!this._node) return;
  10316. this._node.removeAllChildren();
  10317. this._pools.forEach(function (v, k) {
  10318. v.clear();
  10319. });
  10320. this._pools.clear();
  10321. };
  10322. _proto.getAllPoolNames = function getAllPoolNames() {
  10323. return Object.keys(this._pools);
  10324. };
  10325. _proto.getPoolSize = function getPoolSize(poolName) {
  10326. var pool = this._pools[poolName];
  10327. if (pool) {
  10328. return pool.size();
  10329. }
  10330. return 0;
  10331. };
  10332. return PrefabPool;
  10333. }();
  10334. function get_new_prefab_pool() {
  10335. return new PrefabPool();
  10336. }
  10337. cclegacy._RF.pop();
  10338. }
  10339. };
  10340. });
  10341. System.register("chunks:///_virtual/ProjectileMathUtil.ts", ['cc'], function (exports) {
  10342. var cclegacy;
  10343. return {
  10344. setters: [function (module) {
  10345. cclegacy = module.cclegacy;
  10346. }],
  10347. execute: function () {
  10348. cclegacy._RF.push({}, "16ac3tSOM5FwpZe8CFKhU2G", "ProjectileMathUtil", undefined);
  10349. /** 用于弧度转角度 */
  10350. var rad2Deg = 180 / Math.PI;
  10351. /** 用于角度转弧度 */
  10352. var deg2Rad = Math.PI / 180;
  10353. /**
  10354. * 抛射运动的数学工具
  10355. */
  10356. var ProjectileMathUtil = exports('default', /*#__PURE__*/function () {
  10357. function ProjectileMathUtil() {}
  10358. /**
  10359. * 计算耗时
  10360. * @param x 水平位移
  10361. * @param angle 初始角度
  10362. * @param velocity 初始速度
  10363. */
  10364. ProjectileMathUtil.calculateTotalTime = function calculateTotalTime(x, angle, velocity) {
  10365. // 初始角度(弧度制)
  10366. var θ = angle * deg2Rad;
  10367. // 时间
  10368. // t = x / ( v * cos(θ) )
  10369. var t = x / (velocity * Math.cos(θ));
  10370. return t;
  10371. }
  10372. /**
  10373. * 计算指定时刻的运动角度
  10374. * @param angle 初始角度
  10375. * @param velocity 初始速度
  10376. * @param time 时间
  10377. * @param gravity 重力加速度
  10378. * @param returnInRadians 是否返回弧度制结果
  10379. */;
  10380. ProjectileMathUtil.calculateAngleAtMoment = function calculateAngleAtMoment(angle, velocity, time, gravity, returnInRadians) {
  10381. if (returnInRadians === void 0) {
  10382. returnInRadians = false;
  10383. }
  10384. // 重力加速度(垂直向下)
  10385. var g = gravity; //
  10386. // 初始角度(弧度制)
  10387. var θ = angle * deg2Rad;
  10388. // 水平瞬时速度
  10389. // vx = v * cos(θ)
  10390. var vx = velocity * Math.cos(θ);
  10391. // 垂直瞬时速度
  10392. // vy = v * sin(θ) - g * t
  10393. var vy = velocity * Math.sin(θ) - g * time;
  10394. // 该时刻的运动角度(弧度制)
  10395. var θt = Math.atan(vy / vx);
  10396. return returnInRadians ? θt : θt * rad2Deg;
  10397. }
  10398. /**
  10399. * 计算指定时刻的位移距离
  10400. * @param angle 初始角度
  10401. * @param velocity 初始速度
  10402. * @param gravity 重力加速度
  10403. * @param time 时间点
  10404. */;
  10405. ProjectileMathUtil.calculateDisplacementAtMoment = function calculateDisplacementAtMoment(angle, velocity, gravity, time) {
  10406. // 重力加速度(垂直向下)
  10407. var g = gravity;
  10408. // 初始角度(弧度制)
  10409. var θ = angle * deg2Rad;
  10410. // 水平位移
  10411. // x = v * cos(θ) * t
  10412. var x = velocity * Math.cos(θ) * time;
  10413. // 垂直位移
  10414. // y = v * sin(θ) * t - 0.5 * g * t^2
  10415. var y = velocity * Math.sin(θ) * time - 0.5 * g * Math.pow(time, 2);
  10416. return {
  10417. x: x,
  10418. y: y
  10419. };
  10420. }
  10421. /**
  10422. * 根据初始角度计算初始速度
  10423. * @param x 水平距离
  10424. * @param y 垂直距离
  10425. * @param gravity 重力加速度
  10426. * @param angle 初始角度(角度制)
  10427. */;
  10428. ProjectileMathUtil.calculateWithAngle = function calculateWithAngle(x, y, gravity, angle) {
  10429. // 重力加速度(垂直向下)
  10430. var g = Math.abs(gravity);
  10431. // 初始角度(弧度制)
  10432. var θ = angle * deg2Rad;
  10433. // 速度公式
  10434. // v = sqrt( ( x^2 * g ) / ( 2 * x * sin(θ) * cos(θ) - 2 * y * cos(θ)^2 ) )
  10435. // 部分计算结果
  10436. var p1 = 2 * x * Math.sin(θ) * Math.cos(θ) - 2 * y * Math.pow(Math.cos(θ), 2);
  10437. // 负数没有平方根
  10438. if (p1 < 0) {
  10439. return NaN;
  10440. }
  10441. // 速度
  10442. var v = Math.sqrt(g * Math.pow(x, 2) / p1);
  10443. return v;
  10444. }
  10445. /**
  10446. * 根据初始速度计算初始角度
  10447. * @param x 水平距离
  10448. * @param y 垂直距离
  10449. * @param gravity 重力加速度
  10450. * @param velocity 初始速度
  10451. */;
  10452. ProjectileMathUtil.calculateWithVelocity = function calculateWithVelocity(x, y, velocity, gravity) {
  10453. // 重力加速度(垂直向下)
  10454. var g = gravity;
  10455. // 初始速度
  10456. var v = velocity;
  10457. // 角度公式
  10458. // θ = atan( ( -v^2 ± sqrt( v^4 - g * ( g * x^2 + 2 * y * v^2 ) ) / ( -g * x ) ) )
  10459. // 部分计算结果
  10460. var p1 = Math.pow(v, 2);
  10461. var p2 = Math.pow(v, 4) - g * (g * Math.pow(x, 2) + 2 * y * p1);
  10462. // 负数没有平方根
  10463. if (p2 < 0) {
  10464. return {
  10465. angle1: NaN,
  10466. angle2: NaN
  10467. };
  10468. }
  10469. // 部分计算结果
  10470. var p3 = Math.sqrt(p2);
  10471. // 角度(两个解)
  10472. var θ1 = Math.atan((-p1 + p3) / (-g * x));
  10473. var θ2 = Math.atan((-p1 - p3) / (-g * x));
  10474. return {
  10475. angle1: θ1 * rad2Deg,
  10476. angle2: θ2 * rad2Deg
  10477. };
  10478. }
  10479. /**
  10480. * 根据最大高度计算速度和角度
  10481. * @param x 水平距离
  10482. * @param y 垂直距离
  10483. * @param gravity 重力加速度
  10484. * @param maxHeight 最大高度
  10485. */;
  10486. ProjectileMathUtil.calculateWithMaxHeight = function calculateWithMaxHeight(x, y, maxHeight, gravity) {
  10487. // 重力加速度(垂直向下)
  10488. var g = gravity;
  10489. // 最大高度
  10490. var h = maxHeight;
  10491. // 最大高度不能小于 0,也不能够小于垂直距离
  10492. if (h < 0 || h - y < 0) {
  10493. return {
  10494. angle: NaN,
  10495. velocity: NaN,
  10496. time: NaN
  10497. };
  10498. }
  10499. // 部分计算结果
  10500. var p1 = Math.sqrt(2 * g * h);
  10501. var p2 = Math.sqrt(2 * g * (h - y));
  10502. // 时间公式
  10503. // t = ( -sqrt( 2 * g * h ) ± sqrt( 2 * g * ( h - y ) ) ) / -g
  10504. var t1 = (-p1 + p2) / -g;
  10505. var t2 = (-p1 - p2) / -g;
  10506. // 始终使用较大的解
  10507. var t = Math.max(t1, t2);
  10508. // 角度公式
  10509. // θ = atan( ( sqrt( 2 * g * h ) * t ) / x )
  10510. var θ = Math.atan(p1 * t / x);
  10511. // 速度公式
  10512. // v = sqrt( 2 * g * h ) / sin(θ)
  10513. var v = p1 / Math.sin(θ);
  10514. return {
  10515. angle: θ * rad2Deg,
  10516. velocity: v,
  10517. time: t
  10518. };
  10519. };
  10520. return ProjectileMathUtil;
  10521. }());
  10522. cclegacy._RF.pop();
  10523. }
  10524. };
  10525. });
  10526. System.register("chunks:///_virtual/Queue.ts", ['cc'], function (exports) {
  10527. var cclegacy;
  10528. return {
  10529. setters: [function (module) {
  10530. cclegacy = module.cclegacy;
  10531. }],
  10532. execute: function () {
  10533. cclegacy._RF.push({}, "16900mmPzlPkZiuO57PxvRs", "Queue", undefined);
  10534. var Queue = exports('default', /*#__PURE__*/function () {
  10535. function Queue() {
  10536. this.count = void 0;
  10537. this.lowestCount = void 0;
  10538. this.items = void 0;
  10539. this.count = 0;
  10540. this.lowestCount = 0;
  10541. this.items = {};
  10542. }
  10543. /**加入队列*/
  10544. var _proto = Queue.prototype;
  10545. _proto.enqueue = function enqueue(item) {
  10546. // 队列的末尾添加元素: 将队列的大小作为key
  10547. this.items[this.count] = item;
  10548. this.count++;
  10549. }
  10550. /**拿出队首*/;
  10551. _proto.dequeue = function dequeue() {
  10552. if (this.isEmpty()) {
  10553. return undefined;
  10554. }
  10555. var result = this.items[this.lowestCount];
  10556. // 删除队首元素
  10557. delete this.items[this.lowestCount];
  10558. // 队首元素自增
  10559. this.lowestCount++;
  10560. return result;
  10561. }
  10562. /**是否为空队列*/;
  10563. _proto.isEmpty = function isEmpty() {
  10564. return this.count - this.lowestCount === 0;
  10565. }
  10566. /**查看下一个出队元素 */;
  10567. _proto.peek = function peek() {
  10568. if (this.isEmpty()) {
  10569. return undefined;
  10570. }
  10571. return this.items[this.lowestCount];
  10572. }
  10573. /**队列个数*/;
  10574. _proto.size = function size() {
  10575. return this.count - this.lowestCount;
  10576. }
  10577. /**清空队列*/;
  10578. _proto.clear = function clear() {
  10579. this.count = 0;
  10580. this.lowestCount = 0;
  10581. this.items = {};
  10582. };
  10583. _proto.toString = function toString() {
  10584. if (this.isEmpty()) {
  10585. return "";
  10586. }
  10587. var objString = "" + this.items[this.lowestCount];
  10588. for (var i = this.lowestCount + 1; i < this.count; i++) {
  10589. objString = objString + "," + this.items[i];
  10590. }
  10591. return objString;
  10592. };
  10593. return Queue;
  10594. }());
  10595. var Deque = exports('Deque', /*#__PURE__*/function () {
  10596. function Deque() {
  10597. this.items = void 0;
  10598. this.lowestCount = void 0;
  10599. this.count = void 0;
  10600. this.items = {};
  10601. this.lowestCount = 0;
  10602. this.count = 0;
  10603. }
  10604. /**
  10605. * 向队列的尾端添加元素
  10606. * @param element
  10607. * @returns size
  10608. */
  10609. var _proto2 = Deque.prototype;
  10610. _proto2.addTail = function addTail(element) {
  10611. this.items[this.count++] = element;
  10612. return this.size();
  10613. }
  10614. /**
  10615. * 向队列头部添加元素
  10616. * @param element
  10617. * @returns size
  10618. */;
  10619. _proto2.addHead = function addHead(element) {
  10620. if (this.count === 0) {
  10621. this.addTail(element);
  10622. } else if (this.lowestCount > 0) {
  10623. this.items[--this.lowestCount] = element;
  10624. } else {
  10625. for (var i = this.count; i > this.lowestCount; i--) {
  10626. this.items[i] = this.items[i - 1];
  10627. }
  10628. this.count++;
  10629. this.items[0] = element;
  10630. }
  10631. return this.size();
  10632. }
  10633. /**
  10634. * 返回队列尾部的元素
  10635. * @returns T
  10636. */;
  10637. _proto2.getTail = function getTail() {
  10638. if (this.isEmpty()) return undefined;
  10639. this.count--;
  10640. var res = this.items[this.count];
  10641. delete this.items[this.count];
  10642. return res;
  10643. }
  10644. /**
  10645. * 返回头部元素
  10646. * @returns T
  10647. */;
  10648. _proto2.getHead = function getHead() {
  10649. if (this.isEmpty()) return undefined;
  10650. var res = this.items[this.lowestCount];
  10651. delete this.items[this.lowestCount];
  10652. this.lowestCount++;
  10653. return res;
  10654. }
  10655. /**
  10656. * 看一下队列首部的元素
  10657. * @returns T
  10658. */;
  10659. _proto2.peekHead = function peekHead() {
  10660. if (this.isEmpty()) return undefined;
  10661. return this.items[this.lowestCount];
  10662. }
  10663. /**
  10664. * 看一下队列尾部的元素
  10665. * @return T
  10666. */;
  10667. _proto2.peekTail = function peekTail() {
  10668. if (this.isEmpty()) return undefined;
  10669. return this.items[this.count - 1];
  10670. }
  10671. /**
  10672. * 返回元素的个数
  10673. * @returns number
  10674. */;
  10675. _proto2.size = function size() {
  10676. return this.count - this.lowestCount;
  10677. }
  10678. /**
  10679. * 判断队列是否为空
  10680. */;
  10681. _proto2.isEmpty = function isEmpty() {
  10682. return this.size() === 0;
  10683. }
  10684. /**
  10685. * 清空队列
  10686. */;
  10687. _proto2.clear = function clear() {
  10688. this.items = {};
  10689. this.count = this.lowestCount = 0;
  10690. };
  10691. _proto2.toString = function toString() {
  10692. if (this.isEmpty()) {
  10693. return '';
  10694. }
  10695. var res = this.items[this.lowestCount].toString();
  10696. for (var i = this.lowestCount + 1; i < this.count; i++) {
  10697. res = res + ", " + this.items[i].toString();
  10698. }
  10699. return res;
  10700. };
  10701. return Deque;
  10702. }());
  10703. cclegacy._RF.pop();
  10704. }
  10705. };
  10706. });
  10707. System.register("chunks:///_virtual/Random.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  10708. var _createClass, cclegacy;
  10709. return {
  10710. setters: [function (module) {
  10711. _createClass = module.createClass;
  10712. }, function (module) {
  10713. cclegacy = module.cclegacy;
  10714. }],
  10715. execute: function () {
  10716. exports('default', get_new_random);
  10717. cclegacy._RF.push({}, "0df919aG5RLDb2SUzCkvbif", "Random", undefined);
  10718. /**设种一个随机种子保证随机结果一致
  10719. * 后面需要可以引入 seedrandom 库
  10720. */
  10721. var Random = /*#__PURE__*/function () {
  10722. /**随机种子*/
  10723. function Random(seed) {
  10724. this._seed = void 0;
  10725. this._start_seed = void 0;
  10726. this.set_seed(seed);
  10727. }
  10728. /**设置当前开始种子*/
  10729. var _proto = Random.prototype;
  10730. _proto.set_seed = function set_seed(seed) {
  10731. this._seed = seed;
  10732. this._start_seed = seed;
  10733. };
  10734. _proto._nextSeed = function _nextSeed() {
  10735. this._seed = (this._seed * 9301 + 49297) % 233280;
  10736. }
  10737. /**0.0(含)-1.0(不含)*/;
  10738. _proto._nextFloat = function _nextFloat() {
  10739. this._nextSeed();
  10740. return this._seed / 233280;
  10741. }
  10742. /**0(含)-max(不含) */;
  10743. _proto._nextInt = function _nextInt(max) {
  10744. max = Math.floor(max);
  10745. this._nextSeed();
  10746. return this._seed % max;
  10747. }
  10748. /**
  10749. * 生成指定范围的随机浮点数
  10750. * @param min 最小值(含)
  10751. * @param max 最大值(不含)
  10752. */;
  10753. _proto["float"] = function float(min, max) {
  10754. if (min === void 0) {
  10755. min = 0;
  10756. }
  10757. if (max === void 0) {
  10758. max = 1;
  10759. }
  10760. return this._nextFloat() * (max - min) + min;
  10761. }
  10762. /**
  10763. * 生成指定范围的随机整数
  10764. * @param min 最小值(含)
  10765. * @param max 最大值(不含)
  10766. * @returns
  10767. */;
  10768. _proto["int"] = function int(min, max) {
  10769. if (min === void 0) {
  10770. min = 0;
  10771. }
  10772. if (max === void 0) {
  10773. max = 100;
  10774. }
  10775. return this._nextInt(max - min) + Math.ceil(min);
  10776. }
  10777. /** 生成随机整数 -1 或 1*/;
  10778. _proto.dir = function dir() {
  10779. return Math.floor(this["float"]() * 2) === 0 ? -1 : 1;
  10780. }
  10781. /**
  10782. * 在指定数组中随机取出N个不重复的数据
  10783. * @param resArr
  10784. * @param ranNum
  10785. * @returns {Array}
  10786. */;
  10787. _proto.getDiffValueFromArr = function getDiffValueFromArr(resArr, ranNum) {
  10788. var arr = new Array();
  10789. var result = new Array();
  10790. if (!resArr || resArr.length <= 0 || ranNum <= 0) {
  10791. return result;
  10792. }
  10793. for (var i = 0; i < resArr.length; i++) {
  10794. arr.push(resArr[i]);
  10795. }
  10796. if (ranNum >= arr.length) return arr;
  10797. ranNum = Math.min(ranNum, arr.length - 1);
  10798. for (var _i = 0; _i < ranNum; _i++) {
  10799. var ran = this["int"](0, arr.length - 1);
  10800. result.push(arr.splice(ran, 1)[0]);
  10801. }
  10802. return result;
  10803. }
  10804. /**
  10805. * 生成指定范围的随机整数
  10806. * @param min 最小值
  10807. * @param max 最大值
  10808. * @param type 类型
  10809. * @example
  10810. //type=1 [min,max) 得到一个两数之间的随机整数,这个值不小于min(如果min不是整数的话,得到一个向上取整的 min),并且小于(但不等于)max
  10811. //type=2 [min,max] 得到一个两数之间的随机整数,包括两个数在内,这个值比min大(如果min不是整数,那就不小于比min大的整数),但小于(但不等于)max
  10812. //type=3 (min,max) 得到一个两数之间的随机整数
  10813. */;
  10814. _proto.int_type = function int_type(min, max, type) {
  10815. min = Math.ceil(min);
  10816. max = Math.floor(max);
  10817. switch (type) {
  10818. case 1:
  10819. // [min,max) 得到一个两数之间的随机整数,这个值不小于min(如果min不是整数的话,得到一个向上取整的 min),并且小于(但不等于)max
  10820. return Math.floor(this._nextFloat() * (max - min)) + min;
  10821. case 2:
  10822. // [min,max] 得到一个两数之间的随机整数,包括两个数在内,这个值比min大(如果min不是整数,那就不小于比min大的整数),但小于(但不等于)max
  10823. return Math.floor(this._nextFloat() * (max - min + 1)) + min;
  10824. case 3:
  10825. // (min,max) 得到一个两数之间的随机整数
  10826. return Math.floor(this._nextFloat() * (max - min - 1)) + min + 1;
  10827. }
  10828. return 0;
  10829. };
  10830. _createClass(Random, [{
  10831. key: "seed",
  10832. get: /**当前种子*/
  10833. function get() {
  10834. return this._seed;
  10835. }
  10836. /**原始种子*/
  10837. }, {
  10838. key: "start_seed",
  10839. get: function get() {
  10840. return this._start_seed;
  10841. }
  10842. }]);
  10843. return Random;
  10844. }();
  10845. /**创建一个设定好种子的随机数实例*/
  10846. function get_new_random(seed) {
  10847. return new Random(seed);
  10848. }
  10849. cclegacy._RF.pop();
  10850. }
  10851. };
  10852. });
  10853. System.register("chunks:///_virtual/ResUtil.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  10854. var _asyncToGenerator, _regeneratorRuntime, cclegacy, assetManager, resources, AssetManager, director, Texture2D, ImageAsset;
  10855. return {
  10856. setters: [function (module) {
  10857. _asyncToGenerator = module.asyncToGenerator;
  10858. _regeneratorRuntime = module.regeneratorRuntime;
  10859. }, function (module) {
  10860. cclegacy = module.cclegacy;
  10861. assetManager = module.assetManager;
  10862. resources = module.resources;
  10863. AssetManager = module.AssetManager;
  10864. director = module.director;
  10865. Texture2D = module.Texture2D;
  10866. ImageAsset = module.ImageAsset;
  10867. }],
  10868. execute: function () {
  10869. exports('ResUtil', void 0);
  10870. cclegacy._RF.push({}, "fdca4buPvxCtqd20MSvpC7T", "ResUtil", undefined);
  10871. //export type Constructor<T extends Asset> = new () => T;
  10872. var headImgExt = exports('headImgExt', ".head");
  10873. var ResUtil;
  10874. (function (_ResUtil) {
  10875. function loadRemote(url, option) {
  10876. return new Promise(function (resolve, reject) {
  10877. assetManager.loadRemote(url, option, function (err, asset) {
  10878. resolve && resolve(err ? null : asset);
  10879. });
  10880. });
  10881. }
  10882. _ResUtil.loadRemote = loadRemote;
  10883. function loadBundle(bundleName) {
  10884. return new Promise(function (resolve, reject) {
  10885. assetManager.loadBundle(bundleName, function (err, bundle) {
  10886. resolve && resolve(err ? null : bundle);
  10887. });
  10888. });
  10889. }
  10890. _ResUtil.loadBundle = loadBundle;
  10891. function getBundle(bundleName) {
  10892. if (null == bundleName || '' === bundleName) {
  10893. return resources;
  10894. } else {
  10895. return assetManager.getBundle(bundleName);
  10896. }
  10897. }
  10898. _ResUtil.getBundle = getBundle;
  10899. function loadAsset(_x, _x2) {
  10900. return _loadAsset.apply(this, arguments);
  10901. }
  10902. function _loadAsset() {
  10903. _loadAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path, bundle) {
  10904. var bd, asset;
  10905. return _regeneratorRuntime().wrap(function _callee$(_context) {
  10906. while (1) switch (_context.prev = _context.next) {
  10907. case 0:
  10908. if (!bundle) bundle = '';
  10909. if (!(typeof bundle === 'string')) {
  10910. _context.next = 9;
  10911. break;
  10912. }
  10913. bd = getBundle(bundle);
  10914. if (bd) {
  10915. _context.next = 7;
  10916. break;
  10917. }
  10918. _context.next = 6;
  10919. return loadBundle(bundle);
  10920. case 6:
  10921. bd = _context.sent;
  10922. case 7:
  10923. _context.next = 10;
  10924. break;
  10925. case 9:
  10926. if (bundle instanceof AssetManager.Bundle) {
  10927. bd = bundle;
  10928. }
  10929. case 10:
  10930. asset = bd.get(path);
  10931. if (!(null != asset)) {
  10932. _context.next = 13;
  10933. break;
  10934. }
  10935. return _context.abrupt("return", Promise.resolve(asset));
  10936. case 13:
  10937. return _context.abrupt("return", new Promise(function (resolve, reject) {
  10938. bd.load(path, function (err, asset) {
  10939. resolve(err ? null : asset);
  10940. });
  10941. }));
  10942. case 14:
  10943. case "end":
  10944. return _context.stop();
  10945. }
  10946. }, _callee);
  10947. }));
  10948. return _loadAsset.apply(this, arguments);
  10949. }
  10950. _ResUtil.loadAsset = loadAsset;
  10951. function loadDir(_x3, _x4, _x5) {
  10952. return _loadDir.apply(this, arguments);
  10953. }
  10954. function _loadDir() {
  10955. _loadDir = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, bundle, progressCallback) {
  10956. var bd;
  10957. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  10958. while (1) switch (_context2.prev = _context2.next) {
  10959. case 0:
  10960. if (!bundle) bundle = '';
  10961. if (!(typeof bundle === 'string')) {
  10962. _context2.next = 9;
  10963. break;
  10964. }
  10965. bd = getBundle(bundle);
  10966. if (bd) {
  10967. _context2.next = 7;
  10968. break;
  10969. }
  10970. _context2.next = 6;
  10971. return loadBundle(bundle);
  10972. case 6:
  10973. bd = _context2.sent;
  10974. case 7:
  10975. _context2.next = 10;
  10976. break;
  10977. case 9:
  10978. if (bundle instanceof AssetManager.Bundle) {
  10979. bd = bundle;
  10980. }
  10981. case 10:
  10982. return _context2.abrupt("return", new Promise(function (resolve, reject) {
  10983. bd.loadDir(path, function (finished, total, item) {
  10984. progressCallback == null || progressCallback(finished, total);
  10985. }, function (err, assets) {
  10986. resolve(err ? null : assets);
  10987. });
  10988. }));
  10989. case 11:
  10990. case "end":
  10991. return _context2.stop();
  10992. }
  10993. }, _callee2);
  10994. }));
  10995. return _loadDir.apply(this, arguments);
  10996. }
  10997. _ResUtil.loadDir = loadDir;
  10998. function loadAssets(_x6, _x7, _x8) {
  10999. return _loadAssets.apply(this, arguments);
  11000. }
  11001. function _loadAssets() {
  11002. _loadAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(list, bundle, progressCallback) {
  11003. var bd;
  11004. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  11005. while (1) switch (_context3.prev = _context3.next) {
  11006. case 0:
  11007. if (!bundle) bundle = '';
  11008. if (!(typeof bundle === 'string')) {
  11009. _context3.next = 9;
  11010. break;
  11011. }
  11012. bd = getBundle(bundle);
  11013. if (bd) {
  11014. _context3.next = 7;
  11015. break;
  11016. }
  11017. _context3.next = 6;
  11018. return loadBundle(bundle);
  11019. case 6:
  11020. bd = _context3.sent;
  11021. case 7:
  11022. _context3.next = 10;
  11023. break;
  11024. case 9:
  11025. if (bundle instanceof AssetManager.Bundle) {
  11026. bd = bundle;
  11027. }
  11028. case 10:
  11029. return _context3.abrupt("return", new Promise(function (resolve, reject) {
  11030. bd.load(list, function (finished, total, item) {
  11031. progressCallback == null || progressCallback(finished, total);
  11032. }, function (err, data) {
  11033. resolve(err ? null : data);
  11034. });
  11035. }));
  11036. case 11:
  11037. case "end":
  11038. return _context3.stop();
  11039. }
  11040. }, _callee3);
  11041. }));
  11042. return _loadAssets.apply(this, arguments);
  11043. }
  11044. _ResUtil.loadAssets = loadAssets;
  11045. function loadScene(_x9, _x10, _x11) {
  11046. return _loadScene.apply(this, arguments);
  11047. }
  11048. function _loadScene() {
  11049. _loadScene = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(scene_name, bundle, show) {
  11050. var bd;
  11051. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  11052. while (1) switch (_context4.prev = _context4.next) {
  11053. case 0:
  11054. if (show === void 0) {
  11055. show = false;
  11056. }
  11057. if (!bundle) bundle = '';
  11058. if (!(typeof bundle === 'string')) {
  11059. _context4.next = 10;
  11060. break;
  11061. }
  11062. bd = getBundle(bundle);
  11063. if (bd) {
  11064. _context4.next = 8;
  11065. break;
  11066. }
  11067. _context4.next = 7;
  11068. return loadBundle(bundle);
  11069. case 7:
  11070. bd = _context4.sent;
  11071. case 8:
  11072. _context4.next = 11;
  11073. break;
  11074. case 10:
  11075. if (bundle instanceof AssetManager.Bundle) {
  11076. bd = bundle;
  11077. }
  11078. case 11:
  11079. return _context4.abrupt("return", new Promise(function (resolve, reject) {
  11080. bd.loadScene(scene_name, function (err, asset) {
  11081. resolve(err ? null : asset);
  11082. if (show) director.loadScene(scene_name);
  11083. });
  11084. }));
  11085. case 12:
  11086. case "end":
  11087. return _context4.stop();
  11088. }
  11089. }, _callee4);
  11090. }));
  11091. return _loadScene.apply(this, arguments);
  11092. }
  11093. _ResUtil.loadScene = loadScene;
  11094. function releaseAll() {
  11095. assetManager.releaseAll();
  11096. }
  11097. _ResUtil.releaseAll = releaseAll;
  11098. function releaseAsset(asset) {
  11099. assetManager.releaseAsset(asset);
  11100. }
  11101. _ResUtil.releaseAsset = releaseAsset;
  11102. function release(path, bundle) {
  11103. var bd;
  11104. if (!bundle) bundle = '';
  11105. if (typeof bundle === 'string') {
  11106. bd = getBundle(bundle);
  11107. } else if (bundle instanceof AssetManager.Bundle) {
  11108. bd = bundle;
  11109. }
  11110. if (path && path != '') {
  11111. var _bd;
  11112. (_bd = bd) == null || _bd.release(path);
  11113. } else {
  11114. var _bd2;
  11115. (_bd2 = bd) == null || _bd2.releaseAll();
  11116. }
  11117. }
  11118. _ResUtil.release = release;
  11119. function registerHeadImgLoader() {
  11120. assetManager.downloader.register(headImgExt, function (content, options, onComplete) {
  11121. onComplete(null, content);
  11122. });
  11123. assetManager.parser.register(headImgExt, downloadDomImage);
  11124. assetManager.factory.register(headImgExt, createTexture);
  11125. }
  11126. _ResUtil.registerHeadImgLoader = registerHeadImgLoader;
  11127. function createTexture(id, data, options, onComplete) {
  11128. var out = null;
  11129. var err = null;
  11130. try {
  11131. out = new Texture2D();
  11132. var imageAsset = new ImageAsset(data);
  11133. out.image = imageAsset;
  11134. } catch (e) {
  11135. err = e;
  11136. }
  11137. onComplete && onComplete(err, out);
  11138. }
  11139. function downloadDomImage(url, options, onComplete) {
  11140. var img = new Image();
  11141. if (window.location.protocol !== 'file:') {
  11142. img.crossOrigin = 'anonymous';
  11143. }
  11144. function loadCallback() {
  11145. img.removeEventListener('load', loadCallback);
  11146. img.removeEventListener('error', errorCallback);
  11147. if (onComplete) {
  11148. onComplete(null, img);
  11149. }
  11150. }
  11151. function errorCallback() {
  11152. img.removeEventListener('load', loadCallback);
  11153. img.removeEventListener('error', errorCallback);
  11154. if (onComplete) {
  11155. onComplete(new Error(url));
  11156. }
  11157. }
  11158. img.addEventListener('load', loadCallback);
  11159. img.addEventListener('error', errorCallback);
  11160. img.src = url;
  11161. return img;
  11162. }
  11163. })(ResUtil || (ResUtil = exports('ResUtil', {})));
  11164. cclegacy._RF.pop();
  11165. }
  11166. };
  11167. });
  11168. System.register("chunks:///_virtual/RewardFly.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  11169. var _inheritsLoose, cclegacy, _decorator, UITransform, Node, Vec3, instantiate, Widget, v3, UIOpacity, tween, easing, Component;
  11170. return {
  11171. setters: [function (module) {
  11172. _inheritsLoose = module.inheritsLoose;
  11173. }, function (module) {
  11174. cclegacy = module.cclegacy;
  11175. _decorator = module._decorator;
  11176. UITransform = module.UITransform;
  11177. Node = module.Node;
  11178. Vec3 = module.Vec3;
  11179. instantiate = module.instantiate;
  11180. Widget = module.Widget;
  11181. v3 = module.v3;
  11182. UIOpacity = module.UIOpacity;
  11183. tween = module.tween;
  11184. easing = module.easing;
  11185. Component = module.Component;
  11186. }],
  11187. execute: function () {
  11188. var _dec, _dec2, _class;
  11189. cclegacy._RF.push({}, "9d999oa7ZtO/Jhnk1+iN63E", "RewardFly", undefined);
  11190. var ccclass = _decorator.ccclass,
  11191. requireComponent = _decorator.requireComponent;
  11192. var RewardFly = exports('RewardFly', (_dec = ccclass('RewardFly'), _dec2 = requireComponent(UITransform), _dec(_class = _dec2(_class = /*#__PURE__*/function (_Component) {
  11193. _inheritsLoose(RewardFly, _Component);
  11194. function RewardFly() {
  11195. return _Component.apply(this, arguments) || this;
  11196. }
  11197. var _proto = RewardFly.prototype;
  11198. _proto.onLoad = function onLoad() {
  11199. //this.node.on(Node.EventType.TOUCH_START, function (event: EventTouch) {
  11200. //event.propagationStopped = true;
  11201. //event.preventSwallow = true;
  11202. //}, this, true);
  11203. };
  11204. _proto.onDisable = function onDisable() {
  11205. this.node.destroyAllChildren();
  11206. };
  11207. _proto.convertToNodeSpaceAR = function convertToNodeSpaceAR(target) {
  11208. if (target instanceof Node) {
  11209. return this.node.getComponent(UITransform).convertToNodeSpaceAR(target.getComponent(UITransform).convertToWorldSpaceAR(Vec3.ZERO));
  11210. }
  11211. return this.node.getComponent(UITransform).convertToNodeSpaceAR(target);
  11212. };
  11213. _proto.add = function add(opts) {
  11214. var _this = this;
  11215. var startPos = this.convertToNodeSpaceAR(opts.start);
  11216. var endPos = this.convertToNodeSpaceAR(opts.end);
  11217. if (opts.endOffset) {
  11218. endPos.add3f(opts.endOffset[0], opts.endOffset[1], 0);
  11219. }
  11220. var nodeCopy = null;
  11221. if (opts.highlight) {
  11222. if (opts.highlightOffset) {
  11223. endPos.add3f(opts.highlightOffset[0], opts.highlightOffset[1], 0);
  11224. }
  11225. if (opts.highlightArea) {
  11226. var _nodeCopy$getComponen;
  11227. var endAreaPos = this.convertToNodeSpaceAR(opts.highlightArea);
  11228. if (opts.highlightOffset) {
  11229. endAreaPos.add3f(opts.highlightOffset[0], opts.highlightOffset[1], 0);
  11230. }
  11231. nodeCopy = instantiate(opts.highlightArea);
  11232. (_nodeCopy$getComponen = nodeCopy.getComponent(Widget)) == null || _nodeCopy$getComponen.destroy();
  11233. nodeCopy.setParent(this.node);
  11234. nodeCopy.setPosition(endAreaPos);
  11235. } else if (Node.isNode(opts.end)) {
  11236. var _nodeCopy$getComponen2;
  11237. nodeCopy = instantiate(opts.end);
  11238. (_nodeCopy$getComponen2 = nodeCopy.getComponent(Widget)) == null || _nodeCopy$getComponen2.destroy();
  11239. nodeCopy.setParent(this.node);
  11240. nodeCopy.setPosition(endPos);
  11241. }
  11242. }
  11243. var _loop = function _loop(index) {
  11244. var aniNode = instantiate(opts.item);
  11245. aniNode.setPosition(startPos);
  11246. aniNode.setParent(_this.node);
  11247. // 炸开位置
  11248. var midPos = v3(startPos.x, startPos.y, 0);
  11249. midPos.x += (Math.random() * 2 - 1) * (opts.startRange ? opts.startRange[0] : 100);
  11250. midPos.y += (Math.random() * 2 - 1) * (opts.startRange ? opts.startRange[1] : 100);
  11251. // 执行动画
  11252. (aniNode.getComponent(UIOpacity) || aniNode.addComponent(UIOpacity)).opacity = 0;
  11253. tween(aniNode).delay(index * 0.025).call(function () {
  11254. aniNode.getComponent(UIOpacity).opacity = 200;
  11255. tween(aniNode.getComponent(UIOpacity)).to(0.4, {
  11256. opacity: 255
  11257. }, {
  11258. easing: easing.expoOut
  11259. }).start();
  11260. }).to(0.4, {
  11261. position: midPos
  11262. }, {
  11263. easing: easing.expoOut
  11264. }).call(function () {
  11265. tween(aniNode.getComponent(UIOpacity)).delay(0.5).to(0.1, {
  11266. opacity: 70
  11267. }).start();
  11268. }).to(0.6, {
  11269. position: endPos
  11270. }, {
  11271. easing: easing.expoIn
  11272. }).call(function () {
  11273. if (index === 0) {
  11274. // 结束节点缩放
  11275. if (nodeCopy) {
  11276. var scale = v3(nodeCopy.scale);
  11277. tween(nodeCopy).to(0.1, {
  11278. scale: v3(scale.x * 1.3, scale.y * 1.3)
  11279. }).delay(0.025 * Math.max(opts.count, 4)).to(0.1, {
  11280. scale: scale
  11281. }).call(function () {
  11282. // 结束节点透明销毁
  11283. var uiOpacity = nodeCopy.getComponent(UIOpacity) || nodeCopy.addComponent(UIOpacity);
  11284. tween(uiOpacity).to(0.1, {
  11285. opacity: uiOpacity.opacity * 0.3
  11286. }).call(function () {
  11287. return nodeCopy.destroy();
  11288. }).start();
  11289. }).start();
  11290. }
  11291. opts.onBegin && opts.onBegin(nodeCopy);
  11292. }
  11293. opts.onContact && opts.onContact(nodeCopy);
  11294. }).delay(0.01).call(function () {
  11295. aniNode.destroy();
  11296. if (index === opts.count - 1) {
  11297. opts.onFinish && opts.onFinish(nodeCopy);
  11298. }
  11299. }).start();
  11300. };
  11301. for (var index = 0; index < opts.count; index++) {
  11302. _loop(index);
  11303. }
  11304. };
  11305. return RewardFly;
  11306. }(Component)) || _class) || _class));
  11307. cclegacy._RF.pop();
  11308. }
  11309. };
  11310. });
  11311. System.register("chunks:///_virtual/SafeNumber.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  11312. var _createClass, cclegacy;
  11313. return {
  11314. setters: [function (module) {
  11315. _createClass = module.createClass;
  11316. }, function (module) {
  11317. cclegacy = module.cclegacy;
  11318. }],
  11319. execute: function () {
  11320. exports({
  11321. get_new_safe_const_number: get_new_safe_const_number,
  11322. get_new_safe_number: get_new_safe_number
  11323. });
  11324. cclegacy._RF.push({}, "7e0d8kg6FBL46wNVfNiK7eE", "SafeNumber", undefined);
  11325. /**
  11326. * 防内存调试变量数字类型
  11327. */
  11328. var SafeVarNumber = /*#__PURE__*/function () {
  11329. function SafeVarNumber(num) {
  11330. if (num === void 0) {
  11331. num = 0;
  11332. }
  11333. this.cache = 0;
  11334. this.scale = 2;
  11335. this.map = {};
  11336. this.idx = 0;
  11337. this.value = num;
  11338. }
  11339. /**数值 */
  11340. var _proto = SafeVarNumber.prototype;
  11341. _proto.valueOf = function valueOf() {
  11342. return this.value;
  11343. };
  11344. _proto.toString = function toString() {
  11345. return this.value.toString();
  11346. };
  11347. _proto.clone = function clone() {
  11348. return new SafeVarNumber(this.value);
  11349. };
  11350. _createClass(SafeVarNumber, [{
  11351. key: "value",
  11352. get: function get() {
  11353. if (Math.abs(this.map[this.idx] * this.scale - this.cache) > 0.000001) {
  11354. this.map[this.idx] = this.cache / this.scale;
  11355. }
  11356. return this.map[this.idx];
  11357. },
  11358. set: function set(num) {
  11359. delete this.map[this.idx];
  11360. this.idx = Math.floor(Math.random() * 256);
  11361. this.map[this.idx] = num;
  11362. this.scale = Math.floor(Math.random() * 2) + 2;
  11363. this.cache = num * this.scale;
  11364. }
  11365. }]);
  11366. return SafeVarNumber;
  11367. }();
  11368. /**
  11369. * 防内存调试常量数字类型
  11370. */
  11371. var SafeConstNumber = /*#__PURE__*/function () {
  11372. function SafeConstNumber(num) {
  11373. if (num === void 0) {
  11374. num = 0;
  11375. }
  11376. this.cache = 0;
  11377. this.scale = 2;
  11378. this.map = {};
  11379. this.idx = 0;
  11380. this.idx = Math.floor(Math.random() * 256);
  11381. this.map[this.idx] = num;
  11382. this.scale = Math.floor(Math.random() * 2) + 2;
  11383. this.cache = num * this.scale;
  11384. }
  11385. /**数值 */
  11386. var _proto2 = SafeConstNumber.prototype;
  11387. _proto2.valueOf = function valueOf() {
  11388. return this.value;
  11389. };
  11390. _proto2.toString = function toString() {
  11391. return this.value.toString();
  11392. };
  11393. _proto2.clone = function clone() {
  11394. return new SafeConstNumber(this.value);
  11395. };
  11396. _createClass(SafeConstNumber, [{
  11397. key: "value",
  11398. get: function get() {
  11399. var num = this.map[this.idx];
  11400. if (Math.abs(num * this.scale - this.cache) > 0.000001) {
  11401. num = this.cache / this.scale;
  11402. }
  11403. delete this.map[this.idx];
  11404. this.idx = Math.floor(Math.random() * 256);
  11405. this.map[this.idx] = num;
  11406. return this.map[this.idx];
  11407. }
  11408. }]);
  11409. return SafeConstNumber;
  11410. }();
  11411. function get_new_safe_number(num) {
  11412. return new SafeVarNumber(num);
  11413. }
  11414. function get_new_safe_const_number(num) {
  11415. return new SafeConstNumber(num);
  11416. }
  11417. cclegacy._RF.pop();
  11418. }
  11419. };
  11420. });
  11421. System.register("chunks:///_virtual/SceneDef.ts", ['cc'], function (exports) {
  11422. var cclegacy;
  11423. return {
  11424. setters: [function (module) {
  11425. cclegacy = module.cclegacy;
  11426. }],
  11427. execute: function () {
  11428. cclegacy._RF.push({}, "01aa7QePwpMF4PE+VsC8QVh", "SceneDef", undefined);
  11429. var SceneDef = exports('SceneDef', function SceneDef() {});
  11430. SceneDef.START = 'start';
  11431. SceneDef.GAME = 'game';
  11432. SceneDef.Hall = 'hall';
  11433. cclegacy._RF.pop();
  11434. }
  11435. };
  11436. });
  11437. System.register("chunks:///_virtual/Shake.ts", ['cc'], function (exports) {
  11438. var Vec3, cclegacy;
  11439. return {
  11440. setters: [function (module) {
  11441. Vec3 = module.Vec3;
  11442. cclegacy = module.cclegacy;
  11443. }],
  11444. execute: function () {
  11445. exports('default', get_new_shake);
  11446. cclegacy._RF.push({}, "88adahxArtIPKhtXnEB29+o", "Shake", undefined);
  11447. var Shake = /*#__PURE__*/function () {
  11448. function Shake(startPos) {
  11449. if (startPos === void 0) {
  11450. startPos = new Vec3(0, 0, 0);
  11451. }
  11452. this.intensity = void 0;
  11453. this.duration = void 0;
  11454. this.shakePos = new Vec3(0, 0, 0);
  11455. this.startPos = startPos;
  11456. this.duration = 0;
  11457. this.intensity = 0;
  11458. }
  11459. /**改变初起点*/
  11460. var _proto = Shake.prototype;
  11461. _proto.setStartPos = function setStartPos(x, y) {
  11462. this.startPos.x = x;
  11463. this.startPos.y = y;
  11464. }
  11465. /**开始抖动
  11466. * duration 时间
  11467. * intensity 强度
  11468. */;
  11469. _proto.start = function start(duration, intensity) {
  11470. if (duration === void 0) {
  11471. duration = 0.3;
  11472. }
  11473. if (intensity === void 0) {
  11474. intensity = 3.8;
  11475. }
  11476. this.duration = duration;
  11477. this.intensity = intensity;
  11478. }
  11479. /**停止抖动*/;
  11480. _proto.stop = function stop() {
  11481. this.shakePos.x = this.startPos.x;
  11482. this.shakePos.y = this.startPos.y;
  11483. this.duration = 0;
  11484. return this.shakePos;
  11485. };
  11486. _proto.getShakePos = function getShakePos() {
  11487. return this.shakePos;
  11488. };
  11489. _proto.action = function action(dt) {
  11490. if (this.duration > 0) {
  11491. this.duration -= dt;
  11492. if (this.duration <= 0) {
  11493. return this.stop();
  11494. } else {
  11495. var randomX = Math.random() * this.intensity - this.intensity * 0.5;
  11496. var randomY = Math.random() * this.intensity - this.intensity * 0.5;
  11497. this.shakePos.x = this.startPos.x + randomX;
  11498. this.shakePos.y = this.startPos.y + randomY;
  11499. return this.shakePos;
  11500. }
  11501. }
  11502. return null;
  11503. };
  11504. return Shake;
  11505. }();
  11506. function get_new_shake(startPos) {
  11507. if (startPos === void 0) {
  11508. startPos = new Vec3(0, 0, 0);
  11509. }
  11510. return new Shake(startPos);
  11511. }
  11512. cclegacy._RF.pop();
  11513. }
  11514. };
  11515. });
  11516. System.register("chunks:///_virtual/sign.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  11517. var _createClass, cclegacy;
  11518. return {
  11519. setters: [function (module) {
  11520. _createClass = module.createClass;
  11521. }, function (module) {
  11522. cclegacy = module.cclegacy;
  11523. }],
  11524. execute: function () {
  11525. cclegacy._RF.push({}, "6d031yryKRLYaiOHaXKh4Av", "sign", undefined);
  11526. var ch_sign = exports('default', /*#__PURE__*/function () {
  11527. function ch_sign() {
  11528. this._sign_data = new Set();
  11529. this._max = 7;
  11530. this._creat_date = 0;
  11531. this._sign_count = 0;
  11532. this._mode = 1;
  11533. }
  11534. ch_sign.getInstance = function getInstance() {
  11535. if (!this._instance) this._instance = new ch_sign();
  11536. return this._instance;
  11537. };
  11538. var _proto = ch_sign.prototype;
  11539. _proto.getCreatDayCount = function getCreatDayCount() {
  11540. if (this._creat_date == 0) {
  11541. chsdk.log.warn("签到模块没有初始化");
  11542. return 0;
  11543. }
  11544. return chsdk.date.getDiffDayNum(this._creat_date, chsdk.date.now()) + 1;
  11545. }
  11546. /**
  11547. * 签到初始化
  11548. * @param mode =1可以补签 =2不可补签
  11549. * @param data 签到存档数据,可以为空为第一天
  11550. * @param max_day 签到最大天数
  11551. */;
  11552. _proto.init = function init(mode, data, max_day) {
  11553. if (max_day === void 0) {
  11554. max_day = 7;
  11555. }
  11556. this._mode = mode;
  11557. if (this._mode == 1) {
  11558. if (data) {
  11559. var _data$sign_list, _data$creat_date;
  11560. data = data;
  11561. var sign_list = (_data$sign_list = data.sign_list) != null ? _data$sign_list : [];
  11562. var creat_date = (_data$creat_date = data.creat_date) != null ? _data$creat_date : chsdk.date.now();
  11563. for (var i = 0; i < sign_list.length; i++) this._sign_data.add(sign_list[i]);
  11564. this._sign_count = this._sign_data.size;
  11565. this._creat_date = creat_date;
  11566. } else {
  11567. this._sign_count = 0;
  11568. this._sign_data.clear();
  11569. this._creat_date = chsdk.date.now();
  11570. }
  11571. } else {
  11572. if (data) {
  11573. var _data$sign_count, _data$last_date;
  11574. data = data;
  11575. this._sign_count = (_data$sign_count = data.sign_count) != null ? _data$sign_count : 0;
  11576. this._creat_date = (_data$last_date = data.last_date) != null ? _data$last_date : 0;
  11577. } else {
  11578. this._sign_count = 0;
  11579. this._creat_date = 0;
  11580. }
  11581. }
  11582. this._max = max_day;
  11583. }
  11584. /**已签到的数据,用于存档*/;
  11585. _proto.getSignData = function getSignData() {
  11586. if (this._mode == 1) {
  11587. return {
  11588. sign_list: Array.from(this._sign_data.keys()),
  11589. creat_date: this._creat_date
  11590. };
  11591. } else if (this._mode == 2) {
  11592. return {
  11593. sign_count: this._sign_count,
  11594. last_date: this._creat_date
  11595. };
  11596. }
  11597. }
  11598. /** 返回某一天的状态
  11599. * 0 等待签到
  11600. * 1 已经签到
  11601. * 2 失效等待补签
  11602. * */;
  11603. _proto.checkSigineState = function checkSigineState(day) {
  11604. if (this._mode == 1) {
  11605. if (day < 1 || day > this._max) return 0;
  11606. if (this._sign_data.has(day)) return 1;
  11607. var count = this.getCreatDayCount();
  11608. if (count <= 0) return 0;
  11609. if (day < count) return 2;
  11610. } else if (this._mode == 2) {
  11611. if (day <= this._sign_count) return 1;
  11612. }
  11613. return 0;
  11614. }
  11615. /**今天是否可以签到*/;
  11616. _proto.checkSigin = function checkSigin() {
  11617. if (this._mode == 1) {
  11618. var count = this.getCreatDayCount();
  11619. if (count <= 0 || count > this._max) return false;
  11620. return !this._sign_data.has(count);
  11621. } else if (this._mode == 2) {
  11622. var _count = this._sign_count;
  11623. if (_count >= this._max) return false;
  11624. return !chsdk.date.isSameDate(this._creat_date, chsdk.date.now());
  11625. }
  11626. return false;
  11627. }
  11628. /**签到是否全部完成*/;
  11629. _proto.checkSiginComplete = function checkSiginComplete() {
  11630. var count = this._sign_count;
  11631. return count >= this._max;
  11632. }
  11633. /**
  11634. * 是否能补签
  11635. * 不能返回0,
  11636. * 可以补签返回可以补签的那一天*/;
  11637. _proto.checkReSigin = function checkReSigin() {
  11638. if (this._mode != 1) return 0;
  11639. var count = this.getCreatDayCount() - 1;
  11640. if (count <= 0) return 0;
  11641. if (count > this._max) count = this._max;
  11642. for (var i = 1; i <= count; i++) {
  11643. if (!this._sign_data.has(i)) return i;
  11644. }
  11645. return 0;
  11646. }
  11647. /**签到
  11648. * 失败返回 0
  11649. * 成功返回签到当天
  11650. */;
  11651. _proto.signIn = function signIn() {
  11652. if (!this.checkSigin()) {
  11653. return 0;
  11654. }
  11655. if (this._mode == 1) {
  11656. var day = this.getCreatDayCount();
  11657. this._sign_data.add(day);
  11658. this._sign_count = this._sign_data.size;
  11659. return day;
  11660. } else if (this._mode == 2) {
  11661. this._sign_count++;
  11662. this._creat_date = chsdk.date.now();
  11663. return this._sign_count;
  11664. }
  11665. return 0;
  11666. }
  11667. /**补签
  11668. * 失败返回 0
  11669. * 成功返回补签那天
  11670. */;
  11671. _proto.reSignIn = function reSignIn() {
  11672. if (this._mode != 1) return 0;
  11673. var index = this.checkReSigin();
  11674. if (index <= 0 || index > this._max) {
  11675. return 0;
  11676. }
  11677. this._sign_data.add(index);
  11678. this._sign_count = this._sign_data.size;
  11679. return index;
  11680. }
  11681. //
  11682. ;
  11683. _createClass(ch_sign, [{
  11684. key: "max_day",
  11685. get: /**设定的签到天数*/
  11686. function get() {
  11687. return this._max;
  11688. }
  11689. }]);
  11690. return ch_sign;
  11691. }());
  11692. ch_sign._instance = void 0;
  11693. cclegacy._RF.pop();
  11694. }
  11695. };
  11696. });
  11697. System.register("chunks:///_virtual/SpineView.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  11698. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, cclegacy, _decorator, sp, Color, sys, Component;
  11699. return {
  11700. setters: [function (module) {
  11701. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  11702. _inheritsLoose = module.inheritsLoose;
  11703. _initializerDefineProperty = module.initializerDefineProperty;
  11704. _assertThisInitialized = module.assertThisInitialized;
  11705. }, function (module) {
  11706. cclegacy = module.cclegacy;
  11707. _decorator = module._decorator;
  11708. sp = module.sp;
  11709. Color = module.Color;
  11710. sys = module.sys;
  11711. Component = module.Component;
  11712. }],
  11713. execute: function () {
  11714. var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
  11715. cclegacy._RF.push({}, "ce889T62SpI8ot39/O0nFrT", "SpineView", undefined);
  11716. var ccclass = _decorator.ccclass,
  11717. property = _decorator.property;
  11718. /**
  11719. * spine动画表现管理
  11720. * @author
  11721. *
  11722. */
  11723. var SpineView = exports('default', (_dec = ccclass('SpineView'), _dec2 = property({
  11724. displayName: '待机'
  11725. }), _dec3 = property({
  11726. type: sp.Skeleton,
  11727. tooltip: '角色动画'
  11728. }), _dec(_class = (_class2 = /*#__PURE__*/function (_Component) {
  11729. _inheritsLoose(SpineView, _Component);
  11730. function SpineView() {
  11731. var _this;
  11732. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  11733. args[_key] = arguments[_key];
  11734. }
  11735. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  11736. _this.skin = "default";
  11737. _initializerDefineProperty(_this, "idle", _descriptor, _assertThisInitialized(_this));
  11738. _initializerDefineProperty(_this, "spine", _descriptor2, _assertThisInitialized(_this));
  11739. _this.cur = null;
  11740. _this.OnComp = void 0;
  11741. _this.resetColor = Color.WHITE;
  11742. return _this;
  11743. }
  11744. var _proto = SpineView.prototype;
  11745. _proto.onLoad = function onLoad() {
  11746. //console.log("111111111111");
  11747. //this.spine.enableBatch=false;
  11748. if (sys.isNative) {
  11749. //原生共享模式有bug
  11750. this.spine.setAnimationCacheMode(sp.AnimationCacheMode.REALTIME);
  11751. this.spine.clearTracks(); //清理所有播放队列的动画
  11752. }
  11753. //this.SetSkin(this.skin);
  11754. };
  11755. _proto.start = function start() {
  11756. this.DoAnimation(this.idle, true);
  11757. this.spine.setCompleteListener(function () {
  11758. if (this.OnComp) this.OnComp();
  11759. }.bind(this));
  11760. };
  11761. _proto.onBeforeRemove = function onBeforeRemove() {
  11762. this.spine.setCompleteListener(null);
  11763. };
  11764. _proto.Dispos = function Dispos() {
  11765. this.ResetColor();
  11766. this.OnComp = null;
  11767. //this.spine.setCompleteListener(null);
  11768. };
  11769. _proto.SetSkin = function SetSkin(skin) {
  11770. this.spine.setSkin(skin);
  11771. };
  11772. _proto.DoAnimation = function DoAnimation(animation, loop, track, force) {
  11773. if (loop === void 0) {
  11774. loop = true;
  11775. }
  11776. if (track === void 0) {
  11777. track = 0;
  11778. }
  11779. if (force === void 0) {
  11780. force = false;
  11781. }
  11782. if (force) {
  11783. this.spine.setAnimation(track, animation, loop);
  11784. return;
  11785. }
  11786. if (this.cur == animation) return;
  11787. this.spine.setAnimation(track, animation, loop);
  11788. }
  11789. /**设置是否暂停 */;
  11790. _proto.SetPaused = function SetPaused(paused) {
  11791. this.spine.paused = paused;
  11792. }
  11793. /**获取是否暂停 */;
  11794. _proto.GetPaused = function GetPaused() {
  11795. return this.spine.paused;
  11796. };
  11797. _proto.CheckPaused = function CheckPaused(paused) {
  11798. if (this.spine.paused != paused) this.spine.paused = paused;
  11799. }
  11800. /** 闪色表现 Color.RED 0.1*/;
  11801. _proto.Flash = function Flash(color, time) {
  11802. var _this2 = this;
  11803. if (this.spine.color != color) {
  11804. this.spine.color = color;
  11805. this.unscheduleAllCallbacks();
  11806. this.scheduleOnce(function () {
  11807. _this2.spine.color = _this2.resetColor;
  11808. }, time);
  11809. }
  11810. };
  11811. _proto.ChangeMagenta = function ChangeMagenta() {
  11812. this.ChangeColor(Color.MAGENTA);
  11813. };
  11814. _proto.ChangeGreen = function ChangeGreen() {
  11815. this.ChangeColor(Color.GREEN);
  11816. };
  11817. _proto.ChangeGray = function ChangeGray() {
  11818. this.ChangeColor(Color.GRAY);
  11819. };
  11820. _proto.ChangeRed = function ChangeRed() {
  11821. this.ChangeColor(Color.RED);
  11822. };
  11823. _proto.ChangeCyan = function ChangeCyan() {
  11824. this.ChangeColor(Color.CYAN);
  11825. };
  11826. _proto.ChangeBlack = function ChangeBlack() {
  11827. this.ChangeColor(Color.BLACK);
  11828. };
  11829. _proto.ChangeBule = function ChangeBule() {
  11830. this.ChangeColor(Color.BLUE);
  11831. };
  11832. _proto.ChangeYellow = function ChangeYellow() {
  11833. this.ChangeColor(Color.YELLOW);
  11834. }
  11835. //
  11836. /** 变色表现 Color.RED 0.1*/;
  11837. _proto.ChangeColor = function ChangeColor(color) {
  11838. this.resetColor = color;
  11839. if (this.spine.color != this.resetColor) {
  11840. this.spine.color = this.resetColor;
  11841. }
  11842. };
  11843. _proto.ResetColor = function ResetColor() {
  11844. this.resetColor = Color.WHITE;
  11845. if (this.spine.color != this.resetColor) {
  11846. this.spine.color = this.resetColor;
  11847. }
  11848. }
  11849. /**
  11850. * 缩放动画播放速率
  11851. * @override
  11852. * @param scale 缩放倍率
  11853. */;
  11854. _proto.scaleTime = function scaleTime(scale) {
  11855. if (scale > 0) this.spine.timeScale = scale;
  11856. };
  11857. _proto.getBone = function getBone(name) {
  11858. var bone = this.spine.findBone(name);
  11859. return bone;
  11860. }
  11861. /**
  11862. * 换装
  11863. * @param slotName 插槽名字
  11864. * @param attachmentName 元素名字
  11865. */;
  11866. _proto.changeEquipment = function changeEquipment(slotName, attachmentName) {
  11867. if (attachmentName === void 0) {
  11868. attachmentName = null;
  11869. }
  11870. var slot = this.spine.findSlot(slotName);
  11871. if (slot) {
  11872. if (attachmentName) {
  11873. var attachment = this.spine.getAttachment(slotName, attachmentName);
  11874. slot.setAttachment(attachment);
  11875. } else {
  11876. slot.setAttachment(null);
  11877. }
  11878. }
  11879. }
  11880. /**换装
  11881. * @param skinName 要替换的部件皮肤名称
  11882. * @param slotName 要替换的部件的插槽名称
  11883. * @param targetAttaName Spine中皮肤占位符的名字
  11884. */;
  11885. _proto.changeSlot = function changeSlot(skinName, slotName, targetAttaName) {
  11886. //查找局部皮肤
  11887. var skeletonData = this.spine.skeletonData.getRuntimeData();
  11888. var targetSkin = skeletonData.findSkin(skinName);
  11889. //查找局部皮肤下的插槽与附件
  11890. var targetSkinSlotIndex = skeletonData.findSlotIndex(slotName);
  11891. var atta = targetSkin.getAttachment(targetSkinSlotIndex, targetAttaName);
  11892. //查找全身皮肤下的插槽
  11893. var curSlot = this.spine.findSlot(slotName);
  11894. //替换全身皮肤插槽的附件
  11895. curSlot && curSlot.setAttachment(atta);
  11896. };
  11897. return SpineView;
  11898. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "idle", [_dec2], {
  11899. configurable: true,
  11900. enumerable: true,
  11901. writable: true,
  11902. initializer: function initializer() {
  11903. return "";
  11904. }
  11905. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "spine", [_dec3], {
  11906. configurable: true,
  11907. enumerable: true,
  11908. writable: true,
  11909. initializer: function initializer() {
  11910. return null;
  11911. }
  11912. })), _class2)) || _class));
  11913. cclegacy._RF.pop();
  11914. }
  11915. };
  11916. });
  11917. System.register("chunks:///_virtual/Start.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ch.ts', './ui.ts', './ch_start_pack.ts', './ResUtil.ts', './ModuleDef.ts', './SceneDef.ts'], function (exports) {
  11918. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, _asyncToGenerator, _regeneratorRuntime, cclegacy, _decorator, ProgressBar, Prefab, game, ch, gui, ch_start_pack, ResUtil, ModuleDef, SceneDef;
  11919. return {
  11920. setters: [function (module) {
  11921. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  11922. _inheritsLoose = module.inheritsLoose;
  11923. _initializerDefineProperty = module.initializerDefineProperty;
  11924. _assertThisInitialized = module.assertThisInitialized;
  11925. _asyncToGenerator = module.asyncToGenerator;
  11926. _regeneratorRuntime = module.regeneratorRuntime;
  11927. }, function (module) {
  11928. cclegacy = module.cclegacy;
  11929. _decorator = module._decorator;
  11930. ProgressBar = module.ProgressBar;
  11931. Prefab = module.Prefab;
  11932. game = module.game;
  11933. }, function (module) {
  11934. ch = module.ch;
  11935. }, function (module) {
  11936. gui = module.gui;
  11937. }, function (module) {
  11938. ch_start_pack = module.ch_start_pack;
  11939. }, function (module) {
  11940. ResUtil = module.ResUtil;
  11941. }, function (module) {
  11942. ModuleDef = module.ModuleDef;
  11943. }, function (module) {
  11944. SceneDef = module.SceneDef;
  11945. }],
  11946. execute: function () {
  11947. var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2, _class3;
  11948. cclegacy._RF.push({}, "66e163GxmdDp7kaguqDvTVl", "Start", undefined);
  11949. // import TableLoadUtil from '../core/util/TableLoadUtil';
  11950. // import { TableUtil } from '../module_extra/table_ts/TableUtil';
  11951. var ccclass = _decorator.ccclass,
  11952. property = _decorator.property;
  11953. //预加载模块
  11954. var _preloadBundles = [ModuleDef.BASIC, ModuleDef.EXTRA, ModuleDef.GAME];
  11955. //预加载资源
  11956. var _preloadRes = [
  11957. // { bundle: ModuleDef.EXTRA, url: 'ui_loading/UI_Loading' },
  11958. {
  11959. bundle: ModuleDef.BASIC,
  11960. url: 'ui_alert/UI_Alert'
  11961. }, {
  11962. bundle: ModuleDef.BASIC,
  11963. url: 'ui_waiting/UI_Waiting'
  11964. }, {
  11965. bundle: ModuleDef.BASIC,
  11966. url: 'ui_notify/UI_Notify'
  11967. }
  11968. // { bundle: ModuleDef.Link, url: 'ui/main/UI_Main' },
  11969. ];
  11970. var _totalNum = _preloadBundles.length + _preloadRes.length + 1;
  11971. var Start = exports('Start', (_dec = ccclass('Start'), _dec2 = property(ProgressBar), _dec3 = property({
  11972. type: Prefab,
  11973. displayName: 'ui初始预制体'
  11974. }), _dec(_class = (_class2 = (_class3 = /*#__PURE__*/function (_ch_start_pack) {
  11975. _inheritsLoose(Start, _ch_start_pack);
  11976. function Start() {
  11977. var _this;
  11978. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  11979. args[_key] = arguments[_key];
  11980. }
  11981. _this = _ch_start_pack.call.apply(_ch_start_pack, [this].concat(args)) || this;
  11982. // @property(Label)
  11983. // txtLoading: Label;
  11984. // @property(Slider)
  11985. // loadingSlider: Slider;
  11986. _initializerDefineProperty(_this, "loadingBar", _descriptor, _assertThisInitialized(_this));
  11987. _this._percent = '1';
  11988. _this._numCurrentLoaded = 0;
  11989. _initializerDefineProperty(_this, "ui_prefab", _descriptor2, _assertThisInitialized(_this));
  11990. return _this;
  11991. }
  11992. var _proto = Start.prototype;
  11993. _proto.onLoad = function onLoad() {
  11994. Start.packId = this.pid;
  11995. };
  11996. _proto.start = /*#__PURE__*/function () {
  11997. var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
  11998. return _regeneratorRuntime().wrap(function _callee$(_context) {
  11999. while (1) switch (_context.prev = _context.next) {
  12000. case 0:
  12001. console.log('Start');
  12002. gui.init(this.ui_prefab);
  12003. game.frameRate = 61;
  12004. // if (this.pid == 1) {
  12005. // // seeg.onLoginRet(
  12006. // // async (ret: { openid: string; white: boolean }) => {
  12007. // // console.log(ret);
  12008. // // await this.try_init(3);
  12009. // // this.preloadBundle(0);
  12010. // // }
  12011. // // //(ret: { userId: number; openId: string; isTest: boolean; abTest: number }) => {
  12012. // // //console.log(ret);
  12013. // // //}
  12014. // // )
  12015. // // seeg.init({ gid: this.gid, loggerLevel: this.log, old: false });
  12016. // } else {
  12017. // await this.try_init(3);
  12018. // this.preloadBundle(0);
  12019. // }
  12020. _context.next = 5;
  12021. return this.try_init(3);
  12022. case 5:
  12023. this.preloadBundle(0);
  12024. case 6:
  12025. case "end":
  12026. return _context.stop();
  12027. }
  12028. }, _callee, this);
  12029. }));
  12030. function start() {
  12031. return _start.apply(this, arguments);
  12032. }
  12033. return start;
  12034. }();
  12035. _proto.onResLoaded = function onResLoaded() {
  12036. this._numCurrentLoaded++;
  12037. console.log(this._numCurrentLoaded);
  12038. // this._percent = ~~(this._numCurrentLoaded / _totalNum * 100) + '%';
  12039. };
  12040. _proto.preloadBundle = /*#__PURE__*/function () {
  12041. var _preloadBundle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(idx) {
  12042. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  12043. while (1) switch (_context2.prev = _context2.next) {
  12044. case 0:
  12045. _context2.next = 2;
  12046. return ResUtil.loadBundle(_preloadBundles[idx]);
  12047. case 2:
  12048. ch.log.info('module:<' + _preloadBundles[idx] + '>loaded.');
  12049. idx++;
  12050. this.onResLoaded();
  12051. if (idx < _preloadBundles.length) {
  12052. this.preloadBundle(idx);
  12053. } else {
  12054. this.preloadRes(0);
  12055. }
  12056. case 6:
  12057. case "end":
  12058. return _context2.stop();
  12059. }
  12060. }, _callee2, this);
  12061. }));
  12062. function preloadBundle(_x) {
  12063. return _preloadBundle.apply(this, arguments);
  12064. }
  12065. return preloadBundle;
  12066. }();
  12067. _proto.preloadRes = /*#__PURE__*/function () {
  12068. var _preloadRes2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(idx) {
  12069. var res;
  12070. return _regeneratorRuntime().wrap(function _callee3$(_context3) {
  12071. while (1) switch (_context3.prev = _context3.next) {
  12072. case 0:
  12073. res = _preloadRes[idx];
  12074. _context3.next = 3;
  12075. return ResUtil.loadAsset(res.url, res.bundle);
  12076. case 3:
  12077. idx++;
  12078. this.onResLoaded();
  12079. if (idx < _preloadRes.length) {
  12080. this.preloadRes(idx);
  12081. } else {
  12082. this.onPreloadingComplete();
  12083. }
  12084. case 6:
  12085. case "end":
  12086. return _context3.stop();
  12087. }
  12088. }, _callee3, this);
  12089. }));
  12090. function preloadRes(_x2) {
  12091. return _preloadRes2.apply(this, arguments);
  12092. }
  12093. return preloadRes;
  12094. }();
  12095. _proto.onPreloadingComplete = /*#__PURE__*/function () {
  12096. var _onPreloadingComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
  12097. return _regeneratorRuntime().wrap(function _callee4$(_context4) {
  12098. while (1) switch (_context4.prev = _context4.next) {
  12099. case 0:
  12100. _context4.next = 2;
  12101. return ResUtil.loadScene(SceneDef.Hall, ModuleDef.GAME, true);
  12102. case 2:
  12103. this.onResLoaded();
  12104. case 3:
  12105. case "end":
  12106. return _context4.stop();
  12107. }
  12108. }, _callee4, this);
  12109. }));
  12110. function onPreloadingComplete() {
  12111. return _onPreloadingComplete.apply(this, arguments);
  12112. }
  12113. return onPreloadingComplete;
  12114. }();
  12115. _proto.update = function update(deltaTime) {
  12116. if (this._percent) {
  12117. // this.txtLoading.string = 'Loading...' + this._percent;
  12118. var sc = this._numCurrentLoaded / _totalNum;
  12119. if (sc >= 1) {
  12120. this.loadingBar.progress = sc;
  12121. } else {
  12122. this.loadingBar.progress = this._numCurrentLoaded / _totalNum;
  12123. }
  12124. }
  12125. // else {
  12126. // let idx = Math.floor(game.totalTime / 1000) % 3;
  12127. // this.txtLoading.string = _loadingText[idx];
  12128. // }
  12129. };
  12130. return Start;
  12131. }(ch_start_pack), _class3.packId = void 0, _class3), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "loadingBar", [_dec2], {
  12132. configurable: true,
  12133. enumerable: true,
  12134. writable: true,
  12135. initializer: null
  12136. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "ui_prefab", [_dec3], {
  12137. configurable: true,
  12138. enumerable: true,
  12139. writable: true,
  12140. initializer: null
  12141. })), _class2)) || _class));
  12142. cclegacy._RF.pop();
  12143. }
  12144. };
  12145. });
  12146. System.register("chunks:///_virtual/State.ts", ['cc'], function (exports) {
  12147. var cclegacy;
  12148. return {
  12149. setters: [function (module) {
  12150. cclegacy = module.cclegacy;
  12151. }],
  12152. execute: function () {
  12153. exports('default', get_new_state);
  12154. cclegacy._RF.push({}, "d9db0FDjAhNuLA9MVTSVAgv", "State", undefined);
  12155. /*enum states{
  12156. Read = 1, //0001
  12157. Write = 2, //0010
  12158. Create = 4,//0100
  12159. Delete = 8 //1000
  12160. }/**状态类型不算合并的不超过32种
  12161. export enum StateType {
  12162. Unmatched = 1<<1,//无敌
  12163. Swoon = 1<<2,//晕眩
  12164. }*/
  12165. /**状态对像*/
  12166. var State = /*#__PURE__*/function () {
  12167. function State() {
  12168. this._state = 0;
  12169. }
  12170. var _proto = State.prototype;
  12171. //无状态
  12172. _proto.Init = function Init() {
  12173. this._state = 0;
  12174. }
  12175. /**是否满足传入的状态*/;
  12176. _proto.Meet = function Meet(state) {
  12177. return State.Has(this._state, state);
  12178. }
  12179. /**传入的状态是组合型时只要满足其一 */;
  12180. _proto.MeetAny = function MeetAny(state) {
  12181. var a = this._state & state;
  12182. if (a === state) return true;
  12183. if (a == 0) return false;
  12184. return State.Has(state, a);
  12185. }
  12186. /**是否满足所有传入的状态*/;
  12187. _proto.MeetAll = function MeetAll() {
  12188. var result = 0;
  12189. for (var i = 0; i < arguments.length; i++) {
  12190. result |= i < 0 || arguments.length <= i ? undefined : arguments[i];
  12191. }
  12192. return this.Meet(State.CombieState(result));
  12193. }
  12194. /**是否满足其中传入的状态*/;
  12195. _proto.MeetAnyOne = function MeetAnyOne() {
  12196. for (var i = 0; i < arguments.length; i++) {
  12197. if (this.Meet(i < 0 || arguments.length <= i ? undefined : arguments[i])) return true;
  12198. }
  12199. return false;
  12200. }
  12201. /**加入状态*/;
  12202. _proto.Add = function Add(state) {
  12203. this._state |= state;
  12204. }
  12205. /**删除状态*/;
  12206. _proto.Delete = function Delete(state) {
  12207. if (!this.Meet(state)) return;
  12208. this._state ^= state;
  12209. }
  12210. /**转成状态*/;
  12211. State.ToState = function ToState(Id) {
  12212. return 1 << Id;
  12213. }
  12214. /**合并状态*/;
  12215. State.CombieState = function CombieState() {
  12216. var result = 0;
  12217. for (var i = 0; i < arguments.length; i++) {
  12218. result |= i < 0 || arguments.length <= i ? undefined : arguments[i];
  12219. }
  12220. return result;
  12221. };
  12222. State.Has = function Has(statss, state) {
  12223. return (statss & state) === state;
  12224. };
  12225. return State;
  12226. }();
  12227. function get_new_state() {
  12228. return new State();
  12229. }
  12230. cclegacy._RF.pop();
  12231. }
  12232. };
  12233. });
  12234. System.register("chunks:///_virtual/StringUtil.ts", ['cc'], function (exports) {
  12235. var cclegacy;
  12236. return {
  12237. setters: [function (module) {
  12238. cclegacy = module.cclegacy;
  12239. }],
  12240. execute: function () {
  12241. cclegacy._RF.push({}, "77722BYjyNHJpJ4DuMACErZ", "StringUtil", undefined);
  12242. var StringUtil = exports('StringUtil', /*#__PURE__*/function () {
  12243. function StringUtil() {}
  12244. /**小数转成保留几位小数的字符串*/
  12245. StringUtil.ToFixed = function ToFixed(s, count) {
  12246. return s.toFixed(count).toString();
  12247. }
  12248. /**秒转成 00:00时间格式*/;
  12249. StringUtil.ToTimeString = function ToTimeString(s) {
  12250. s = Math.floor(s);
  12251. var m = Math.floor(s / 60);
  12252. s = s - m * 60;
  12253. var mm = m.toString();
  12254. if (mm.length <= 1) {
  12255. mm = "0".concat(mm);
  12256. }
  12257. if (s < 10) {
  12258. return mm + ":" + "0".concat(s.toString());
  12259. }
  12260. return mm + ":" + s;
  12261. }
  12262. /**秒*/;
  12263. StringUtil.ToSce = function ToSce(s, u) {
  12264. if (u === void 0) {
  12265. u = "s";
  12266. }
  12267. s = Math.floor(s);
  12268. return "" + s + u;
  12269. }
  12270. /**货币值转字符 */;
  12271. StringUtil.ToMoneyString = function ToMoneyString(n) {
  12272. if (n > 1000000) {
  12273. var m = Math.floor(n * 0.000001);
  12274. n -= m * 1000000;
  12275. if (n > 1000) {
  12276. return m + "M" + Math.floor(n * 0.001) + "K";
  12277. }
  12278. return m + "M";
  12279. } else if (n > 1000) {
  12280. var _m = Math.floor(n * 0.001);
  12281. n -= _m * 1000;
  12282. if (n > 100) {
  12283. n = Math.floor(n * 0.01);
  12284. return _m + "K" + n;
  12285. }
  12286. return _m + "K";
  12287. }
  12288. return n.toString();
  12289. }
  12290. /**毫秒转秒显示*/;
  12291. StringUtil.MS2S = function MS2S(ms) {
  12292. return (ms * 0.001).toFixed(1);
  12293. }
  12294. /**
  12295. * 去掉前后空格
  12296. * @param str
  12297. * @returns {string}
  12298. */;
  12299. var _proto = StringUtil.prototype;
  12300. _proto.trimSpace = function trimSpace(str) {
  12301. return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
  12302. }
  12303. /**
  12304. * 获取字符串长度,中文为2
  12305. * @param str
  12306. */;
  12307. _proto.getStringLength = function getStringLength(str) {
  12308. var strArr = str.split("");
  12309. var length = 0;
  12310. for (var i = 0; i < strArr.length; i++) {
  12311. var s = strArr[i];
  12312. if (this.isChinese(s)) {
  12313. length += 2;
  12314. } else {
  12315. length += 1;
  12316. }
  12317. }
  12318. return length;
  12319. }
  12320. /**
  12321. * 判断一个字符串是否包含中文
  12322. * @param str
  12323. * @returns {boolean}
  12324. */;
  12325. _proto.isChinese = function isChinese(str) {
  12326. var reg = /^.*[\u4E00-\u9FA5]+.*$/;
  12327. return reg.test(str);
  12328. }
  12329. /**
  12330. * 格式化字符串 "{0},{1}.format("text0","text1")
  12331. */;
  12332. _proto.format = function format(val) {
  12333. for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; i++) {
  12334. var reg = new RegExp("({)" + i + "(})", "g");
  12335. val = val.replace(reg, i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1]);
  12336. }
  12337. return val;
  12338. };
  12339. return StringUtil;
  12340. }());
  12341. cclegacy._RF.pop();
  12342. }
  12343. };
  12344. });
  12345. System.register("chunks:///_virtual/TableLoadUtil.ts", ['cc'], function (exports) {
  12346. var cclegacy, assetManager, JsonAsset;
  12347. return {
  12348. setters: [function (module) {
  12349. cclegacy = module.cclegacy;
  12350. assetManager = module.assetManager;
  12351. JsonAsset = module.JsonAsset;
  12352. }],
  12353. execute: function () {
  12354. cclegacy._RF.push({}, "0d2abQaWYVLPptXiFU69SYv", "TableLoadUtil", undefined);
  12355. var TableLoadUtil = exports('default', /*#__PURE__*/function () {
  12356. function TableLoadUtil() {}
  12357. TableLoadUtil.preloadAll = function preloadAll(bundleName, path, callback, util_cb) {
  12358. var _this = this;
  12359. assetManager.loadBundle(bundleName, function (err, bundle) {
  12360. if (err) {
  12361. console.log(err);
  12362. return;
  12363. }
  12364. bundle.loadDir(path, JsonAsset, function (err, assets) {
  12365. if (err) {
  12366. console.log(err);
  12367. return;
  12368. }
  12369. for (var i = 0; i < assets.length; i++) {
  12370. util_cb == null || util_cb(assets[i].name, assets[i].json);
  12371. }
  12372. callback(assets);
  12373. }.bind(_this));
  12374. });
  12375. };
  12376. return TableLoadUtil;
  12377. }());
  12378. cclegacy._RF.pop();
  12379. }
  12380. };
  12381. });
  12382. System.register("chunks:///_virtual/TimeJobCenter.ts", ['cc'], function (exports) {
  12383. var cclegacy;
  12384. return {
  12385. setters: [function (module) {
  12386. cclegacy = module.cclegacy;
  12387. }],
  12388. execute: function () {
  12389. exports('default', get_new_job);
  12390. cclegacy._RF.push({}, "29a956DSGFLW6G8399hAoz8", "TimeJobCenter", undefined);
  12391. /**任务*/
  12392. var TimeTask = function TimeTask(tid, callback, destTime, delay, count) {
  12393. this.tid = void 0;
  12394. this.destTime = void 0;
  12395. //延时执行时间
  12396. this.callback = void 0;
  12397. //执行方法
  12398. this.count = void 0;
  12399. //执行次数
  12400. this.delay = void 0;
  12401. //间隔
  12402. this.doDelete = false;
  12403. this.tid = tid;
  12404. this.callback = callback;
  12405. this.destTime = destTime;
  12406. this.delay = delay;
  12407. this.count = count;
  12408. };
  12409. /**时间单位*/
  12410. var TimeUnit = exports('TimeUnit', /*#__PURE__*/function (TimeUnit) {
  12411. TimeUnit[TimeUnit["Millisecond"] = 0] = "Millisecond";
  12412. TimeUnit[TimeUnit["Second"] = 1] = "Second";
  12413. TimeUnit[TimeUnit["Hour"] = 2] = "Hour";
  12414. TimeUnit[TimeUnit["Day"] = 3] = "Day";
  12415. return TimeUnit;
  12416. }({}));
  12417. /**
  12418. * 时间定时任务
  12419. * 更好管理某一模块层级的时间任务,暂停,取消等
  12420. */
  12421. var TimeJobCenter = /*#__PURE__*/function () {
  12422. function TimeJobCenter() {
  12423. this.tid = 0;
  12424. this.tempList = new Array();
  12425. this.taskList = new Array();
  12426. this.nowTime = 0;
  12427. //
  12428. this._index = void 0;
  12429. this._count = void 0;
  12430. this._tt = void 0;
  12431. }
  12432. var _proto = TimeJobCenter.prototype;
  12433. _proto.Dispose = function Dispose() {
  12434. this.taskList.length = 0;
  12435. this.tempList.length = 0;
  12436. this.nowTime = 0;
  12437. };
  12438. _proto.getTid = function getTid() {
  12439. //安全代码以防过了
  12440. if (this.tid == Number.MAX_VALUE) {
  12441. var id = 0;
  12442. while (true) {
  12443. var used = false;
  12444. for (var index = 0; index < this.taskList.length; index++) {
  12445. if (this.taskList[index].tid == id) {
  12446. used = true;
  12447. break;
  12448. }
  12449. }
  12450. if (!used) {
  12451. break;
  12452. } else {
  12453. id++;
  12454. }
  12455. }
  12456. return id;
  12457. } else {
  12458. this.tid += 1;
  12459. return this.tid;
  12460. }
  12461. }
  12462. /**延迟(ms)*/;
  12463. _proto.delay = function delay(ms) {
  12464. var _this = this;
  12465. return new Promise(function (resolve) {
  12466. return _this.AddTimeTask(resolve, ms, 1, TimeUnit.Millisecond);
  12467. });
  12468. }
  12469. /**延迟(s)*/;
  12470. _proto.delay_second = function delay_second(ms) {
  12471. var _this2 = this;
  12472. return new Promise(function (resolve) {
  12473. return _this2.AddTimeTask(resolve, ms, 1, TimeUnit.Second);
  12474. });
  12475. }
  12476. /**
  12477. * 增加时间任务
  12478. * @param callback 执行方法
  12479. * @param delay 延迟时间
  12480. * @param count 次数
  12481. * @param timeUnit 时间单位 默认为 秒 TimeUnit.Second
  12482. * @returns 时间任务id
  12483. */;
  12484. _proto.AddTimeTask = function AddTimeTask(callback, delay, count, timeUnit) {
  12485. if (count === void 0) {
  12486. count = 1;
  12487. }
  12488. if (timeUnit === void 0) {
  12489. timeUnit = TimeUnit.Second;
  12490. }
  12491. var tid = this.getTid();
  12492. this.tempList.push(this.CreatNewTimeTask(tid, callback, delay, count, timeUnit)); //增加一个任务到缓存
  12493. return tid;
  12494. }
  12495. //
  12496. ;
  12497. _proto.CreatNewTimeTask = function CreatNewTimeTask(tid, callback, delay, count, timeUnit) {
  12498. if (count === void 0) {
  12499. count = 1;
  12500. }
  12501. if (timeUnit === void 0) {
  12502. timeUnit = TimeUnit.Second;
  12503. }
  12504. if (timeUnit != TimeUnit.Second) {
  12505. //如果单位不是秒,就全换算成秒做为单位
  12506. switch (timeUnit) {
  12507. case TimeUnit.Millisecond:
  12508. delay *= 0.001;
  12509. break;
  12510. case TimeUnit.Hour:
  12511. delay *= 360;
  12512. break;
  12513. case TimeUnit.Day:
  12514. delay *= 360 * 24;
  12515. break;
  12516. default:
  12517. console.error("Add Task TimeUnit Type Error...");
  12518. break;
  12519. }
  12520. }
  12521. return new TimeTask(tid, callback, this.nowTime + delay, delay, count);
  12522. }
  12523. /**
  12524. * 删除一个时间任务
  12525. * @param tid 时间任务id
  12526. * @returns 是否删除成功
  12527. */;
  12528. _proto.DeleteTimeTask = function DeleteTimeTask(tid) {
  12529. var exist = false;
  12530. var tt;
  12531. for (var i = 0; i < this.tempList.length; i++) {
  12532. tt = this.tempList[i];
  12533. if (tt.tid == tid) {
  12534. this.tempList[i].doDelete = true;
  12535. exist = true;
  12536. break;
  12537. }
  12538. }
  12539. if (!exist) {
  12540. for (var _i = 0; _i < this.taskList.length; _i++) {
  12541. tt = this.taskList[_i];
  12542. if (tt.tid == tid) {
  12543. this.taskList[_i].doDelete = true;
  12544. exist = true;
  12545. break;
  12546. }
  12547. }
  12548. }
  12549. return exist;
  12550. };
  12551. //运行调用
  12552. _proto.Run = function Run(dt) {
  12553. this.nowTime += dt;
  12554. this._count = this.tempList.length;
  12555. if (this._count > 0) {
  12556. for (this._index = 0; this._index < this._count; this._index++) {
  12557. if (this.tempList[this._index].doDelete) continue;
  12558. this.taskList.push(this.tempList[this._index]);
  12559. }
  12560. this.tempList.length = 0;
  12561. }
  12562. this._count = this.taskList.length;
  12563. if (this._count > 0) {
  12564. for (this._index = 0; this._index < this._count; this._index++) {
  12565. this._tt = this.taskList[this._index];
  12566. if (this.nowTime < this._tt.destTime) continue;
  12567. if (this._tt.doDelete) continue;
  12568. this._tt.callback();
  12569. if (this._tt.count == 1) {
  12570. this._tt.doDelete = true;
  12571. } else if (this._tt.count > 0) {
  12572. this._tt.count--;
  12573. this._tt.destTime += this._tt.delay; //下次执行时间
  12574. } else {
  12575. this._tt.destTime += this._tt.delay;
  12576. }
  12577. }
  12578. }
  12579. this.taskList = this.taskList.filter(function (task) {
  12580. return !task.doDelete;
  12581. }); //把标记为删除的真正删除
  12582. }
  12583. //
  12584. ;
  12585. return TimeJobCenter;
  12586. }();
  12587. function get_new_job() {
  12588. return new TimeJobCenter();
  12589. }
  12590. cclegacy._RF.pop();
  12591. }
  12592. };
  12593. });
  12594. System.register("chunks:///_virtual/Timer.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  12595. var _createClass, cclegacy;
  12596. return {
  12597. setters: [function (module) {
  12598. _createClass = module.createClass;
  12599. }, function (module) {
  12600. cclegacy = module.cclegacy;
  12601. }],
  12602. execute: function () {
  12603. exports('default', get_new_timer);
  12604. cclegacy._RF.push({}, "890248SdzRIsa6dPHIO+Qxy", "Timer", undefined);
  12605. var Timer = /*#__PURE__*/function () {
  12606. function Timer(step) {
  12607. if (step === void 0) {
  12608. step = 0;
  12609. }
  12610. this._elapsedTime = 0;
  12611. this._step = -1;
  12612. this.step = step;
  12613. }
  12614. /**
  12615. * 序列化(数据库存储)
  12616. */
  12617. var _proto = Timer.prototype;
  12618. _proto.serialize = function serialize() {
  12619. var data = {
  12620. "step": this._step,
  12621. "elapsed": this._elapsedTime
  12622. };
  12623. return data;
  12624. }
  12625. /**
  12626. * 反序列化
  12627. */;
  12628. _proto.unserialize = function unserialize(data) {
  12629. if (!data) return;
  12630. this._step = data.step;
  12631. this._elapsedTime = data.elapsed;
  12632. };
  12633. _proto.update = function update(dt) {
  12634. if (this.step <= 0) return false;
  12635. this._elapsedTime += dt;
  12636. if (this._elapsedTime >= this._step) {
  12637. this._elapsedTime -= this._step;
  12638. return true;
  12639. }
  12640. return false;
  12641. };
  12642. _proto.reset = function reset() {
  12643. this._elapsedTime = 0;
  12644. };
  12645. _proto.stop = function stop() {
  12646. this._elapsedTime = 0;
  12647. this.step = -1;
  12648. };
  12649. _createClass(Timer, [{
  12650. key: "elapsedTime",
  12651. get: function get() {
  12652. return this._elapsedTime;
  12653. }
  12654. }, {
  12655. key: "step",
  12656. get: /** 触发间隔时间(秒) */
  12657. function get() {
  12658. return this._step;
  12659. },
  12660. set: function set(step) {
  12661. this._step = step; // 每次修改时间
  12662. this._elapsedTime = 0; // 逝去时间
  12663. }
  12664. }, {
  12665. key: "coundown",
  12666. get: function get() {
  12667. return this._step - this._elapsedTime;
  12668. }
  12669. }, {
  12670. key: "progress",
  12671. get: function get() {
  12672. return this._elapsedTime / this._step;
  12673. }
  12674. }]);
  12675. return Timer;
  12676. }();
  12677. function get_new_timer(step) {
  12678. return new Timer(step);
  12679. }
  12680. cclegacy._RF.pop();
  12681. }
  12682. };
  12683. });
  12684. System.register("chunks:///_virtual/Toast.ts", ['cc'], function (exports) {
  12685. var cclegacy, ImageAsset, UIOpacity, tween, Label, UITransform, v3, Node, Layers, view, BlockInputEvents, Sprite, Texture2D, SpriteFrame, color;
  12686. return {
  12687. setters: [function (module) {
  12688. cclegacy = module.cclegacy;
  12689. ImageAsset = module.ImageAsset;
  12690. UIOpacity = module.UIOpacity;
  12691. tween = module.tween;
  12692. Label = module.Label;
  12693. UITransform = module.UITransform;
  12694. v3 = module.v3;
  12695. Node = module.Node;
  12696. Layers = module.Layers;
  12697. view = module.view;
  12698. BlockInputEvents = module.BlockInputEvents;
  12699. Sprite = module.Sprite;
  12700. Texture2D = module.Texture2D;
  12701. SpriteFrame = module.SpriteFrame;
  12702. color = module.color;
  12703. }],
  12704. execute: function () {
  12705. cclegacy._RF.push({}, "0cfc340yupKhKm9JAtrMkIE", "Toast", undefined);
  12706. /**
  12707. * 位置
  12708. */
  12709. var Gravity = exports('Gravity', /*#__PURE__*/function (Gravity) {
  12710. Gravity[Gravity["BOTTOM"] = 0] = "BOTTOM";
  12711. return Gravity;
  12712. }({}));
  12713. var imageObj = new Image();
  12714. imageObj.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACAQMAAABIeJ9nAAAAA1BMVEX///+nxBvIAAAACklEQVQI12MAAgAABAABINItbwAAAABJRU5ErkJggg==";
  12715. var imageAsset = new ImageAsset(imageObj);
  12716. /*
  12717. Toast.makeText(gui.getLayerNode(5),"可笑可笑1").show();
  12718. */
  12719. var Toast = exports('Toast', /*#__PURE__*/function () {
  12720. function Toast(root) {
  12721. this._bgNode = null;
  12722. this._textNode = null;
  12723. this._node = null;
  12724. this._text = '';
  12725. this._time = 0;
  12726. this._textSize = 26;
  12727. this._gravity = Gravity.BOTTOM;
  12728. this._node = this.getPNode(root);
  12729. this._bgNode = new Node();
  12730. this._bgNode.layer = Layers.Enum.UI_2D;
  12731. this._bgNode.addComponent(BlockInputEvents);
  12732. var sprite = this._bgNode.addComponent(Sprite);
  12733. sprite.type = Sprite.Type.SLICED;
  12734. var textureObj = new Texture2D();
  12735. textureObj.image = imageAsset;
  12736. var sf = new SpriteFrame();
  12737. sf.texture = textureObj;
  12738. sprite.spriteFrame = sf;
  12739. sprite.color = color(128, 128, 128, 255);
  12740. this._bgNode.addComponent(UIOpacity);
  12741. this._bgNode.active = false;
  12742. this._textNode = new Node('Text');
  12743. this._textNode.layer = Layers.Enum.UI_2D;
  12744. var uiTransform = this._textNode.addComponent(UITransform);
  12745. uiTransform.width = this._node.getComponent(UITransform).width;
  12746. var label = this._textNode.addComponent(Label);
  12747. label.horizontalAlign = Label.HorizontalAlign.CENTER;
  12748. label.verticalAlign = Label.VerticalAlign.CENTER;
  12749. this._textSize = 26;
  12750. this._textNode.parent = this._bgNode;
  12751. this._bgNode.parent = this._node;
  12752. }
  12753. /**
  12754. * 生成吐司
  12755. * @param node
  12756. * @param text
  12757. * @param time
  12758. * @returns
  12759. */
  12760. Toast.makeText = function makeText(parent, text, time) {
  12761. if (time === void 0) {
  12762. time = Toast.LENGTH_SHORT;
  12763. }
  12764. var toast = new Toast(parent);
  12765. toast.setText(text);
  12766. toast.setTime(time);
  12767. return toast;
  12768. }
  12769. /**
  12770. * 显示吐司
  12771. */;
  12772. var _proto = Toast.prototype;
  12773. _proto.show = function show() {
  12774. var _this = this;
  12775. this.setFontSize(this._textSize);
  12776. this.setOverFlow();
  12777. this._bgNode.active = true;
  12778. var uiOpacity = this._bgNode.getComponent(UIOpacity);
  12779. tween(uiOpacity).delay(this._time).to(0.3, {
  12780. opacity: 0
  12781. }).call(function () {
  12782. _this._bgNode.destroy();
  12783. }).start();
  12784. }
  12785. /**
  12786. * 设置文字
  12787. * @param text 文字
  12788. * @returns
  12789. */;
  12790. _proto.setText = function setText(text) {
  12791. this._text = text;
  12792. var label = this._textNode.getComponent(Label);
  12793. label.string = this._text;
  12794. return this;
  12795. }
  12796. /**
  12797. * 设置文字大小
  12798. * @param textSize 文字大小
  12799. * @returns
  12800. */;
  12801. _proto.setFontSize = function setFontSize(textSize) {
  12802. this._textSize = textSize;
  12803. var label = this._textNode.getComponent(Label);
  12804. label.fontSize = this._textSize;
  12805. return this;
  12806. }
  12807. /**
  12808. * 设置时间
  12809. * @param time 时间
  12810. * @returns
  12811. */;
  12812. _proto.setTime = function setTime(time) {
  12813. this._time = time;
  12814. return this;
  12815. }
  12816. /**
  12817. * 设置位置
  12818. * @param gravity 位置
  12819. * @returns
  12820. */;
  12821. _proto.setGravity = function setGravity(gravity) {
  12822. this._gravity = gravity;
  12823. return this;
  12824. };
  12825. _proto.setPosition = function setPosition() {
  12826. var uiTransform = this._node.getComponent(UITransform);
  12827. var bgUITransform = this._bgNode.getComponent(UITransform);
  12828. if (Gravity.BOTTOM === this._gravity) {
  12829. var y = bgUITransform.height / 2;
  12830. this._bgNode.position = v3(0, y, 0);
  12831. }
  12832. };
  12833. _proto.setOverFlow = function setOverFlow() {
  12834. var maxLength = this._node.getComponent(UITransform).width / 2;
  12835. var label = this._textNode.getComponent(Label);
  12836. var fontLength = this._text.length * label.fontSize;
  12837. var uiTransform = this._textNode.getComponent(UITransform);
  12838. if (fontLength > maxLength) {
  12839. uiTransform.width = maxLength;
  12840. label.overflow = Label.Overflow.RESIZE_HEIGHT;
  12841. } else {
  12842. uiTransform.width = fontLength;
  12843. label.overflow = Label.Overflow.NONE;
  12844. }
  12845. var bgUITransform = this._bgNode.getComponent(UITransform);
  12846. bgUITransform.width = uiTransform.width + label.fontSize * 4;
  12847. bgUITransform.height = uiTransform.height;
  12848. this.setPosition();
  12849. };
  12850. _proto.getPNode = function getPNode(root) {
  12851. if (null == Toast.pNode || !Toast.pNode.isValid) {
  12852. Toast.pNode = new Node('Toast');
  12853. var transform = Toast.pNode.addComponent(UITransform);
  12854. Toast.pNode.layer = Layers.Enum.UI_2D;
  12855. root.addChild(Toast.pNode);
  12856. Toast.pNode.setSiblingIndex(root.children.length);
  12857. var size = view.getVisibleSize();
  12858. transform.contentSize = size;
  12859. transform.width = size.width;
  12860. transform.height = size.height;
  12861. }
  12862. return Toast.pNode;
  12863. };
  12864. return Toast;
  12865. }());
  12866. Toast.LENGTH_SHORT = 1;
  12867. // 短时间吐司
  12868. Toast.LENGTH_LONG = 3.5;
  12869. // 长时间吐司
  12870. Toast.pNode = null;
  12871. cclegacy._RF.pop();
  12872. }
  12873. };
  12874. });
  12875. System.register("chunks:///_virtual/ui_base.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  12876. var _inheritsLoose, _createClass, cclegacy, _decorator, Button, assetManager, Node, find, EventHandler, Toggle, ToggleContainer, Component, isValid;
  12877. return {
  12878. setters: [function (module) {
  12879. _inheritsLoose = module.inheritsLoose;
  12880. _createClass = module.createClass;
  12881. }, function (module) {
  12882. cclegacy = module.cclegacy;
  12883. _decorator = module._decorator;
  12884. Button = module.Button;
  12885. assetManager = module.assetManager;
  12886. Node = module.Node;
  12887. find = module.find;
  12888. EventHandler = module.EventHandler;
  12889. Toggle = module.Toggle;
  12890. ToggleContainer = module.ToggleContainer;
  12891. Component = module.Component;
  12892. isValid = module.isValid;
  12893. }],
  12894. execute: function () {
  12895. var _dec, _class;
  12896. cclegacy._RF.push({}, "a34ebvwnv5E2LG2J8RHwXU2", "ui_base", undefined);
  12897. var ccclass = _decorator.ccclass,
  12898. property = _decorator.property;
  12899. /***
  12900. * @en internal class, used for handling node event.
  12901. * @zh 内部类,用于节点事件监听
  12902. *
  12903. * */
  12904. var __NodeEventAgent__ = (_dec = ccclass('tgxNodeEventAgent'), _dec(_class = /*#__PURE__*/function (_Component) {
  12905. _inheritsLoose(__NodeEventAgent__, _Component);
  12906. function __NodeEventAgent__() {
  12907. return _Component.apply(this, arguments) || this;
  12908. }
  12909. var _proto = __NodeEventAgent__.prototype;
  12910. /***
  12911. * @en recieve button click event and deliver them to the real handlers.
  12912. * @zh 接受按钮事件,并转发给真正的处理函数
  12913. * */
  12914. _proto.onButtonClicked = function onButtonClicked(evt, customEventData) {
  12915. var btn = evt.target.getComponent(Button);
  12916. var clickEvents = btn.clickEvents;
  12917. for (var i = 0; i < clickEvents.length; ++i) {
  12918. var h = clickEvents[i];
  12919. if (h.customEventData == customEventData) {
  12920. var cb = h['$cb$'];
  12921. var target = h['$target$'];
  12922. var args = h['$args$'];
  12923. cb.apply(target, [btn, args]);
  12924. }
  12925. }
  12926. }
  12927. /***
  12928. * @en recieve toggle event and deliver them to the real handlers.
  12929. * @zh 接受Toggle事件,并转发给真正的处理函数
  12930. * */;
  12931. _proto.onToggleEvent = function onToggleEvent(toggle, customEventData) {
  12932. var checkEvents = toggle.checkEvents;
  12933. //if (toggle['_toggleContainer']) {
  12934. // checkEvents = toggle['_toggleContainer'].checkEvents;
  12935. //}
  12936. for (var i = 0; i < checkEvents.length; ++i) {
  12937. var h = checkEvents[i];
  12938. if (h.customEventData == customEventData) {
  12939. var cb = h['$cb$'];
  12940. var target = h['$target$'];
  12941. var args = h['$args$'];
  12942. cb.apply(target, [toggle, args]);
  12943. }
  12944. }
  12945. };
  12946. return __NodeEventAgent__;
  12947. }(Component)) || _class);
  12948. var _id = 0;
  12949. var ui_base = exports('default', /*#__PURE__*/function () {
  12950. /***
  12951. * @en hide and destroy all ui panel.
  12952. * @zh 隐藏并销毁所有UI面板
  12953. * */
  12954. ui_base.closeAll = function closeAll() {
  12955. while (this._uis.length) {
  12956. this._uis[0].close();
  12957. }
  12958. this._clss.clear();
  12959. }
  12960. //
  12961. ;
  12962. ui_base.closeAndReleaseAll = function closeAndReleaseAll() {
  12963. while (this._uis.length) {
  12964. this._uis[0].closeAndRelease();
  12965. }
  12966. this._clss.clear();
  12967. }
  12968. //update all ui, called by UI.
  12969. ;
  12970. ui_base.updateAll = function updateAll(dt) {
  12971. for (var i = 0; i < this._uis.length; ++i) {
  12972. var ctrl = this._uis[i];
  12973. if (ctrl.node && isValid(ctrl.node)) {
  12974. this._uis[i].onUpdate(dt);
  12975. }
  12976. }
  12977. };
  12978. ui_base._addCls = function _addCls(cls) {
  12979. if (!cls) return;
  12980. this._clss.add(cls);
  12981. };
  12982. ui_base._removeCls = function _removeCls(cls) {
  12983. if (!cls) return;
  12984. this._clss["delete"](cls);
  12985. };
  12986. ui_base._hasCls = function _hasCls(cls) {
  12987. return this._clss.has(cls);
  12988. };
  12989. var _proto2 = ui_base.prototype;
  12990. _proto2.getLayout = function getLayout() {
  12991. return this._layout;
  12992. };
  12993. function ui_base(bundle, prefab, layer, layoutCls) {
  12994. this._id = 0;
  12995. this._bundle = void 0;
  12996. this._prefab = void 0;
  12997. this._layer = void 0;
  12998. this._layout = void 0;
  12999. this._cls = void 0;
  13000. this.node = void 0;
  13001. this._destroyed = false;
  13002. this._resolve_close = null;
  13003. this._cls = null;
  13004. this._bundle = bundle;
  13005. this._prefab = prefab;
  13006. this._layer = layer;
  13007. this._layout = layoutCls;
  13008. this._id = _id++;
  13009. }
  13010. //setup this ui,called by UIMgr.
  13011. _proto2._setup = function _setup(cls, node) {
  13012. ui_base._uis.push(this);
  13013. this._cls = cls;
  13014. ui_base._addCls(this._cls);
  13015. this.node = node;
  13016. if (this._layout) this._layout = this.node.getComponent(this._layout);
  13017. //notify sub class to handle something.
  13018. //节点创建完毕,调用子类的处理函数。
  13019. for (var _len = arguments.length, data = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  13020. data[_key - 2] = arguments[_key];
  13021. }
  13022. this.onCreated.apply(this, data);
  13023. //check whether it has been destroyed, if has, hide it.
  13024. //检查是否为已销毁,如果已销毁,则走销毁流程
  13025. if (this._destroyed) this.close();
  13026. }
  13027. /**
  13028. * @en hide and destroy this ui panel.
  13029. * @zh 隐藏并销毁此UI面板
  13030. * */;
  13031. _proto2.close = function close() {
  13032. var _this$_resolve_close;
  13033. (_this$_resolve_close = this._resolve_close) == null || _this$_resolve_close.call(this);
  13034. this._resolve_close = null;
  13035. this._destroyed = true;
  13036. if (!this.node) return;
  13037. this.node.removeFromParent();
  13038. for (var i = 0; i < ui_base._uis.length; ++i) {
  13039. if (ui_base._uis[i] == this) {
  13040. ui_base._uis.splice(i, 1);
  13041. break;
  13042. }
  13043. }
  13044. this.onDispose();
  13045. this.node.destroy();
  13046. this.node = null;
  13047. ui_base._removeCls(this._cls);
  13048. this._cls = null;
  13049. };
  13050. _proto2.closeAndRelease = function closeAndRelease() {
  13051. var _assetManager$getBund;
  13052. this.close();
  13053. (_assetManager$getBund = assetManager.getBundle(this._bundle)) == null || _assetManager$getBund.release(this._prefab);
  13054. };
  13055. /**等待此ui关闭*/
  13056. _proto2.wait_close = function wait_close() {
  13057. var _this = this;
  13058. if (this._resolve_close) return;
  13059. return new Promise(function (resolve) {
  13060. _this._resolve_close = resolve;
  13061. });
  13062. }
  13063. /**
  13064. * @en add button event handler
  13065. * @zh 添加按钮事件
  13066. * @param relativeNodePath to indicate a button node, can pass `string`|`Node`|`Button` here.
  13067. * @param cb will be called when event emits. method format:(btn:Button,args:any)=>void
  13068. * @param target the `this` argument of `cb`
  13069. * */;
  13070. _proto2.onButtonEvent = function onButtonEvent(relativeNodePath, cb, target, args) {
  13071. var buttonNode = null;
  13072. if (relativeNodePath instanceof Node) {
  13073. buttonNode = relativeNodePath;
  13074. } else if (relativeNodePath instanceof Button) {
  13075. buttonNode = relativeNodePath.node;
  13076. } else {
  13077. buttonNode = find(relativeNodePath, this.node);
  13078. }
  13079. if (!buttonNode) {
  13080. return null;
  13081. }
  13082. //添加转发器
  13083. var agent = this.node.getComponent(__NodeEventAgent__);
  13084. if (!agent) {
  13085. agent = this.node.addComponent(__NodeEventAgent__);
  13086. }
  13087. var btn = buttonNode.getComponent(Button);
  13088. var clickEvents = btn.clickEvents;
  13089. var handler = new EventHandler();
  13090. handler.target = this.node;
  13091. handler.component = 'tgxNodeEventAgent';
  13092. handler.handler = 'onButtonClicked';
  13093. handler.customEventData = '' + _id++;
  13094. //附加额外信息 供事件转发使用
  13095. handler['$cb$'] = cb;
  13096. handler['$target$'] = target;
  13097. handler['$args$'] = args;
  13098. clickEvents.push(handler);
  13099. btn.clickEvents = clickEvents;
  13100. }
  13101. /**
  13102. * @en remove button event handler
  13103. * @zh 移除按钮事件
  13104. * @param relativeNodePath to indicate a button node, can pass `string`|`Node`|`Button` here.
  13105. * @param cb will be called when event emits.
  13106. * @param target the `this` argument of `cb`
  13107. * */;
  13108. _proto2.offButtonEvent = function offButtonEvent(relativeNodePath, cb, target) {
  13109. var buttonNode = null;
  13110. if (relativeNodePath instanceof Node) {
  13111. buttonNode = relativeNodePath;
  13112. } else if (relativeNodePath instanceof Button) {
  13113. buttonNode = relativeNodePath.node;
  13114. } else {
  13115. buttonNode = find(relativeNodePath, this.node);
  13116. }
  13117. if (!buttonNode) {
  13118. return;
  13119. }
  13120. var agent = this.node.getComponent(__NodeEventAgent__);
  13121. if (!agent) {
  13122. return;
  13123. }
  13124. var btn = buttonNode.getComponent(Button);
  13125. if (!btn) {
  13126. return;
  13127. }
  13128. var clickEvents = btn.clickEvents;
  13129. for (var i = 0; i < clickEvents.length; ++i) {
  13130. var h = clickEvents[i];
  13131. if (h['$cb$'] == cb && h['$target$'] == target) {
  13132. clickEvents.splice(i, 1);
  13133. btn.clickEvents = clickEvents;
  13134. break;
  13135. }
  13136. }
  13137. }
  13138. /**
  13139. * @en add toggle event handler
  13140. * @zh 添加Toggle事件
  13141. * @param relativeNodePath to indicate a button node, can pass `string`|`Node`|`Button` here.
  13142. * @param cb will be called when event emits. method format:(btn:Toggle,args:any)=>void
  13143. * @param target the `this` argument of `cb`
  13144. */;
  13145. _proto2.onToggleEvent = function onToggleEvent(relativeNodePath, cb, target, args) {
  13146. var buttonNode = null;
  13147. if (relativeNodePath instanceof Node) {
  13148. buttonNode = relativeNodePath;
  13149. } else if (relativeNodePath instanceof Toggle) {
  13150. buttonNode = relativeNodePath.node;
  13151. } else if (relativeNodePath instanceof ToggleContainer) {
  13152. buttonNode = relativeNodePath.node;
  13153. } else {
  13154. buttonNode = find(relativeNodePath, this.node);
  13155. }
  13156. if (!buttonNode) {
  13157. return null;
  13158. }
  13159. //添加转发器
  13160. var agent = this.node.getComponent(__NodeEventAgent__);
  13161. if (!agent) agent = this.node.addComponent(__NodeEventAgent__);
  13162. var btn = buttonNode.getComponent(Toggle);
  13163. if (!btn) btn = buttonNode.getComponent(ToggleContainer);
  13164. var checkEvents = btn.checkEvents;
  13165. var handler = new EventHandler();
  13166. handler.target = this.node;
  13167. handler.component = 'tgxNodeEventAgent';
  13168. handler.handler = 'onToggleEvent';
  13169. handler.customEventData = '' + _id++;
  13170. //附加额外信息 供事件转发使用
  13171. handler['$cb$'] = cb;
  13172. handler['$target$'] = target;
  13173. handler['$args$'] = args;
  13174. checkEvents.push(handler);
  13175. btn.checkEvents = checkEvents;
  13176. }
  13177. /**
  13178. * @en remove toggle event handler
  13179. * @zh 移除Toggle事件
  13180. * @param relativeNodePath to indicate a button node, can pass `string`|`Node`|`Button` here.
  13181. * @param cb will be called when event emits. method format:(btn:Toggle,args:any)=>void
  13182. * @param target the `this` argument of `cb`
  13183. * */;
  13184. _proto2.offToggleEvent = function offToggleEvent(relativeNodePath, cb, target) {
  13185. var buttonNode = null;
  13186. if (relativeNodePath instanceof Node) {
  13187. buttonNode = relativeNodePath;
  13188. } else if (relativeNodePath instanceof Toggle) {
  13189. buttonNode = relativeNodePath.node;
  13190. } else if (relativeNodePath instanceof ToggleContainer) {
  13191. buttonNode = relativeNodePath.node;
  13192. } else {
  13193. buttonNode = find(relativeNodePath, this.node);
  13194. }
  13195. if (!buttonNode) {
  13196. return null;
  13197. }
  13198. //添加转发器
  13199. var agent = this.node.getComponent(__NodeEventAgent__);
  13200. if (!agent) {
  13201. return;
  13202. }
  13203. var btn = buttonNode.getComponent(Toggle);
  13204. if (!btn) {
  13205. btn = buttonNode.getComponent(ToggleContainer);
  13206. }
  13207. var checkEvents = btn.checkEvents;
  13208. for (var i = 0; i < checkEvents.length; ++i) {
  13209. var h = checkEvents[i];
  13210. if (h['$cb$'] == cb && h['$target$'] == target) {
  13211. checkEvents.splice(i, 1);
  13212. btn.checkEvents = checkEvents;
  13213. break;
  13214. }
  13215. }
  13216. }
  13217. //子类的所有操作,需要在这个函数之后。
  13218. ;
  13219. _proto2.onCreated = function onCreated() {}
  13220. //当界面销毁时调用
  13221. ;
  13222. _proto2.onDispose = function onDispose() {}
  13223. //
  13224. ;
  13225. _proto2.onUpdate = function onUpdate(dt) {};
  13226. _createClass(ui_base, [{
  13227. key: "id",
  13228. get:
  13229. /***
  13230. * @en the instance id to indicate an unique ui panel.
  13231. * @zh 实例ID,用于标记一个唯一面板实例
  13232. * */
  13233. function get() {
  13234. return this._id;
  13235. }
  13236. /***
  13237. * @en url of the prefab used by this ui panel.
  13238. * @zh 本UI使用prefab路径
  13239. * */
  13240. }, {
  13241. key: "prefab",
  13242. get: function get() {
  13243. return this._prefab;
  13244. }
  13245. }, {
  13246. key: "bundle",
  13247. get: function get() {
  13248. return this._bundle;
  13249. }
  13250. /***
  13251. * @en layer of this ui panel.
  13252. * @zh 本UI所在的UI层级
  13253. * */
  13254. }, {
  13255. key: "layer",
  13256. get: function get() {
  13257. return this._layer;
  13258. }
  13259. /***
  13260. * @en layout of this ui panel.
  13261. * @zh 本UI组件
  13262. * */
  13263. }, {
  13264. key: "layout",
  13265. get: function get() {
  13266. return this._layout;
  13267. }
  13268. }]);
  13269. return ui_base;
  13270. }());
  13271. ui_base._clss = new Set();
  13272. ui_base._uis = [];
  13273. cclegacy._RF.pop();
  13274. }
  13275. };
  13276. });
  13277. System.register("chunks:///_virtual/ui_ResolutionAutoFit.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  13278. var _inheritsLoose, cclegacy, _decorator, screen, view, ResolutionPolicy, size, Component;
  13279. return {
  13280. setters: [function (module) {
  13281. _inheritsLoose = module.inheritsLoose;
  13282. }, function (module) {
  13283. cclegacy = module.cclegacy;
  13284. _decorator = module._decorator;
  13285. screen = module.screen;
  13286. view = module.view;
  13287. ResolutionPolicy = module.ResolutionPolicy;
  13288. size = module.size;
  13289. Component = module.Component;
  13290. }],
  13291. execute: function () {
  13292. var _dec, _class;
  13293. cclegacy._RF.push({}, "c7d72SJqEtIhpLiAo3HdgLR", "ui_ResolutionAutoFit", undefined);
  13294. var ccclass = _decorator.ccclass,
  13295. property = _decorator.property;
  13296. var CHECK_INTERVAL = 0.1;
  13297. var ResolutionAutoFit = exports('ResolutionAutoFit', (_dec = ccclass('ch.ResolutionAutoFit'), _dec(_class = /*#__PURE__*/function (_Component) {
  13298. _inheritsLoose(ResolutionAutoFit, _Component);
  13299. function ResolutionAutoFit() {
  13300. var _this;
  13301. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  13302. args[_key] = arguments[_key];
  13303. }
  13304. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  13305. _this._oldSize = size();
  13306. _this.lastCheckTime = 0;
  13307. return _this;
  13308. }
  13309. var _proto = ResolutionAutoFit.prototype;
  13310. _proto.start = function start() {
  13311. this.adjustResolutionPolicy();
  13312. };
  13313. _proto.update = function update(deltaTime) {
  13314. this.lastCheckTime += deltaTime;
  13315. if (this.lastCheckTime < CHECK_INTERVAL) {
  13316. return;
  13317. }
  13318. this.lastCheckTime = 0;
  13319. this.adjustResolutionPolicy();
  13320. };
  13321. _proto.adjustResolutionPolicy = function adjustResolutionPolicy() {
  13322. var winSize = screen.windowSize;
  13323. if (!this._oldSize.equals(winSize)) {
  13324. var ratio = winSize.width / winSize.height;
  13325. var drs = view.getDesignResolutionSize();
  13326. var drsRatio = drs.width / drs.height;
  13327. if (ratio > drsRatio) {
  13328. //wider than desgin. fixed height
  13329. view.setResolutionPolicy(ResolutionPolicy.FIXED_HEIGHT);
  13330. } else {
  13331. //
  13332. view.setResolutionPolicy(ResolutionPolicy.FIXED_WIDTH);
  13333. }
  13334. this._oldSize.set(winSize);
  13335. }
  13336. };
  13337. return ResolutionAutoFit;
  13338. }(Component)) || _class));
  13339. cclegacy._RF.pop();
  13340. }
  13341. };
  13342. });
  13343. System.register("chunks:///_virtual/ui.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc', './ui_base.ts', './ui_ResolutionAutoFit.ts'], function (exports) {
  13344. var _inheritsLoose, _asyncToGenerator, _regeneratorRuntime, cclegacy, _decorator, Component, tween, v3, UIOpacity, Tween, Vec3, UITransform, Node, Widget, error, instantiate, director, assetManager, ui_base, ResolutionAutoFit;
  13345. return {
  13346. setters: [function (module) {
  13347. _inheritsLoose = module.inheritsLoose;
  13348. _asyncToGenerator = module.asyncToGenerator;
  13349. _regeneratorRuntime = module.regeneratorRuntime;
  13350. }, function (module) {
  13351. cclegacy = module.cclegacy;
  13352. _decorator = module._decorator;
  13353. Component = module.Component;
  13354. tween = module.tween;
  13355. v3 = module.v3;
  13356. UIOpacity = module.UIOpacity;
  13357. Tween = module.Tween;
  13358. Vec3 = module.Vec3;
  13359. UITransform = module.UITransform;
  13360. Node = module.Node;
  13361. Widget = module.Widget;
  13362. error = module.error;
  13363. instantiate = module.instantiate;
  13364. director = module.director;
  13365. assetManager = module.assetManager;
  13366. }, function (module) {
  13367. ui_base = module.default;
  13368. exports('ui_base', module.default);
  13369. }, function (module) {
  13370. ResolutionAutoFit = module.ResolutionAutoFit;
  13371. }],
  13372. execute: function () {
  13373. var _dec, _class;
  13374. cclegacy._RF.push({}, "81e48wxjGBMPp2rQOJDljTG", "ui", undefined);
  13375. var ccclass = _decorator.ccclass,
  13376. property = _decorator.property;
  13377. var ui_updater = (_dec = ccclass('ui_updater'), _dec(_class = /*#__PURE__*/function (_Component) {
  13378. _inheritsLoose(ui_updater, _Component);
  13379. function ui_updater() {
  13380. return _Component.apply(this, arguments) || this;
  13381. }
  13382. var _proto = ui_updater.prototype;
  13383. _proto.update = function update(dt) {
  13384. ui_base.updateAll(dt);
  13385. };
  13386. return ui_updater;
  13387. }(Component)) || _class);
  13388. var GameUILayers = exports('GameUILayers', /*#__PURE__*/function (GameUILayers) {
  13389. GameUILayers[GameUILayers["GAME"] = 0] = "GAME";
  13390. GameUILayers[GameUILayers["JOY_STICK"] = 1] = "JOY_STICK";
  13391. GameUILayers[GameUILayers["HUD"] = 2] = "HUD";
  13392. GameUILayers[GameUILayers["POPUP"] = 3] = "POPUP";
  13393. GameUILayers[GameUILayers["ALERT"] = 4] = "ALERT";
  13394. GameUILayers[GameUILayers["NOTICE"] = 5] = "NOTICE";
  13395. GameUILayers[GameUILayers["LOADING"] = 6] = "LOADING";
  13396. GameUILayers[GameUILayers["OVERLAY"] = 7] = "OVERLAY";
  13397. return GameUILayers;
  13398. }({}));
  13399. /**ui管理模块*/
  13400. var ui = /*#__PURE__*/function () {
  13401. function ui() {
  13402. this._uiCanvas = void 0;
  13403. this._uiRoot = void 0;
  13404. this._clss_loading = new Set();
  13405. }
  13406. ui.getInstance = function getInstance() {
  13407. if (!this._instance) this._instance = new ui();
  13408. return this._instance;
  13409. };
  13410. var _proto2 = ui.prototype;
  13411. _proto2.delay = function delay(ms) {
  13412. return new Promise(function (resolve) {
  13413. return setTimeout(resolve, ms);
  13414. });
  13415. };
  13416. _proto2.delay_second = function delay_second(s) {
  13417. return new Promise(function (resolve) {
  13418. return setTimeout(resolve, s * 1000);
  13419. });
  13420. };
  13421. _proto2.progressBar_anim = function progressBar_anim(bar, progress, duration) {
  13422. if (duration === void 0) {
  13423. duration = 0.2;
  13424. }
  13425. if (bar.progress >= progress) {
  13426. bar.progress = progress;
  13427. return;
  13428. } else {
  13429. return new Promise(function (resolve) {
  13430. return tween(bar).to(duration, {
  13431. progress: progress
  13432. }).call(function () {
  13433. resolve();
  13434. }).start();
  13435. });
  13436. }
  13437. };
  13438. _proto2.fillRange_anim = function fillRange_anim(sp, progress, duration, limt) {
  13439. if (duration === void 0) {
  13440. duration = 0.2;
  13441. }
  13442. if (limt === void 0) {
  13443. limt = 0;
  13444. }
  13445. if (limt > 0 && sp.fillRange >= progress && limt < 0 && sp.fillRange <= progress) {
  13446. sp.fillRange = progress;
  13447. return;
  13448. } else {
  13449. return new Promise(function (resolve) {
  13450. return tween(sp).to(duration, {
  13451. fillRange: progress
  13452. }).call(function () {
  13453. resolve();
  13454. }).start();
  13455. });
  13456. }
  13457. };
  13458. _proto2.scale_anim = function scale_anim(node, duration, start, end) {
  13459. if (duration === void 0) {
  13460. duration = 0.2;
  13461. }
  13462. if (start === void 0) {
  13463. start = 0.5;
  13464. }
  13465. if (end === void 0) {
  13466. end = 1;
  13467. }
  13468. node.setScale(start, start, 1);
  13469. return new Promise(function (resolve) {
  13470. return tween(node).to(duration, {
  13471. scale: v3(end, end, 1)
  13472. }).call(function () {
  13473. resolve();
  13474. }).start();
  13475. });
  13476. };
  13477. _proto2.scale_elasticOut_anim = function scale_elasticOut_anim(node, duration, start, end) {
  13478. if (duration === void 0) {
  13479. duration = 0.2;
  13480. }
  13481. if (start === void 0) {
  13482. start = 0.5;
  13483. }
  13484. if (end === void 0) {
  13485. end = 1;
  13486. }
  13487. node.setScale(start, start, 1);
  13488. return new Promise(function (resolve) {
  13489. return tween(node).to(duration, {
  13490. scale: v3(end, end, 1)
  13491. }, {
  13492. easing: 'elasticOut'
  13493. }).call(function () {
  13494. resolve();
  13495. }).start();
  13496. });
  13497. };
  13498. _proto2.fade_anim = function fade_anim(node, duration, startOpacity, targetOpacity) {
  13499. var _node$getComponent;
  13500. if (duration === void 0) {
  13501. duration = 0.2;
  13502. }
  13503. if (startOpacity === void 0) {
  13504. startOpacity = 0;
  13505. }
  13506. if (targetOpacity === void 0) {
  13507. targetOpacity = 255;
  13508. }
  13509. var opacity = (_node$getComponent = node.getComponent(UIOpacity)) != null ? _node$getComponent : node.addComponent(UIOpacity);
  13510. opacity.opacity = startOpacity;
  13511. return new Promise(function (resolve) {
  13512. tween(opacity).to(duration, {
  13513. opacity: targetOpacity
  13514. }).call(function () {
  13515. resolve();
  13516. }).start();
  13517. });
  13518. };
  13519. _proto2.shake_anim = function shake_anim(node, duration, intensity, shakeCount) {
  13520. if (duration === void 0) {
  13521. duration = 0.2;
  13522. }
  13523. if (intensity === void 0) {
  13524. intensity = 5;
  13525. }
  13526. if (shakeCount === void 0) {
  13527. shakeCount = 7;
  13528. }
  13529. return new Promise(function (resolve) {
  13530. var originalPosition = node.position.clone(); // 保存原始位置
  13531. var shakeDuration = duration / (shakeCount * 2); // 每次抖动的持续时间
  13532. var shakeTween = tween(node);
  13533. for (var i = 0; i < shakeCount; i++) {
  13534. var offsetX = i % 2 === 0 ? intensity : -intensity; // 交替偏移
  13535. shakeTween.to(shakeDuration, {
  13536. position: v3(originalPosition.x + offsetX, originalPosition.y, originalPosition.z)
  13537. }).to(shakeDuration, {
  13538. position: originalPosition
  13539. }); // 回到原位
  13540. }
  13541. shakeTween.call(function () {
  13542. resolve();
  13543. }).start(); // 开始抖动动画
  13544. });
  13545. };
  13546. _proto2.rotate_shake_anim = function rotate_shake_anim(node, duration, intensity, shakeCount) {
  13547. if (duration === void 0) {
  13548. duration = 0.3;
  13549. }
  13550. if (intensity === void 0) {
  13551. intensity = 5;
  13552. }
  13553. if (shakeCount === void 0) {
  13554. shakeCount = 5;
  13555. }
  13556. return new Promise(function (resolve) {
  13557. var originalAngle = node.angle; // 保存原始角度
  13558. var shakeDuration = duration / (shakeCount * 2); // 每次晃动的持续时间
  13559. var shakeTween = tween(node);
  13560. for (var i = 0; i < shakeCount; i++) {
  13561. var offsetAngle = i % 2 === 0 ? intensity : -intensity; // 交替旋转
  13562. shakeTween.to(shakeDuration, {
  13563. angle: originalAngle + offsetAngle
  13564. }).to(shakeDuration, {
  13565. angle: originalAngle
  13566. }); // 回到原位
  13567. }
  13568. shakeTween.call(function () {
  13569. resolve();
  13570. }).start(); // 开始角度晃动动画
  13571. });
  13572. };
  13573. _proto2.scale_shake_anim = function scale_shake_anim(node, duration, intensity, shakeCount, reset) {
  13574. if (duration === void 0) {
  13575. duration = 0.3;
  13576. }
  13577. if (intensity === void 0) {
  13578. intensity = 0.1;
  13579. }
  13580. if (shakeCount === void 0) {
  13581. shakeCount = 10;
  13582. }
  13583. if (reset === void 0) {
  13584. reset = null;
  13585. }
  13586. if (reset) {
  13587. Tween.stopAllByTarget(node);
  13588. node.setScale(reset, reset, reset);
  13589. }
  13590. return new Promise(function (resolve) {
  13591. var originalScale = node.scale.clone(); // 保存原始缩放
  13592. var shakeDuration = duration / (shakeCount * 2); // 每次震动的持续时间
  13593. var shakeTween = tween(node);
  13594. for (var i = 0; i < shakeCount; i++) {
  13595. var offsetScale = i % 2 === 0 ? intensity : -intensity; // 交替缩放
  13596. shakeTween.to(shakeDuration, {
  13597. scale: v3(originalScale.x + offsetScale, originalScale.y + offsetScale, originalScale.z)
  13598. }).to(shakeDuration, {
  13599. scale: originalScale
  13600. }); // 回到原位
  13601. }
  13602. shakeTween.call(function () {
  13603. resolve();
  13604. }).start(); // 开始缩放震动动画
  13605. });
  13606. };
  13607. _proto2.opacity_shake_anim = function opacity_shake_anim(node, duration, intensity, shakeCount) {
  13608. var _node$getComponent2;
  13609. if (duration === void 0) {
  13610. duration = 0.8;
  13611. }
  13612. if (intensity === void 0) {
  13613. intensity = 80;
  13614. }
  13615. if (shakeCount === void 0) {
  13616. shakeCount = 5;
  13617. }
  13618. var opacity = (_node$getComponent2 = node.getComponent(UIOpacity)) != null ? _node$getComponent2 : node.addComponent(UIOpacity);
  13619. var originalOpacity = opacity.opacity;
  13620. var shakeDuration = duration / (shakeCount * 2);
  13621. return new Promise(function (resolve) {
  13622. var shakeTween = tween(opacity);
  13623. for (var i = 0; i < shakeCount; i++) {
  13624. var offsetOpacity = i % 2 === 0 ? intensity : -intensity;
  13625. shakeTween.to(shakeDuration, {
  13626. opacity: Math.min(Math.max(originalOpacity + offsetOpacity, 0), 255)
  13627. }).to(shakeDuration, {
  13628. opacity: originalOpacity
  13629. });
  13630. }
  13631. shakeTween.call(function () {
  13632. resolve();
  13633. }).start(); // 开始透明度震动动画
  13634. });
  13635. }
  13636. /**处理弹跳动画*/;
  13637. _proto2.bounce_anim = function bounce_anim(node, height, duration) {
  13638. if (height === void 0) {
  13639. height = 100;
  13640. }
  13641. if (duration === void 0) {
  13642. duration = 0.5;
  13643. }
  13644. return new Promise(function (resolve) {
  13645. tween(node).to(duration, {
  13646. position: node.position.clone().add(new Vec3(0, height, 0))
  13647. }, {
  13648. easing: 'bounceOut'
  13649. }) // 向上弹跳
  13650. .to(duration, {
  13651. position: node.position
  13652. }, {
  13653. easing: 'bounceIn'
  13654. }) // 回到原位
  13655. .call(function () {
  13656. resolve();
  13657. }) //完成动画
  13658. .start(); //开始动画
  13659. });
  13660. }
  13661. /**
  13662. * 奖励物飞行动画
  13663. * @param node 奖励物节点
  13664. * @param startPos 起始爆开点
  13665. * @param targetPos 最终目标点
  13666. * @param explosionDistance 爆开距离
  13667. * @param explosionDuration 爆开时间
  13668. * @param stayDuration 停留时间
  13669. * @param moveDuration 移动到目标的时间
  13670. * @returns
  13671. */;
  13672. _proto2.reward_fly_anim = function reward_fly_anim(node, startPos, targetPos, explosionDistance, explosionDuration, stayDuration, moveDuration) {
  13673. if (explosionDistance === void 0) {
  13674. explosionDistance = 100;
  13675. }
  13676. if (explosionDuration === void 0) {
  13677. explosionDuration = 0.3;
  13678. }
  13679. if (stayDuration === void 0) {
  13680. stayDuration = 0.5;
  13681. }
  13682. if (moveDuration === void 0) {
  13683. moveDuration = 0.3;
  13684. }
  13685. node.setPosition(startPos);
  13686. return new Promise(function (resolve) {
  13687. //随机方向
  13688. var randomDirection = new Vec3(Math.random() * 2 - 1, Math.random() * 2 - 1, 0).normalize();
  13689. var explosionEndPos = startPos.add(randomDirection.multiplyScalar(explosionDistance)); // 爆炸效果的位置
  13690. tween(node).to(explosionDuration, {
  13691. worldPosition: explosionEndPos
  13692. }) // 爆炸动画
  13693. .delay(stayDuration) //停留时间
  13694. .to(moveDuration, {
  13695. worldPosition: targetPos
  13696. }, {
  13697. easing: 'cubicIn'
  13698. }).call(function () {
  13699. resolve();
  13700. }).start();
  13701. });
  13702. };
  13703. _proto2.createFullScreenNode = function createFullScreenNode() {
  13704. var canvas = this._uiCanvas.getComponent(UITransform);
  13705. var node = new Node();
  13706. node.layer = this._uiCanvas.layer;
  13707. var uiTransform = node.addComponent(UITransform);
  13708. uiTransform.width = canvas.width;
  13709. uiTransform.height = canvas.height;
  13710. var widget = node.addComponent(Widget);
  13711. widget.isAlignBottom = true;
  13712. widget.isAlignTop = true;
  13713. widget.isAlignLeft = true;
  13714. widget.isAlignRight = true;
  13715. widget.left = 0;
  13716. widget.right = 0;
  13717. widget.top = 0;
  13718. widget.bottom = 0;
  13719. return node;
  13720. };
  13721. _proto2.getLayers = function getLayers() {
  13722. return Object.values(GameUILayers).filter(function (value) {
  13723. return typeof value === 'number';
  13724. });
  13725. }
  13726. /**
  13727. * @en init,`don't call more than once`.
  13728. * @zh 初始化UIMgr,`不要多次调用`
  13729. * */;
  13730. _proto2.init = function init(uiCanvas) {
  13731. if (this._uiCanvas) return;
  13732. if (!uiCanvas) throw error('uiCanvas must be a Node or Prefab');
  13733. if (uiCanvas instanceof Node) {
  13734. this._uiCanvas = uiCanvas;
  13735. } else {
  13736. this._uiCanvas = instantiate(uiCanvas);
  13737. director.getScene().addChild(this._uiCanvas);
  13738. }
  13739. this._uiCanvas.name = '__ui_canvas__';
  13740. director.addPersistRootNode(this._uiCanvas);
  13741. if (!this._uiCanvas.getComponent(ui_updater)) {
  13742. this._uiCanvas.addComponent(ui_updater);
  13743. }
  13744. var canvas = this._uiCanvas.getComponent(UITransform);
  13745. this._uiCanvas.addComponent(ResolutionAutoFit);
  13746. this._uiRoot = this.createFullScreenNode();
  13747. this._uiRoot.name = 'root';
  13748. canvas.node.addChild(this._uiRoot);
  13749. var layers = this.getLayers();
  13750. //create layers
  13751. for (var i = 0; i < layers.length; ++i) {
  13752. var layerNode = this.createFullScreenNode();
  13753. layerNode.name = 'layer_' + GameUILayers[layers[i]];
  13754. this._uiRoot.addChild(layerNode);
  13755. }
  13756. }
  13757. /**获取层级节点*/;
  13758. _proto2.getLayerNode = function getLayerNode(layerIndex) {
  13759. return this._uiRoot.children[layerIndex] || this._uiRoot;
  13760. }
  13761. /**关闭所有界面*/;
  13762. _proto2.closeAll = function closeAll() {
  13763. ui_base.closeAll();
  13764. }
  13765. /**关闭和释放所有界面 */;
  13766. _proto2.closeAndReleaseAll = function closeAndReleaseAll() {
  13767. ui_base.closeAndReleaseAll();
  13768. }
  13769. /**关闭某个界面*/;
  13770. _proto2.close = function close(uiCls) {
  13771. var _this$get;
  13772. (_this$get = this.get(uiCls)) == null || _this$get.close();
  13773. }
  13774. /**获取界面*/;
  13775. _proto2.get = function get(uiCls) {
  13776. var all = ui_base._uis;
  13777. for (var i = 0; i < all.length; ++i) {
  13778. var c = all[i];
  13779. if (c instanceof uiCls) {
  13780. return c;
  13781. }
  13782. }
  13783. return null;
  13784. }
  13785. /**某个界面是否显示中*/;
  13786. _proto2.isShowing = function isShowing(uiCls) {
  13787. return ui_base._hasCls(uiCls);
  13788. };
  13789. /**是否有正在加载中的界面*/
  13790. _proto2.isLoading = function isLoading(uiCls) {
  13791. if (!uiCls) return this._clss_loading.size > 0;
  13792. return this._clss_loading.has(uiCls);
  13793. }
  13794. /***
  13795. * @en show ui by the given parameters.
  13796. * @zh 显示UI
  13797. * @param uiCls the class, must inherits from the class `UIController`.
  13798. * @returns the instance of `uiCls`
  13799. * */;
  13800. _proto2.show = /*#__PURE__*/
  13801. function () {
  13802. var _show = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(uiCls) {
  13803. var _ui,
  13804. bundleName,
  13805. bundle,
  13806. _len,
  13807. data,
  13808. _key,
  13809. loadedBundle,
  13810. _args = arguments;
  13811. return _regeneratorRuntime().wrap(function _callee$(_context) {
  13812. while (1) switch (_context.prev = _context.next) {
  13813. case 0:
  13814. if (!this.isLoading(uiCls)) {
  13815. _context.next = 2;
  13816. break;
  13817. }
  13818. return _context.abrupt("return", null);
  13819. case 2:
  13820. if (!this.isShowing(uiCls)) {
  13821. _context.next = 4;
  13822. break;
  13823. }
  13824. return _context.abrupt("return", null);
  13825. case 4:
  13826. _ui = new uiCls();
  13827. this._clss_loading.add(uiCls);
  13828. bundleName = _ui.bundle;
  13829. if (!bundleName) {
  13830. _context.next = 31;
  13831. break;
  13832. }
  13833. bundle = assetManager.getBundle(bundleName);
  13834. for (_len = _args.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  13835. data[_key - 1] = _args[_key];
  13836. }
  13837. if (bundle) {
  13838. _context.next = 26;
  13839. break;
  13840. }
  13841. _context.prev = 11;
  13842. _context.next = 14;
  13843. return this.loadBundleAsync(bundleName);
  13844. case 14:
  13845. loadedBundle = _context.sent;
  13846. _context.next = 17;
  13847. return this._create.apply(this, [loadedBundle, _ui, uiCls].concat(data));
  13848. case 17:
  13849. return _context.abrupt("return", _context.sent);
  13850. case 20:
  13851. _context.prev = 20;
  13852. _context.t0 = _context["catch"](11);
  13853. console.error(_context.t0);
  13854. this._clss_loading["delete"](uiCls);
  13855. case 24:
  13856. _context.next = 29;
  13857. break;
  13858. case 26:
  13859. _context.next = 28;
  13860. return this._create.apply(this, [bundle, _ui, uiCls].concat(data));
  13861. case 28:
  13862. return _context.abrupt("return", _context.sent);
  13863. case 29:
  13864. _context.next = 34;
  13865. break;
  13866. case 31:
  13867. this._clss_loading["delete"](uiCls);
  13868. console.error("ui no bundle name");
  13869. return _context.abrupt("return", null);
  13870. case 34:
  13871. case "end":
  13872. return _context.stop();
  13873. }
  13874. }, _callee, this, [[11, 20]]);
  13875. }));
  13876. function show(_x) {
  13877. return _show.apply(this, arguments);
  13878. }
  13879. return show;
  13880. }();
  13881. _proto2._create = /*#__PURE__*/function () {
  13882. var _create2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(bundle, _ui2, uiCls) {
  13883. var _ref,
  13884. _data,
  13885. node,
  13886. parent,
  13887. _len2,
  13888. p,
  13889. _key2,
  13890. _args2 = arguments;
  13891. return _regeneratorRuntime().wrap(function _callee2$(_context2) {
  13892. while (1) switch (_context2.prev = _context2.next) {
  13893. case 0:
  13894. _context2.prev = 0;
  13895. _context2.next = 3;
  13896. return this.loadPrefabAsync(bundle, _ui2.prefab);
  13897. case 3:
  13898. _data = _context2.sent;
  13899. node = instantiate(_data);
  13900. parent = this.getLayerNode(_ui2.layer);
  13901. parent.addChild(node);
  13902. for (_len2 = _args2.length, p = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
  13903. p[_key2 - 3] = _args2[_key2];
  13904. }
  13905. (_ref = _ui2)._setup.apply(_ref, [uiCls, node].concat(p));
  13906. this._clss_loading["delete"](uiCls);
  13907. return _context2.abrupt("return", _ui2);
  13908. case 13:
  13909. _context2.prev = 13;
  13910. _context2.t0 = _context2["catch"](0);
  13911. console.error(_context2.t0);
  13912. this._clss_loading["delete"](uiCls);
  13913. return _context2.abrupt("return");
  13914. case 18:
  13915. case "end":
  13916. return _context2.stop();
  13917. }
  13918. }, _callee2, this, [[0, 13]]);
  13919. }));
  13920. function _create(_x2, _x3, _x4) {
  13921. return _create2.apply(this, arguments);
  13922. }
  13923. return _create;
  13924. }();
  13925. _proto2.loadBundleAsync = function loadBundleAsync(bundleName) {
  13926. return new Promise(function (resolve, reject) {
  13927. assetManager.loadBundle(bundleName, null, function (err, loadedBundle) {
  13928. if (err) {
  13929. reject(err);
  13930. } else {
  13931. resolve(loadedBundle);
  13932. }
  13933. });
  13934. });
  13935. };
  13936. _proto2.loadPrefabAsync = function loadPrefabAsync(bundle, prefabName) {
  13937. return new Promise(function (resolve, reject) {
  13938. bundle.load(prefabName, function (err, data) {
  13939. if (err) {
  13940. reject(err);
  13941. } else {
  13942. resolve(data);
  13943. }
  13944. });
  13945. });
  13946. };
  13947. return ui;
  13948. }();
  13949. ui._instance = void 0;
  13950. var gui = exports('gui', ui.getInstance());
  13951. cclegacy._RF.pop();
  13952. }
  13953. };
  13954. });
  13955. System.register("chunks:///_virtual/UISpineMovie.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  13956. var _applyDecoratedDescriptor, _inheritsLoose, _initializerDefineProperty, _assertThisInitialized, cclegacy, _decorator, CCString, sp, Color, Component;
  13957. return {
  13958. setters: [function (module) {
  13959. _applyDecoratedDescriptor = module.applyDecoratedDescriptor;
  13960. _inheritsLoose = module.inheritsLoose;
  13961. _initializerDefineProperty = module.initializerDefineProperty;
  13962. _assertThisInitialized = module.assertThisInitialized;
  13963. }, function (module) {
  13964. cclegacy = module.cclegacy;
  13965. _decorator = module._decorator;
  13966. CCString = module.CCString;
  13967. sp = module.sp;
  13968. Color = module.Color;
  13969. Component = module.Component;
  13970. }],
  13971. execute: function () {
  13972. var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
  13973. cclegacy._RF.push({}, "4ce979zctxD67dYVnpW4Mn+", "UISpineMovie", undefined);
  13974. var ccclass = _decorator.ccclass,
  13975. property = _decorator.property;
  13976. /**
  13977. * spine动画表现管理
  13978. * @author
  13979. */
  13980. var UISpineMovie = exports('default', (_dec = ccclass('UISpineMovie'), _dec2 = property({
  13981. type: [CCString],
  13982. displayName: '动画列表'
  13983. }), _dec3 = property({
  13984. type: sp.Skeleton,
  13985. tooltip: '角色动画'
  13986. }), _dec(_class = (_class2 = /*#__PURE__*/function (_Component) {
  13987. _inheritsLoose(UISpineMovie, _Component);
  13988. function UISpineMovie() {
  13989. var _this;
  13990. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  13991. args[_key] = arguments[_key];
  13992. }
  13993. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  13994. _initializerDefineProperty(_this, "animat_names", _descriptor, _assertThisInitialized(_this));
  13995. _initializerDefineProperty(_this, "spine", _descriptor2, _assertThisInitialized(_this));
  13996. _this.cur = null;
  13997. _this.index = 0;
  13998. return _this;
  13999. }
  14000. var _proto = UISpineMovie.prototype;
  14001. _proto.onLoad = function onLoad() {};
  14002. _proto.start = function start() {
  14003. //this.spine.clearTracks()
  14004. /*this.spine.setStartListener(function(){
  14005. console.log("动画开始")
  14006. }.bind(this));*/
  14007. /* this.spine.setEventListener(((trackEntry:any, event:any) => {
  14008. //var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  14009. //console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
  14010. this.unit.DoEvent(event.data.name);
  14011. }) as any);*/
  14012. //
  14013. //let duration = this.spine.getCurrent(0).animation.duration;
  14014. //let frames = Math.ceil(frameRate * duration);
  14015. //let secondsPerFrame = 1 / frameRate;
  14016. //`总帧数 ${this.frames}`;
  14017. //this.spine.setCompleteListener(trackEntry => {
  14018. //});
  14019. if (this.animat_names.length > 0) {
  14020. this.index = 0;
  14021. if (this.index == this.animat_names.length - 1) {
  14022. this.DoAnimation(this.animat_names[this.index], true);
  14023. } else {
  14024. this.DoAnimation(this.animat_names[this.index], false);
  14025. }
  14026. this.spine.setCompleteListener(function () {
  14027. this.index++;
  14028. if (this.index < this.animat_names.length) {
  14029. if (this.index == this.animat_names.length - 1) {
  14030. this.DoAnimation(this.animat_names[this.index], true);
  14031. } else {
  14032. this.DoAnimation(this.animat_names[this.index], false);
  14033. }
  14034. } else {
  14035. this.spine.setCompleteListener(null);
  14036. }
  14037. }.bind(this));
  14038. }
  14039. };
  14040. _proto.SetSkin = function SetSkin(skin) {
  14041. this.spine.setSkin(skin);
  14042. };
  14043. _proto.DoAnimation = function DoAnimation(animation, loop, track, force) {
  14044. if (loop === void 0) {
  14045. loop = true;
  14046. }
  14047. if (track === void 0) {
  14048. track = 0;
  14049. }
  14050. if (force === void 0) {
  14051. force = false;
  14052. }
  14053. if (force) {
  14054. this.spine.setAnimation(track, animation, loop);
  14055. return;
  14056. }
  14057. if (this.cur == animation) return;
  14058. this.spine.setAnimation(track, animation, loop);
  14059. }
  14060. /**设置是否暂停 */;
  14061. _proto.SetPaused = function SetPaused(paused) {
  14062. this.spine.paused = paused;
  14063. }
  14064. /**获取是否暂停 */;
  14065. _proto.GetPaused = function GetPaused() {
  14066. return this.spine.paused;
  14067. };
  14068. _proto.CheckPaused = function CheckPaused(paused) {
  14069. if (this.spine.paused != paused) this.spine.paused = paused;
  14070. }
  14071. /** 闪色表现 Color.RED 0.1*/;
  14072. _proto.Flash = function Flash(color, time, reColor) {
  14073. var _this2 = this;
  14074. if (reColor === void 0) {
  14075. reColor = Color.WHITE;
  14076. }
  14077. if (this.spine.color != color) {
  14078. this.spine.color = color;
  14079. this.unscheduleAllCallbacks();
  14080. this.scheduleOnce(function () {
  14081. _this2.spine.color = reColor;
  14082. }, time);
  14083. }
  14084. }
  14085. /**
  14086. * 缩放动画播放速率
  14087. * @override
  14088. * @param scale 缩放倍率
  14089. */;
  14090. _proto.scaleTime = function scaleTime(scale) {
  14091. if (scale > 0) this.spine.timeScale = scale;
  14092. };
  14093. _proto.getBone = function getBone(name) {
  14094. var bone = this.spine.findBone(name);
  14095. return bone;
  14096. };
  14097. return UISpineMovie;
  14098. }(Component), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "animat_names", [_dec2], {
  14099. configurable: true,
  14100. enumerable: true,
  14101. writable: true,
  14102. initializer: function initializer() {
  14103. return [];
  14104. }
  14105. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "spine", [_dec3], {
  14106. configurable: true,
  14107. enumerable: true,
  14108. writable: true,
  14109. initializer: function initializer() {
  14110. return null;
  14111. }
  14112. })), _class2)) || _class));
  14113. cclegacy._RF.pop();
  14114. }
  14115. };
  14116. });
  14117. System.register("chunks:///_virtual/UrlUtil.ts", ['cc'], function (exports) {
  14118. var cclegacy;
  14119. return {
  14120. setters: [function (module) {
  14121. cclegacy = module.cclegacy;
  14122. }],
  14123. execute: function () {
  14124. cclegacy._RF.push({}, "27d07mMayFBBZrBncxUySIT", "UrlUtil", undefined);
  14125. var UrlUtil = exports('default', /*#__PURE__*/function () {
  14126. function UrlUtil() {}
  14127. /**
  14128. * 获取URL参数(字符串)
  14129. * @param url 地址
  14130. * @returns {string}
  14131. */
  14132. UrlUtil.getParamString = function getParamString(url) {
  14133. var _window$location;
  14134. url = url || ((_window$location = window.location) == null ? void 0 : _window$location.href);
  14135. if (url != void 0) {
  14136. var index = url.indexOf('?');
  14137. if (index != -1) {
  14138. return url.substring(index + 1);
  14139. }
  14140. }
  14141. return null;
  14142. }
  14143. /**
  14144. * 获取URL参数
  14145. * @param url 地址
  14146. * @returns {JSON}
  14147. */;
  14148. UrlUtil.getParam = function getParam(url) {
  14149. var param = {};
  14150. var paramString = this.getParamString(url);
  14151. if (paramString) {
  14152. paramString.split("&").forEach(function (value) {
  14153. var values = value.split("=");
  14154. if (values.length == 2) {
  14155. param[values[0]] = values[1];
  14156. }
  14157. });
  14158. }
  14159. return param;
  14160. }
  14161. /**
  14162. * 根据key获取URL参数
  14163. * @param key key
  14164. * @param url 地址
  14165. * @returns {string}
  14166. */;
  14167. UrlUtil.getParamValue = function getParamValue(key, url) {
  14168. var paramString = this.getParamString(url);
  14169. if (paramString) {
  14170. var values = paramString.match("(^|&)" + key + "=([^&]*)(&|$)");
  14171. if (values) {
  14172. return values[2];
  14173. }
  14174. }
  14175. return null;
  14176. };
  14177. return UrlUtil;
  14178. }());
  14179. cclegacy._RF.pop();
  14180. }
  14181. };
  14182. });
  14183. System.register("chunks:///_virtual/Utils.ts", ['cc'], function (exports) {
  14184. var cclegacy;
  14185. return {
  14186. setters: [function (module) {
  14187. cclegacy = module.cclegacy;
  14188. }],
  14189. execute: function () {
  14190. cclegacy._RF.push({}, "7ea66r0AApIFbjuTFjXJIWh", "Utils", undefined);
  14191. var Utils = exports('Utils', /*#__PURE__*/function () {
  14192. function Utils() {}
  14193. /**
  14194. * 随机数 (包含min,不包含max)
  14195. * @param min
  14196. * @param max
  14197. * @param isInt
  14198. * @return {*}
  14199. */
  14200. Utils.getRandom = function getRandom(min, max, isInt) {
  14201. if (min === void 0) {
  14202. min = 0;
  14203. }
  14204. if (max === void 0) {
  14205. max = 1;
  14206. }
  14207. if (isInt === void 0) {
  14208. isInt = false;
  14209. }
  14210. if (min == null) min = 0;
  14211. if (max == null) max = 1;
  14212. if (isInt == null) isInt = false;
  14213. if (min === max) return min;
  14214. var value = min + Math.random() * (max - min);
  14215. if (isInt) {
  14216. value = Math.floor(value);
  14217. }
  14218. return value;
  14219. }
  14220. /**
  14221. * 随机整数-包含最大值,最小值
  14222. * @param min
  14223. * @param max
  14224. * @return {*}
  14225. */;
  14226. Utils.getRandomIntInclusive = function getRandomIntInclusive(min, max) {
  14227. min = Math.ceil(min);
  14228. max = Math.floor(max);
  14229. if (min == max) return min;
  14230. return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
  14231. }
  14232. /**
  14233. * 随机整数-不包含最大值,最小值
  14234. * @param min
  14235. * @param max
  14236. * @return {*}
  14237. */;
  14238. Utils.getRandomInt = function getRandomInt(min, max) {
  14239. min = Math.ceil(min);
  14240. max = Math.ceil(max);
  14241. return Math.floor(Math.random() * (max - min)) + min;
  14242. }
  14243. /** */;
  14244. Utils.getRandomNumberInRange = function getRandomNumberInRange(min, max) {
  14245. return Math.random() * (max - min) + min;
  14246. }
  14247. /**生成随机整数 -1 或 1*/;
  14248. Utils.getRandomDir = function getRandomDir() {
  14249. return Math.floor(Math.random() * 2) === 0 ? -1 : 1; //
  14250. }
  14251. /**
  14252. * 在指定数组中随机取出N个不重复的数据
  14253. * @param resArr
  14254. * @param ranNum
  14255. * @returns {Array}
  14256. */;
  14257. Utils.getRandomDiffValueFromArr = function getRandomDiffValueFromArr(resArr, ranNum) {
  14258. var arr = new Array();
  14259. var result = new Array();
  14260. if (!resArr || resArr.length <= 0 || ranNum <= 0) {
  14261. return result;
  14262. }
  14263. for (var i = 0; i < resArr.length; i++) {
  14264. arr.push(resArr[i]);
  14265. }
  14266. if (ranNum >= arr.length) {
  14267. return arr;
  14268. }
  14269. ranNum = Math.min(ranNum, arr.length - 1);
  14270. for (var _i = 0; _i < ranNum; _i++) {
  14271. var ran = Utils.getRandomIntInclusive(0, arr.length - 1); // Math.floor(Math.random() * arr.length);
  14272. result.push(arr.splice(ran, 1)[0]);
  14273. }
  14274. return result;
  14275. }
  14276. /**
  14277. * 随机一个字符串
  14278. * @param length
  14279. * @returns
  14280. */;
  14281. Utils.randomStr = function randomStr(length) {
  14282. var result = '';
  14283. var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  14284. var charactersLength = characters.length;
  14285. for (var i = 0; i < length; i++) {
  14286. result += characters.charAt(Math.floor(Math.random() * charactersLength));
  14287. }
  14288. return result;
  14289. }
  14290. /**
  14291. * 时间转换 毫秒=》2019-03-28 19:55:34
  14292. * @param milliseconds
  14293. * @return {string}
  14294. */;
  14295. Utils.time2str = function time2str(milliseconds) {
  14296. var time = new Date();
  14297. time.setTime(milliseconds);
  14298. var year = time.getFullYear();
  14299. var hours = time.getHours();
  14300. var min = time.getMinutes();
  14301. var sec = time.getSeconds();
  14302. var month = time.getMonth() + 1;
  14303. var date = time.getDate();
  14304. return year + "-" + month + "-" + date + " " + (hours > 9 ? hours : "0" + hours) + ":" + (min > 9 ? min : "0" + min) + ":" + (sec > 9 ? sec : "0" + sec);
  14305. }
  14306. /**
  14307. * 将毫秒转换为时间格式 00:00:00
  14308. * @param delay
  14309. * @param detail
  14310. * @return
  14311. */;
  14312. Utils.second2time = function second2time(delay, detail) {
  14313. if (detail === void 0) {
  14314. detail = 2;
  14315. }
  14316. // if (detail == undefined) detail = 2;
  14317. //天
  14318. var d = Math.floor(delay / 86400000);
  14319. delay = delay % 86400000;
  14320. // 小时
  14321. var h = Math.floor(delay / 3600000);
  14322. delay = delay % 3600000;
  14323. // 分钟
  14324. var m = Math.floor(delay / 60000);
  14325. delay = delay % 60000;
  14326. // 秒
  14327. var s = Math.floor(delay / 1000);
  14328. delay = delay % 1000;
  14329. // 毫秒
  14330. var ml = delay;
  14331. var result = "";
  14332. if (d > 0 && detail > 0) {
  14333. result += (d > 9 ? d : "0" + d) + ":"; // "天";
  14334. detail--;
  14335. }
  14336. if (h > 0 && detail > 0) {
  14337. result += (h > 9 ? h : "0" + h) + ":"; // "小时";
  14338. detail--;
  14339. }
  14340. if (m > 0 && detail > 0) {
  14341. result += (m > 9 ? m : "0" + m) + ":"; // "分钟";
  14342. detail--;
  14343. }
  14344. if (detail > 0) {
  14345. result += s > 9 ? s : "0" + s; // "秒";
  14346. detail--;
  14347. }
  14348. if (ml > 0 && detail > 0) {
  14349. detail--;
  14350. }
  14351. return result;
  14352. };
  14353. Utils.formatMilliseconds = function formatMilliseconds(milliseconds) {
  14354. var seconds = Math.floor(milliseconds / 1000 % 60);
  14355. var minutes = Math.floor(milliseconds / (1000 * 60) % 60);
  14356. var hours = Math.floor(milliseconds / (1000 * 60 * 60) % 24);
  14357. //const formattedSeconds = seconds < 10 ? "0" + seconds : seconds;
  14358. //const formattedMinutes = minutes < 10 ? "0" + minutes : minutes;
  14359. //const formattedHours = hours < 10 ? "0" + hours : hours;
  14360. //`${formattedHours}:${formattedMinutes}:${formattedSeconds}`;
  14361. return hours.toString().padStart(2, "0") + ":" + minutes.toString().padStart(2, "0") + ":" + seconds.toString().padStart(2, "0");
  14362. }
  14363. /**
  14364. * 取小数位
  14365. * @param decimal 小数
  14366. * @param places 位数
  14367. * @return {number}
  14368. */;
  14369. Utils.getDecimal = function getDecimal(decimal, places) {
  14370. var round = Math.pow(10, places);
  14371. return Math.round(decimal * round) / round;
  14372. }
  14373. /**
  14374. * 本年第几周
  14375. * @param timestamp 毫秒
  14376. * @returns
  14377. */;
  14378. Utils.getYearWeek = function getYearWeek(timestamp) {
  14379. // let nowDate: Date = new Date(date);
  14380. // let firstDay: Date = new Date(date);
  14381. // firstDay.setMonth(0);//设置1月
  14382. // firstDay.setDate(1);//设置1号
  14383. // let diffDays = Math.ceil((nowDate.valueOf() - firstDay.valueOf())/(24*60*60*1000));
  14384. // return Math.ceil((diffDays + (firstDay.getDay() + 1 - 1)) / 7);
  14385. var currentDate = new Date(timestamp);
  14386. var year = new Date(currentDate.getFullYear(), 0, 1);
  14387. var days = Math.floor((currentDate.valueOf() - year.valueOf()) / (24 * 60 * 60 * 1000));
  14388. var week = Math.ceil((currentDate.getDay() + 1 + days) / 7);
  14389. return week;
  14390. }
  14391. /**
  14392. * 是否是同一天
  14393. * @param timeStampA
  14394. * @param timeStampB
  14395. * @return {boolean}
  14396. */;
  14397. Utils.isSameDay = function isSameDay(timeStampA, timeStampB) {
  14398. var dateA = new Date(timeStampA);
  14399. dateA.setHours(0, 0, 0, 0);
  14400. var dateB = new Date(timeStampB);
  14401. dateB.setHours(0, 0, 0, 0);
  14402. return dateA.getTime() == dateB.getTime() ? true : false;
  14403. }
  14404. //
  14405. ;
  14406. Utils.checkAndAdd = function checkAndAdd(map, k, v) {
  14407. if (map.has(k)) {
  14408. map.set(k, map.get(k) + v);
  14409. } else {
  14410. map.set(k, v);
  14411. }
  14412. }
  14413. //
  14414. /**
  14415. * 随机权重下标
  14416. * @param weights 权重数组
  14417. */;
  14418. Utils.randomWeights = function randomWeights(weights) {
  14419. // 总权重值
  14420. var totalWeight = weights.reduce(function (a, b) {
  14421. return a + b;
  14422. }, 0);
  14423. // 随机的权重值
  14424. var randomWeight = this.getRandom(0, totalWeight);
  14425. for (var index = 0, weight = 0; index < weights.length; index++) {
  14426. weight += weights[index];
  14427. if (weight >= randomWeight) {
  14428. return index;
  14429. }
  14430. }
  14431. return -1;
  14432. }
  14433. /**
  14434. * 随机数组下标
  14435. * @param array 数组
  14436. */;
  14437. Utils.randomArray = function randomArray(array, weights) {
  14438. if (!weights) {
  14439. var index = this.getRandom(0, array.length, true);
  14440. return index;
  14441. }
  14442. return this.randomWeights(weights.slice(0, array.length));
  14443. };
  14444. return Utils;
  14445. }());
  14446. cclegacy._RF.pop();
  14447. }
  14448. };
  14449. });
  14450. System.register("chunks:///_virtual/Wait.ts", ['cc'], function (exports) {
  14451. var cclegacy;
  14452. return {
  14453. setters: [function (module) {
  14454. cclegacy = module.cclegacy;
  14455. }],
  14456. execute: function () {
  14457. exports('default', get_new_wait);
  14458. cclegacy._RF.push({}, "5f7efxwnidOU6yhMrPMB9m6", "Wait", undefined);
  14459. var Wait = /*#__PURE__*/function () {
  14460. function Wait() {
  14461. this._resolve = null;
  14462. }
  14463. var _proto = Wait.prototype;
  14464. _proto.wait = function wait() {
  14465. var _this = this;
  14466. return new Promise(function (resolve) {
  14467. return _this._resolve = resolve;
  14468. });
  14469. };
  14470. _proto.resolve = function resolve(value) {
  14471. if (this._resolve) {
  14472. this._resolve(value);
  14473. this.dispose();
  14474. }
  14475. };
  14476. _proto.dispose = function dispose() {
  14477. this._resolve = null;
  14478. };
  14479. return Wait;
  14480. }();
  14481. function get_new_wait() {
  14482. return new Wait();
  14483. }
  14484. cclegacy._RF.pop();
  14485. }
  14486. };
  14487. });
  14488. System.register("chunks:///_virtual/WsClient.ts", ['./rollupPluginModLoBabelHelpers.js', 'cc'], function (exports) {
  14489. var _createClass, cclegacy;
  14490. return {
  14491. setters: [function (module) {
  14492. _createClass = module.createClass;
  14493. }, function (module) {
  14494. cclegacy = module.cclegacy;
  14495. }],
  14496. execute: function () {
  14497. cclegacy._RF.push({}, "d14186TLCpDIa2nmf/PWkp9", "WsClient", undefined);
  14498. /**web scoket 客户端*/
  14499. var WsClient = exports('WsClient', /*#__PURE__*/function () {
  14500. var _proto = WsClient.prototype;
  14501. _proto.onConnected = function onConnected(evt) {};
  14502. _proto.onError = function onError(err) {};
  14503. _proto.onClosing = function onClosing() {};
  14504. _proto.onClosed = function onClosed(event) {};
  14505. _proto.onMessage = function onMessage(msg) {};
  14506. function WsClient(url, ca, autoConnect) {
  14507. //
  14508. this._ws = null;
  14509. /** 连接地址*/
  14510. this._url = null;
  14511. /**证书*/
  14512. this._ca = void 0;
  14513. this._ca = ca;
  14514. this._url = url;
  14515. if (autoConnect) this.connect();
  14516. }
  14517. /**连接成功时的回调 */
  14518. _proto._onConnected = function _onConnected(evt) {
  14519. this.onConnected(evt);
  14520. }
  14521. /**收到消息时的回调 */;
  14522. _proto._onMessage = function _onMessage(msg) {
  14523. this.onMessage(msg);
  14524. }
  14525. /** 错误处理回调 */;
  14526. _proto._onError = function _onError(err) {
  14527. this.onError(err);
  14528. }
  14529. /**连接关闭时的回调 */;
  14530. _proto._onClosed = function _onClosed(event) {
  14531. this.onClosed(event);
  14532. }
  14533. /**
  14534. * 获取当前连接状态
  14535. * @returns 是否处于活动状态
  14536. */;
  14537. /**手动连接*/
  14538. _proto.connect = function connect() {
  14539. if (this.isConnecting) return false;
  14540. if (this.isActive) return false;
  14541. var url = this._url;
  14542. if (!url) return false;
  14543. try {
  14544. //eslint-disable-next-line @typescript-eslint/ban-ts-comment
  14545. //@ts-ignore
  14546. //eslint-disable-next-line @typescript-eslint/no-unsafe-call
  14547. var ws = this._ca && url.startsWith('wss://') ? new WebSocket(url, {}, this._ca) : new WebSocket(url);
  14548. ws.binaryType = 'arraybuffer';
  14549. ws.onmessage = this._onMessage.bind(this);
  14550. ws.onopen = this._onConnected.bind(this);
  14551. ws.onerror = this._onError.bind(this);
  14552. ws.onclose = this._onClosed.bind(this);
  14553. this._ws = ws;
  14554. } catch (error) {
  14555. this._onError(error instanceof Error ? error.message : 'Unknown error');
  14556. }
  14557. return true;
  14558. }
  14559. /**
  14560. * 主动关闭WebSocket连接
  14561. */;
  14562. _proto.close = function close(code, reason) {
  14563. if (this.isClosed || this.isClosing) return;
  14564. this.onClosing();
  14565. this._ws.close(code, reason);
  14566. }
  14567. /**
  14568. * 发送数据
  14569. * @param data 指定格式数据
  14570. */;
  14571. _proto.send = function send(data) {
  14572. this._ws.send(data);
  14573. };
  14574. _createClass(WsClient, [{
  14575. key: "ws",
  14576. get: /** WebSocket对象*/function get() {
  14577. return this._ws;
  14578. }
  14579. }, {
  14580. key: "isActive",
  14581. get: function get() {
  14582. var _this$_ws;
  14583. return ((_this$_ws = this._ws) == null ? void 0 : _this$_ws.readyState) === WebSocket.OPEN;
  14584. }
  14585. /**
  14586. * 检查是否正在连接
  14587. * @returns 是否正在连接
  14588. */
  14589. }, {
  14590. key: "isConnecting",
  14591. get: function get() {
  14592. var _this$_ws2;
  14593. return ((_this$_ws2 = this._ws) == null ? void 0 : _this$_ws2.readyState) === WebSocket.CONNECTING;
  14594. }
  14595. /**
  14596. *是否正在关闭
  14597. */
  14598. }, {
  14599. key: "isClosing",
  14600. get: function get() {
  14601. var _this$_ws3;
  14602. return ((_this$_ws3 = this._ws) == null ? void 0 : _this$_ws3.readyState) === WebSocket.CLOSING;
  14603. }
  14604. /**是否已经关闭 */
  14605. }, {
  14606. key: "isClosed",
  14607. get: function get() {
  14608. var _this$_ws4;
  14609. return ((_this$_ws4 = this._ws) == null ? void 0 : _this$_ws4.readyState) === WebSocket.CLOSED;
  14610. }
  14611. }]);
  14612. return WsClient;
  14613. }());
  14614. cclegacy._RF.pop();
  14615. }
  14616. };
  14617. });
  14618. (function(r) {
  14619. r('virtual:///prerequisite-imports/main', 'chunks:///_virtual/main');
  14620. })(function(mid, cid) {
  14621. System.register(mid, [cid], function (_export, _context) {
  14622. return {
  14623. setters: [function(_m) {
  14624. var _exportObj = {};
  14625. for (var _key in _m) {
  14626. if (_key !== "default" && _key !== "__esModule") _exportObj[_key] = _m[_key];
  14627. }
  14628. _export(_exportObj);
  14629. }],
  14630. execute: function () { }
  14631. };
  14632. });
  14633. });