---@class UGCPlayerStartManager_C:BP_PlayerStartManager_C ---@field PlayerStartClass UClass --Edit Below-- ---@type UGCPlayerStartManager_C local UGCPlayerStartManager = { AllPlayerStart = {}; WaitingPlayerStarts = {}; PlayerStartIndexW = 0; Team1PlayerStarts = {}; Team2PlayerStarts = {}; PlayerStartIndexT1 = 0; PlayerStartIndexT2 = 0; AllPlayerStartIndex = 0; TempGameState = -1; bSwapBornPoint = false; }; function UGCPlayerStartManager:ReceiveBeginPlay() self.SuperClass.ReceiveBeginPlay(self) self.TwoTeamType = {CustomEnum.ETeamMode.BurstMode, CustomEnum.ETeamMode.TurnBase, CustomEnum.ETeamMode.TeamSports} self.TempGameState = UGCGameSystem.GameState:GetGameStateType() self:InitPlayerStartList() UGCEventSystem.AddListener(EventEnum.SwapBornPoint, self.SwapBornPoint, self) UGCEventSystem.AddListener(EventEnum.UpdatePlayerSpawnPoint, self.InitPlayerStartList, self) end function UGCPlayerStartManager:InitPlayerStartList() local TempAllPlayerStart = GameplayStatics.GetAllActorsOfClass(self, self.PlayerStartClass, {}) self.Team1PlayerStarts = {} self.Team2PlayerStarts = {} self.WaitingPlayerStarts = {} self.AllPlayerStart = {} for k, TempPlayerStart in pairs(TempAllPlayerStart) do if TempPlayerStart.PlayerBornPointID == 1 then self.Team1PlayerStarts[#self.Team1PlayerStarts + 1] = TempPlayerStart elseif TempPlayerStart.PlayerBornPointID == 2 then self.Team2PlayerStarts[#self.Team2PlayerStarts + 1] = TempPlayerStart else self.WaitingPlayerStarts[#self.WaitingPlayerStarts + 1] = TempPlayerStart end if TempPlayerStart.PlayerBornPointID > 0 then self.AllPlayerStart[#self.AllPlayerStart + 1] = TempPlayerStart end end table.Shuffle(self.WaitingPlayerStarts) table.Shuffle(self.Team1PlayerStarts) table.Shuffle(self.Team2PlayerStarts) table.Shuffle(self.AllPlayerStart) UGCLogSystem.Log("[UGCPlayerStartManager_ReceiveBeginPlay]Team1PlayerStarts:%d Team2PlayerStarts:%d", #self.Team1PlayerStarts, #self.Team2PlayerStarts) end function UGCPlayerStartManager:GetUGCModePlayerStart(Controller) if self.PlayerStartFunc then if self.PlayerStartObj then return self.PlayerStartFunc(self.PlayerStartObj, Controller) else return self.PlayerStartFunc(Controller) end end return self:DefaultGetPlayerStartFunc(Controller) end function UGCPlayerStartManager:GetTeamPlayerState(Controller) if table.hasValue(self.TwoTeamType, GlobalConfigs.GameModeSetting.TeamModeType) then if UGCPlayerStateSystem.GetTeamID(Controller.PlayerKey) == (self.bSwapBornPoint and 2 or 1) then local ResPlayerStart = self.Team1PlayerStarts[self.PlayerStartIndexT1 + 1] self.PlayerStartIndexT1 = (self.PlayerStartIndexT1 + 1) % #self.Team1PlayerStarts return ResPlayerStart else local ResPlayerStart = self.Team2PlayerStarts[self.PlayerStartIndexT2 + 1] self.PlayerStartIndexT2 = (self.PlayerStartIndexT2 + 1) % #self.Team2PlayerStarts return ResPlayerStart end else local ResPlayerStart = self.AllPlayerStart[self.AllPlayerStartIndex + 1] self.AllPlayerStartIndex = (self.AllPlayerStartIndex + 1) % #self.AllPlayerStart return ResPlayerStart end end function UGCPlayerStartManager:SwapBornPoint() self.bSwapBornPoint = not self.bSwapBornPoint end function UGCPlayerStartManager:BindGetPlayerStartFunc(Func, Obj) self.PlayerStartFunc = Func self.PlayerStartObj = Obj end function UGCPlayerStartManager:ClearGetPlayerStartFunc() self.PlayerStartFunc = nil self.PlayerStartObj = nil end function UGCPlayerStartManager:DefaultGetPlayerStartFunc(Controller) if self.TempGameState ~= UGCGameSystem.GameState:GetGameStateType() then self.TempGameState = UGCGameSystem.GameState:GetGameStateType() self:InitPlayerStartList() end if UGCGameSystem.GameState:GetGameStateType() == CustomEnum.EGameState.Waiting then local ResPlayerStart = self.WaitingPlayerStarts[self.PlayerStartIndexW + 1] self.PlayerStartIndexW = (self.PlayerStartIndexW + 1) % #self.WaitingPlayerStarts return ResPlayerStart else return self:GetTeamPlayerState(Controller) end end return UGCPlayerStartManager;