private async Task <IEnumerable <Item> > LoadItems(IEnumerable <DestinyItemComponent> itemComponents, IDictionary <long, DestinyItemInstanceComponent> itemInstances) { var items = new List <Item>(); foreach (var itemComponent in itemComponents) { var itemDef = await _manifest.LoadInventoryItem(itemComponent.ItemHash); var bucket = await _manifest.LoadBucket(itemDef.Inventory.BucketTypeHash); if (!ShouldInclude(bucket)) { continue; } string iconUrl = null; if (itemComponent.OverrideStyleItemHash != null && !_defaultOrnaments.Contains(itemComponent.OverrideStyleItemHash.Value)) { var overrideIcon = await _manifest.LoadInventoryItem(itemComponent.OverrideStyleItemHash.Value); iconUrl = overrideIcon.DisplayProperties.Icon; } var watermark = GetWatermarkIcon(itemDef); itemInstances.TryGetValue(itemComponent.ItemInstanceId, out DestinyItemInstanceComponent instance); items.Add(new Item(_bungie.Value.BaseUrl, itemComponent, itemDef, bucket, instance, iconUrl, watermark)); } return(items); }
private static async Task <IEnumerable <Item> > ParseItems(IEnumerable <DestinyItemComponent> unparsedItems, IManifest manifest) { var items = await Task.WhenAll((await Task.WhenAll(unparsedItems.Select(async item => { var bucket = await manifest.LoadBucket(item.BucketHash); if (bucket.Category != BucketCategory.Equippable) { return(null); } return(item); }))).Where(i => i != null).Select(item => Item.BuildItem(item))); return(items.Where(i => i.Type == DestinyItemType.Armor || i.Type == DestinyItemType.Weapon)); }
public async Task <IEnumerable <Item> > GetEngrams(IEnumerable <DestinyItemComponent> inventory, IDictionary <long, DestinyItemInstanceComponent> itemInstances) { var engramItemComponents = inventory.Where(itemComponent => itemComponent.BucketHash == (uint)ItemSlot.SlotHashes.Engrams); var bucket = await _manifest.LoadBucket((uint)ItemSlot.SlotHashes.Engrams); var tasks = engramItemComponents.Select(async itemComponent => { var itemDef = await _manifest.LoadInventoryItem(itemComponent.ItemHash); itemInstances.TryGetValue(itemComponent.ItemInstanceId, out DestinyItemInstanceComponent instance); return(new Item(_bungie.Value.BaseUrl, itemComponent, itemDef, bucket, instance)); }); return(await Task.WhenAll(tasks)); }
public ManifestCache(IManifest manifest) { _manifest = manifest; _itemDefs = new Cache <DestinyInventoryItemDefinition>(hash => _manifest.LoadInventoryItem(hash)); _bucketDefs = new Cache <DestinyInventoryBucketDefinition>(hash => _manifest.LoadBucket(hash)); _statDefs = new CollectionCache <DestinyStatDefinition>(hashes => _manifest.LoadStats(hashes)); _socketCategoryDefs = new Cache <DestinySocketCategoryDefinition>(hash => _manifest.LoadSocketCategory(hash)); _itemCategoryDefs = new CollectionCache <DestinyItemCategoryDefinition>(hashes => _manifest.LoadItemCategories(hashes)); _socketTypeDefs = new Cache <DestinySocketTypeDefinition>(hash => _manifest.LoadSocketType(hash)); _plugDefs = new Cache <DestinyInventoryItemDefinition>(hash => _manifest.LoadPlug(hash)); }