예제 #1
0
        private static void ConnectStartToGraph()
        {
            if (randomizationError)
            {
                return;
            }
            Log("Attaching start to graph...");

            tm.pm = new ProgressionManager(
                RandomizerState.InProgress
                );
            im.ResetReachableLocations();
            vm.ResetReachableLocations();
            tm.ResetReachableTransitions();

            tm.pm.Add(startProgression);

            {   // keeping local variables out of the way
                DirectedTransitions d = new DirectedTransitions(rand);
                d.Add(startTransition);
                string transition2 = tm.ForceTransition(d);
                if (transition2 is null) // this should happen extremely rarely, but it has to be handled
                {
                    Log("No way out of start?!?");
                    Log("Was the start transition already placed? " + TransitionManager.transitionPlacements.ContainsKey(startTransition));
                    randomizationError = true;
                    return;
                }
                tm.PlaceTransitionPair(startTransition, transition2);
            }

            while (true)
            {
                if (!RandomizerMod.Instance.Settings.RandomizeSkills)
                {
                    // it is essentially impossible to generate a transition randomizer without one of these accessible
                    if (tm.pm.CanGet("Mantis_Claw") || tm.pm.CanGet("Mothwing_Cloak") || tm.pm.CanGet("Shade_Cloak"))
                    {
                        return;
                    }
                }
                else if (im.FindNextLocation(tm.pm) != null)
                {
                    return;
                }

                tm.UnloadReachableStandby();
                List <string> placeableTransitions = tm.reachableTransitions.Intersect(tm.unplacedTransitions.Union(tm.standbyTransitions.Keys)).ToList();
                if (!placeableTransitions.Any())
                {
                    Log("Could not connect start to map--ran out of placeable transitions.");
                    foreach (string t in tm.reachableTransitions)
                    {
                        Log(t);
                    }
                    randomizationError = true;
                    return;
                }

                DirectedTransitions directed = new DirectedTransitions(rand);
                directed.Add(placeableTransitions);

                if (tm.ForceTransition(directed) is string transition1)
                {
                    string transition2 = directed.GetNextTransition(transition1);
                    tm.PlaceTransitionPair(transition1, transition2);
                }
                else
                {
                    Log("Could not connect start to map--ran out of progression transitions.");
                    randomizationError = true;
                    return;
                }
            }
        }