Пример #1
0
        private void Start()
        {
#if DEBUG
            Fields["displayChance"].guiActive       = true;
            Fields["displayChance"].guiActiveEditor = true;
            Fields["safetyRating"].guiActive        = true;
#endif
            if (HighLogic.LoadedSceneIsEditor)
            {
                hasFailed = false;
            }
            //find the ScrapYard Module straight away, as we can't do any calculations without it.
            SYP             = part.FindModuleImplementing <ModuleSYPartTracker>();
            chanceOfFailure = baseChanceOfFailure;
            //overrides are defined in each failue Module - stuff that the generic module can't handle.
            Overrides();
            //listen to ScrapYard Events so we can recalculate when needed
            ScrapYardEvents.OnSYTrackerUpdated.Add(OnSYTrackerUpdated);
            ScrapYardEvents.OnSYInventoryAppliedToVessel.Add(OnSYInventoryAppliedToVessel);
            ScrapYardEvents.OnSYInventoryAppliedToPart.Add(OnSYInventoryAppliedToPart);
            OhScrap = part.FindModuleImplementing <ModuleUPFMEvents>();
            //refresh part if we are in the editor and parts never been used before (just returns if not)
            OhScrap.RefreshPart();
            //Initialise the Failure Module.
            if (launched || HighLogic.LoadedSceneIsEditor)
            {
                Initialise();
            }
        }
Пример #2
0
        //SRBs cant be repaired.
        public override void RepairPart()
        {
            ScreenMessages.PostScreenMessage("Igniting an SRB manually doesn't seem like a good idea");
            ModuleUPFMEvents UPFM = part.FindModuleImplementing <ModuleUPFMEvents>();

            UPFM.customFailureEvent = true;
        }
Пример #3
0
        private void StartFailure(BaseFailureModule failedModule)
        {
            failedModule.FailPart();
            failedModule.hasFailed = true;
            ModuleUPFMEvents eventModule = failedModule.part.FindModuleImplementing <ModuleUPFMEvents>();

            eventModule.highlight = true;
            eventModule.SetFailedHighlight();
            eventModule.Events["ToggleHighlight"].active = true;
            eventModule.Events["RepairChecks"].active    = true;
            eventModule.doNotRecover = true;
            ScreenMessages.PostScreenMessage(failedModule.part.partInfo.title + ": " + failedModule.failureType);
            StringBuilder msg = new StringBuilder();

            msg.AppendLine(failedModule.part.vessel.vesselName);
            msg.AppendLine("");
            msg.AppendLine(failedModule.part.partInfo.title + " has suffered a " + failedModule.failureType);
            msg.AppendLine("");
            MessageSystem.Message m = new MessageSystem.Message("OhScrap", msg.ToString(), MessageSystemButton.MessageButtonColor.ORANGE, MessageSystemButton.ButtonIcons.ALERT);
            MessageSystem.Instance.AddMessage(m);
            Debug.Log("[OhScrap]: " + failedModule.SYP.ID + " of type " + failedModule.part.partInfo.title + " has suffered a " + failedModule.failureType);
            TimeWarp.SetRate(0, true);
            Logger.instance.Log("Failure Successful");
        }