private static void AddCustomEquipment( AvatarState avatarState, IRandom random, SkillSheet skillSheet, EquipmentItemSheet equipmentItemSheet, EquipmentItemOptionSheet equipmentItemOptionSheet, int level, int recipeId, params int[] optionIds ) { if (!equipmentItemSheet.TryGetValue(recipeId, out var equipmentRow)) { return; } var itemId = random.GenerateRandomGuid(); var equipment = (Equipment)ItemFactory.CreateItemUsable(equipmentRow, itemId, 0, level); var optionRows = new List <EquipmentItemOptionSheet.Row>(); foreach (var optionId in optionIds) { if (!equipmentItemOptionSheet.TryGetValue(optionId, out var optionRow)) { continue; } optionRows.Add(optionRow); } AddOption(skillSheet, equipment, optionRows, random); avatarState.inventory.AddItem2(equipment); }
public static void AddItem(CostumeItemSheet costumeItemSheet, EquipmentItemSheet equipmentItemSheet, EquipmentItemOptionSheet optionSheet, SkillSheet skillSheet, MaterialItemSheet materialItemSheet, ConsumableItemSheet consumableItemSheet, IRandom random, Item item, AddedItemInfo addedItemInfo, AvatarState avatarState) { switch (item.ItemSubType) { case ItemSubType.FullCostume: case ItemSubType.HairCostume: case ItemSubType.EarCostume: case ItemSubType.EyeCostume: case ItemSubType.TailCostume: case ItemSubType.Title: if (costumeItemSheet.TryGetValue(item.ID, out var costumeRow)) { var costume = ItemFactory.CreateCostume(costumeRow, addedItemInfo.TradableId); avatarState.inventory.AddItem(costume); } break; case ItemSubType.Weapon: case ItemSubType.Armor: case ItemSubType.Belt: case ItemSubType.Necklace: case ItemSubType.Ring: if (equipmentItemSheet.TryGetValue(item.ID, out var equipmentRow)) { var equipment = (Equipment)ItemFactory.CreateItemUsable(equipmentRow, addedItemInfo.TradableId, 0, item.Level); if (item.OptionIds.Length > 0) { var optionRows = new List <EquipmentItemOptionSheet.Row>(); foreach (var optionId in item.OptionIds) { if (!optionSheet.TryGetValue(optionId, out var optionRow)) { continue; } optionRows.Add(optionRow); } AddOption(skillSheet, equipment, optionRows, random); } avatarState.inventory.AddItem(equipment); } break; case ItemSubType.Hourglass: case ItemSubType.ApStone: if (materialItemSheet.TryGetValue(item.ID, out var materialRow)) { var material = ItemFactory.CreateTradableMaterial(materialRow); avatarState.inventory.AddItem(material, item.Count); addedItemInfo.TradableId = material.TradableId; } break; case ItemSubType.Food: if (consumableItemSheet.TryGetValue(item.ID, out var consumableRow)) { var consumable = (Consumable)ItemFactory.CreateItemUsable(consumableRow, addedItemInfo.TradableId, 0, item.Level); avatarState.inventory.AddItem(consumable); } break; default: throw new ArgumentOutOfRangeException(); } }