140 lines
3.3 KiB
Lua
140 lines
3.3 KiB
Lua
---@class UGCPlayerState_C:BP_UGCPlayerState_C
|
||
--Edit Below--
|
||
---@type UGCPlayerState_C
|
||
local UGCPlayerState = {
|
||
--PluginData = {};
|
||
|
||
--- {
|
||
--- LoginTimes = 0;
|
||
---}
|
||
---@type table
|
||
ArchiveData = nil;
|
||
AccountInfo = nil;
|
||
|
||
---@type table<int32, table<PlayerKey, float>> { { PlayerKey, AddTime }, }
|
||
KillAssists = {};
|
||
};
|
||
|
||
--[[
|
||
function UGCPlayerState:ReceiveBeginPlay()
|
||
self.SuperClass.ReceiveBeginPlay(self);
|
||
end
|
||
--]]
|
||
|
||
function UGCPlayerState:ReceiveTick(DeltaTime)
|
||
self.SuperClass.ReceiveTick(self, DeltaTime);
|
||
|
||
if self:HasAuthority() then
|
||
if table.isEmpty(self.KillAssists) then
|
||
return;
|
||
end
|
||
local RemoveIndies = {};
|
||
local ServerTime = KismetSystemLibrary.GetGameTimeInSeconds(self);
|
||
for i, v in pairs(self.KillAssists) do
|
||
if v.AddTime ~= nil and v.AddTime + DefaultSettings.AssistTime <= ServerTime then
|
||
RemoveIndies[#RemoveIndies + 1] = i;
|
||
end
|
||
end
|
||
|
||
if not table.isEmpty(RemoveIndies) then
|
||
for i = table.getCount(RemoveIndies), 1, -1 do
|
||
self.KillAssists[RemoveIndies[i]] = nil;
|
||
end
|
||
RemoveIndies = {};
|
||
end
|
||
end
|
||
end
|
||
|
||
--[[
|
||
function UGCPlayerState:ReceiveEndPlay()
|
||
self.SuperClass.ReceiveEndPlay(self);
|
||
end
|
||
--]]
|
||
|
||
function UGCPlayerState:GetReplicatedProperties()
|
||
return
|
||
{ "ArchiveData", "Lazy" },
|
||
{ "AccountInfo", "Lazy" }
|
||
end
|
||
|
||
--[[
|
||
function UGCPlayerState:GetAvailableServerRPCs()
|
||
return
|
||
end
|
||
--]]
|
||
|
||
--- 重置玩家
|
||
function UGCPlayerState:ResetPlayer()
|
||
|
||
end
|
||
|
||
-- 初始化存档
|
||
function UGCPlayerState:InitArchive()
|
||
self.ArchiveData = {
|
||
-- 登录次数
|
||
LoginTimes = 0;
|
||
SoldierSelect = {}; -- 不同兵种选择
|
||
Scores = {};
|
||
}
|
||
end
|
||
|
||
-- 加载存档
|
||
function UGCPlayerState:LoadArchiveData(InData)
|
||
print(string.format("[UGCPlayerState:LoadArchive] 加载存档"))
|
||
if InData == nil or table.isEmpty(InData) then
|
||
self:InitArchive();
|
||
else
|
||
UGCLogSystem.LogTree("[UGCPlayerState:LoadArchive] InData = ", InData)
|
||
self.ArchiveData = InData
|
||
end
|
||
-- 立刻同步一下
|
||
DOREPONCE(self, "ArchiveData");
|
||
UnrealNetwork.CallUnrealRPC(self, self, "Client_LoadArchive", self.ArchiveData);
|
||
end
|
||
|
||
---@param InWeapon ASTExtraWeapon
|
||
function UGCPlayerState:UpdateWeaponAttachment(Pawn, InWeapon)
|
||
-- 获取玩家的缓存
|
||
UGCLogSystem.Log("[UGCPlayerState:UpdateWeaponAttachment] 执行")
|
||
local ArchiveData = UGCPlayerStateSystem.GetPlayerArchiveData(self.UID);
|
||
if table.isEmpty(ArchiveData) then ArchiveData = {}; end
|
||
if ArchiveData.Weapons == nil then ArchiveData.Weapons = {}; end
|
||
local ItemId = InWeapon:GetWeaponItemID();
|
||
local Weapon = UGCWeaponManagerSystem.GetCurrentWeapon(Pawn);
|
||
local Parts = ItemTool.GetWeaponParts(Weapon);
|
||
ArchiveData.Weapons[ItemId] = Parts;
|
||
UGCPlayerStateSystem.SavePlayerArchiveData(self.UID, ArchiveData);
|
||
end
|
||
|
||
function UGCPlayerState:Client_LoadArchive(InData)
|
||
end
|
||
|
||
---@param InData PlayerAccountInfo
|
||
function UGCPlayerState:LoadAccountInfo(InData)
|
||
self.AccountInfo = InData;
|
||
DOREPONCE(self, "AccountInfo");
|
||
end
|
||
|
||
function UGCPlayerState:OnRep_ArchiveData()
|
||
if self.ArchiveData == nil then
|
||
return;
|
||
end
|
||
end
|
||
|
||
function UGCPlayerState:GetArchiveData()
|
||
return self.ArchiveData;
|
||
end
|
||
|
||
--- 直接加载对应头像
|
||
function UGCPlayerState:OnRep_AccountInfo()
|
||
end
|
||
|
||
function UGCPlayerState:GetKillAssists()
|
||
return self.KillAssists;
|
||
end
|
||
|
||
function UGCPlayerState:ClearKillAssist()
|
||
self.KillAssists = {};
|
||
end
|
||
|
||
return UGCPlayerState; |