Example #1
0
        private IndexSummary BuildIndex(Action <string> stateChangeCallback)
        {
            _index.Clear();
            var summary = new IndexSummary();

            foreach (var c in _characters)
            {
                stateChangeCallback("Indexing " + c.Header.Name);
                BuildEquippedIndexItems(c, c.Inventory.Equipment, summary);
                BuildEquippedIndexItems(c, c.Inventory.Weapon1, summary);
                BuildEquippedIndexItems(c, c.Inventory.Weapon2, summary);

                int bagIndex = 1;
                foreach (var e in c.Inventory.Sacks)
                {
                    BuildUnequippedIndexItems(c, e.Items.ToArray(), summary, "Bag " + (bagIndex++));
                }

                bagIndex = 1;
                foreach (var e in c.Stash.stashPages)
                {
                    BuildUnequippedIndexItems(c, e.items.ToArray(), summary, "Stash " + (bagIndex++));
                }
            }

            return(summary);
        }
Example #2
0
        private void BuildUnequippedIndexItems(CharacterFile c, Item[] items, IndexSummary summary, string bagName)
        {
            foreach (var e in items)
            {
                if (e == null)
                {
                    continue;
                }

                var item = BuildIndexItem(e, c);
                if (item != null)
                {
                    item.Bag = bagName;
                }

                AddIndexItem(item, summary);
            }
        }
Example #3
0
        private void BuildEquippedIndexItems(CharacterFile c, Item[] equipment, IndexSummary summary)
        {
            foreach (var e in equipment)
            {
                if (e == null)
                {
                    continue;
                }

                var item = BuildIndexItem(e, c);
                if (item != null)
                {
                    item.Bag        = "Equipped";
                    item.IsEquipped = true;
                }

                AddIndexItem(item, summary);
            }
        }
Example #4
0
        private void AddIndexItem(IndexItem item, IndexSummary summary)
        {
            if (item != null)
            {
                var itemType = ItemHelper.GetItemType(item.Source);
                if (new string[] {
                    "OneShot_PotionMana",
                    "OneShot_PotionHealth",
                    "OneShot_Scroll",
                    "ItemEnchantment",
                    "QuestItem",
                    "ItemTransmuter",
                    "ItemNote"
                }.Contains(itemType))
                {
                    return;
                }

                summary.Entries++;

                var rarity = item.Rarity;
                if (rarity != null)
                {
                    summary.ItemRarities.Add(rarity);
                }

                if (itemType != null)
                {
                    summary.ItemTypes.Add(itemType);
                }

                if (item.Owner != null)
                {
                    summary.Characters.Add(item.Owner);
                }

                _index.Add(item);
            }
        }