private static void AddItemsForTest( AvatarState avatarState, IRandom random, CostumeItemSheet costumeItemSheet, MaterialItemSheet materialItemSheet, EquipmentItemSheet equipmentItemSheet ) { foreach (var row in costumeItemSheet.OrderedList) { avatarState.inventory.AddItem2(ItemFactory.CreateCostume(row, random.GenerateRandomGuid())); } foreach (var row in materialItemSheet.OrderedList) { avatarState.inventory.AddItem2(ItemFactory.CreateMaterial(row), 10); if (row.ItemSubType == ItemSubType.Hourglass || row.ItemSubType == ItemSubType.ApStone) { avatarState.inventory.AddItem2(ItemFactory.CreateTradableMaterial(row), 100); } } foreach (var row in equipmentItemSheet.OrderedList.Where(row => row.Id > GameConfig.DefaultAvatarWeaponId)) { var itemId = random.GenerateRandomGuid(); avatarState.inventory.AddItem2(ItemFactory.CreateItemUsable(row, itemId, default)); } }
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(); } }