private HashSet <string> FakeUpdateReachableTransitions(string newThing = "Tutorial_01[right1]", ProgressionManager _pm = null)
        {
            if (_pm != null)
            {
                pm = _pm;
            }

            Queue <string>   updates   = new Queue <string>();
            HashSet <string> reachable = new HashSet <string>(reachableTransitions);

            reachable.Add(newThing);
            pm.Add(newThing);
            updates.Enqueue(newThing);

            while (updates.Any())
            {
                string next = updates.Dequeue();
                foreach (string transition in LogicManager.GetTransitionsByProgression(next))
                {
                    if (!reachable.Contains(transition) && pm.CanGet(transition))
                    {
                        reachable.Add(transition);
                        pm.Add(transition);
                        updates.Enqueue(transition);
                        if (transitionPlacements.TryGetValue(transition, out string transition2))
                        {
                            reachable.Add(transition2);
                            pm.Add(transition2);
                            updates.Enqueue(transition2);
                        }
                    }
                }
            }
            reachable.ExceptWith(reachableTransitions);
            foreach (string transition in reachable)
            {
                pm.Remove(transition);
            }
            return(reachable);
        }
Пример #2
0
        public string ForceItem()
        {
            Queue <string> progressionQueue = new Queue <string>();
            List <string>  tempProgression  = new List <string>();

            void UpdateTransitions(string item)
            {
                foreach (string transition in LogicManager.GetTransitionsByProgression(item))
                {
                    if (!pm.Has(transition) && pm.CanGet(transition))
                    {
                        tempProgression.Add(transition);
                        progressionQueue.Enqueue(transition);
                        pm.Add(transition);
                        if (TransitionManager.transitionPlacements.TryGetValue(transition, out string transition2))
                        {
                            tempProgression.Add(transition2);
                            progressionQueue.Enqueue(transition2);
                            pm.Add(transition2);
                        }
                    }
                }
            }

            bool CheckForNewLocations(string item)
            {
                foreach (string location in LogicManager.GetItemsByProgression(item))
                {
                    if (!randomizedLocations.Contains(location))
                    {
                        continue;
                    }
                    if (!reachableLocations.Contains(location) && pm.CanGet(location))
                    {
                        return(true);
                    }
                }
                return(false);
            }

            for (int i = 0; i < unplacedProgression.Count; i++)
            {
                string item = unplacedProgression[i];
                pm.Add(item);
                if (CheckForNewLocations(item))
                {
                    return(item);
                }
                else if (RandomizerMod.Instance.Settings.RandomizeTransitions)
                {
                    bool found = false;
                    UpdateTransitions(item);
                    while (progressionQueue.Any())
                    {
                        string t = progressionQueue.Dequeue();
                        UpdateTransitions(t);
                        found = found || CheckForNewLocations(t);
                    }
                    if (found)
                    {
                        return(item);
                    }
                    foreach (string transition in tempProgression)
                    {
                        pm.Remove(transition);
                    }
                }

                pm.Remove(item);
            }
            return(null);
        }