---@class WB_TeamRank_C:UUserWidget ---@field VerticalBox_Left UVerticalBox ---@field VerticalBox_Right UVerticalBox --Edit Below-- ---@type WB_TeamRank_C local WB_TeamRank = { bInitDoOnce = false; }; 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() 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[TeamConfig.TeamType.CT] and RankData[TeamConfig.TeamType.CT][i + 1] or nil local PlayerKeyRight = RankData[TeamConfig.TeamType.T] and RankData[TeamConfig.TeamType.T][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;