UGCProjects/InfFire/Script/Blueprint/UGCPlayerState.lua
2025-01-14 17:23:50 +08:00

67 lines
2.2 KiB
Lua

---@class UGCPlayerState_C:BP_UGCPlayerState_C
--Edit Below--
---@type UGCPlayerState_C
local UGCPlayerState = {};
UGCPlayerState.WeaponInfiniteType = 0;
function UGCPlayerState:ReceiveBeginPlay()
self.OnCurrentPlayerKillNumChangedDelegate:Add(self.OnKillNumChange, self);
end
function UGCPlayerState:OnKillNumChange(KillCount,bIsAI)
if IsClient then
-- 同步击杀数
UGCLogSystem.Log("[UGCPlayerState:OnKillNumChange] 击杀数 %d", KillCount)
end
end
--- 操作是一旦使用了换装备的按钮,就会调用该函数,之后玩家添加的时候就会使用该配置
---@param InWeapon ASTExtraWeapon
function UGCPlayerState:UpdateWeaponAttachment(Pawn, InWeapon)
-- 获取玩家的缓存
UGCLogSystem.Log("[UGCPlayerState:UpdateWeaponAttachment] 执行")
UGCLogSystem.LogTree(string.format("[UGCPlayerState:UpdateWeaponAttachment] Player Archive ="), ArchiveTable[self.PlayerKey])
if table.isEmpty(ArchiveTable[self.PlayerKey]) then ArchiveTable[self.PlayerKey] = {}; end
if table.isEmpty(ArchiveTable[self.PlayerKey].Weapons) then ArchiveTable[self.PlayerKey].Weapons = {}; end
local ItemId = InWeapon:GetWeaponItemID();
local Weapon = UGCWeaponManagerSystem.GetCurrentWeapon(Pawn);
local Parts = ItemTool.GetWeaponParts(Weapon);
ArchiveTable[self.PlayerKey].Weapons[ItemId] = Parts;
UGCLogSystem.Log("[UGCPlayerState:UpdateWeaponAttachment] 更新配件");
-- 直接保存即可(主要是没几把枪)
UGCPlayerStateSystem.SavePlayerArchiveData(AccountTable[self.PlayerKey].UID, ArchiveTable[self.PlayerKey]);
end
--function UGCPlayerState:GetReplicatedProperties()
-- return ;
--end
---@param InType EFillBulletType
function UGCPlayerState:SetInfiniteType(InType)
self.WeaponInfiniteType = InType;
DOREPONCE(self, "WeaponInfiniteType");
end
function UGCPlayerState:GetInfiniteType() return self.WeaponInfiniteType; end
--- 重置击杀数
function UGCPlayerState:ResetKillNum()
-- 重置击杀数
self.Kills = 0;
self.KillPlayerNum = 0;
DOREPONCE(self, "Kills")
DOREPONCE(self, "KillPlayerNum")
end
function UGCPlayerState:ResetGame()
self:ResetKillNum();
end
--[[
function UGCPlayerState:GetAvailableServerRPCs()
return
end
--]]
return UGCPlayerState;