/// <summary> /// Creates an ItemBase that sets <see cref="ItemClass"/> and <see cref="Tags"/> on /// a best effort basis. They might not be set correctly. /// <para/> /// Only <see cref="Name"/>, <see cref="ItemClass"/> and <see cref="Tags"/> may be called on /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent /// of the <see cref="Item"/> they are created for. /// </summary> /// <param name="itemImageService"></param> /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into. /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param> /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param> /// <param name="frameType">The frame type of the item.</param> public ItemBase(ItemImageService itemImageService, ItemSlot itemSlot, string typeLine, FrameType frameType) { // These don't matter as we won't create new items from this base. Level = 0; RequiredStrength = 0; RequiredDexterity = 0; RequiredIntelligence = 0; DropDisabled = false; InventoryHeight = 0; InventoryWidth = 0; MetadataId = ""; ImplicitMods = new List <IMod>(); _properties = new List <string>(); CanHaveQuality = false; Name = typeLine; ItemClass = ItemSlotToClass(itemSlot); if (ItemClass == ItemClass.ActiveSkillGem) { ItemClass = ItemClassEx.ItemClassForGem(typeLine); } if (ItemClass == ItemClass.Unknown) { if (frameType == FrameType.Gem) { ItemClass = ItemClassEx.ItemClassForGem(typeLine); } else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard || frameType == FrameType.QuestItem || frameType == FrameType.Prophecy) { ItemClass = ItemClass.Unknown; } else if (typeLine.Contains("Quiver")) { ItemClass = ItemClass.Quiver; } else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler")) { ItemClass = ItemClass.Shield; } else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman")) { ItemClass = ItemClass.Amulet; } else if (typeLine.Contains("Ring")) { ItemClass = ItemClass.Ring; } else if (typeLine.Contains("Belt")) { ItemClass = ItemClass.Belt; } } // This might miss some tags, but those are only important for mod crafting, // which will not happen with this item. Tags = ItemClass.ToTags(); Image = new ItemImage(itemImageService, ItemClass); }
public UniqueBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBase itemBase, XmlUnique xmlUnique) { UniqueName = xmlUnique.Name; Level = xmlUnique.Level; DropDisabled = xmlUnique.DropDisabled; _base = itemBase; _properties = xmlUnique.Properties; var explicits = new List <IMod>(); foreach (var id in xmlUnique.Explicit) { if (!modDatabase.Mods.TryGetValue(id, out var mod)) { Log.Error($"Unknown mod id {id} on unique {UniqueName}"); continue; } explicits.Add(mod); } ExplicitMods = explicits; Image = itemBase.Image.AsDefaultForUniqueImage(itemImageService, UniqueName); }
public ItemBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBaseDto xmlBase) { Level = xmlBase.Level; RequiredStrength = xmlBase.Strength; RequiredDexterity = xmlBase.Dexterity; RequiredIntelligence = xmlBase.Intelligence; DropDisabled = xmlBase.DropDisabled; InventoryHeight = xmlBase.InventoryHeight; InventoryWidth = xmlBase.InventoryWidth; Name = xmlBase.Name; ItemClass = xmlBase.ItemClass; Tags = xmlBase.Tags; MetadataId = xmlBase.MetadataId; ImplicitMods = xmlBase.Implicit.Select(id => modDatabase.Mods[id]).ToList(); _properties = xmlBase.Properties; CanHaveQuality = Tags.HasFlag(Tags.Weapon) || Tags.HasFlag(Tags.Armour); Image = new ItemImage(itemImageService, Name, ItemClass); MaximumNumberOfSockets = GetMaximumNumberOfSockets(); }