UGCProjects/EnergyHuntingGround/Script/Global/EventManager/EventAction/EventAction_RespiratoryRegurgitation.lua
2025-01-04 23:00:19 +08:00

47 lines
1.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local EventAction_RespiratoryRegurgitation = {
AddHealthFrequency = 5;
ReplyPerSecond = 10.;
WaitAddHealthTime = 5.;
PlayerVictimTime = {};
UpdateAddTime = 0;
}
-- 触发器激活时将执行Action的Execute
function EventAction_RespiratoryRegurgitation:Execute(...)
UGCEventSystem.AddListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_Execute]")
self.bEnableActionTick = true
return true
end
function EventAction_RespiratoryRegurgitation:Update(DeltaSeconds)
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_Update]")
self.UpdateAddTime = self.UpdateAddTime + DeltaSeconds
if self.UpdateAddTime >= (1. / self.AddHealthFrequency) then
self.UpdateAddTime = self.UpdateAddTime - 1. / self.AddHealthFrequency
self:AddPlayerHealth()
end
end
function EventAction_RespiratoryRegurgitation:PlayerInjuryInfo(VictimKey)
self.PlayerVictimTime[VictimKey] = UGCSystemLibrary.GetGameTime()
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_PlayerInjuryInfo]")
end
function EventAction_RespiratoryRegurgitation:AddPlayerHealth()
local AllPlayer = UGCGameSystem.GameState:GetRespiratoryRegurgitationPlayers()
local NowTime = UGCSystemLibrary.GetGameTime()
for k, PlayerKey in pairs(AllPlayer) do
local PlayerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey)
if UE.IsValid(PlayerPawn) and PlayerKey and PlayerPawn:IsAlive()
and (self.PlayerVictimTime[PlayerKey] == nil or (NowTime - self.PlayerVictimTime[PlayerKey] >= self.WaitAddHealthTime)) then
UGCPawnAttrSystem.SetHealth(PlayerPawn, UGCPawnAttrSystem.GetHealth(PlayerPawn) + self.ReplyPerSecond / self.AddHealthFrequency)
end
end
end
return EventAction_RespiratoryRegurgitation