---@class WBP_SkillBtn_C:UAEUserWidget ---@field SkillBtn_Slot0 UWBP_SkillBtn_Item_2_C ---@field SkillBtn_Slot1 UWBP_SkillBtn_Item_C ---@field SkillBtn_Slot2 UWBP_SkillBtn_Item_C ---@field SkillBtn_Slot3 UWBP_SkillBtn_Item_C ---@field SkillBtn_Slot4 UWBP_SkillBtn_Item_C --Edit Below-- local WBP_SkillBtn = { bInitOnce = false, SkillButtons = {}, SkillsMapping = {}, }; function WBP_SkillBtn:Construct() if self.bInitOnce then return end self.bInitOnce = true self.bCanEverTick = true self.SkillButtons = { [ESkillSlot.Slot0] = self.SkillBtn_Slot0, [ESkillSlot.Slot1] = self.SkillBtn_Slot1, [ESkillSlot.Slot2] = self.SkillBtn_Slot2, [ESkillSlot.Slot3] = self.SkillBtn_Slot3, [ESkillSlot.Slot4] = self.SkillBtn_Slot4, } self.SkillsMapping = { [ESkillSlot.Slot0] = -1, [ESkillSlot.Slot1] = -1, [ESkillSlot.Slot2] = -1, [ESkillSlot.Slot3] = -1, [ESkillSlot.Slot4] = -1, } for _, Button in pairs(self.SkillButtons) do if Button then Button:Show() end end local LocalPC = GameDataManager.GetLocalPlayerController() if UE.IsValid(LocalPC) then for Slot, SkillInfo in pairs(LocalPC.ActiveSkillNameList) do self:OnSetupSkillButton(SkillInfo.SkillName, Slot, SkillInfo.SkillLevel) end end self:OnGameStageChange(UGCGameSystem.GameState.GameStage) EventSystem:AddListener(EventType.OnGameStageChanged, WBP_SkillBtn.OnGameStageChange, self) EventSystem:AddListener(EventType.OnSetupSkillButton, WBP_SkillBtn.OnSetupSkillButton, self) EventSystem:AddListener(EventType.PlayerSkillCDTriggered, WBP_SkillBtn.OnSkillCDTriggered, self) end function WBP_SkillBtn:Destruct() EventSystem:RemoveListener(EventType.OnGameStageChanged, WBP_SkillBtn.OnGameStageChange, self) EventSystem:RemoveListener(EventType.OnSetupSkillButton, WBP_SkillBtn.OnSetupSkillButton, self) EventSystem:RemoveListener(EventType.PlayerSkillCDTriggered, WBP_SkillBtn.OnSkillCDTriggered, self) end ---@param InGameStage EGameStage function WBP_SkillBtn:OnGameStageChange(InGameStage) if InGameStage == EGameStage.GameFight then UIManager:VisiblePanel(EUIType.SkillButton) end end ---@param SkillName ESkillName ---@param SkillSlot ESkillSlot function WBP_SkillBtn:OnSetupSkillButton(SkillName, SkillSlot, SkillLevel) UE.Log("[WBP_SkillBtn:OnSetupSkillButton] SkillName=%d, SkillSlot=%d, PlayerKey=%d", SkillName, SkillSlot, GameDataManager.GetLocalPlayerController().PlayerKey) self:OnGameStageChange(UGCGameSystem.GameState.GameStage) self.SkillsMapping[SkillSlot] = SkillName local Button = self.SkillButtons[SkillSlot] Button:Show() Button:SetupSkillButton(SkillName, SkillLevel) end ---@param SkillName ESkillName ---@param CD float function WBP_SkillBtn:OnSkillCDTriggered(Slot, CD) local Button = self:GetSkillButtonBySlot(Slot) if Button then UE.Log("[WBP_SkillBtn:OnSkillCDTriggered] Slot=%d, CD=%.2f", Slot, CD) Button:OnSkillCD(Slot, CD) end end ---@param InSkillSlot ESkillSlot ---@return SkillButton function WBP_SkillBtn:GetSkillButtonBySlot(InSkillSlot) return self.SkillButtons[InSkillSlot] end return WBP_SkillBtn;