---@class WB_TeamRank_C:UUserWidget ---@field REINST_WB_TeamRankItem_C_0 UWB_TeamRankItem_C ---@field REINST_WB_TeamRankItem_C_1 UWB_TeamRankItem_C ---@field REINST_WB_TeamRankItem_C_2 UWB_TeamRankItem_C ---@field REINST_WB_TeamRankItem_C_3 UWB_TeamRankItem_C ---@field VerticalBox_Left UVerticalBox ---@field VerticalBox_Right UVerticalBox --Edit Below-- ---@type WB_TeamRank_C local WB_TeamRank = { bInitDoOnce = false; LeftTeamType = 1; RightTeamType = 2; }; function WB_TeamRank:Construct() UGCEventSystem.AddListener(EventEnum.UpdatePlayerScoreData, self.UpdateRank, self); UGCEventSystem.AddListener(EventEnum.UpdatePlayerRank, self.UpdateRank, self); self:SetItemTeam() end function WB_TeamRank:SetItemTeam() local LocalPlayerTeamID = UGCPlayerControllerSystem.GetTeamID(UGCSystemLibrary.GetLocalPlayerController()) if LocalPlayerTeamID == TeamConfig.TeamType.CT then self.LeftTeamType, self.RightTeamType = TeamConfig.TeamType.CT, TeamConfig.TeamType.T else self.LeftTeamType, self.RightTeamType = TeamConfig.TeamType.T, TeamConfig.TeamType.CT end for i = 0, self.VerticalBox_Left:GetChildrenCount() - 1 do local ItemLeftInst = self.VerticalBox_Left:GetChildAt(i) local ItemRightInst = self.VerticalBox_Right:GetChildAt(i) ItemLeftInst:SetTeam(TeamConfig.TeamType.CT) ItemRightInst:SetTeam(TeamConfig.TeamType.T) end end function WB_TeamRank:UpdateRank() -- ScoreData: {[PlayerKey] = {Kill = int32, Dead = int32, Score = float}...} local RankData = UGCGameSystem.GameState:GetPlayerRank() UGCLogSystem.LogTree("[WB_TeamRank_UpdateRank]", RankData) for i = 0, self.VerticalBox_Left:GetChildrenCount() - 1 do local ItemLeftInst = self.VerticalBox_Left:GetChildAt(i) local ItemRightInst = self.VerticalBox_Right:GetChildAt(i) local PlayerKeyLeft = RankData[self.LeftTeamType] and RankData[self.LeftTeamType][i + 1] or nil local PlayerKeyRight = RankData[self.RightTeamType] and RankData[self.RightTeamType][i + 1] or nil if PlayerKeyLeft then ItemLeftInst:SetVisibility(ESlateVisibility.SelfHitTestInvisible) ItemLeftInst:InitRankInfo(PlayerKeyLeft) else ItemLeftInst:SetVisibility(ESlateVisibility.Collapsed) end if PlayerKeyRight then ItemRightInst:SetVisibility(ESlateVisibility.SelfHitTestInvisible) ItemRightInst:InitRankInfo(PlayerKeyRight) else ItemRightInst:SetVisibility(ESlateVisibility.Collapsed) end end end return WB_TeamRank;