add weapon parts

This commit is contained in:
Naruse
2026-04-30 17:18:23 +08:00
parent 49f4fdfda5
commit 2883ac3d41
12 changed files with 182 additions and 7 deletions

View File

@@ -312,4 +312,25 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
return callInfo;
}
public async ValueTask<BaseGameItemInfo?> AddWeaponPartItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
{
if (genre != ItemTypeEnum.TYPE_WEAPON_PART) return null;
var weaponPartData = GameData.WeaponPartsData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
if (weaponPartData == null) return null;
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
var weaponPartInfo = new BaseGameItemInfo
{
TemplateId = templateId,
UniqueId = InventoryData.NextUniqueUid++,
ItemType = genre,
ItemCount = 1
};
InventoryData.Items[weaponPartInfo.UniqueId] = weaponPartInfo;
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([weaponPartInfo]));
return weaponPartInfo;
}
}