92 lines
3.3 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
local EventAction_PlayerExit = {
PlayerKey = 0;
EndEvent = -1;
}
-- 触发器激活时将执行Action的Execute
function EventAction_PlayerExit:Execute(...)
if not UGCGameSystem.IsServer() then return end
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("[EventAction_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("[EventAction_PlayerExit_Execute] HasNotControlled is false") end
end
if UGCGameSystem.GameState and PlayerState then
UGCLogSystem.Log("[EventAction_PlayerExit_Execute] PlayerName = "..PlayerState.PlayerName)
local PlayerData = UGCGameSystem.GameState.PlayerPersonalInfos[self.PlayerKey]
if PlayerData ~= nil then
PlayerData.IsOffline = true
end
end
--if self:CheckGameEnd() then
-- UGCGameSystem.GameState:SetGameStateType(CustomEnum.EGameState.End)
--end
--UGCEventSystem.SendEvent(EventEnum.PlayerExit, self.PlayerKey)
return true
end
--function EventAction_PlayerExit:CheckGameEnd()
--
-- if UGCGameSystem.GameState:GetGameStateType() == CustomEnum.EGameState.Playing then
-- local PlayerNum = #UGCGameSystem.GetAllPlayerController()
-- if PlayerNum == 0 then
-- return true
-- end
--
-- local TeamModeType = GlobalConfigs.GameModeSetting.TeamModeType
-- if TeamModeType == CustomEnum.ETeamMode.PersonalWarfare then
-- if PlayerNum <= 1 then
-- return true
-- end
-- elseif TeamModeType == CustomEnum.ETeamMode.PartyMode then
-- return false
-- elseif TeamModeType == CustomEnum.ETeamMode.TeamSports or TeamModeType == CustomEnum.ETeamMode.BurstMode then
-- local TeamIDs = UGCTeamSystem.GetTeamIDs()
-- if #TeamIDs <= 1 then
-- return true
-- end
-- local Team1Player = UGCTeamSystem.GetPlayerKeysByTeamID(1)
-- local Team2Player = UGCTeamSystem.GetPlayerKeysByTeamID(2)
-- local Team1HasPlayer, Team2HasPlayer = false, false
-- for i, v in pairs(Team1Player) do
-- if UGCGameSystem.GetPlayerControllerByPlayerKey(v) then
-- Team1HasPlayer = true
-- break
-- end
-- end
-- if not Team1HasPlayer then
-- return true
-- end
-- for i, v in pairs(Team2Player) do
-- if UGCGameSystem.GetPlayerControllerByPlayerKey(v) then
-- Team2HasPlayer = true
-- break
-- end
-- end
-- if not Team2HasPlayer then
-- return true
-- end
-- end
-- end
-- return false
--end
return EventAction_PlayerExit