Beispiel #1
0
        public static ItemSet Parse(WZProperty set)
        {
            ItemSet result = new ItemSet();
            ILookup <int, ItemNameInfo> itemNameLookup = ItemNameInfo.GetNameLookup(set.ResolveOutlink("String"));

            result.SetName       = set.ResolveForOrNull <string>("setItemName");
            result.CompleteCount = set.ResolveFor <int>("completeCount") ?? 1;
            result.RequiredItems = set.Resolve("ItemID").Children.Select(c =>
            {
                if (c.Type == PropertyType.SubProperty)
                {
                    return(c.Children.Where(b => int.TryParse(b.NameWithoutExtension, out int blah)).Select(b => b.ResolveFor <int>() ?? -1));
                }
                else
                {
                    return new int[] { c.ResolveFor <int>() ?? -1 }
                };
            }).Select(c => c.Select(b => itemNameLookup[b].First()));

            return(result);
        }
        public static ILookup <int, ItemNameInfo> GetNameLookup(WZProperty stringFile)
        {
            ILookup <int, ItemNameInfo> itemNameLookup = null;

            if (stringFile.FileContainer.Collection.VersionCache.TryGetValue("itemNameLookup", out object itemNameLookupCached))
            {
                itemNameLookup = (ILookup <int, ItemNameInfo>)itemNameLookupCached;
            }
            else
            {
                itemNameLookup = (stringFile.Resolve("Eqp.img/Eqp") ?? stringFile.Resolve("Item/Eqp")).Children
                                 .SelectMany(c => c.Children)
                                 //Etc
                                 .Concat((stringFile.Resolve("Etc.img/Etc") ?? stringFile.Resolve("Item.img/Etc")).Children)
                                 //Cash
                                 .Concat((stringFile.Resolve("Cash.img") ?? stringFile.Resolve("Item.img/Cash")).Children)
                                 //Ins
                                 .Concat((stringFile.Resolve("Ins.img") ?? stringFile.Resolve("Item.img/Ins")).Children)
                                 //Consume
                                 .Concat((stringFile.Resolve("Consume.img") ?? stringFile.Resolve("Item.img/Con")).Children)
                                 //Pet
                                 .Concat((stringFile.Resolve("Pet.img") ?? stringFile.Resolve("Item.img/Pet")).Children)
                                 .ToLookup(c => int.Parse(c.NameWithoutExtension), c => ItemNameInfo.Parse(c));
                stringFile.FileContainer.Collection.VersionCache.AddOrUpdate("itemNameLookup", itemNameLookup, (a, b) => b);
            }

            return(itemNameLookup);
        }