Esempio n. 1
0
        public void Inspect()
        {
            StringBuilder sb = new StringBuilder();

            List <FailureModule> failModules = part.Modules.OfType <FailureModule>().ToList();

            if (failModules.Count == 0)
            {
                sb.AppendLine("This part seems to be as good as new");
            }

            foreach (FailureModule fm in failModules)
            {
                fm.TimeOfLastInspection = DangIt.Now();
                sb.AppendLine(fm.InspectionName + ":");
                sb.AppendLine(fm.InspectionMessage());
                sb.AppendLine("");
            }

            DangIt.PostMessage("Inspection results",
                               sb.ToString(),
                               MessageSystemButton.MessageButtonColor.BLUE,
                               MessageSystemButton.ButtonIcons.MESSAGE,
                               overrideMute: true);
        }
Esempio n. 2
0
        public void Inspect()
        {
            StringBuilder sb = new StringBuilder();

            List <FailureModule> failModules = part.Modules.OfType <FailureModule>().ToList();

            // The part doesn't have any failure module:
            // instead of a black message, return a placeholder
            if (failModules.Count == 0)
            {
                sb.AppendLine("This part seems to be as good as new");
            }
            else
            {
                foreach (FailureModule fm in failModules)
                {
                    fm.TimeOfLastInspection = DangIt.Now();     // set the time of inspection so that the module gains the inspection bonus
                    sb.AppendLine(fm.ScreenName + ":");
                    sb.AppendLine(fm.InspectionMessage());
                    sb.AppendLine("");
                }
            }

            DangIt.PostMessage("Inspection results",
                               sb.ToString(),
                               MessageSystemButton.MessageButtonColor.BLUE,
                               MessageSystemButton.ButtonIcons.MESSAGE,
                               overrideMute: true);
        }
Esempio n. 3
0
        public void Fail()
        {
            try
            {
                this.Log("Initiating Fail()");

                // First, run the custom failure logic
                // The child class can refuse to fail in FailBegin()
                if (!this.DI_FailBegin())
                {
                    this.Log(this.DebugName + " has not agreed to fail, failure aborted!");
                    return;
                }
                else
                {
                    this.Log(this.DebugName + " has agreed to fail, failure allowed.");
                }

                // If control reaches this point, the child class has agreed to fail
                // Disable the part and handle the internal state and notifications

                this.DI_Disable();

                TimeWarp.SetRate(0, true);      // stop instantly
                this.SetFailureState(true);     // Sets the failure state, handles the events, handles the glow

                if (!this.Silent)
                {
                    DangIt.Broadcast(this.FailureMessage);
                    DangIt.PostMessage("Failure!",
                                       this.FailureMessage,
                                       MessageSystemButton.MessageButtonColor.RED,
                                       MessageSystemButton.ButtonIcons.ALERT);

                    if (FindObjectOfType <AlarmManager>() != null)
                    {
                        FindObjectOfType <AlarmManager>().AddAlarm(this, DangIt.Instance.CurrentSettings.GetSoundLoopsForPriority(Priority));
                        if (FindObjectOfType <AlarmManager>().HasAlarmsForModule(this))
                        {
                            Events ["MuteAlarms"].active    = true;
                            Events ["MuteAlarms"].guiActive = true;
                        }
                    }
                }

                DangIt.FlightLog(this.FailureMessage);
            }
            catch (Exception e)
            {
                OnError(e);
            }
        }
Esempio n. 4
0
        public void Fail()
        {
            try
            {
                this.Log("Initiating Fail()");

                // First, run the custom failure logic
                // The child class can refuse to fail in FailBegin()
                if (!this.DI_FailBegin())
                {
                    this.Log(this.DebugName + " has not agreed to fail, failure aborted!");
                    return;
                }
                else
                {
                    this.Log(this.DebugName + " has agreed to fail, failure allowed.");
                }

                // If control reaches this point, the child class has agreed to fail
                // Disable the part and handle the internal state and notifications

                this.DI_Disable();

                TimeWarp.SetRate(0, true);      // stop instantly
                this.SetFailureState(true);     // Sets the failure state, handles the events, handles the glow

                if (!this.Silent)
                {
                    DangIt.Broadcast(this.FailureMessage);
                    DangIt.PostMessage("Failure!",
                                       this.FailureMessage,
                                       MessageSystemButton.MessageButtonColor.RED,
                                       MessageSystemButton.ButtonIcons.ALERT);

                }

                DangIt.FlightLog(this.FailureMessage);

            }
            catch (Exception e)
            {
                OnError(e);
            }
        }