internal void Update() { if (NPCLoader.NPCCount - 1 != npcSlots.Count) { // should only happen once npcSlots.Clear(); for (int type = 1; type < NPCLoader.NPCCount; type++) { NPC npc = new NPC(); npc.SetDefaults(type); var slot = new UINPCSlot(npc); npcSlots.Add(slot); } } if (!updateNeeded) { return; } updateNeeded = false; npcGrid.Clear(); for (int type = 1; type < NPCLoader.NPCCount; type++) { var slot = npcSlots[type - 1]; if (PassNPCFilters(slot)) { npcGrid._items.Add(slot); npcGrid._innerList.Append(slot); } } npcGrid.UpdateOrder(); npcGrid._innerList.Recalculate(); lootGrid.Clear(); if (queryLootNPC != null) { var drops = queryLootNPC.GetDrops(); if (NewLootOnlyRadioButton.Selected && RecipeBrowserUI.instance.foundItems != null) { drops.RemoveWhere(x => RecipeBrowserUI.instance.foundItems[x]); } foreach (var dropitem in drops) { Item item = new Item(); item.SetDefaults(dropitem, false); var slot = new UIBestiaryItemSlot(item); lootGrid._items.Add(slot); lootGrid._innerList.Append(slot); } } lootGrid.UpdateOrder(); lootGrid._innerList.Recalculate(); }
private bool PassNPCFilters(UINPCSlot slot) { if (EncounteredRadioButton.Selected) { int bannerID = Item.NPCtoBanner(slot.npc.BannerID()); if (bannerID > 0) { if (NPC.killCount[bannerID] <= 0) { return(false); } } else { return(false); } } if (HasLootRadioButton.Selected) { // Slow, AnyDrops or Cache results. if (slot.GetDrops().Count == 0) { return(false); } } if (NewLootOnlyRadioButton.Selected) { // Item Checklist integration if (RecipeBrowserUI.instance.foundItems != null) { bool hasNewItem = false; var drops = slot.GetDrops(); foreach (var item in drops) { if (!RecipeBrowserUI.instance.foundItems[item]) { hasNewItem = true; break; } } if (!hasNewItem) { return(false); } } else { Main.NewText("How is this happening?"); } } if (RecipeBrowserUI.modIndex != 0) { if (slot.npc.modNPC == null) { return(false); } if (slot.npc.modNPC.mod.Name != RecipeBrowserUI.instance.mods[RecipeBrowserUI.modIndex]) { return(false); } } if (!queryItem.item.IsAir) { if (!slot.GetDrops().Contains(queryItem.item.type)) { return(false); } } if (Lang.GetNPCNameValue(slot.npcType).IndexOf(npcNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1) { return(false); } return(true); }