public void Update(Status status, IIsaacReader reader) { if (MainWindow.IsShuttingDown) { return; } Dispatcher.Invoke(() => { if (!status.Ready) { Reset(); return; } var pool = reader.GetPillPool(); if (!pool.Any()) { Reset(); return; } var seed = reader.GetSeed(); if (seed == 0) { Reset(); return; } var pillKnowledge = reader.GetPillKnowledge(); var hasPhd = reader.HasItem(new Item(75)); var considerCache = pillKnowledge.Any(known => known); // any pill known if (considerCache) { if (!_pillKnowledgeCache.ContainsKey(seed)) { _pillKnowledgeCache[seed] = new List <bool>() { false, false, false, false, false, false, false, false, false, false, false, false, false }; } var cache = _pillKnowledgeCache[seed]; if (hasPhd) { var isPill = reader.IsPillOrCard() == Consumable.Pill; var pillIndex = reader.GetPillCardId(); if (isPill && pillIndex > 0 && pillIndex <= 13) { cache[pillIndex - 1] = true; } pillKnowledge = cache; } else { for (var i = 0; i < 13; i++) { cache[i] = pillKnowledge[i]; } } } var toGoodPills = hasPhd || reader.HasItem(new Item(303)); if (PillPanel.Children.Count != pool.Count) { InitPills(pool, pillKnowledge, toGoodPills); } else { UpdatePills(pool, pillKnowledge, toGoodPills); } var lastPillIndex = reader.IndexOfLastPillTaken(); if (lastPillIndex == 0 || pool.Count < lastPillIndex) { Model.LastPillVisibility = Visibility.Hidden; } else { Item lastPill = null; if (lastPillIndex > 0 && lastPillIndex <= 13) { lastPill = pool[lastPillIndex - 1]; } SetPill(LastPill.Model, lastPill, lastPillIndex, true, toGoodPills); Model.LastPillVisibility = Visibility.Visible; } }); }