--[[ ---@field ItemID int32 ---@field ItemName FString ---@field ItemType int32 ---@field ItemSubType int32 ---@field BPID int32 ---@field Durability int32 ---@field Electricity int32 ---@field AIFullVaule int32 ---@field Equippable bool ---@field Consumable bool ---@field AutoEquipAndDrop bool ---@field MaxCount int32 ---@field WeightforOrder int32 ---@field WeightforOrder2 int32 ---@field UnitWeight_f float ---@field ItemBigIcon_n FName ---@field ItemSmallIcon_n FName ---@field ItemWhiteIcon_n FName ---@field ArmorySimpleDesc FString ---@field BackpackSimple FString ---@field ItemQuality int32 ---@field PickUpSound FString ---@field DropSound FString ---@field EquipSound FString ---@field UnEquipSound FString ---@field PickUpBank FString ---@field DropBank FString ---@field EquipBank FString ---@field UnEquipBank FString ---@field KillWhiteIcon FString ---@field StTime int32 ---@field ItemTypeBigWorld int32 ---@field BigWorldBackpackTab_n FName ---@field IsVirtualItem bool ---@field Droppable bool ---@field HomeBackpackTab_n FName ---@field Rarelevel int32 ---@field RarelevelEffPath FString ---@field CustomizedType FString ]] MyWeaponSystem = MyWeaponSystem or {} --- 异步加载Item小图标到Image画刷 function MyWeaponSystem.AsyncLoadItemSmallIconToBrush(InItemID, ImageWidget) MyWeaponSystem.AsyncLoadItemIconToBrush(InItemID, ImageWidget, "ItemSmallIcon_n") end --- 异步加载Item大图标到Image画刷 function MyWeaponSystem.AsyncLoadItemBigIconToBrush(InItemID, ImageWidget) MyWeaponSystem.AsyncLoadItemIconToBrush(InItemID, ImageWidget, "ItemBigIcon_n") end --- 异步加载Item白色剪影图标到Image画刷 function MyWeaponSystem.AsyncLoadItemWhiteIconToBrush(InItemID, ImageWidget) MyWeaponSystem.AsyncLoadItemIconToBrush(InItemID, ImageWidget, "ItemWhiteIcon_n") end --- 异步加载Item图标到Image画刷 function MyWeaponSystem.AsyncLoadItemIconToBrush(InItemID, ImageWidget, TexKey) local ItemInfo = UGCItemSystem.GetItemData(InItemID); if ItemInfo then UGCSystemLibrary.AsyncLoadAsset(ItemInfo[TexKey], function(Tex) if UE.IsValid(ImageWidget) then ImageWidget:SetBrushFromTexture(Tex); end end , nil ,true) end end --- 判断Item是否为武器的配件 function MyWeaponSystem.IsWeaponPartValid(InId) if InId == nil then return false; end return WeaponParts[InId] ~= nil; end --- 获取Item名 function MyWeaponSystem.GetItemName(InItemID) if InItemID == nil then return "" end if InItemID <= 0 then return "拳击" else local ItemInfo = UGCItemSystem.GetItemData(InItemID); if ItemInfo then return ItemInfo.ItemName end end UGCLogSystem.Log("[GetWeaponName]无法找到对应 Weapon ID: " .. InItemID) return "" end --- 获取配件Item是否为武器可用Item ---@param WeaponID int ---@param PartItemID int function MyWeaponSystem.PartIsWeaponCanBeUsed(WeaponID, PartItemID) if WeaponSuits[WeaponID] == nil then UGCLogSystem.LogError("[MyWeaponSystem_PartIsWeaponCanBeUsed]") return false end for i, v in pairs(WeaponSuits[WeaponID]) do for _, PartItemIDTemp in pairs(v) do if PartItemIDTemp == PartItemID then return true end end end return false end --- 获取武器最佳配件 function MyWeaponSystem.GetWeaponBastParts(InWeaponID) if WeaponTable.RecommendedWeaponParts[InWeaponID] then return WeaponTable.RecommendedWeaponParts[InWeaponID] end return {} end --- 获取武器可用配件 function MyWeaponSystem.GetWeaponCanUsePartFromPartType(WeaponID, PartType) if WeaponSuits[WeaponID] == nil then return {} end if WeaponSuits[WeaponID][PartType] == nil then return {} end return WeaponSuits[WeaponID][PartType] end --- 将配件列表转化为配件字典 Key为PartType Value为ItemID function MyWeaponSystem.PartListToPartMap(InPartList) local Res = {} for i, v in pairs(InPartList) do if WeaponParts[v] then Res[WeaponParts[v].Type] = v end end return Res end function MyWeaponSystem.GetPartType(InPartItemID) if WeaponParts[InPartItemID] then return WeaponParts[InPartItemID].Type end return nil end Weapon_LastGetWeaponIDTime = -1. Weapon_LastGetWeaponIDRes = {} -- PlayerKey = {} --- 获取配件Item是否为武器可用Item ---@param PlayerKey uint function MyWeaponSystem.GetPlayerShootWeaponIDs(PlayerKey) local NowTime = KismetSystemLibrary.GetGameTimeInSeconds(UGCGameSystem.GameState) if Weapon_LastGetWeaponIDTime == NowTime then if Weapon_LastGetWeaponIDRes[PlayerKey] then return Weapon_LastGetWeaponIDRes[PlayerKey] end else Weapon_LastGetWeaponIDTime = NowTime Weapon_LastGetWeaponIDRes = {} end local TargetPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey) local Res = {} if UE.IsValid(TargetPawn) then for i, v in pairs(ShootWeaponEnums) do local Weapon = UGCWeaponManagerSystem.GetWeaponBySlot(TargetPawn, v) if Weapon then Res[#Res + 1] = UGCWeaponManagerSystem.GetWeaponItemID(Weapon) end end end Weapon_LastGetWeaponIDRes[PlayerKey] = Res return Res end function MyWeaponSystem.GetItemWeaponAmmunitionItemID(WeaponID) return WeaponAmmunitionItem[WeaponID] end MyWeaponSystem.BackPackHandle1 = {} MyWeaponSystem.BackPackHandle2 = {} MyWeaponSystem.BackPackHandle3 = {} MyWeaponSystem.BackPackHandle4 = {} function MyWeaponSystem.UpdatePlayerBackPack(PlayerKey) -- 默认武器 if MyWeaponSystem.BackPackHandle1[PlayerKey] then UGCEventSystem.StopTimer(MyWeaponSystem.BackPackHandle1[PlayerKey]) end MyWeaponSystem.BackPackHandle1[PlayerKey] = UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() MyWeaponSystem.BackPackHandle1[PlayerKey] = nil UGCGameSystem.GameState:UpdatePlayerWeapon(PlayerKey) end, 1.) -- 默认装备 if MyWeaponSystem.BackPackHandle2[PlayerKey] then UGCEventSystem.StopTimer(MyWeaponSystem.BackPackHandle2[PlayerKey]) end MyWeaponSystem.BackPackHandle2[PlayerKey] = UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() MyWeaponSystem.BackPackHandle2[PlayerKey] = nil local DefaultBackPack = TableHelper.DeepCopy(UGCGameSystem.GameState:GetPlayerBeBornParts(PlayerKey)) UGCGameSystem.GameState:PlayerAddItemInfo(PlayerKey, DefaultBackPack) end, 2.) -- 校验玩家的武器和配件1次 if MyWeaponSystem.BackPackHandle3[PlayerKey] then UGCEventSystem.StopTimer(MyWeaponSystem.BackPackHandle3[PlayerKey]) end MyWeaponSystem.BackPackHandle3[PlayerKey] = UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() MyWeaponSystem.BackPackHandle3[PlayerKey] = nil UGCGameSystem.GameState:CheckWeaponAndParts(PlayerKey) end, 6.) -- 校验玩家的武器和配件2次 if MyWeaponSystem.BackPackHandle4[PlayerKey] then UGCEventSystem.StopTimer(MyWeaponSystem.BackPackHandle4[PlayerKey]) end MyWeaponSystem.BackPackHandle4[PlayerKey] = UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() MyWeaponSystem.BackPackHandle4[PlayerKey] = nil UGCGameSystem.GameState:CheckWeaponAndParts(PlayerKey) end, 8.) -- 补满武器弹夹 UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() UGCSystemLibrary.PlayerFullBullet(PlayerKey) end, 3.) end