Beispiel #1
0
    private void StartPatchFileSelection()
    {
        ShowOptions(TechSupportData.PatchFiles, selectPatchFileMessage);

        onSelected = delegate
        {
            ConfirmSelection();

            int correctPatchFile = CorrectPatchFile(errorData);

            TechSupportLog.LogFormat("Patch File: Selected option: {0}; Correct option {1}.",
                                     TechSupportData.PatchFiles[selectedOption],
                                     TechSupportData.PatchFiles[correctPatchFile]);

            if (selectedOption == correctPatchFile || forcePatchFileCorrect)
            {
                console.Show(correctSelectionMessage);
                StartParametersSelection();
            }
            else
            {
                TechSupportLog.Log("STRIKE: Wrong patch file.");
                needyModule.HandleStrike();
                console.Show(incorrectSelectionMessage);
                StartPatchFileSelection();
            }
        };
    }
Beispiel #2
0
    private void StartVersionSelection()
    {
        ShowOptions(TechSupportData.VersionNumbers, selectVersionMessage);

        onSelected = delegate
        {
            ConfirmSelection();

            int correctVersion = CorrectVersion(errorData);

            TechSupportLog.LogFormat("Software Version: Selected option: {0}; Correct option {1}.",
                                     TechSupportData.VersionNumbers[selectedOption],
                                     TechSupportData.VersionNumbers[correctVersion]);

            if (selectedOption == correctVersion || forceVersionCorrect)
            {
                console.Show(correctSelectionMessage);
                StartPatchFileSelection();
            }
            else
            {
                TechSupportLog.Log("STRIKE: Wrong software version.");
                needyModule.HandleStrike();
                console.Show(incorrectSelectionMessage);
                StartVersionSelection();
            }
        };
    }
    public void Remove(int hash)
    {
        for (int i = messages.Count - 1; i >= 0; i--)
        {
            Tuple <string, int> message = messages[i];
            if (message.B == hash)
            {
                messages.RemoveAt(i);
                UpdateConsole();
                return;
            }
        }

        TechSupportLog.LogFormat("Couldn't find message with hash: {0}", hash);
    }
    public int Replace(int hash, string message)
    {
        for (int i = messages.Count - 1; i >= 0; i--)
        {
            Tuple <string, int> current = messages[i];
            if (current.B == hash)
            {
                current.A   = message;
                current.B   = message.GetHashCode();
                messages[i] = current;
                UpdateConsole();
                return(current.B);
            }
        }

        TechSupportLog.LogFormat("Couldn't find message with hash: {0}", hash);
        return(-1);
    }
Beispiel #5
0
    private void OnTimerExpired()
    {
        if (moduleResolved)
        {
            return;
        }

        TechSupportLog.Log("STRIKE: Timer Expired");
        needyModule.HandleStrike();

        for (int i = 0; i < options.Count; i++)
        {
            console.Remove(options[i].B);
        }

        console.Show(timerExpiredMessage);
        StartCoroutine(RebootModule());
    }
Beispiel #6
0
    public ErrorData(
        int errorIndex,
        int sourceFileIndex,
        int lineIndex,
        int columnIndex,
        string moduleName)
    {
        this.ErrorIndex      = errorIndex;
        this.SourceFileIndex = sourceFileIndex;
        this.LineIndex       = lineIndex;
        this.ColumnIndex     = columnIndex;
        this.ModuleName      = moduleName;

        TechSupportLog.LogFormat(
            "Created New Error for module {4} - Error: {0}, Source: {1}, Line: {2}, Column: {3}",
            Error,
            SourceFile,
            lineIndex,
            columnIndex,
            moduleName ?? "[no module]");
    }
Beispiel #7
0
    private void StartParametersSelection()
    {
        ShowOptions(TechSupportData.Parameters, selectParametersMessage);

        onSelected = delegate
        {
            ConfirmSelection();

            int correctParameter = CorrectParameter(errorData);

            TechSupportLog.LogFormat("Parameter: Selected option: {0}; Correct option {1}.",
                                     TechSupportData.Parameters[selectedOption],
                                     TechSupportData.Parameters[correctParameter]);

            if (selectedOption == correctParameter || forceParametersCorrect)
            {
                ReactivateInterruptedModule();
                moduleResolved = true;
                console.Show(correctSelectionMessage);

                if (errorData.ModuleName == null)
                {
                    console.Show(exceptionWithoutModuleResolvedMessage);
                }
                else
                {
                    InterruptableModule module = interruptableModules[interrupted];
                    string message             = string.Format(moduleReleasedFormat, module.BombModule.ModuleDisplayName);
                    console.Show(message);
                }
            }
            else
            {
                TechSupportLog.Log("STRIKE: Wrong parameters.");
                needyModule.HandleStrike();
                console.Show(incorrectSelectionMessage);
                StartParametersSelection();
            }
        };
    }
    private void Serialize(GameObject obj, int i)
    {
        string output = "";

        for (int j = 0; j < i; j++)
        {
            output += "\t";
        }

        output += obj.name;

        TechSupportLog.Log(output);

        output = "";

        Component[] components = obj.GetComponents <Component>();
        foreach (Component c in components)
        {
            output = "";
            for (int j = 0; j < i; j++)
            {
                output += "\t";
            }
            output += " [c] " + c.GetType().ToString();
            TechSupportLog.Log(output);
        }


        int childCount = obj.transform.childCount;

        for (int j = 0; j < childCount; j++)
        {
            GameObject child = obj.transform.GetChild(j).gameObject;
            Serialize(child, i + 1);
        }
    }
 // Use this for initialization
 private void Awake()
 {
     instance    = this;
     needyModule = GetComponent <KMNeedyModule>();
 }
