public void UpdateReachableLocations(string newThing = null) { if (newThing != null) { pm.Add(newThing); updateQueue.Enqueue(newThing); } HashSet <string> potentialLocations; HashSet <string> potentialTransitions = new HashSet <string>(); while (updateQueue.Any()) { potentialLocations = LogicManager.GetLocationsByProgression(recentProgression); if (RandomizerMod.Instance.Settings.RandomizeTransitions) { potentialTransitions = LogicManager.GetTransitionsByProgression(recentProgression); } recentProgression = new HashSet <string>(); string item = updateQueue.Dequeue(); foreach (string location in potentialLocations) { if (pm.CanGet(location)) { reachableLocations.Add(location); if (vm.progressionLocations.Contains(location)) { vm.UpdateVanillaLocations(location); } } } if (RandomizerMod.Instance.Settings.RandomizeTransitions) { if (TransitionManager.transitionPlacements.TryGetValue(item, out string transition1) && !pm.Has(transition1)) { pm.Add(transition1); updateQueue.Enqueue(transition1); } foreach (string transition in potentialTransitions) { if (!pm.Has(transition) && pm.CanGet(transition)) { pm.Add(transition); updateQueue.Enqueue(transition); if (TransitionManager.transitionPlacements.TryGetValue(transition, out string transition2) && !pm.Has(transition2)) { pm.Add(transition2); updateQueue.Enqueue(transition2); } } } } } }
private HashSet <string> FakeUpdateReachableTransitions(string newThing = null, ProgressionManager _pm = null) { if (_pm != null) { pm = _pm; } if (newThing == null) { newThing = Randomizer.startTransition; } Queue <string> updates = new Queue <string>(); HashSet <string> reachable = new HashSet <string>(reachableTransitions); reachable.Add(newThing); pm.AddTemp(newThing); updates.Enqueue(newThing); while (updates.Any()) { string next = updates.Dequeue(); foreach (string transition in LogicManager.GetTransitionsByProgression(recentProgression)) { if (!reachable.Contains(transition) && pm.CanGet(transition)) { reachable.Add(transition); pm.AddTemp(transition); updates.Enqueue(transition); if (transitionPlacements.TryGetValue(transition, out string transition2)) { reachable.Add(transition2); pm.AddTemp(transition2); updates.Enqueue(transition2); } } } if (!updates.Any()) // check vanilla items last, because these almost never change { foreach (string loc in LogicManager.GetLocationsByProgression(recentProgression)) { if (!vanillaProgression.Contains(loc) && !checkProgression.Contains(loc)) { continue; } if (!pm.Has(loc) && pm.CanGet(loc)) { pm.AddTemp(loc); updates.Enqueue(loc); } } } } reachable.ExceptWith(reachableTransitions); pm.RemoveTempItems(); return(reachable); }