public Tuple <ItemNameInfo, IconInfo, EquipInfo>[] BulkItemInfo(int[] itemIds) { WZProperty stringWz = WZ.Resolve("String"); ILookup <int, ItemNameInfo> nameLookup = ItemNameInfo.GetNameLookup(stringWz); return(itemIds.Select(c => { ItemNameInfo name = nameLookup[c].FirstOrDefault(); if (name != null) { return new Tuple <int, ItemNameInfo>(c, name); } return null; }).Where(c => c != null) .Select(c => { WZProperty info = GetItemNode(c.Item1).Resolve("info"); return new Tuple <ItemNameInfo, IconInfo, EquipInfo>(c.Item2, IconInfo.Parse(info), EquipInfo.Parse(info)); }) .ToArray()); }
public static Mob Parse(WZProperty stringWz, bool followLink = true) { int id; if (!int.TryParse(stringWz.NameWithoutExtension, out id)) { return(null); } Mob result = new Mob(); result.Id = id; result.mobImage = stringWz.ResolveOutlink($"Mob/{id.ToString("D7")}") ?? stringWz.ResolveOutlink($"Mob2/{id.ToString("D7")}"); result.Name = stringWz.ResolveForOrNull <string>("name"); result.Meta = result.mobImage.Children.Any(c => c.NameWithoutExtension.Equals("info")) ? MobMeta.Parse(result.mobImage.Resolve("info")) : null; result.LinksTo = result.Meta.LinksToOtherMob; result.Framebooks = result.mobImage.Children .Where(c => c.NameWithoutExtension != "info") .DistinctBy(c => c.NameWithoutExtension) .ToDictionary(c => c.NameWithoutExtension, c => FrameBook.GetFrameCount(c)); WZProperty familiarEntry = stringWz.ResolveOutlink($"String/MonsterBook/{id}"); result.Description = familiarEntry?.ResolveForOrNull <string>("episode"); ILookup <int, MapName> lookup = MapName.GetMapNameLookup(stringWz); result.FoundAt = stringWz.ResolveOutlink($"Etc/MobLocation/{id}")? .Children.Concat(familiarEntry?.Resolve("map")?.Children ?? (new Dictionary <string, WZProperty>()).Values) .Select(c => c.ResolveFor <int>() ?? -1).Distinct() .Select(c => lookup[c]?.FirstOrDefault() ?? new MapName() { Name = "Unknown", StreetName = "Unknown", Id = c }) .ToArray(); ILookup <int, ItemNameInfo> reportedDrops = ItemNameInfo.GetNameLookup(stringWz.ResolveOutlink("String")); result.Drops = familiarEntry?.Resolve("reward")?.Children .Select(c => c.ResolveFor <int>() ?? -1) .Select(c => reportedDrops[c]?.FirstOrDefault()) .Where(c => c != null) .ToArray(); List <int> linkFollowed = new List <int>(); Mob linked = result; while (followLink && linked.Meta.LinksToOtherMob.HasValue && !linkFollowed.Contains(linked.Meta.LinksToOtherMob.Value)) { linkFollowed.Add(linked.Meta.LinksToOtherMob.Value); linked = Parse(stringWz.ResolveOutlink($"String/Mob/{linked.Meta.LinksToOtherMob.Value}"), false); } if (linked != result) { result.Extend(linked); } return(result); }