Beispiel #10
0
    private IEnumerator DelayedStart()
    {
        TechSupportService mysteryKeyService = GetComponent <TechSupportService>();

        while (!mysteryKeyService.SettingsLoaded)
        {
            yield return(null);
        }

        KMBossModule bossModule = GetComponent <KMBossModule>();

        string[] ignoredModules = bossModule.GetIgnoredModules(needyModule.ModuleDisplayName);

        if (ignoredModules == null || ignoredModules.Length == 0)
        {
            TechSupportLog.Log("Using backup ignorelist.");
            ignoredModules = backUpIgnoreList.text.Split('\n');
        }

        KMBombModule[] bombModules = FindObjectsOfType <KMBombModule>();

        foreach (KMBombModule bombModule in bombModules)
        {
            try
            {
                bool mustNotBeHidden = mysteryKeyService.MustNotBeHidden(bombModule.ModuleType);
                bool isIgnored       = ignoredModules.Contains(bombModule.ModuleDisplayName);

                // Ignored modules are ignored.
                if (mustNotBeHidden || isIgnored)
                {
                    TechSupportLog.LogFormat("Ignored module {0} - Must Not Be Hidden: {1}; Is Ignored {2}",
                                             bombModule.ModuleDisplayName,
                                             mustNotBeHidden,
                                             isIgnored);
                    continue;
                }

                // Collects the module's KMSelectable.
                KMSelectable selectable = bombModule.GetComponent <KMSelectable>();

                GameObject passLight   = TransformUtilities.FindChildIn(bombModule.transform, "Component_LED_PASS").gameObject;
                Transform  statusLight = passLight.transform.parent;
                GameObject strikeLight = TransformUtilities.FindChildIn(statusLight, "Component_LED_STRIKE").gameObject;
                GameObject errorLight  = Instantiate(
                    errorLightPrefab,
                    statusLight.position,
                    statusLight.rotation,
                    statusLight.transform);
                errorLight.SetActive(false);

                // Stores the acquired data.
                InterruptableModule interruptableModule = new InterruptableModule(bombModule, selectable, passLight, strikeLight, errorLight);

                interruptableModules.Add(interruptableModule);
            }
            catch (Exception exception)
            {
                TechSupportLog.LogFormat
                    ("Set-Up Interruptable ({0}) failed with message ({1}), at ({2}).",
                    bombModule.ModuleDisplayName,
                    exception.Message,
                    exception.StackTrace);
            }
        }

        TechSupportLog.LogFormat("Loaded total of {0} interruptable modules", interruptableModules.Count);
    }
Beispiel #11
0
    private void Interrupt()
    {
        moduleResolved = false;

        // Selects module to interrupt.
        InterruptableModule selected = null;

        // The module can no longer reset when too little time is left.
        float bombTime = bombInfo.GetTime();

        if (bombTime >= needyModule.CountdownTime)
        {
            InterruptableModule[] potentials = new InterruptableModule[interruptableModules.Count];
            interruptableModules.CopyTo(potentials);
            potentials.Shuffle();

            foreach (InterruptableModule current in potentials)
            {
                // A module is only interrupted when the off light is on,
                // and it isn't currently used.
                TechSupportLog.Log(!current.PassLight.activeSelf
                                   + " " + !current.StrikeLight.activeSelf
                                   + " " + !current.ErrorLight.activeSelf
                                   + " " + !current.IsFocussed);

                if (!current.PassLight.activeSelf &&
                    !current.StrikeLight.activeSelf &&
                    !current.ErrorLight.activeSelf &&
                    !current.IsFocussed)
                {
                    selected = current;
                    break;
                }
            }

            interrupted = interruptableModules.IndexOf(selected);
        }
        else
        {
            TechSupportLog.Log("Not enough time left, forcing to interrupt without module.");
        }

        // Interrupts that module (if there is one).
        if (selected == null)
        {
            TechSupportLog.Log("Could not find interruptable module. Creating exception without one.");

            errorData = data.GenerateError(null);
            allErrors.Add(errorData);

            string message = exceptionWithoutModuleMessages[Random.Range(0, exceptionWithoutModuleMessages.Length)];
            message = string.Format(message, errorData.Error, errorData.SourceFile, errorData.LineIndex, errorData.ColumnIndex);
            console.Show(message);
        }
        else
        {
            TechSupportLog.LogFormat("Interrupting: {0}", selected.BombModule.ModuleDisplayName);

            // All other lights are disabled, and the error light is enabled.
            Transform parent     = selected.PassLight.transform.parent;
            int       childCount = parent.childCount;
            for (int i = 0; i < childCount; i++)
            {
                parent.GetChild(i).gameObject.SetActive(false);
            }

            selected.ErrorLight.SetActive(true);

            // Disabling all interaction with the module.
            interruptedInteractHandler     = selected.Selectable.OnInteract;
            selected.Selectable.OnInteract = new KMSelectable.OnInteractHandler(delegate
            {
                bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.NeedyActivated, selected.BombModule.transform);
                return(false);
            });

            // Generating error and Updating the console.
            errorData = data.GenerateError(selected.BombModule.ModuleDisplayName);
            allErrors.Add(errorData);

            string message = string.Format(errorFormat, selected.BombModule.ModuleDisplayName, errorData.Error, errorData.SourceFile, errorData.LineIndex, errorData.ColumnIndex);
            console.Show(message);
        }

        StartVersionSelection();
    }