---@class WB_BondSystemTip_C:UUserWidget ---@field WidgetSwitcher_BondState UWidgetSwitcher --Edit Below-- local WB_BondSystemTip = { bInitDoOnce = false; FPS = 3; } --[==[ Construct function WB_BondSystemTip:Construct() end -- Construct ]==] -- function WB_BondSystemTip:Tick(MyGeometry, InDeltaTime) -- end -- function WB_BondSystemTip:Destruct() -- end function WB_BondSystemTip:Destruct() if self.LoopHandle then UGCEventSystem.StopTimer(self.LoopHandle) end end function WB_BondSystemTip:Active() if self.LoopHandle == nil then self.LoopHandle = UGCEventSystem.SetTimerLoop(self, self.Update, 1./self.FPS) end end function WB_BondSystemTip:Update() local LocalPlayerTeam = UGCGameSystem.GameState:GetPlayerTeamIDByPlayerKey(UGCSystemLibrary.GetLocalPlayerKey()) self:BondFromTeamID(LocalPlayerTeam) end function WB_BondSystemTip:BondFromTeamID(InTeamID) local TeamPlayers = UGCGameSystem.GameState:GetTeamPlayer(InTeamID) -- 不为2人队伍则无羁绊 if table.getCount(TeamPlayers) ~= 2 then self.WidgetSwitcher_BondState:SetActiveWidgetIndex(3) return end local OtherPlayer = ((TeamPlayers[1] == UGCSystemLibrary.GetLocalPlayerKey()) and TeamPlayers[2] or TeamPlayers[1]) local Pawn1 = UGCGameSystem.GetPlayerPawnByPlayerKey(UGCSystemLibrary.GetLocalPlayerKey()) local Pawn2 = UGCGameSystem.GetPlayerPawnByPlayerKey(OtherPlayer) -- 判有效 if not UE.IsValid(Pawn1) or not UE.IsValid(Pawn2) then self.WidgetSwitcher_BondState:SetActiveWidgetIndex(3) return end -- 判存活 if UGCPawnSystem.HasPawnState(Pawn1, EPawnState.Dead) or UGCPawnSystem.HasPawnState(Pawn2, EPawnState.Dead) then self.WidgetSwitcher_BondState:SetActiveWidgetIndex(3) return end -- 获取两个玩家的信息 local PawnHealth1 = UGCPawnAttrSystem.GetHealth(Pawn1) local PawnHealth2 = UGCPawnAttrSystem.GetHealth(Pawn2) local PawnMaxHealth1 = UGCPawnAttrSystem.GetHealthMax(Pawn1) local PawnMaxHealth2 = UGCPawnAttrSystem.GetHealthMax(Pawn2) local PawnHasDying1 = UGCPawnSystem.HasPawnState(Pawn1, EPawnState.Dying) local PawnHasDying2 = UGCPawnSystem.HasPawnState(Pawn2, EPawnState.Dying) local HealthPercentage1 = PawnHealth1 / PawnMaxHealth1 local HealthPercentage2 = PawnHealth2 / PawnMaxHealth2 if not PawnHasDying1 and not PawnHasDying2 then -- 同步血量状态 if HealthPercentage1 > BondManager.SynchronizedPercentageOfBloodVolume or HealthPercentage2 > BondManager.SynchronizedPercentageOfBloodVolume then self.WidgetSwitcher_BondState:SetActiveWidgetIndex(0) else self.WidgetSwitcher_BondState:SetActiveWidgetIndex(3) end elseif PawnHasDying1 ~= PawnHasDying2 then if PawnHasDying1 then -- 自己倒地 self.WidgetSwitcher_BondState:SetActiveWidgetIndex(1) else -- 队友倒地 self.WidgetSwitcher_BondState:SetActiveWidgetIndex(2) end else self.WidgetSwitcher_BondState:SetActiveWidgetIndex(3) end return end return WB_BondSystemTip