Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a unique image that is loaded asynchronously.
 /// This image is used as default as long as the loading is not done and in case it fails.
 /// </summary>
 public ItemImage AsDefaultForUniqueImage(ItemImageService itemImageService, string uniqueName)
 {
     return(new ItemImage(
                ImageSource.Result,
                itemImageService.LoadItemImageAsync(uniqueName, ImageSource.Task),
                "Loading of unique item image failed"
                ));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns an image that is loaded asynchronously from an url. Only urls stored in an item's json as
 /// retrieved from the official api are supported. This image is used as default as long as
 /// the loading is not done and in case it fails.
 /// </summary>
 public ItemImage AsDefaultForImageFromUrl(ItemImageService itemImageService, string imageUrl)
 {
     return(new ItemImage(
                ImageSource.Result,
                itemImageService.LoadFromUrlAsync(MakeUrl(imageUrl), ImageSource.Task),
                "Downloading of item image from official url failed"
                ));
 }
Exemplo n.º 4
0
        /// <summary>
        /// Represents an image for an item base. First the classes's image will be loaded synchronously,
        /// which is then used as the image until the base item's image is loaded asynchronously.
        /// </summary>
        public ItemImage(ItemImageService itemImageService, string baseName, ItemClass baseClass)
        {
            var defaultImage = itemImageService.LoadDefaultImage(baseClass);

            ImageSource = NewImageSourceTask(
                itemImageService.LoadItemImageAsync(baseName, Task.FromResult(defaultImage)),
                "Loading of base item image failed",
                defaultImage
                );
        }
Exemplo n.º 5
0
        /// <summary>
        /// Represents an image for an item class. The image will be loaded synchronously.
        /// </summary>
        public ItemImage(ItemImageService itemImageService, ItemClass baseClass)
        {
            var defaultImage = itemImageService.LoadDefaultImage(baseClass);

            ImageSource = NewImageSourceTask(
                Task.FromResult(defaultImage),
                "Exception in completed task",
                defaultImage
                );
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
#pragma warning disable CS8618 // Initialization takes place in InitializeAsync
        private EquipmentData(Options options)
#pragma warning restore
        {
            _itemImageService = new ItemImageService(options);
        }
Exemplo n.º 9
0
 private EquipmentData(Options options)
 {
     _itemImageService = new ItemImageService(options);
 }