53 lines
1.8 KiB
Lua
53 lines
1.8 KiB
Lua
local Action_PlayerExit = {
|
||
PlayerKey = 0;
|
||
}
|
||
|
||
-- 触发器激活时,将执行Action的Execute
|
||
function Action_PlayerExit:Execute(...)
|
||
UGCGameSystem.SendPlayerSettlement(self.PlayerKey);
|
||
|
||
local PlayerState = UGCGameSystem.GetPlayerStateByPlayerKey(self.PlayerKey)
|
||
local PlayerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey)
|
||
|
||
if PlayerPawn then
|
||
PlayerPawn:K2_DestroyActor()
|
||
else
|
||
UGCLogSystem.LogError("[Action_PlayerExit_Execute] PlayerPawn is nil")
|
||
local AllPawn = UGCGameSystem.GetAllPlayerPawn()
|
||
local HasNotControlled = false
|
||
for k, Pawn in pairs(AllPawn) do
|
||
if not Pawn:IsControlled() then
|
||
Pawn:K2_DestroyActor()
|
||
HasNotControlled = true
|
||
end
|
||
end
|
||
if HasNotControlled == false then UGCLogSystem.LogError("[Action_PlayerExit_Execute] HasNotControlled is false") end
|
||
end
|
||
|
||
if UGCGameSystem.GameState and PlayerState then
|
||
UGCLogSystem.Log("[Action_PlayerExit_Execute] PlayerName = "..PlayerState.PlayerName)
|
||
local PlayerData = UGCGameSystem.GameState.PlayerDataList[self.PlayerKey]
|
||
if PlayerData ~= nil then
|
||
PlayerData.IsOffline = true
|
||
end
|
||
|
||
local PlayerNum = #UGCGameSystem.GetAllPlayerState()
|
||
if PlayerNum == 0 then
|
||
UGCGameSystem.GameState.GameEndTimeStamp = GameplayStatics.GetRealTimeSeconds(self)
|
||
UGCGameSystem.SendModeCustomEvent("GameEnd")
|
||
end
|
||
end
|
||
|
||
UGCEventSystem.SendEvent(EventEnum.PlayerExit, self.PlayerKey)
|
||
return true
|
||
end
|
||
|
||
--[[
|
||
-- 需要勾选Action的EnableTick,才会执行Update
|
||
-- 触发器激活后,将在每个tick执行Action的Update,直到self.bEnableActionTick为false
|
||
function Action_PlayerExit:Update(DeltaSeconds)
|
||
|
||
end
|
||
]]
|
||
|
||
return Action_PlayerExit |