2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								const  i18n  =  require ( 'LanguageData' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								i18n . init ( window . language ) ;  // languageID should be equal to the one we input in New Language ID input field
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								const  RingBuffer  =  require ( './RingBuffer' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-23 16:42:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								window . ALL _MAP _STATES  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  VISUAL :  0 ,  // For free dragging & zooming.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  EDITING _BELONGING :  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  SHOWING _MODAL _POPUP :  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								window . ALL _BATTLE _STATES  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 16:01:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  NONE :  - 1 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  WAITING :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  IN _BATTLE :  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  IN _SETTLEMENT :  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  IN _DISMISSAL :  3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								window . MAGIC _ROOM _DOWNSYNC _FRAME _ID  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  BATTLE _READY _TO _START :  - 1 , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 23:54:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  BATTLE _START :  0 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								window . PlayerBattleState  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ADDED _PENDING _BATTLE _COLLIDER _ACK :  0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  READDED _PENDING _BATTLE _COLLIDER _ACK :  1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  ACTIVE :  2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  DISCONNECTED :  3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  LOST :  4 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  EXPELLED _DURING _GAME :  5 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  EXPELLED _IN _DISMISSAL :  6 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								cc . Class ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  extends :  cc . Component , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  properties :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    canvasNode :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Node , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    controlledCharacterPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    joystickInputControllerNode :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Node , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    confirmLogoutPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    simplePressToGoDialogPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    boundRoomIdLabel :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Label , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    countdownLabel :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Label , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    resultPanelPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    gameRulePrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    findingPlayerPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    countdownToBeginGamePrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    playersInfoPrefab :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Prefab , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  null 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    forceBigEndianFloatingNumDecoding :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  false , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    renderFrameIdLagTolerance :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      type :  cc . Integer , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  4  // implies (renderFrameIdLagTolerance >> inputScaleFrames) count of inputFrameIds
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-10 18:18:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    jigglingEps1D :  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 14:33:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      type :  cc . Float , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  1e-3 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-23 22:11:28 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    bulletTriggerEnabled :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    closeOnForcedtoResyncNotSelf :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      default :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  _inputFrameIdDebuggable ( inputFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  ( 0  ==  inputFrameId  %  10 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  _allConfirmed ( confirmedList )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  ( confirmedList  +  1 )  ==  ( 1  <<  this . playerRichInfoDict . size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  getOrPrefabInputFrameUpsync ( inputFrameId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // TODO: find some kind of synchronization mechanism against "onInputFrameDownsyncBatch"!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  ( 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      null  ==  self . ctrl  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      null  ==  self . selfPlayerInfo 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      throw  ` noDelayInputFrameId= ${ inputFrameId }  couldn't be generated: recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  previousSelfInput  =  null , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      currSelfInput  =  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  joinIndex  =  self . selfPlayerInfo . JoinIndex ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  existingInputFrame  =  self . recentInputCache . GetByFrameId ( inputFrameId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  previousInputFrameDownsync  =  self . recentInputCache . GetByFrameId ( inputFrameId  -  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    previousSelfInput  =  ( null  ==  previousInputFrameDownsync  ?  null  :  previousInputFrameDownsync . InputList [ joinIndex  -  1 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  !=  existingInputFrame )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      // This could happen upon either [type#1] or [type#2] forceConfirmation, where "refRenderFrame" is accompanied by some "inputFrameDownsyncs". The check here also guarantees that we don't override history 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      console . log ( ` noDelayInputFrameId= ${ inputFrameId }  already exists in recentInputCache: recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      return  [ previousSelfInput ,  existingInputFrame . InputList [ joinIndex  -  1 ] ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:36:57 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  lastAllConfirmedInputFrame  =  self . recentInputCache . GetByFrameId ( self . lastAllConfirmedInputFrameId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  prefabbedInputList  =  new  Array ( self . playerRichInfoDict . size ) . fill ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // the returned "gopkgs.NewInputFrameDownsync.InputList" is immutable, thus we can only modify the values in "prefabbedInputList"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  prefabbedInputList )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( null  !=  previousInputFrameDownsync )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        prefabbedInputList [ k ]  =  previousInputFrameDownsync . InputList [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( 0  <=  self . lastAllConfirmedInputFrameId  &&  inputFrameId  -  1  >  self . lastAllConfirmedInputFrameId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        prefabbedInputList [ k ]  =  lastAllConfirmedInputFrame . InputList [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      // Don't predict "btnA & btnB"!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      prefabbedInputList [ k ]  =  ( prefabbedInputList [ k ]  &  15 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    currSelfInput  =  self . ctrl . getEncodedInput ( ) ;  // When "null == existingInputFrame", it'd be safe to say that the realtime "self.ctrl.getEncodedInput()" is for the requested "inputFrameId"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    prefabbedInputList [ ( joinIndex  -  1 ) ]  =  currSelfInput ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    while  ( self . recentInputCache . EdFrameId  <=  inputFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // Fill the gap
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  prefabbedInputFrameDownsync  =  gopkgs . NewInputFrameDownsync ( self . recentInputCache . EdFrameId ,  prefabbedInputList . slice ( ) ,  ( 1  <<  ( joinIndex  -  1 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      // console.log(`Prefabbed inputFrameId=${prefabbedInputFrameDownsync.InputFrameId}`);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . recentInputCache . Put ( prefabbedInputFrameDownsync ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-20 18:53:33 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  [ previousSelfInput ,  currSelfInput ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  shouldSendInputFrameUpsyncBatch ( prevSelfInput ,  currSelfInput ,  lastUpsyncInputFrameId ,  currInputFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    / * 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 15:14:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    For  a  2 - player - battle ,  this  "shouldUpsyncForEarlyAllConfirmedOnBackend"  can  be  omitted ,  however  for  more  players  in  a  same  battle ,  to  avoid  a  "long time non-moving player"  jamming  the  downsync  of  other  moving  players ,  we  should  use  this  flag . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    When  backend  implements  the  "force confirmation"  feature ,  we  can  have  "false == shouldUpsyncForEarlyAllConfirmedOnBackend"  all  the  time  as  well ! 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  currSelfInput )  return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 15:14:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  shouldUpsyncForEarlyAllConfirmedOnBackend  =  ( currInputFrameId  -  lastUpsyncInputFrameId  >=  this . inputFrameUpsyncDelayTolerance ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 15:14:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  shouldUpsyncForEarlyAllConfirmedOnBackend  ||  ( prevSelfInput  !=  currSelfInput ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  sendInputFrameUpsyncBatch ( latestLocalInputFrameId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // [WARNING] Why not just send the latest input? Because different player would have a different "latestLocalInputFrameId" of changing its last input, and that could make the server not recognizing any "all-confirmed inputFrame"!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    let  inputFrameUpsyncBatch  =  [ ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  batchInputFrameIdSt  =  self . lastUpsyncInputFrameId  +  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( batchInputFrameIdSt  <  self . recentInputCache . StFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // Upon resync, "self.lastUpsyncInputFrameId" might not have been updated properly.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      batchInputFrameIdSt  =  self . recentInputCache . StFrameId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  i  =  batchInputFrameIdSt ;  i  <=  latestLocalInputFrameId ;  ++ i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  inputFrameDownsync  =  self . recentInputCache . GetByFrameId ( i ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( null  ==  inputFrameDownsync )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        console . error ( ` sendInputFrameUpsyncBatch: recentInputCache is NOT having inputFrameId=i: latestLocalInputFrameId= ${ latestLocalInputFrameId } , recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  inputFrameUpsync  =  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          inputFrameId :  i , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          encoded :  inputFrameDownsync . InputList [ self . selfPlayerInfo . JoinIndex  -  1 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        inputFrameUpsyncBatch . push ( inputFrameUpsync ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 00:23:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 17:27:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // console.info(`inputFrameUpsyncBatch: ${JSON.stringify(inputFrameUpsyncBatch)}`);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 23:46:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  reqData  =  window . pb . protos . WsReq . encode ( { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      msgId :  Date . now ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      playerId :  self . selfPlayerInfo . Id , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      act :  window . UPSYNC _MSG _ACT _PLAYER _CMD , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      joinIndex :  self . selfPlayerInfo . JoinIndex , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      ackingInputFrameId :  self . lastAllConfirmedInputFrameId , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      inputFrameUpsyncBatch :  inputFrameUpsyncBatch , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ) . finish ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    window . sendSafely ( reqData ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . lastUpsyncInputFrameId  =  latestLocalInputFrameId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . lastUpsyncInputFrameId  >=  self . recentInputCache . EdFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      throw  ` noDelayInputFrameId= ${ self . lastUpsyncInputFrameId }  == latestLocalInputFrameId= ${ latestLocalInputFrameId }  seems not properly dumped #2: recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onEnable ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cc . log ( "+++++++ Map onEnable()" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onDisable ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    cc . log ( "+++++++ Map onDisable()" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onDestroy ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    console . warn ( "+++++++ Map onDestroy()" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 16:01:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . battleState  ||  ALL _BATTLE _STATES . IN _BATTLE  !=  self . battleState )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      window . clearBoundRoomIdInBothVolatileAndPersistentStorage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  !=  window . handleBattleColliderInfo )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      window . handleBattleColliderInfo  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 16:01:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onManualRejoinRequired ( labelString )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . battleState  =  ALL _BATTLE _STATES . NONE ;  // Effectively stops "update(dt)" 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . showPopupInCanvas ( self . gameRuleNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . popupSimplePressToGo ( labelString ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  popupSimplePressToGo ( labelString ,  hideYesButton )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . state  =  ALL _MAP _STATES . SHOWING _MODAL _POPUP ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  canvasNode  =  self . canvasNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  simplePressToGoDialogNode  =  cc . instantiate ( self . simplePressToGoDialogPrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    simplePressToGoDialogNode . setPosition ( cc . v2 ( 0 ,  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    simplePressToGoDialogNode . setScale ( 1  /  canvasNode . scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  simplePressToGoDialogScriptIns  =  simplePressToGoDialogNode . getComponent ( "SimplePressToGoDialog" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  yesButton  =  simplePressToGoDialogNode . getChildByName ( "Yes" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  postDismissalByYes  =  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . transitToState ( ALL _MAP _STATES . VISUAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      canvasNode . removeChild ( simplePressToGoDialogNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    simplePressToGoDialogNode . getChildByName ( "Hint" ) . getComponent ( cc . Label ) . string  =  labelString ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    yesButton . once ( "click" ,  simplePressToGoDialogScriptIns . dismissDialog . bind ( simplePressToGoDialogScriptIns ,  postDismissalByYes ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    yesButton . getChildByName ( "Label" ) . getComponent ( cc . Label ) . string  =  "OK" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( true  ==  hideYesButton )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      yesButton . active  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . transitToState ( ALL _MAP _STATES . SHOWING _MODAL _POPUP ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    safelyAddChild ( self . widgetsAboveAllNode ,  simplePressToGoDialogNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    setLocalZOrder ( simplePressToGoDialogNode ,  20 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  simplePressToGoDialogNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  alertForGoingBackToLoginScene ( labelString ,  mapIns ,  shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  millisToGo  =  3000 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    mapIns . popupSimplePressToGo ( cc . js . formatStr ( "%s will logout in %s seconds." ,  labelString ,  millisToGo  /  1000 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    setTimeout ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      mapIns . logout ( false ,  shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ,  millisToGo ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  _resetCurrentMatch ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  mapNode  =  self . node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  canvasNode  =  mapNode . parent ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-09 17:22:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    // Clearing previous info of all players. [BEGINS]
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . collisionPlayerIndexPrefix  =  ( 1  <<  17 ) ;  // For tracking the movements of players 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  !=  self . playerRichInfoDict )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . playerRichInfoDict . forEach ( ( playerRichInfo ,  playerId )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 23:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( playerRichInfo . node  &&  playerRichInfo . node . parent )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          playerRichInfo . node . parent . removeChild ( playerRichInfo . node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . playerRichInfoDict  =  new  Map ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    // Clearing previous info of all players. [ENDS]
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . renderFrameId  =  0 ;  // After battle started
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 17:12:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . bulletBattleLocalIdCounter  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . lastAllConfirmedInputFrameId  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    self . lastUpsyncInputFrameId  =  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . chaserRenderFrameId  =  - 1 ;  // at any moment, "chaserRenderFrameId <= renderFrameId", but "chaserRenderFrameId" would fluctuate according to "onInputFrameDownsyncBatch"
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-23 12:30:30 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . recentRenderCache  =  new  RingBuffer ( self . renderCacheSize ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . selfPlayerInfo  =  null ;  // This field is kept for distinguishing "self" and "others".
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . recentInputCache  =  gopkgs . NewRingBufferJs ( ( self . renderCacheSize  >>  1 )  +  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-23 16:42:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . gopkgsCollisionSys  =  gopkgs . NewCollisionSpaceJs ( ( self . spaceOffsetX  <<  1 ) ,  ( self . spaceOffsetY  <<  1 ) ,  self . collisionMinStep ,  self . collisionMinStep ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . gopkgsCollisionSysMap  =  { } ;  // [WARNING] Don't use "JavaScript Map" which could cause loss of type information when passing through Golang transpiled functions!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . collisionBarrierIndexPrefix  =  ( 1  <<  16 ) ;  // For tracking the movements of barriers, though not yet actually used 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 17:12:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . collisionBulletIndexPrefix  =  ( 1  <<  15 ) ;  // For tracking the movements of bullets 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    console . log ( ` collisionSys & collisionSysMap reset ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    self . transitToState ( ALL _MAP _STATES . VISUAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . battleState  =  ALL _BATTLE _STATES . WAITING ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . othersForcedDownsyncRenderFrameDict  =  new  Map ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . rdfIdToActuallyUsedInput  =  new  Map ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-23 22:11:28 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . countdownNanos  =  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . countdownLabel )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . countdownLabel . string  =  "" ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  ( self . findingPlayerNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  findingPlayerScriptIns  =  self . findingPlayerNode . getComponent ( "FindingPlayer" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      findingPlayerScriptIns . init ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . playersInfoNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      safelyAddChild ( self . widgetsAboveAllNode ,  self . playersInfoNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( self . findingPlayerNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      safelyAddChild ( self . widgetsAboveAllNode ,  self . findingPlayerNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  initDebugDrawers ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( self . showCriticalCoordinateLabels )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  drawer1  =  new  cc . Node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      drawer1 . setPosition ( cc . v2 ( 0 ,  0 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      safelyAddChild ( self . node ,  drawer1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      setLocalZOrder ( drawer1 ,  999 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  g1  =  drawer1 . addComponent ( cc . Graphics ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      g1 . lineWidth  =  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . g1  =  g1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  collisionSpaceObjs  =  gopkgs . GetCollisionSpaceObjsJs ( self . gopkgsCollisionSys ) ;  // This step is slow according to Chrome profiling, and we only need draw it once for those static barriers
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for  ( let  k  in  collisionSpaceObjs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  body  =  collisionSpaceObjs [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  padding  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( null  !=  body . Data  &&  null  !=  body . Data . JoinIndex )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          // character
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          if  ( 1  ==  body . Data . JoinIndex )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            g1 . strokeColor  =  cc . Color . BLUE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            g1 . strokeColor  =  cc . Color . RED ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          padding  =  self . snapIntoPlatformOverlap ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          // barrier
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          g1 . strokeColor  =  cc . Color . WHITE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  points  =  body . Shape . Points ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  wpos  =  [ body . X  -  self . spaceOffsetX ,  body . Y  -  self . spaceOffsetY ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        g1 . moveTo ( wpos [ 0 ] ,  wpos [ 1 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  cnt  =  points . length ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( let  j  =  0 ;  j  <  cnt ;  j  +=  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  x  =  wpos [ 0 ]  +  points [ j ] [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            y  =  wpos [ 1 ]  +  points [ j ] [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          g1 . lineTo ( x ,  y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        g1 . lineTo ( wpos [ 0 ] ,  wpos [ 1 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        g1 . stroke ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  drawer2  =  new  cc . Node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      drawer2 . setPosition ( cc . v2 ( 0 ,  0 ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      safelyAddChild ( self . node ,  drawer2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      setLocalZOrder ( drawer2 ,  999 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  g2  =  drawer2 . addComponent ( cc . Graphics ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      g2 . lineWidth  =  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . g2  =  g2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  onLoad ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    window . mapIns  =  self ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    window . forceBigEndianFloatingNumDecoding  =  self . forceBigEndianFloatingNumDecoding ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-15 12:28:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . showCriticalCoordinateLabels  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-12 20:34:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    console . warn ( "+++++++ Map onLoad()" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  mapNode  =  self . node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  canvasNode  =  mapNode . parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // self.musicEffectManagerScriptIns = self.node.getComponent("MusicEffectManager");
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . musicEffectManagerScriptIns  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    /** Init required prefab started. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . confirmLogoutNode  =  cc . instantiate ( self . confirmLogoutPrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . confirmLogoutNode . getComponent ( "ConfirmLogout" ) . mapNode  =  self . node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Initializes Result panel.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . resultPanelNode  =  cc . instantiate ( self . resultPanelPrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . resultPanelNode . width  =  self . canvasNode . width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . resultPanelNode . height  =  self . canvasNode . height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  resultPanelScriptIns  =  self . resultPanelNode . getComponent ( "ResultPanel" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    resultPanelScriptIns . mapScriptIns  =  self ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    resultPanelScriptIns . onAgainClicked  =  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . battleState  =  ALL _BATTLE _STATES . WAITING ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      window . clearBoundRoomIdInBothVolatileAndPersistentStorage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      window . initPersistentSessionClient ( self . initAfterWSConnected ,  null  /* Deliberately NOT passing in any `expectedRoomId`. -- YFLu */  ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    resultPanelScriptIns . onCloseDelegate  =  ( )  =>  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleNode  =  cc . instantiate ( self . gameRulePrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleNode . width  =  self . canvasNode . width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleNode . height  =  self . canvasNode . height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleScriptIns  =  self . gameRuleNode . getComponent ( "GameRule" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleScriptIns . mapNode  =  self . node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . findingPlayerNode  =  cc . instantiate ( self . findingPlayerPrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . findingPlayerNode . width  =  self . canvasNode . width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . findingPlayerNode . height  =  self . canvasNode . height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  findingPlayerScriptIns  =  self . findingPlayerNode . getComponent ( "FindingPlayer" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    findingPlayerScriptIns . init ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . playersInfoNode  =  cc . instantiate ( self . playersInfoPrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . countdownToBeginGameNode  =  cc . instantiate ( self . countdownToBeginGamePrefab ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . countdownToBeginGameNode . width  =  self . canvasNode . width ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . countdownToBeginGameNode . height  =  self . canvasNode . height ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . mainCameraNode  =  canvasNode . getChildByName ( "Main Camera" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . mainCamera  =  self . mainCameraNode . getComponent ( cc . Camera ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  child  of  self . mainCameraNode . children )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      child . setScale ( 1  /  self . mainCamera . zoomRatio ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . widgetsAboveAllNode  =  self . mainCameraNode . getChildByName ( "WidgetsAboveAll" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . mainCameraNode . setPosition ( cc . v2 ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    /** Init required prefab ended. */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    window . handleBattleColliderInfo  =  function ( parsedBattleColliderInfo )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      console . log ( ` Received parsedBattleColliderInfo via ws ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // TODO: Upon reconnection, the backend might have already been sending down data that'd trigger "onRoomDownsyncFrame & onInputFrameDownsyncBatch", but frontend could reject those data due to "battleState != PlayerBattleState.ACTIVE".
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-22 17:12:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      Object . assign ( self ,  parsedBattleColliderInfo ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . tooFastDtIntervalMillis  =  0.5  *  self . rollbackEstimatedDtMillis ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 18:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      const  tiledMapIns  =  self . node . getComponent ( cc . TiledMap ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 22:11:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // It's easier to just use the "barrier"s extracted by the backend (all anchor points in world coordinates), but I'd like to verify frontend tmx parser logic as well.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      const  fullPathOfTmxFile  =  cc . js . formatStr ( "map/%s/map" ,  parsedBattleColliderInfo . stageName ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      cc . loader . loadRes ( fullPathOfTmxFile ,  cc . TiledMapAsset ,  ( err ,  tmxAsset )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( null  !=  err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          console . error ( err ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        [ WARNING ]  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        -  The  order  of  the  following  statements  is  important ,  because  we  should  have  finished  "_resetCurrentMatch"  before  the  first  "RoomDownsyncFrame" .  
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        -  It ' s  important  to  assign  new  "tmxAsset"  before  "extractBoundaryObjects" ,  to  ensure  that  the  correct  tilesets  are  used . 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        -  To  ensure  clearance ,  put  destruction  of  the  "cc.TiledMap"  component  preceding  that  of  "mapNode.destroyAllChildren()" . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        tiledMapIns . tmxAsset  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        mapNode . removeAllChildren ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . _resetCurrentMatch ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        tiledMapIns . tmxAsset  =  tmxAsset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  newMapSize  =  tiledMapIns . getMapSize ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  newTileSize  =  tiledMapIns . getTileSize ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . node . setContentSize ( newMapSize . width  *  newTileSize . width ,  newMapSize . height  *  newTileSize . height ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        self . node . setPosition ( cc . v2 ( 0 ,  0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        *  Deliberately  hiding  "ImageLayer" s .  This  dirty  fix  is  specific  to  "CocosCreator v2.2.1" ,  where  it  got  back  the  rendering  capability  of  "ImageLayer of Tiled" ,  yet  made  incorrectly .  In  this  game  our  "markers of ImageLayers"  are  rendered  by  dedicated  prefabs  with  associated  colliders . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        *  --  YFLu ,  2020 - 01 - 23 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  existingImageLayers  =  tiledMapIns . getObjectGroups ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( let  singleImageLayer  of  existingImageLayers )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          singleImageLayer . node . opacity  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  barrierIdCounter  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  boundaryObjs  =  tileCollisionManager . extractBoundaryObjects ( self . node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        for  ( let  boundaryObj  of  boundaryObjs . barriers )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  gopkgsBoundaryAnchor  =  gopkgs . NewVec2DJs ( boundaryObj . anchor . x ,  boundaryObj . anchor . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  gopkgsBoundaryPts  =  Array . from ( boundaryObj ,  p  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            return  gopkgs . NewVec2DJs ( p . x ,  p . y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  gopkgsBoundary  =  gopkgs . NewPolygon2DJs ( gopkgsBoundaryAnchor ,  gopkgsBoundaryPts ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  gopkgsBarrier  =  gopkgs . NewBarrierJs ( gopkgsBoundary ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  newBarrierCollider  =  gopkgs . GenerateConvexPolygonColliderJs ( gopkgsBoundary ,  self . spaceOffsetX ,  self . spaceOffsetY ,  gopkgsBarrier ,  "Barrier" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          self . gopkgsCollisionSys . Add ( newBarrierCollider ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          // console.log("Created barrier: ", newBarrierCollider);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          ++ barrierIdCounter ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          const  collisionBarrierIndex  =  ( self . collisionBarrierIndexPrefix  +  barrierIdCounter ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          self . gopkgsCollisionSysMap [ collisionBarrierIndex ]  =  newBarrierCollider ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        self . selfPlayerInfo  =  JSON . parse ( cc . sys . localStorage . getItem ( 'selfPlayer' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        Object . assign ( self . selfPlayerInfo ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:21:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          Id :  self . selfPlayerInfo . playerId 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . initDebugDrawers ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-16 22:11:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  reqData  =  window . pb . protos . WsReq . encode ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          msgId :  Date . now ( ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          act :  window . UPSYNC _MSG _ACT _PLAYER _COLLIDER _ACK , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } ) . finish ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        window . sendSafely ( reqData ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        console . log ( ` Sent UPSYNC_MSG_ACT_PLAYER_COLLIDER_ACK via ws ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . initAfterWSConnected  =  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  self  =  window . mapIns ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . hideGameRuleNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . transitToState ( ALL _MAP _STATES . WAITING ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . _inputControlEnabled  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The player is now viewing "self.gameRuleNode" with button(s) to start an actual battle. -- YFLu
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  expectedRoomId  =  window . getExpectedRoomIdSync ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  boundRoomId  =  window . getBoundRoomIdFromPersistentStorage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    console . warn ( "Map.onLoad, expectedRoomId == " ,  expectedRoomId ,  ", boundRoomId == " ,  boundRoomId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  !=  expectedRoomId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . disableGameRuleNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      // The player is now possibly viewing "self.gameRuleNode" with no button, and should wait for `self.initAfterWSConnected` to be called. 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . battleState  =  ALL _BATTLE _STATES . WAITING ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      window . initPersistentSessionClient ( self . initAfterWSConnected ,  expectedRoomId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  else  if  ( null  !=  boundRoomId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . disableGameRuleNode ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . battleState  =  ALL _BATTLE _STATES . WAITING ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      window . initPersistentSessionClient ( self . initAfterWSConnected ,  boundRoomId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . showPopupInCanvas ( self . gameRuleNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Deliberately left blank. -- YFLu
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  disableGameRuleNode ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  window . mapIns ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . gameRuleNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . gameRuleScriptIns )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . gameRuleScriptIns . modeButton )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleScriptIns . modeButton . active  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  hideGameRuleNode ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  window . mapIns ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . gameRuleNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . gameRuleNode . active  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  enableInputControls ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    this . _inputControlEnabled  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  disableInputControls ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    this . _inputControlEnabled  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  onRoomDownsyncFrame ( pbRdf  /* pb.RoomDownsyncFrame */  ,  accompaniedInputFrameDownsyncBatch  /* pb.InputFrameDownsyncBatch */  )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  jsPlayersArr  =  new  Array ( ) . fill ( null ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  pbRdf . playersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  pbPlayer  =  pbRdf . playersArr [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 10:20:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  jsPlayer  =  gopkgs . NewPlayerDownsyncJs ( pbPlayer . id ,  pbPlayer . virtualGridX ,  pbPlayer . virtualGridY ,  pbPlayer . dirX ,  pbPlayer . dirY ,  pbPlayer . velX ,  pbPlayer . velY ,  pbPlayer . framesToRecover ,  pbPlayer . framesInChState ,  pbPlayer . activeSkillId ,  pbPlayer . activeSkillHit ,  pbPlayer . framesInvinsible ,  pbPlayer . speed ,  pbPlayer . battleState ,  pbPlayer . characterState ,  pbPlayer . joinIndex ,  pbPlayer . hp ,  pbPlayer . maxHp ,  pbPlayer . colliderRadius ,  pbPlayer . inAir ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      jsPlayersArr [ k ]  =  jsPlayer ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  jsMeleeBulletsArr  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  pbRdf . meleeBullets )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  pbBullet  =  pbRdf . meleeBullets [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-05 10:20:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  jsBullet  =  gopkgs . NewMeleeBulletJs ( pbBullet . originatedRenderFrameId ,  pbBullet . offenderJoinIndex ,  pbBullet . startupFrames ,  pbBullet . cancellableStFrame ,  pbBullet . cancellableEdFrame ,  pbBullet . activeFrames ,  pbBullet . hitStunFrames ,  pbBullet . blockStunFrames ,  pbBullet . pushbackVelX ,  pbBullet . pushbackVelY ,  pbBullet . damage ,  pbBullet . selfLockVelX ,  pbBullet . selfLockVelY ,  pbBullet . hitboxOffsetX ,  pbBullet . hitboxOffsetY ,  pbBullet . hitboxSizeX ,  pbBullet . hitboxSizeY ,  pbBullet . blowUp ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      jsMeleeBulletsArr . push ( jsBullet ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 12:21:36 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // This function is also applicable to "re-joining".
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  rdf  =  gopkgs . NewRoomDownsyncFrameJs ( pbRdf . id ,  jsPlayersArr ,  jsMeleeBulletsArr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  window . mapIns ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . onInputFrameDownsyncBatch ( accompaniedInputFrameDownsyncBatch ) ;  // Important to do this step before setting IN_BATTLE
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! self . recentRenderCache )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ALL _BATTLE _STATES . IN _SETTLEMENT  ==  self . battleState )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  shouldForceDumping1  =  ( window . MAGIC _ROOM _DOWNSYNC _FRAME _ID . BATTLE _START  ==  rdf . Id ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  shouldForceDumping2  =  ( rdf . Id  >=  self . renderFrameId  +  self . renderFrameIdLagTolerance ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 15:11:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  shouldForceResync  =  pbRdf . shouldForceResync ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  notSelfUnconfirmed  =  ( 0  ==  ( pbRdf . backendUnconfirmedMask  &  ( 1  <<  ( self . selfPlayerInfo . JoinIndex  -  1 ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( notSelfUnconfirmed )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      shouldForceDumping2  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      shouldForceResync  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . othersForcedDownsyncRenderFrameDict . set ( rdf . Id ,  rdf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-19 19:51:55 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    TODO 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    If  "BackendUnconfirmedMask"  is  non - all - 1  and  contains  the  current  player ,  show  a  label / button  to  hint  manual  reconnection .  Note  that  the  continuity  of  "recentInputCache"  is  not  a  good  indicator ,  because  due  to  network  delay  upon  a  [ type # 1  forceConfirmation ]  a  player  might  just  lag  in  upsync  networking  and  have  all  consecutive  inputFrameIds  locally .  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    * / 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-08 21:38:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  [ dumpRenderCacheRet ,  oldStRenderFrameId ,  oldEdRenderFrameId ]  =  ( shouldForceDumping1  ||  shouldForceDumping2  ||  shouldForceResync )  ?  self . recentRenderCache . setByFrameId ( rdf ,  rdf . Id )  :  [ window . RING _BUFF _CONSECUTIVE _SET ,  null ,  null ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( window . RING _BUFF _FAILED _TO _SET  ==  dumpRenderCacheRet )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      throw  ` Failed to dump render cache#1 (maybe recentRenderCache too small)! rdf.id= ${ rdf . id } , lastAllConfirmedInputFrameId= ${ self . lastAllConfirmedInputFrameId } ; recentRenderCache= ${ self . _stringifyRecentRenderCache ( false ) } , recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 18:05:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! shouldForceResync  &&  ( window . MAGIC _ROOM _DOWNSYNC _FRAME _ID . BATTLE _START  <  rdf . id  &&  window . RING _BUFF _CONSECUTIVE _SET  ==  dumpRenderCacheRet ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      Don ' t  change  
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 13:27:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      -  chaserRenderFrameId ,  it ' s  updated  only  in  "rollbackAndChase & onInputFrameDownsyncBatch"  ( except  for  when  RING _BUFF _NON _CONSECUTIVE _SET ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      * / 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      return  dumpRenderCacheRet ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // The logic below applies to (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.id || window.RING_BUFF_NON_CONSECUTIVE_SET == dumpRenderCacheRet)
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  ==  pbRdf . speciesIdList )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      console . error ( ` pbRdf.speciesIdList is required for starting or resyncing battle! ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-31 15:47:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . chConfigsOrderedByJoinIndex  =  gopkgs . GetCharacterConfigsOrderedByJoinIndex ( pbRdf . speciesIdList ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . _initPlayerRichInfoDict ( rdf . PlayersArr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Show the top status indicators for IN_BATTLE 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . playersInfoNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  playersInfoScriptIns  =  self . playersInfoNode . getComponent ( "PlayersInfo" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      for  ( let  i  in  pbRdf . playersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        playersInfoScriptIns . updateData ( pbRdf . playersArr [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( shouldForceDumping1  ||  shouldForceDumping2  ||  shouldForceResync )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // In fact, not having "window.RING_BUFF_CONSECUTIVE_SET == dumpRenderCacheRet" should already imply that "self.renderFrameId <= rdf.id", but here we double check and log the anomaly  
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( window . MAGIC _ROOM _DOWNSYNC _FRAME _ID . BATTLE _START  ==  rdf . Id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        console . log ( 'On battle started! renderFrameId=' ,  rdf . Id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 15:11:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . hideFindingPlayersGUI ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        console . warn ( 'On battle resynced! renderFrameId=' ,  rdf . Id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . renderFrameId  =  rdf . Id ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . lastRenderFrameIdTriggeredAt  =  performance . now ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // In this case it must be true that "rdf.id > chaserRenderFrameId".
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . chaserRenderFrameId  =  rdf . Id ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  canvasNode  =  self . canvasNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . ctrl  =  canvasNode . getComponent ( "TouchEventsManager" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . enableInputControls ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . transitToState ( ALL _MAP _STATES . VISUAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . battleState  =  ALL _BATTLE _STATES . IN _BATTLE ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 23:46:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . countdownToBeginGameNode  &&  self . countdownToBeginGameNode . parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . countdownToBeginGameNode . parent . removeChild ( self . countdownToBeginGameNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  !=  self . musicEffectManagerScriptIns )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . musicEffectManagerScriptIns . playBGM ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 13:24:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // [WARNING] Leave all graphical updates in "update(dt)" by "applyRoomDownsyncFrameDynamics"
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  dumpRenderCacheRet ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  equalInputLists ( lhs ,  rhs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  lhs  ||  null  ==  rhs )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . length  !=  rhs . length )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  i  in  lhs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( lhs [ i ]  ==  rhs [ i ] )  continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  equalPlayers ( lhs ,  rhs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  lhs  ||  null  ==  rhs )  return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-31 15:47:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( lhs . VirtualGridX  !=  rhs . VirtualGridX )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . VirtualGridY  !=  rhs . VirtualGridY )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . DirX  !=  rhs . DirX )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . DirY  !=  rhs . DirY )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . VelX  !=  rhs . VelX )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . VelY  !=  rhs . VelY )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . Speed  !=  rhs . Speed )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . Hp  !=  rhs . Hp )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . MaxHp  !=  rhs . MaxHp )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . CharacterState  !=  rhs . CharacterState )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . InAir  !=  rhs . InAir )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . FramesToRecover  !=  rhs . FramesToRecover )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . FramesInChState  !=  rhs . FramesInChState )  return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  equalMeleeBullets ( lhs ,  rhs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  lhs  ||  null  ==  rhs )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . battleLocalId  !=  rhs . battleLocalId )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . offenderPlayerId  !=  rhs . offenderPlayerId )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . offenderJoinIndex  !=  rhs . offenderJoinIndex )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( lhs . originatedRenderFrameId  !=  rhs . originatedRenderFrameId )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  equalRoomDownsyncFrames ( lhs ,  rhs )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  lhs  ||  null  ==  rhs )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  lhs . players )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( ! this . equalPlayers ( lhs . players [ k ] ,  rhs . players [ k ] ) )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  lhs . meleeBullets )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( ! this . equalMeleeBullets ( lhs . meleeBullets [ k ] ,  rhs . meleeBullets [ k ] ) )  return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  onInputFrameDownsyncBatch ( batch  /* []*pb.InputFrameDownsync */  )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // TODO: find some kind of synchronization mechanism against "getOrPrefabInputFrameUpsync"!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  ==  batch )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ! self . recentInputCache )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ALL _BATTLE _STATES . IN _SETTLEMENT  ==  self . battleState )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  firstPredictedYetIncorrectInputFrameId  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  batch )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  inputFrameDownsync  =  batch [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  inputFrameDownsyncId  =  inputFrameDownsync . inputFrameId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( inputFrameDownsyncId  <=  self . lastAllConfirmedInputFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      // [WARNING] Take all "inputFrameDownsync" from backend as all-confirmed, it'll be later checked by "rollbackAndChase". 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . lastAllConfirmedInputFrameId  =  inputFrameDownsyncId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  localInputFrame  =  self . recentInputCache . GetByFrameId ( inputFrameDownsyncId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( null  !=  localInputFrame 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        && 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        null  ==  firstPredictedYetIncorrectInputFrameId 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        && 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:21:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ! self . equalInputLists ( localInputFrame . InputList ,  inputFrameDownsync . inputList ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        firstPredictedYetIncorrectInputFrameId  =  inputFrameDownsyncId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 20:10:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      inputFrameDownsync . confirmedList  =  ( 1  <<  self . playerRichInfoDict . size )  -  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:21:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  inputFrameDownsyncLocal  =  gopkgs . NewInputFrameDownsync ( inputFrameDownsync . inputFrameId ,  inputFrameDownsync . inputList ,  inputFrameDownsync . confirmedList ) ;  // "battle.InputFrameDownsync" in "jsexport"
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      //console.log(`Confirmed inputFrameId=${inputFrameDownsync.inputFrameId}`);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 12:21:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  [ ret ,  oldStFrameId ,  oldEdFrameId ]  =  self . recentInputCache . SetByFrameId ( inputFrameDownsyncLocal ,  inputFrameDownsync . inputFrameId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( window . RING _BUFF _FAILED _TO _SET  ==  ret )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        throw  ` Failed to dump input cache (maybe recentInputCache too small)! inputFrameDownsync.inputFrameId= ${ inputFrameDownsync . inputFrameId } , lastAllConfirmedInputFrameId= ${ self . lastAllConfirmedInputFrameId } ; recentRenderCache= ${ self . _stringifyRecentRenderCache ( false ) } , recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( null  ==  firstPredictedYetIncorrectInputFrameId )  return ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 20:42:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  renderFrameId1  =  gopkgs . ConvertToFirstUsedRenderFrameId ( firstPredictedYetIncorrectInputFrameId )  -  1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( renderFrameId1  >=  self . chaserRenderFrameId )  return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    A  typical  case  is  as  follows . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < renderFrameId1 >                            :               36 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    < self . chaserRenderFrameId >                  :               62 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    [ self . renderFrameId ]                        :               64 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The actual rollback-and-chase would later be executed in update(dt). 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    console . warn ( ` Mismatched input detected, resetting chaserRenderFrameId:  ${ self . chaserRenderFrameId } -> ${ renderFrameId1 }  by firstPredictedYetIncorrectInputFrameId:  ${ firstPredictedYetIncorrectInputFrameId } 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								lastAllConfirmedInputFrameId = $ { self . lastAllConfirmedInputFrameId } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								recentInputCache = $ { self . _stringifyRecentInputCache ( false ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								batchInputFrameIdRange = [ $ { batch [ 0 ] . inputFrameId } ,  $ { batch [ batch . length  -  1 ] . inputFrameId } ] ` );
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-16 10:38:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . chaserRenderFrameId  =  renderFrameId1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  onPlayerAdded ( rdf  /* pb.RoomDownsyncFrame */  )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Update the "finding player" GUI and show it if not previously present
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( ! self . findingPlayerNode . parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . showPopupInCanvas ( self . findingPlayerNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  findingPlayerScriptIns  =  self . findingPlayerNode . getComponent ( "FindingPlayer" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    findingPlayerScriptIns . updatePlayersInfo ( rdf . playersArr ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  onBattleStopped ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ALL _BATTLE _STATES . IN _BATTLE  !=  self . battleState )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . _stringifyRdfIdToActuallyUsedInput ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 16:01:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    window . closeWSConnection ( constants . RET _CODE . BATTLE _STOPPED ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . battleState  =  ALL _BATTLE _STATES . IN _SETTLEMENT ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    self . countdownNanos  =  null ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( self . musicEffectManagerScriptIns )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . musicEffectManagerScriptIns . stopAllMusic ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  canvasNode  =  self . canvasNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  resultPanelNode  =  self . resultPanelNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  resultPanelScriptIns  =  resultPanelNode . getComponent ( "ResultPanel" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    resultPanelScriptIns . showPlayerInfo ( self . playerRichInfoDict ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    window . clearBoundRoomIdInBothVolatileAndPersistentStorage ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . showPopupInCanvas ( resultPanelNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Clear player info
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . playersInfoNode . getComponent ( "PlayersInfo" ) . clearInfo ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-23 22:11:28 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  spawnPlayerNode ( joinIndex ,  vx ,  vy ,  playerDownsyncInfo )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:59:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  newPlayerNode  =  cc . instantiate ( self . controlledCharacterPrefab ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  playerScriptIns  =  newPlayerNode . getComponent ( "ControlledCharacter" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  chConfig  =  self . chConfigsOrderedByJoinIndex [ joinIndex  -  1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    playerScriptIns . setSpecies ( chConfig . SpeciesName ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 22:59:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 20:18:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( 1  ==  joinIndex )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      newPlayerNode . color  =  cc . Color . RED ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 20:18:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      newPlayerNode . color  =  cc . Color . BLUE ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 20:18:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  [ wx ,  wy ]  =  gopkgs . VirtualGridToWorldPos ( vx ,  vy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    newPlayerNode . setPosition ( wx ,  wy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    playerScriptIns . mapNode  =  self . node ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    console . log ( ` Created new player node: joinIndex= ${ joinIndex } ` ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-01 11:35:56 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    safelyAddChild ( self . node ,  newPlayerNode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    setLocalZOrder ( newPlayerNode ,  5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    newPlayerNode . active  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    playerScriptIns . updateCharacterAnim ( playerDownsyncInfo ,  null ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  [ newPlayerNode ,  playerScriptIns ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  update ( dt )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 20:48:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( ALL _BATTLE _STATES . IN _BATTLE  ==  self . battleState )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 23:54:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  elapsedMillisSinceLastFrameIdTriggered  =  performance . now ( )  -  self . lastRenderFrameIdTriggeredAt ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( elapsedMillisSinceLastFrameIdTriggered  <  self . tooFastDtIntervalMillis )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // [WARNING] We should avoid a frontend ticking too fast to prevent cheating, as well as ticking too slow to cause a "resync avalanche" that impacts user experience!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 23:54:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // console.debug("Avoiding too fast frame@renderFrameId=", self.renderFrameId, ": elapsedMillisSinceLastFrameIdTriggered=", elapsedMillisSinceLastFrameIdTriggered);
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 20:45:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 20:48:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      try  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  st  =  performance . now ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  prevSelfInput  =  null , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          currSelfInput  =  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  noDelayInputFrameId  =  gopkgs . ConvertToNoDelayInputFrameId ( self . renderFrameId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 20:42:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( gopkgs . ShouldGenerateInputFrameUpsync ( self . renderFrameId ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          [ prevSelfInput ,  currSelfInput ]  =  self . getOrPrefabInputFrameUpsync ( noDelayInputFrameId ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-24 12:01:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  t0  =  performance . now ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( self . shouldSendInputFrameUpsyncBatch ( prevSelfInput ,  currSelfInput ,  self . lastUpsyncInputFrameId ,  noDelayInputFrameId ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          // TODO: Is the following statement run asynchronously in an implicit manner? Should I explicitly run it asynchronously?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          self . sendInputFrameUpsyncBatch ( noDelayInputFrameId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  t1  =  performance . now ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        // Use "fractional-frame-chasing" to guarantee that "self.update(dt)" is not jammed by a "large range of frame-chasing". See `<proj-root>/ConcerningEdgeCases.md` for the motivation. 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  prevChaserRenderFrameId  =  self . chaserRenderFrameId ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        let  nextChaserRenderFrameId  =  ( prevChaserRenderFrameId  +  self . maxChasingRenderFramesPerUpdate ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( nextChaserRenderFrameId  >  self . renderFrameId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          nextChaserRenderFrameId  =  self . renderFrameId ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 11:42:19 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( prevChaserRenderFrameId  <  nextChaserRenderFrameId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          // Do not execute "rollbackAndChase" when "prevChaserRenderFrameId == nextChaserRenderFrameId", otherwise if "nextChaserRenderFrameId == self.renderFrameId" we'd be wasting computing power once. 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          self . rollbackAndChase ( prevChaserRenderFrameId ,  nextChaserRenderFrameId ,  self . gopkgsCollisionSys ,  self . gopkgsCollisionSysMap ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  t2  =  performance . now ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 13:27:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // Inside the following "self.rollbackAndChase" actually ROLLS FORWARD w.r.t. the corresponding delayedInputFrame, REGARDLESS OF whether or not "self.chaserRenderFrameId == self.renderFrameId" now. 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  latestRdfResults  =  self . rollbackAndChase ( self . renderFrameId ,  self . renderFrameId  +  1 ,  self . gopkgsCollisionSys ,  self . gopkgsCollisionSysMap ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  prevRdf  =  latestRdfResults [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          rdf  =  latestRdfResults [ 1 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-10 14:33:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        / * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  nonTrivialChaseEnded  =  ( prevChaserRenderFrameId  <  nextChaserRenderFrameId  &&  nextChaserRenderFrameId  ==  self . renderFrameId ) ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( nonTrivialChaseEnded )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            console . debug ( "Non-trivial chase ended, prevChaserRenderFrameId="  +  prevChaserRenderFrameId  +  ", nextChaserRenderFrameId="  +  nextChaserRenderFrameId ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        }   
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        * / 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // [WARNING] Don't try to get "prevRdf(i.e. renderFrameId == latest-1)" by "self.recentRenderCache.getByFrameId(...)" here, as the cache might have been updated by asynchronous "onRoomDownsyncFrame(...)" calls!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        if  ( self . othersForcedDownsyncRenderFrameDict . has ( rdf . id ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 20:42:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          const  delayedInputFrameId  =  gopkgs . ConvertToDelayedInputFrameId ( rdf . id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          const  othersForcedDownsyncRenderFrame  =  self . othersForcedDownsyncRenderFrameDict . get ( rdf . id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          if  ( self . lastAllConfirmedInputFrameId  >=  delayedInputFrameId  &&  ! self . equalRoomDownsyncFrames ( othersForcedDownsyncRenderFrame ,  rdf ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            console . warn ( ` Mismatched render frame@rdf.id= ${ rdf . id }  w/ inputFrameId= ${ delayedInputFrameId } :
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								rdf = $ { JSON . stringify ( rdf ) } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 22:42:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								othersForcedDownsyncRenderFrame = $ { JSON . stringify ( othersForcedDownsyncRenderFrame ) } ` );
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            // closeWSConnection(constants.RET_CODE.CLIENT_MISMATCHED_RENDER_FRAME, "");
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            // self.onManualRejoinRequired("[DEBUG] CLIENT_MISMATCHED_RENDER_FRAME");
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            rdf  =  othersForcedDownsyncRenderFrame ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            self . othersForcedDownsyncRenderFrameDict . delete ( rdf . id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 23:51:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . applyRoomDownsyncFrameDynamics ( rdf ,  prevRdf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 23:17:54 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . showDebugBoundaries ( rdf ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        ++ self . renderFrameId ;  // [WARNING] It's important to increment the renderFrameId AFTER all the operations above!!!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . lastRenderFrameIdTriggeredAt  =  performance . now ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  t3  =  performance . now ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 20:48:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      }  catch  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        console . error ( "Error during Map.update" ,  err ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . onBattleStopped ( ) ;  // TODO: Popup to ask player to refresh browser
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 20:48:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      }  finally  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 17:57:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  countdownSeconds  =  parseInt ( self . countdownNanos  /  1000000000 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( isNaN ( countdownSeconds ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          console . warn ( ` countdownSeconds is NaN for countdownNanos ==  ${ self . countdownNanos } . ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( null  !=  self . countdownLabel )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 20:48:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          self . countdownLabel . string  =  countdownSeconds ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  transitToState ( s )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . state  =  s ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  logout ( byClick  /* The case where this param is "true" will be triggered within `ConfirmLogout.js`.*/  ,  shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  localClearance  =  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      window . clearLocalStorageAndBackToLoginScene ( shouldRetainBoundRoomIdInBothVolatileAndPersistentStorage ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  selfPlayerStr  =  cc . sys . localStorage . getItem ( "selfPlayer" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  selfPlayerStr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      localClearance ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      return ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  selfPlayerInfo  =  JSON . parse ( selfPlayerStr ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    try  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      NetworkUtils . ajax ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        url :  backendAddress . PROTOCOL  +  '://'  +  backendAddress . HOST  +  ':'  +  backendAddress . PORT  +  constants . ROUTE _PATH . API  +  constants . ROUTE _PATH . PLAYER  +  constants . ROUTE _PATH . VERSION  +  constants . ROUTE _PATH . INT _AUTH _TOKEN  +  constants . ROUTE _PATH . LOGOUT , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        type :  "POST" , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        data :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          intAuthToken :  selfPlayerInfo . intAuthToken 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        success :  function ( res )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          if  ( res . ret  !=  constants . RET _CODE . OK )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            console . log ( "Logout failed: " ,  res ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          localClearance ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        error :  function ( xhr ,  status ,  errMsg )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          localClearance ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        timeout :  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          localClearance ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }  catch  ( e )  { }  finally  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      // For Safari (both desktop and mobile).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      localClearance ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onLogoutClicked ( evt )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . showPopupInCanvas ( self . confirmLogoutNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onLogoutConfirmationDismissed ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . transitToState ( ALL _MAP _STATES . VISUAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  canvasNode  =  self . canvasNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    canvasNode . removeChild ( self . confirmLogoutNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . enableInputControls ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  onGameRule1v1ModeClicked ( evt ,  cb )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . battleState  =  ALL _BATTLE _STATES . WAITING ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    window . initPersistentSessionClient ( self . initAfterWSConnected ,  null  /* Deliberately NOT passing in any `expectedRoomId`. -- YFLu */  ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . hideGameRuleNode ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  showPopupInCanvas ( toShowNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-20 16:01:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    toShowNode . active  =  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    self . disableInputControls ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . transitToState ( ALL _MAP _STATES . SHOWING _MODAL _POPUP ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    safelyAddChild ( self . widgetsAboveAllNode ,  toShowNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    setLocalZOrder ( toShowNode ,  10 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-13 11:37:30 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  hideFindingPlayersGUI ( rdf )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  self . findingPlayerNode . parent )  return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . findingPlayerNode . parent . removeChild ( self . findingPlayerNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  onBattleReadyToStart ( rdf  /* pb.RoomDownsyncFrame */  )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  players  =  rdf . playersArr ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 23:46:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Show the top status indicators for IN_BATTLE 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . playersInfoNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  playersInfoScriptIns  =  self . playersInfoNode . getComponent ( "PlayersInfo" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 17:27:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      for  ( let  i  in  players )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        playersInfoScriptIns . updateData ( players [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 23:46:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 17:27:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    console . log ( "Calling `onBattleReadyToStart` with:" ,  players ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . findingPlayerNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  findingPlayerScriptIns  =  self . findingPlayerNode . getComponent ( "FindingPlayer" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      findingPlayerScriptIns . hideExitButton ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-21 17:27:32 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      findingPlayerScriptIns . updatePlayersInfo ( players ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 11:24:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Delay to hide the "finding player" GUI, then show a countdown clock
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-19 20:58:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . countdownToBeginGameNode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      window . setTimeout ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . hideFindingPlayersGUI ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  countDownScriptIns  =  self . countdownToBeginGameNode . getComponent ( "CountdownToBeginGame" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        countDownScriptIns . setData ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . showPopupInCanvas ( self . countdownToBeginGameNode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } ,  1500 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  applyRoomDownsyncFrameDynamics ( rdf ,  prevRdf )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  playersArr  =  rdf . PlayersArr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  playersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  currPlayerDownsync  =  playersArr [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-31 15:47:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  chConfig  =  self . chConfigsOrderedByJoinIndex [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  prevRdfPlayer  =  ( null  ==  prevRdf  ?  null  :  prevRdf . PlayersArr [ k ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  [ wx ,  wy ]  =  gopkgs . VirtualGridToWorldPos ( currPlayerDownsync . VirtualGridX ,  currPlayerDownsync . VirtualGridY ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  playerRichInfo  =  self . playerRichInfoArr [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      playerRichInfo . node . setPosition ( wx ,  wy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      playerRichInfo . scriptIns . updateSpeed ( currPlayerDownsync . Speed ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-31 15:47:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      playerRichInfo . scriptIns . updateCharacterAnim ( currPlayerDownsync ,  prevRdfPlayer ,  false ,  chConfig ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 15:11:35 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // Update countdown
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . countdownNanos  =  self . battleDurationNanos  -  self . renderFrameId  *  self . rollbackEstimatedDtNanos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( self . countdownNanos  <=  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      self . onBattleStopped ( self . playerRichInfoDict ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 19:11:59 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 13:27:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  rollbackAndChase ( renderFrameIdSt ,  renderFrameIdEd ,  collisionSys ,  collisionSysMap ,  isChasing )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 00:01:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 21:30:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    let  prevLatestRdf  =  null , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      latestRdf  =  null ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 21:30:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( let  i  =  renderFrameIdSt ;  i  <  renderFrameIdEd ;  i ++ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  currRdf  =  self . recentRenderCache . getByFrameId ( i ) ;  // typed "RoomDownsyncFrame"; [WARNING] When "true == isChasing" and using Firefox, this function could be interruptted by "onRoomDownsyncFrame(rdf)" asynchronously anytime, making this line return "null"!
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( null  ==  currRdf )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        throw  ` Couldn't find renderFrame for i= ${ i }  to rollback (are you using Firefox?), self.renderFrameId= ${ self . renderFrameId } , lastAllConfirmedInputFrameId= ${ self . lastAllConfirmedInputFrameId } , might've been interruptted by onRoomDownsyncFrame ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 00:01:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 20:42:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  j  =  gopkgs . ConvertToDelayedInputFrameId ( i ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  delayedInputFrame  =  self . recentInputCache . GetByFrameId ( j ) ;  // Don't make prediction here, the inputFrameDownsyncs in recentInputCache was already predicted while prefabbing
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 00:01:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( null  ==  delayedInputFrame )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-29 21:32:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // Shouldn't happen!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        throw  ` Failed to get cached delayedInputFrame for i= ${ i } , j= ${ j } , renderFrameId= ${ self . renderFrameId } , lastUpsyncInputFrameId= ${ self . lastUpsyncInputFrameId } , lastAllConfirmedInputFrameId= ${ self . lastAllConfirmedInputFrameId } , chaserRenderFrameId= ${ self . chaserRenderFrameId } ; recentRenderCache= ${ self . _stringifyRecentRenderCache ( false ) } , recentInputCache= ${ self . _stringifyRecentInputCache ( false ) } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 00:01:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 20:42:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  jPrev  =  gopkgs . ConvertToDelayedInputFrameId ( i  -  1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-27 10:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( self . frameDataLoggingEnabled )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  actuallyUsedInputClone  =  delayedInputFrame . InputList . slice ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-27 10:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  inputFrameDownsyncClone  =  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          inputFrameId :  delayedInputFrame . InputFrameId , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-27 10:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          inputList :  actuallyUsedInputClone , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          confirmedList :  delayedInputFrame . ConfirmedList , 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-27 10:09:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . rdfIdToActuallyUsedInput . set ( currRdf . Id ,  inputFrameDownsyncClone ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-01 15:43:25 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  nextRdf  =  gopkgs . ApplyInputFrameDownsyncDynamicsOnSingleRenderFrameJs ( self . recentInputCache ,  currRdf ,  collisionSys ,  collisionSysMap ,  self . spaceOffsetX ,  self . spaceOffsetY ,  self . chConfigsOrderedByJoinIndex ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 13:27:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      if  ( true  ==  isChasing )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        // [WARNING] Move the cursor "self.chaserRenderFrameId" when "true == isChasing", keep in mind that "self.chaserRenderFrameId" is not monotonic!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . chaserRenderFrameId  =  nextRdf . Id ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      }  else  if  ( nextRdf . Id  ==  self . chaserRenderFrameId  +  1 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        self . chaserRenderFrameId  =  nextRdf . Id ;  // To avoid redundant calculation 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 13:27:48 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . recentRenderCache . setByFrameId ( nextRdf ,  nextRdf . Id ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 11:35:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      prevLatestRdf  =  currRdf ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      latestRdf  =  nextRdf ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-14 21:30:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-25 11:20:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  [ prevLatestRdf ,  latestRdf ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  _initPlayerRichInfoDict ( playersArr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  playersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  immediatePlayerInfo  =  playersArr [ k ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  playerId  =  immediatePlayerInfo . Id ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( self . playerRichInfoDict . has ( playerId ) )  continue ;  // Skip already put keys
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . playerRichInfoDict . set ( playerId ,  immediatePlayerInfo ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  joinIndex  =  immediatePlayerInfo . joinIndex  ||  immediatePlayerInfo . JoinIndex ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  vx  =  immediatePlayerInfo . virtualGridX  ||  immediatePlayerInfo . VirtualGridX ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  vy  =  immediatePlayerInfo . virtualGridY  ||  immediatePlayerInfo . VirtualGridY ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  nodeAndScriptIns  =  self . spawnPlayerNode ( joinIndex ,  vx ,  vy ,  immediatePlayerInfo ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 12:45:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      Object . assign ( self . playerRichInfoDict . get ( playerId ) ,  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 13:55:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        node :  nodeAndScriptIns [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        scriptIns :  nodeAndScriptIns [ 1 ] , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  selfPlayerId  =  self . selfPlayerInfo . Id ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      if  ( selfPlayerId  ==  playerId )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        self . selfPlayerInfo . JoinIndex  =  immediatePlayerInfo . JoinIndex ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-16 13:55:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        nodeAndScriptIns [ 1 ] . showArrowTipNode ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 11:16:18 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    self . playerRichInfoArr  =  new  Array ( self . playerRichInfoDict . size ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    self . playerRichInfoDict . forEach ( ( playerRichInfo ,  playerId )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      self . playerRichInfoArr [ playerRichInfo . JoinIndex  -  1 ]  =  playerRichInfo ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-03 00:22:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  _stringifyRecentInputCache ( usefullOutput )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    if  ( true  ==  usefullOutput )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 17:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      let  s  =  [ ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      for  ( let  i  =  self . recentInputCache . StFrameId ;  i  <  self . recentInputCache . EdFrameId ;  ++ i )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        s . push ( JSON . stringify ( self . recentInputCache . GetByFrameId ( i ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-22 17:09:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      return  s . join ( '\n' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-28 18:06:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  ` [stInputFrameId= ${ self . recentInputCache . StFrameId } , edInputFrameId= ${ self . recentInputCache . EdFrameId } ) ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 17:22:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  _stringifyGopkgRoomDownsyncFrame ( rdf )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  s  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( ` { ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( `   id:  ${ rdf . Id } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( `   players: [ ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  rdf . PlayersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  player  =  rdf . PlayersArr [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      s . push ( `     {joinIndex:  ${ player . JoinIndex } , id:  ${ player . Id } , vx:  ${ player . VirtualGridX } , vy:  ${ player . VirtualGridY } , velX:  ${ player . VelX } , velY:  ${ player . VelY } } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( `   ] ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( ` } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  s . join ( "\n" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  _stringifyRecentRenderCache ( usefullOutput )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 17:22:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( true  ==  usefullOutput )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      let  s  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for  ( let  i  =  self . recentRenderCache . stFrameId ;  i  <  self . recentRenderCache . edFrameId ;  ++ i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  rdf  =  self . recentRenderCache . getByFrameId ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        s . push ( self . _stringifyGopkgRoomDownsyncFrame ( rdf ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 17:22:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 12:27:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      return  s . join ( "\n" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-11 23:43:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  ` [stRenderFrameId= ${ self . recentRenderCache . stFrameId } , edRenderFrameId= ${ self . recentRenderCache . edFrameId } ) ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 17:22:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-26 10:36:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 20:37:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  playerDownsyncStr ( playerDownsync )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  playerDownsync )  return  "" ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-29 15:03:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  ` { ${ playerDownsync . JoinIndex } , ${ playerDownsync . VirtualGridX } , ${ playerDownsync . VirtualGridY } , ${ playerDownsync . VelX } , ${ playerDownsync . VelY } , ${ playerDownsync . FramesToRecover } , ${ playerDownsync . InAir  ?  1  :  0 } } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 20:37:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  inputFrameDownsyncStr ( inputFrameDownsync )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    if  ( null  ==  inputFrameDownsync )  return  "" ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  s  =  [ ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    s . push ( ` InputFrameId: ${ inputFrameDownsync . inputFrameId } ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  ss  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  k  in  inputFrameDownsync . inputList )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      ss . push ( ` " ${ inputFrameDownsync . inputList [ k ] } " ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    s . push ( ` InputList:[ ${ ss . join ( ',' ) } ] ` ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    // The "confirmedList" is not worth comparing, because frontend might actually use a non-all-confirmed inputFrame during its history, as long as it's correctly predicted.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    //s.push(`ConfirmedList:${inputFrameDownsync.confirmedList}`); 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  s . join ( ',' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  _stringifyRdfIdToActuallyUsedInput ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    let  s  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    for  ( let  i  =  self . recentRenderCache . stFrameId ;  i  <  self . recentRenderCache . edFrameId ;  i ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  actuallyUsedInputClone  =  self . rdfIdToActuallyUsedInput . get ( i ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 20:37:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      const  rdf  =  self . recentRenderCache . getByFrameId ( i ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      const  playersStrBldr  =  [ ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for  ( let  k  in  rdf . PlayersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        playersStrBldr . push ( self . playerDownsyncStr ( rdf . PlayersArr [ k ] ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      s . push ( ` rdfId: ${ i } 
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 20:37:40 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								players : [ $ { playersStrBldr . join ( ',' ) } ] 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								actuallyUsedinputList : { $ { self . inputFrameDownsyncStr ( actuallyUsedInputClone ) } } ` );
 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-26 18:25:20 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-22 21:27:14 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    return  s . join ( '\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  stringifyColliderCenterInWorld ( playerCollider ,  halfBoundingW ,  halfBoundingH ,  topPadding ,  bottomPadding ,  leftPadding ,  rightPadding )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    return  ` { ${ ( playerCollider . x  +  leftPadding  +  halfBoundingW ) . toFixed ( 2 ) } ,  ${ ( playerCollider . y  +  bottomPadding  +  halfBoundingH ) . toFixed ( 2 ) } } ` ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 18:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-12-25 20:17:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  showDebugBoundaries ( rdf )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-09 18:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    const  self  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    // Hardcoded paddings for now
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    const  leftPadding  =  0.1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      rightPadding  =  0.1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      topPadding  =  0.1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      bottomPadding  =  0.1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    if  ( self . showCriticalCoordinateLabels  &&  self . g2 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      let  g2  =  self . g2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      g2 . clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for  ( let  k  in  rdf . PlayersArr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  player  =  rdf . PlayersArr [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( 1  ==  player . JoinIndex )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          g2 . strokeColor  =  cc . Color . BLUE ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          g2 . strokeColor  =  cc . Color . RED ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        let  [ colliderWidth ,  colliderHeight ]  =  [ player . ColliderRadius  *  2 ,  player . ColliderRadius  *  4 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        switch  ( player . CharacterState )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          case  ATK _CHARACTER _STATE . LayDown1 [ 0 ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            [ colliderWidth ,  colliderHeight ]  =  [ player . ColliderRadius  *  4 ,  player . ColliderRadius  *  2 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          case  ATK _CHARACTER _STATE . BlownUp1 [ 0 ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          case  ATK _CHARACTER _STATE . InAirIdle1NoJump [ 0 ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          case  ATK _CHARACTER _STATE . InAirIdle1ByJump [ 0 ] : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            [ colliderWidth ,  colliderHeight ]  =  [ player . ColliderRadius  *  2 ,  player . ColliderRadius  *  2 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  [ halfColliderWidth ,  halfColliderHeight ]  =  gopkgs . VirtualGridToWorldPos ( ( colliderWidth  >>  1 ) ,  ( colliderHeight  >>  1 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  [ wx ,  wy ]  =  gopkgs . VirtualGridToWorldPos ( player . VirtualGridX ,  player . VirtualGridY ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  [ cx ,  cy ]  =  gopkgs . WorldToPolygonColliderBLPos ( wx ,  wy ,  halfColliderWidth ,  halfColliderHeight ,  topPadding ,  bottomPadding ,  leftPadding ,  rightPadding ,  0 ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  pts  =  [ [ 0 ,  0 ] ,  [ leftPadding  +  halfColliderWidth  *  2  +  rightPadding ,  0 ] ,  [ leftPadding  +  halfColliderWidth  *  2  +  rightPadding ,  bottomPadding  +  halfColliderHeight  *  2  +  topPadding ] ,  [ 0 ,  bottomPadding  +  halfColliderHeight  *  2  +  topPadding ] ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        g2 . moveTo ( cx ,  cy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        for  ( let  j  =  0 ;  j  <  pts . length ;  j  +=  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          g2 . lineTo ( pts [ j ] [ 0 ]  +  cx ,  pts [ j ] [ 1 ]  +  cy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        g2 . lineTo ( cx ,  cy ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        g2 . stroke ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      for  ( let  k  in  rdf . MeleeBullets )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        const  meleeBullet  =  rdf . MeleeBullets [ k ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          meleeBullet . Bullet . OriginatedRenderFrameId  +  meleeBullet . Bullet . StartupFrames  <=  rdf . Id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          && 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          meleeBullet . Bullet . OriginatedRenderFrameId  +  meleeBullet . Bullet . StartupFrames  +  meleeBullet . Bullet . ActiveFrames  >  rdf . Id 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          const  offender  =  rdf . PlayersArr [ meleeBullet . Bullet . OffenderJoinIndex  -  1 ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          if  ( 1  ==  offender . JoinIndex )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            g2 . strokeColor  =  cc . Color . BLUE ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            g2 . strokeColor  =  cc . Color . RED ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          let  xfac  =  1 ;  // By now, straight Punch offset doesn't respect "y-axis"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          if  ( 0  >  offender . DirX )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            xfac  =  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  [ bulletWx ,  bulletWy ]  =  gopkgs . VirtualGridToWorldPos ( offender . VirtualGridX  +  xfac  *  meleeBullet . Bullet . HitboxOffsetX ,  offender . VirtualGridY ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  [ halfColliderWidth ,  halfColliderHeight ]  =  gopkgs . VirtualGridToWorldPos ( ( meleeBullet . Bullet . HitboxSizeX  >>  1 ) ,  ( meleeBullet . Bullet . HitboxSizeY  >>  1 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          const  [ bulletCx ,  bulletCy ]  =  gopkgs . WorldToPolygonColliderBLPos ( bulletWx ,  bulletWy ,  halfColliderWidth ,  halfColliderHeight ,  topPadding ,  bottomPadding ,  leftPadding ,  rightPadding ,  0 ,  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          const  pts  =  [ [ 0 ,  0 ] ,  [ leftPadding  +  halfColliderWidth  *  2  +  rightPadding ,  0 ] ,  [ leftPadding  +  halfColliderWidth  *  2  +  rightPadding ,  bottomPadding  +  halfColliderHeight  *  2  +  topPadding ] ,  [ 0 ,  bottomPadding  +  halfColliderHeight  *  2  +  topPadding ] ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          g2 . moveTo ( bulletCx ,  bulletCy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          for  ( let  j  =  0 ;  j  <  pts . length ;  j  +=  1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            g2 . lineTo ( pts [ j ] [ 0 ]  +  bulletCx ,  pts [ j ] [ 1 ]  +  bulletCy ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          } 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-04 23:48:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								          g2 . lineTo ( bulletCx ,  bulletCy ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								          g2 . stroke ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-02 16:36:17 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2022-12-12 23:17:54 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 23:50:01 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} ) ;