61 lines
2.0 KiB
Lua
61 lines
2.0 KiB
Lua
|
---@class WBP_ForceGuide_Unpacking_C:UUserWidget
|
||
|
---@field Button_Unpacking UButton
|
||
|
---@field Panel_BG UWBP_WidgetHeader_C
|
||
|
---@field TextBlock_CoinPoint UTextBlock
|
||
|
--Edit Below--
|
||
|
local WBP_ForceGuide_Unpacking = { bInitDoOnce = false; };
|
||
|
|
||
|
function WBP_ForceGuide_Unpacking:OnStartGuideProgress()
|
||
|
self:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
|
||
|
self.PendingEndGuide = false
|
||
|
|
||
|
self.Panel_BG:Construct()
|
||
|
|
||
|
self.Button_Unpacking.OnClicked:Add(self.OnButton_UnpackingClicked, self)
|
||
|
|
||
|
local TargetPlayerState = GameDataManager.GetLocalPlayerState()
|
||
|
self:ChangeCoinPoint(TargetPlayerState.CoinPoint.Current)
|
||
|
|
||
|
EventSystem:AddListener(EventType.PlayerCoinPointChanged, self.ChangeCoinPoint, self)
|
||
|
EventSystem:SendEvent(EventType.ForceGuide_OnGuideTriggered, 3)
|
||
|
end
|
||
|
|
||
|
function WBP_ForceGuide_Unpacking:OnEndGuideProgress()
|
||
|
self:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
|
||
|
self.Button_Unpacking.OnClicked:Remove(self.OnButton_UnpackingClicked, self)
|
||
|
|
||
|
EventSystem:RemoveListener(EventType.PlayerCoinPointChanged, self.ChangeCoinPoint, self)
|
||
|
EventSystem:SendEvent(EventType.ForceGuide_OnGuideFinished, 3)
|
||
|
end
|
||
|
|
||
|
function WBP_ForceGuide_Unpacking:ChangeCoinPoint(NewCoinPoint)
|
||
|
self.TextBlock_CoinPoint:SetText(tostring(math.ceil(NewCoinPoint)))
|
||
|
end
|
||
|
|
||
|
function WBP_ForceGuide_Unpacking:OnUnpackingSuccess()
|
||
|
if self.PendingEndGuide then
|
||
|
return
|
||
|
end
|
||
|
self.PendingEndGuide = true
|
||
|
|
||
|
if self.Timer ~= nil then
|
||
|
EventSystem.StopTimer(self.Timer)
|
||
|
end
|
||
|
self.Timer = EventSystem.SetTimer(self, function()
|
||
|
self:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
self:OnEndGuideProgress()
|
||
|
EventSystem.StopTimer(self.Timer)
|
||
|
self.Timer = nil
|
||
|
end, 0.5)
|
||
|
end
|
||
|
|
||
|
function WBP_ForceGuide_Unpacking:OnButton_UnpackingClicked()
|
||
|
local PC = GameDataManager.GetLocalPlayerController()
|
||
|
UnrealNetwork.CallUnrealRPC(PC, UGCGameSystem.GameState, "Server_RPC_Unpacking", PC.PlayerKey, 1, 1)
|
||
|
|
||
|
self:OnUnpackingSuccess()
|
||
|
end
|
||
|
|
||
|
return WBP_ForceGuide_Unpacking;
|