2025-01-04 23:00:19 +08:00

79 lines
2.4 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.

---@class UGCPlayerState_C:BP_UGCPlayerState_C
--Edit Below--
---@type UGCPlayerState_C
local UGCPlayerState = {
ScoreData = {Kill = 0, Dead = 0, Assist = 0, Score = 0, TechnicalScore = 0}; -- {Kill = int32, Dead = int32, Assist = int32, Score = int32, TechnicalScore = int32}
InjuryInfo = {} -- 其他玩家对自己的伤害[PlayerKey] = float
};
function UGCPlayerState:ReceiveBeginPlay()
self.SuperClass.ReceiveBeginPlay(self);
if UGCGameSystem.IsServer() then
-- UGCEventSystem.AddListener(EventEnum.PlayerInjuryInfo, self.UpdatePlayerInjuryInfo, self)
end
end
function UGCPlayerState:UpdatePlayerInjuryInfo(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
if CauserKey ~= self.PlayerKey then
if self.InjuryInfo[CauserKey] then
self.InjuryInfo[CauserKey] = self.InjuryInfo[CauserKey] + DamageValue
else
self.InjuryInfo[CauserKey] = DamageValue
end
end
end
--- 玩家即将死亡时可向PlayerState获取助攻玩家信息会忽略掉击杀者
function UGCPlayerState:GetAssister(KillerPlayerKey, MinAssistDamage)
local ResPlayerKey, Damage = -1, 0.
for PlayerKey, PlayerDamage in pairs(self.InjuryInfo) do
if PlayerKey ~= KillerPlayerKey and PlayerDamage > MinAssistDamage then
if ResPlayerKey < 0 or PlayerDamage > Damage then
ResPlayerKey = PlayerKey
Damage = PlayerDamage
end
end
end
return ResPlayerKey
end
function UGCPlayerState:GetScore()
return self.ScoreData.Score
end
function UGCPlayerState:SetScore(NewSocre)
self.ScoreData.Score = NewSocre
end
function UGCPlayerState:GetTechnicalScore()
return self.ScoreData.TechnicalScore
end
function UGCPlayerState:SetTechnicalScore(NewSocre)
self.ScoreData.TechnicalScore = NewSocre
end
function UGCPlayerState:PlayerKill(DeadPlayerKey, WeaponID)
self.ScoreData.Kill = self.ScoreData.Kill + 1
end
function UGCPlayerState:PlayerAssist()
self.ScoreData.Assist = self.ScoreData.Assist + 1
end
function UGCPlayerState:PlayerDead(KillerPlayerKey)
self.ScoreData.Dead = self.ScoreData.Dead + 1
self.InjuryInfo = {}
end
function UGCPlayerState:ResetPlayerState()
self.ScoreData = {Kill = 0, Dead = 0, Assist = 0, Score = 0, TechnicalScore = 0}
self.InjuryInfo = {}
end
function UGCPlayerState:ResetInjuryInfo()
self.InjuryInfo = {}
end
return UGCPlayerState;