Ejemplo n.º 1
0
        /// <summary>
        /// If the edge contains the Locked tag it should be skipped unless an enabled fix or glitch is also tagged or
        /// if all of the edge's unlocks are reachable.
        /// </summary>
        /// <param name="edge">Edge to check.</param>
        /// <returns>True if the edge can be skipped.</returns>
        private bool IsLockedEdge(ModuleEdge edge)
        {
            bool isLocked = false;

            if (edge.IsLocked)
            {
                // Check to see if we can bypass this lock with an allowed glitch or enabled fix.
                if ((AllowGlitchClip && edge.IsClip) ||
                    (AllowGlitchDlz && edge.IsDlz) ||
                    (AllowGlitchFlu && edge.IsFlu) ||                       // How to handle FluReq? One FLU still requires Carth...
                    (AllowGlitchGpw && edge.IsGpw) ||
                    (EnabledFixBox && edge.IsFixBox) ||
                    (EnabledFixElev && edge.IsFixElev) ||
                    (EnabledFixMap && edge.IsFixMap) ||
                    (EnabledFixSpice && edge.IsFixSpice) ||
                    (EnabledUnlockDanRuins && edge.IsUnlockDanRuins) ||
                    (EnabledUnlockManSub && edge.IsUnlockManSub) ||
                    (EnabledUnlockStaBastila && edge.IsUnlockStaBastila) ||
                    (EnabledUnlockUnkSummit && edge.IsUnlockUnkSummit))
                {
                    isLocked = false;
                }
                else
                {
                    // Check to see if the edge can be unlocked by any of the possible sets.
                    var unlocked = true;
                    foreach (var set in edge.UnlockSets)
                    {
                        // Reset assumption to true, as we're just looking for one false in each set.
                        unlocked = true;

                        // ALL vertices within a set need to be reachable.
                        foreach (var target in set)
                        {
                            // If the tag is not in Reachable, then it's a one that we haven't seen and the edge is still locked.
                            if (!Reachable.ContainsKey(target))
                            {
                                Reachable.Add(target, false);
                                unlocked = false;
                                break;
                            }

                            // If not Reachable, then the edge is still locked.
                            if (!Reachable[target])
                            {
                                unlocked = false;
                                break;
                            }
                        }

                        // If a reachable set has been found, break out of the loop.
                        if (unlocked)
                        {
                            break;
                        }
                    }

                    // Set return value.
                    isLocked = !unlocked;
                }
            }
            else
            {
                // Edge isn't locked.
                isLocked = false;
            }
            return(isLocked);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Recursive method to perform Depth-First Search reachability checking.
        /// </summary>
        /// <param name="touched">Dictionary indicating if each module has been checked during this cycle.</param>
        /// <param name="v">The current module to check.</param>
        private void DepthFirstSearch(Dictionary <string, bool> touched, ModuleVertex v)
        {
            // This module has been reached, so assume reachable.
            touched[v.WarpCode] = true;
            if (touched[v.WarpCode] != Reachable[v.WarpCode])
            {
                ReachableUpdated      = true;
                Reachable[v.WarpCode] = true;
            }

            // Any tags associated with this vertex are also reachable.
            foreach (var t in v.Tags)
            {
                if (!Reachable.ContainsKey(t))
                {
                    Reachable.Add(t, true);
                }
                else
                {
                    Reachable[t] = true;
                }
            }

            // Check to see if the locked tag is reachable too.
            if (!string.IsNullOrWhiteSpace(v.LockedTag))
            {
                var isUnlocked = true;

                // If ALL tags are reachable, this tag is also reachable.
                foreach (var ul in v.Unlock)
                {
                    if (Reachable.ContainsKey(ul) && Reachable[ul])
                    {
                        isUnlocked = true;
                    }
                    else
                    {
                        isUnlocked = false;
                        break;
                    }
                }

                if (!Reachable.ContainsKey(v.LockedTag))
                {
                    Reachable.Add(v.LockedTag, isUnlocked);
                }
                else
                {
                    Reachable[v.LockedTag] = isUnlocked;
                }
            }

            // Check each edge that hasn't been reached already.
            foreach (var edge in v.LeadsTo)
            {
                // If this is a once edge, determine how to handle it.
                if (IsOnceEdge(edge))
                {
                    // Ignore once edges if setting is enabled.
                    if (!IgnoreOnceEdges)
                    {
                        // If allowed, enqueue the once edge for checking at the end of this cycle.
                        if (!Reachable[RandomLookup[edge.WarpCode]] && !OnceQueue.Contains(edge))
                        {
                            OnceQueue.Enqueue(edge);
                            ReachableUpdated = true;
                        }
                    }
                    continue;
                }
                // If this is a locked edge, determine if it is still locked.
                if (EnforceEdgeTagLocked && IsLockedEdge(edge))
                {
                    continue;
                }
                if (!touched[RandomLookup[edge.WarpCode]])
                {
                    DepthFirstSearch(touched, Modules.Find(m => m.WarpCode == RandomLookup[edge.WarpCode]));
                }
            }
        }