local Action_GameReady = { } function Action_GameReady:Execute(...) local GameState = UGCGameSystem.GameState GameState.GameStage = EGameStage.GameReady -- 应用默认属性 GameState:ApplyDefaultAttributes() self.EnterStateTime = GameplayStatics.GetRealTimeSeconds(self) UE.Log("[Action_GameReady:Execute] EnterStateTime = %.2f", self.EnterStateTime) self.GameStageConfig = TableHelper.DeepCopyTable(Tables.GameReadyStageConfig) table.sort(self.GameStageConfig, function(a, b) return a.Stage < b.Stage end) self.EventTimeLine = {} local TotalWaitTime = self.EnterStateTime + 0.5 for Index, Config in pairs(self.GameStageConfig) do self.EventTimeLine[Index] = TotalWaitTime TotalWaitTime = TotalWaitTime + tonumber(Config.WaitTime) UE.Log("[Action_GameReady:Execute] StageConfig1: Index = %d, Stage = %d, WaitTime = %.2f; EventTime = %.2f", Index, Config.Stage, Config.WaitTime, self.EventTimeLine[Index]) end self.EventIndex = 1 self.LastConfigCheckFunction = "" self.LastConfigTriggerUI = -1 self.CurWaitTime = -1 self.LastUpdateRemainTime = -1 self.bEnableActionTick = true UGCGameSystem.GameState:CloseNoticeUI() return true end function Action_GameReady:Update(DeltaSeconds) local CurrentRealTime = GameplayStatics.GetRealTimeSeconds(self) if self.CurWaitTime > 0 then local RemainTime = self.CurWaitTime - (CurrentRealTime - self.EnterStateTime); RemainTime = RemainTime >= 0 and RemainTime or 0 local CurrentUpdateRemainTime = math.ceil(RemainTime) if self.LastUpdateRemainTime - CurrentUpdateRemainTime >= 1 then self.LastUpdateRemainTime = CurrentUpdateRemainTime end end UGCGameSystem.GameState.GameReadyStageRemainTime = math.ceil(self.LastUpdateRemainTime) if self.EventTimeLine[self.EventIndex] and math.isNearlyEqual(CurrentRealTime, self.EventTimeLine[self.EventIndex], 0.1) then self:FinishLastEvent() self:DispatchEvent(self.EventIndex) self.EventIndex = self.EventIndex + 1 end end function Action_GameReady:DispatchEvent(InIndex) local Config = self.GameStageConfig[InIndex] UE.Log("[Action_GameReady:DispatchEvent] InIndex = %d, DispatchEvent: Stage = %d, CurTime = %.2f", InIndex, Config.Stage, GameplayStatics.GetRealTimeSeconds(self)) UGCGameSystem.GameState.GameReadyStage = Config.Stage; DOREPONCE(UGCGameSystem.GameState, "GameReadyStage"); self.LastConfigCheckFunction = Config.CheckFunction self.LastConfigTriggerUI = Config.TriggerUI self.CurWaitTime = Config.WaitTime self.LastUpdateRemainTime = self.CurWaitTime self.EnterStateTime = GameplayStatics.GetRealTimeSeconds(self) if next(self.GameStageConfig, InIndex) == nil then UE.Log("[Action_GameReady:DispatchEvent] Final Index = %d", InIndex) EventSystem.SetTimer(self, function() self:FinishLastEvent() UGCGameSystem.GameState:CheckAllPlayersDefaultWeaponSelection() UGCGameSystem.GameState.GameReadyStageRemainTime = -1 UGCGameSystem.SendModeCustomEvent("EnterGameFightStage") self.bEnableActionTick = false end, Config.WaitTime) end end function Action_GameReady:FinishLastEvent() if self.LastConfigCheckFunction ~= "" then UGCGameSystem.GameState[self.LastConfigCheckFunction](UGCGameSystem.GameState) end if self.LastConfigTriggerUI ~= -1 then NoticeTipsTools.MulticastClosePanel(self.LastConfigTriggerUI) end end return Action_GameReady