protected void sendPressRelease(Vessel komet) { try { Log("Generating press release"); StringBuilder resultsMessage = new StringBuilder(); MessageSystem.Message msg; string[] kometNameItems = komet.vesselName.Split(new char[] { '/' }); resultsMessage.AppendLine(kometNameItems[1] + "'s Komet has been discovered! It has been designated " + komet.vesselName + " by astronomers."); resultsMessage.AppendLine(" "); resultsMessage.AppendLine("We currently know very little about the komet, other than the following:"); resultsMessage.AppendLine(" "); resultsMessage.AppendLine("Discovered: " + KSPUtil.dateTimeFormatter.PrintDateCompact(komet.DiscoveryInfo.lastObservedTime, false, false)); resultsMessage.AppendLine("Orbiting: " + komet.orbit.referenceBody.name); resultsMessage.AppendLine("Size Category: " + DiscoveryInfo.GetSizeClassSizes(komet.DiscoveryInfo.objectSize)); resultsMessage.AppendLine("Orbital Period: " + KSPUtil.PrintTimeLong(komet.orbit.period)); resultsMessage.AppendLine(komet.DiscoveryInfo.signalStrengthPercent.OneLiner); msg = new MessageSystem.Message(kometNameItems[1] + "'s Komet Discovered!", resultsMessage.ToString(), MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.ACHIEVE); MessageSystem.Instance.AddMessage(msg); } catch (Exception ex) { Log("Oops: " + ex); } }
public void MakeReport() { Report r = GetReport(); MessageSystem.Message message = new MessageSystem.Message(r.ReportTitle, r.ReportBody(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(message); }
protected virtual void RefreshMessages() { RefreshEmptyStatus(); RefreshDupeAssetWarning(); var flag = m_BundleMessages.HighestMessageFlag(); m_CachedHighMessage = MessageSystem.GetMessage(flag); }
private void OnScienceReceived(float science, ScienceSubject subject, ProtoVessel vessel, bool reverseEngineered) { // If this is set, it means that the vessel recovery dialog is figuring out the science that was received if (reverseEngineered) { return; } Biome biome = Science.GetBiome(subject); if (biome == null || biome.IsKSC()) { return; } IEnumerable<ScienceSubject> subjects = ResearchAndDevelopment.GetSubjects().Where(ss => ss.id.Contains(biome.body.name)); if (explorationType == ExplorationType.Biome) { subjects = subjects.Where(ss => ss.id.Contains(biome.biome)); } float totalScience = subjects.Sum(ss => ss.science) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; // The values will be the same if this is the first for the biome if (Math.Abs(totalScience - science) < 0.001) { Funding.Instance.AddFunds(rewardFunds, TransactionReasons.Strategies); string title = "Rewards from strategy '" + Parent.Title + "'"; string header = "Science from new " + ExplorationTypeNamePlural(explorationType) + ":\n"; string rewardMessage = " " + (explorationType == ExplorationType.Biome ? biome.ToString() : biome.body.name) + ": <color=#B4D455>£ " + rewardFunds.ToString("N0") + "</color>\n"; MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == title).FirstOrDefault(); if (message == null) { MessageSystem.Instance.AddMessage(new MessageSystem.Message(title, header + rewardMessage, MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.ACHIEVE)); } else { // Section doesn't exist if (!message.message.Contains(header)) { message.message += "\n" + header; message.message += rewardMessage; } // Section is second (last) else if (message.message.Contains("\n\n" + header)) { message.message += rewardMessage; } // Section is first else { message.message = message.message.Replace("\n\n", "\n" + rewardMessage); } message.IsRead = false; } } }
private void Report(ScienceExperiment experiment, float gain) { StringBuilder msg = new StringBuilder(); string[] template; if (File.Exists <KEI>(experiment.id + ".msg")) { template = File.ReadAllLines <KEI>(experiment.id + ".msg"); } else { template = File.ReadAllLines <KEI>("unknownExperiment.msg"); msg.AppendLine("TOP SECRET!"); msg.AppendLine("Project " + experiment.experimentTitle); msg.AppendLine("Eat this report after reading"); msg.AppendLine("And drink some coffee"); msg.AppendLine("****"); } foreach (var line in template) { msg.AppendLine(line); } msg.AppendLine(""); msg.AppendLine(string.Format("<color=#B4D455>Total science gain: {0}</color>", gain.ToString("0.00"))); MessageSystem.Message message = new MessageSystem.Message( "New Email", msg.ToString(), MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.MESSAGE ); MessageSystem.Instance.AddMessage(message); }
protected override void onCriticalFailure() { base.onCriticalFailure(); if (WBIMainSettings.PartsCanBreak) { StopConverter(); isBroken = true; Events["RepairLab"].active = true; Events["RepairLab"].guiActive = true; Events["StartResourceConverter"].active = false; status = kNeedsRepairs; StringBuilder resultsMessage = new StringBuilder(); MessageSystem.Message msg; resultsMessage.AppendLine("From: " + this.part.vessel.vesselName); resultsMessage.AppendLine("Lab: " + this.part.partInfo.title); resultsMessage.AppendLine("Subject: Lab Critical Failure!"); resultsMessage.AppendLine("Summary: Unfortunately the " + this.part.partInfo.title + " has suffered a catastrophic failure and requires repairs."); if (WBIMainSettings.RepairsRequireResources && string.IsNullOrEmpty(repairResource) == false) { resultsMessage.AppendLine(string.Format("It will take {0:f2}", repairAmount) + " " + repairResource + " to repair"); } msg = new MessageSystem.Message("Lab Critical Failure!", resultsMessage.ToString(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.FAIL); MessageSystem.Instance.AddMessage(msg); } }
protected void emailPlayer(string resourceName, WBIBackroundEmailTypes emailType) { StringBuilder resultsMessage = new StringBuilder(); MessageSystem.Message msg; PartResourceDefinition resourceDef = null; PartResourceDefinitionList definitions = PartResourceLibrary.Instance.resourceDefinitions; string titleMessage; //Spam check if (playerEmailed || !WBIMainSettings.EmailConverterResults) { return; } else { playerEmailed = true; moduleSnapshot.moduleValues.SetValue("playerEmailed", playerEmailed); } //From resultsMessage.AppendLine("From: " + protoPart.pVesselRef.vesselName); switch (emailType) { case WBIBackroundEmailTypes.missingResources: resourceDef = definitions[resourceName]; titleMessage = " needs more resources"; resultsMessage.AppendLine("Subject: Missing Resources"); resultsMessage.AppendLine("There is no more " + resourceDef.displayName + " available to continue production. Operations cannot continue with the " + ConverterName + " until more resource becomes available."); break; case WBIBackroundEmailTypes.missingRequiredResource: resourceDef = definitions[resourceName]; titleMessage = " needs a resource"; resultsMessage.AppendLine("Subject: Missing Required Resource"); resultsMessage.AppendLine(ConverterName + " needs " + resourceDef.displayName + " in order to function. Operations halted until the resource becomes available."); break; case WBIBackroundEmailTypes.containerFull: resourceDef = definitions[resourceName]; titleMessage = " is out of storage space"; resultsMessage.AppendLine("Subject: Containers Are Full"); resultsMessage.AppendLine("There is no more storage space available for " + resourceDef.displayName + ". Operations cannot continue with the " + ConverterName + " until more space becomes available."); break; case WBIBackroundEmailTypes.yieldCriticalFail: titleMessage = "has suffered a critical failure in one of its converters"; resultsMessage.AppendLine("A " + ConverterName + " has failed! The production yield has been lost. It must be repaired and/or restarted before it can begin production again."); break; default: return; } msg = new MessageSystem.Message(protoPart.pVesselRef.vesselName + titleMessage, resultsMessage.ToString(), MessageSystemButton.MessageButtonColor.ORANGE, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(msg); }
/// <summary> /// Notify, that rover has empty batteries /// </summary> private void NotifyBatteryEmpty() { MessageSystem.Message message = new MessageSystem.Message( Localizer.Format("#LOC_BV_Title_RoverStopped"), // title "<color=#74B4E2>" + vessel.vesselName + "</color> " + Localizer.Format("#LOC_BV_Warning_Stopped") + ". " + Localizer.Format("#LOC_BV_Warning_LowPowerRover") + ".\n<color=#AED6EE>", // message MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT ); MessageSystem.Instance.AddMessage(message); }
/// <summary> /// Notify, that ship has not enough fuel /// </summary> private void NotifyNotEnoughFuel() { MessageSystem.Message message = new MessageSystem.Message( Localizer.Format("#LOC_BV_Title_ShipStopped"), // title "<color=#74B4E2>" + vessel.vesselName + "</color> " + Localizer.Format("#LOC_BV_Warning_Stopped") + ". " + Localizer.Format("#LOC_BV_Warning_NotEnoughFuel") + ".\n<color=#AED6EE>", // message MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT ); MessageSystem.Instance.AddMessage(message); }
public static void NotifyDeath(ProtoCrewMember kerbal) { var title = $"{kerbal.name} has died"; var text = $"{kerbal.name} has died while on EVA."; const MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.RED; const MessageSystemButton.ButtonIcons icon = MessageSystemButton.ButtonIcons.FAIL; var message = new MessageSystem.Message(title, text, color, icon); MessageSystem.Instance.AddMessage(message); }
//Adds the message saying the part has failed to the stock messaging app void PostFailureMessage() { StringBuilder msg = new StringBuilder(); msg.AppendLine(part.vessel.vesselName); msg.AppendLine(""); msg.AppendLine(part.partInfo.title + " has suffered a " + failureType); msg.AppendLine(""); MessageSystem.Message m = new MessageSystem.Message("OhScrap", msg.ToString(), MessageSystemButton.MessageButtonColor.ORANGE, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); }
/// <summary> /// Notify, that Kerbal has arrived /// </summary> private void NotifyArrival() { MessageSystem.Message message = new MessageSystem.Message( Localizer.Format("#LOC_BV_Title_KerbalArrived"), // title "<color=#74B4E2>" + vessel.vesselName + "</color> " + Localizer.Format("#LOC_BV_VesselArrived") + " " + vessel.mainBody.bodyDisplayName.Replace("^N", "") + ".\n<color=#AED6EE>" + Localizer.Format("#LOC_BV_Control_Lat") + ": " + targetLatitude.ToString("F2") + "</color>\n<color=#AED6EE>" + Localizer.Format("#LOC_BV_Control_Lon") + ": " + targetLongitude.ToString("F2") + "</color>", // message MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.COMPLETE ); MessageSystem.Instance.AddMessage(message); }
/// <summary> /// Quick wrapper to post a user notification with less hassle. /// </summary> static void PostMessage(string title, string message, MessageSystemButton.MessageButtonColor messageButtonColor, MessageSystemButton.ButtonIcons buttonIcons) { MessageSystem.Message msg = new MessageSystem.Message( title, message, messageButtonColor, buttonIcons); MessageSystem.Instance.AddMessage(msg); }
protected void Notify(StrategiaStrategy strategy, bool requirementsMet) { const string title = "Strategy Availability Changed"; // Check for an existing message MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == title).FirstOrDefault(); if (message != null) { message.IsRead = false; } else { messageStrategies = new Dictionary <string, bool>(); } // Add our strategy to the list messageStrategies[strategy.Title] = requirementsMet; // Build the message string msg = ""; if (messageStrategies.Any(p => p.Value)) { msg += "<b>New strategies available:</b>\n"; } foreach (string strategyTitle in messageStrategies.Where(p => p.Value).Select(p => p.Key)) { msg += " " + strategyTitle + "\n"; } if (messageStrategies.Any(p => !p.Value)) { if (!string.IsNullOrEmpty(msg)) { msg += "\n"; } msg += "<b>Strategies no longer available:</b>\n"; } foreach (string strategyTitle in messageStrategies.Where(p => !p.Value).Select(p => p.Key)) { msg += " " + strategyTitle + "\n"; } if (message == null) { MessageSystem.Instance.AddMessage(new MessageSystem.Message(title, msg, MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.ALERT)); } else { message.message = msg; } }
/// <summary> /// Posts a new message to the messaging system unless notifications have been disabled in the general settings. /// </summary> public static void PostMessage(string title, string message, MessageSystemButton.MessageButtonColor messageButtonColor, MessageSystemButton.ButtonIcons buttonIcons, bool overrideMute = false) { if (DangIt.Instance.CurrentSettings.Messages || overrideMute) { MessageSystem.Message msg = new MessageSystem.Message( title, message, messageButtonColor, buttonIcons); MessageSystem.Instance.AddMessage(msg); } }
void StockOnParameterChange(Contract c, ContractParameter p) { // Workaround for stock bug #18267 if (p.State == ParameterState.Complete && p.FundsCompletion == 0 && p.ScienceCompletion == 0 && p.ReputationCompletion == 0) { Versioning v = Versioning.Instance as Versioning; if (v.versionMajor == 1 && v.versionMinor == 4 && v.revision == 2) { MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.message.Contains(p.MessageComplete)).FirstOrDefault(); if (message != null) { MessageSystem.Instance.DiscardMessage(message.button); } } } }
private static void ShowMessage(CelestialBody body, bool wasVisible, bool visible, RadiationFieldType field) { if (visible && !wasVisible) { StringBuilder sb = new StringBuilder(256); string message = Lib.BuildString("<b>", body.bodyName, ": <color=#8BED8B>", RadiationField.Name(field), "</color> researched</b>"); sb.Append(message); sb.Append("\n\n"); var bd = Instance.BodyData(body); API.Message(sb.ToString()); MessageSystem.Message m = new MessageSystem.Message("Radiation Field Researched", sb.ToString(), MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.ACHIEVE); MessageSystem.Instance.AddMessage(m); } }
/// <summary> /// Notify that rover has arrived /// </summary> private void HoneyImHome() { MessageSystem.Message message = new MessageSystem.Message( "Rover arrived", //------------------------------------------ "<color=#74B4E2>" + vessel.vesselName + "</color>" + " has arrived to destination\n<color=#AED6EE>LAT: " + targetLatitude.ToString("F2") + "</color>\n<color=#AED6EE>LON: " + targetLongitude.ToString("F2") + "</color>\n<color=#82BCE5>At " + vessel.mainBody.bodyDisplayName.Replace("^N", "") + ".</color>\n" + "Distance travelled: " + "<color=#74B4E2>" + distanceTravelled.ToString("N") + "</color> meters", //------------------------------------------ MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.COMPLETE ); MessageSystem.Instance.AddMessage(message); }
void PostFailureMessage() { StringBuilder msg = new StringBuilder(); msg.AppendLine(part.vessel.vesselName); msg.AppendLine(""); msg.AppendLine(part.name + " has suffered a " + failureType); msg.AppendLine(""); if (part.FindModuleImplementing <Broken>() != null) { msg.AppendLine("The part is damaged beyond repair"); } else { msg.AppendLine("Chance of a successful repair is " + (100 - displayChance) + "%"); } MessageSystem.Message m = new MessageSystem.Message("UPFM", msg.ToString(), MessageSystemButton.MessageButtonColor.ORANGE, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); }
private static void ShowMessage(CelestialBody body, bool wasVisible, bool visible, RadiationFieldType field) { if (visible && !wasVisible) { StringBuilder sb = new StringBuilder(256); string message = Localizer.Format("#KerCon_FieldXofYresearched", // <<1>>: <<2>> researched Lib.Bold(body.bodyName), Lib.Color(RadiationField.Name(field), Lib.Kolor.Science)); sb.Append(message); sb.Append("\n\n"); sb.Append(Localizer.Format("#KerCon_FieldResearchedMessage")); var bd = Instance.BodyData(body); API.Message(sb.ToString()); MessageSystem.Message m = new MessageSystem.Message("#KerCon_FieldResearched", sb.ToString(), MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.ACHIEVE); MessageSystem.Instance.AddMessage(m); } }
private void CrewTestProto(int REASON, ProtoPartSnapshot p, double l) { int CUR_CWLS = IFICWLS; CUR_CWLS += (Convert.ToInt16(l) * 10); float rand; ProtoCrewMember iCrew; for (int i = 0; i < p.protoModuleCrew.Count; i++) { rand = UnityEngine.Random.Range(0.0f, 100.0f); IFIDebug.IFIMess("!!!!!!!!"); IFIDebug.IFIMess("Testing Crew Death Crewmember=" + p.protoModuleCrew[i].name); IFIDebug.IFIMess("Crew Death Chance = " + Convert.ToString(CUR_CWLS)); IFIDebug.IFIMess("Crew Death Roll = " + Convert.ToString(rand)); IFIDebug.IFIMess("!!!!!!!!"); if (CUR_CWLS > rand) { iCrew = p.protoModuleCrew[i]; iCrew.rosterStatus = ProtoCrewMember.RosterStatus.Dead; p.RemoveCrew(iCrew); IFIDebug.IFIMess(p.pVesselRef.vesselName + " POD Kerbal Killed due to no LS - " + iCrew.name); string message = ""; message += p.pVesselRef.vesselName + "\n\n"; message += iCrew.name + "\n Was killed due to ::"; if (REASON == 1) { message += "No Electric Charge Remaining"; } else { message += "No Life Support Remaining"; } message += "::"; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death from LifeSupport Failure", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); } } }
protected void sendResultsMessage() { if (notificationSent) { return; } notificationSent = true; StringBuilder resultsMessage = new StringBuilder(); MessageSystem.Message msg; resultsMessage.AppendLine("Results from: " + this.part.vessel.vesselName); resultsMessage.AppendLine("Lab: " + this.part.partInfo.title); resultsMessage.AppendLine("Experiment: " + title); if (isCompleted) { resultsMessage.AppendLine("Conclusion: Success!"); resultsMessage.AppendLine("Summary: We were able to produce usable results for this experiment. Bring it home to gain the science benefits and recover the economic cost, or send the data to an MPL for additional processing."); } else { resultsMessage.AppendLine("Conclusion: Failure!"); resultsMessage.AppendLine("Summary: Unfortunately we were not able to produce viable results from this experiment. It can still be returned to recover the economic cost though."); } if (isCompleted) { msg = new MessageSystem.Message("Experiment Results: Success!", resultsMessage.ToString(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.COMPLETE); } else { msg = new MessageSystem.Message("Experiment Results: Failed!", resultsMessage.ToString(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.FAIL); } MessageSystem.Instance.AddMessage(msg); }
private void CrewTestEVA(Vessel IV, double l) { float rand; int CUR_CWLS = IFICWLS; CUR_CWLS += (Convert.ToInt16(l) * 10); rand = UnityEngine.Random.Range(0.0f, 100.0f); if (CUR_CWLS > rand) { if (IV.loaded) { Part p = IV.rootPart; ProtoCrewMember iCrew = p.protoModuleCrew[0]; iCrew.rosterStatus = ProtoCrewMember.RosterStatus.Dead; p.RemoveCrewmember(iCrew); // Remove crew from part iCrew.Die(); // Kill crew after removal or death will reset to active. IFIDebug.IFIMess(" EVA Kerbal Killed due to no LS - " + iCrew.name); string message = "\n\n\n"; message += iCrew.name + ":\n Was killed for Life Support Failure."; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death on EVA", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); p.explode(); } else { foreach (ProtoPartSnapshot p in IV.protoVessel.protoPartSnapshots) { ProtoCrewMember iCrew = p.protoModuleCrew[0]; string Name = iCrew.name; iCrew.rosterStatus = ProtoCrewMember.RosterStatus.Dead; p.RemoveCrew(iCrew); //IV.Die(); IFIDebug.IFIMess(" EVA Kerbal Killed due to no LS - " + Name); string message = "\n\n\n"; message += Name + ":\n Was killed for Life Support Failure."; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death on EVA", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); } } } }
//Part will just shutdown and not be restartable. public override void FailPart() { if (KRASHWrapper.simulationActive()) { return; } if (engine.currentThrottle == 0) { return; } engine.allowShutdown = true; engine.allowRestart = false; hasFailed = true; engine.Shutdown(); if (!message) { if (vessel.vesselType != VesselType.Debris) { ScreenMessages.PostScreenMessage(part.partInfo.title + " has failed to ignite"); } StringBuilder msg = new StringBuilder(); msg.AppendLine(part.vessel.vesselName); msg.AppendLine(""); msg.AppendLine(part.partInfo.title + " has suffered an " + failureType); msg.AppendLine(""); MessageSystem.Message m = new MessageSystem.Message("OhScrap", msg.ToString(), MessageSystemButton.MessageButtonColor.ORANGE, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); message = true; } if (OhScrap.highlight) { OhScrap.SetFailedHighlight(); } CancelInvoke("FailPart"); Logger.instance.Log("[OhScrap]: " + part.partInfo.title + " has failed to ignite"); }
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"); }
// Returns the nearest open Launchsite to a position and range to the Launchsite in m // The basic ATC feature is in here for now public static void GetNearestOpenBase(Vector3 position, out string sBase, out float flRange, out KKLaunchSite lNearest) { SpaceCenter KSC = SpaceCenter.Instance; var smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position); string sNearestBase = ""; KKLaunchSite lNearestBase = null; KKLaunchSite lKSC = null; foreach (KKLaunchSite site in allLaunchSites) { if (site.isOpen) { var radialposition = site.staticInstance.transform.position; var dist = Vector3.Distance(position, radialposition); if (site.LaunchSiteName == "Runway") { if (lNearestBase == null) { lNearestBase = site; } lKSC = site; } else if (site.LaunchSiteName != "LaunchPad") { if ((float)dist < (float)smallestDist) { { sNearestBase = site.LaunchSiteName; lNearestBase = site; smallestDist = dist; } } } else { lKSC = site; } } } if (sNearestBase.Length == 0) { sNearestBase = "KSC"; lNearestBase = lKSC; } rangeNearestOpenBase = (float)smallestDist; // Air traffic control messaging if (LandingGuideUI.instance.IsOpen()) { if (sNearestBase != nearestOpenBase) { if (rangeNearestOpenBase < 25000) { nearestOpenBase = sNearestBase; MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.BLUE; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You have entered the airspace of " + sNearestBase + " ATC. Please keep this channel open and obey all signal lights. Thank you. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } else if (nearestOpenBase.Length != 0) { // you have left ... MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.GREEN; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You are now leaving the airspace of " + sNearestBase + ". Safe journey. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); nearestOpenBase = ""; } } } sBase = sNearestBase; flRange = rangeNearestOpenBase; lNearest = lNearestBase; }
void Update() { if (HighLogic.LoadedSceneHasPlanetarium) { SetInterval(); int currentPeriod = (int)Math.Floor(Planetarium.GetUniversalTime() / _interval); int currentDegrade = (int)Math.Floor(Planetarium.GetUniversalTime() / intervalDegrade); if (currentDegrade > countIntervalDegrade && degradeReputation == true && loanAmount > 0) { float rep = degradeRate; Reputation.Instance.AddReputation(-rep, TransactionReasons.None); countIntervalDegrade = currentDegrade; } if (currentPeriod > _lastUpdate && billing_enabled == true) { GetInterval(); float multiplier = intervalDays; Debug.Log("Last Update=" + _lastUpdate + ", Current Period=" + currentPeriod); _lastUpdate = currentPeriod; StringBuilder message = new StringBuilder(); message.AppendLine("Payroll is processed."); message.AppendLine("Current staff:"); foreach (ProtoCrewMember crewMember in HighLogic.CurrentGame.CrewRoster.Crew) { message.Append(crewMember.name); if (!crewMember.rosterStatus.Equals(ProtoCrewMember.RosterStatus.Dead) && !crewMember.rosterStatus.Equals(ProtoCrewMember.RosterStatus.Missing)) { float paycheck = (int)Math.Round(GetWages(crewMember.experienceLevel, crewMember.rosterStatus.ToString()) * multiplier); message.AppendLine(" is " + crewMember.rosterStatus + ". Paycheck = " + paycheck); Debug.Log("Multiplier: " + multiplier); Debug.Log("Wages: " + GetWages(crewMember.experienceLevel, crewMember.rosterStatus.ToString())); bills = (int)Math.Round(bills + paycheck); } } //here are some debug checks for the new "updateLoan" function Debug.Log("Starting loan balance: " + loanAmount); float periodInt = updateLoan(periodRate); //this adds the interest to the loan principle if (loanAmount > 0) { message.AppendLine("Your loan payment in the amount of " + loanPayment + " is due, please make your payment."); } float externalFunding = CalcFunding(); Funding.Instance.AddFunds(+externalFunding, 0); Debug.Log(externalFunding); message.AppendLine("Received Funding: " + externalFunding); message.AppendLine("Amount Due: " + bills.ToString()); if (autopayEnabled == true) { message.AppendLine("Autopay enabled, paid out " + AutoPay(bills, Funding.Instance.Funds, threshold).ToString()); } MessageSystem.Message m = new MessageSystem.Message( "New Bill Ready", message.ToString(), MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); if (Kerbanomics_KACWrapper.KACWrapper.AssemblyExists == true) { SetKACAlarm(); } } } }
private void CrewTestEVA(Vessel IV, double l) { float rand; int CUR_CWLS = IFICWLS; CUR_CWLS += (Convert.ToInt16(l) * 10); rand = UnityEngine.Random.Range(0.0f, 100.0f); if (CUR_CWLS > rand) { if (IV.loaded) { Part p = IV.rootPart; ProtoCrewMember iCrew = p.protoModuleCrew[0]; iCrew.rosterStatus = ProtoCrewMember.RosterStatus.Dead; p.Die(); IFIDebug.IFIMess(" EVA Kerbal Killed due to no LS - " + iCrew.name); string message = "\n\n\n"; message += iCrew.name + ":\n Was killed for Life Support Failure."; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death on EVA", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); } else { // Removed Killing Kerbals on EVA when not loaded to fix ghosting bug. } } }
private void HandleInteropMessage(KLFCommon.ClientInteropMessageID id, byte[] data) { switch (id) { case KLFCommon.ClientInteropMessageID.ChatReceive: if (data != null) { string NNmessage = Encoder.GetString(data); if (!KLFGlobalSettings.Instance.ChatWindowEnabled || !KLFInfoDisplay.InfoDisplayActive) { KLF_Button.SetTexture(KLF_button_alert); KLF_button_alert_anim = 1; MessageSystem.Message m = new MessageSystem.Message("Kerbal Live Feed Activity", NNmessage , MessageSystemButton.MessageButtonColor.YELLOW, MessageSystemButton.ButtonIcons.MESSAGE); if (KLFGlobalSettings.Instance.SendNotifications) { m = new MessageSystem.Message("Kerbal Live Feed Activity", NNmessage, MessageSystemButton.MessageButtonColor.YELLOW, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } } KLFChatDisplay.Line(NNmessage); } break; case KLFCommon.ClientInteropMessageID.ClientData: if (data != null && data.Length > 9) { //Read inactive vessels per update count PerUpdate = data[0]; //Read screenshot height KLFScreenshotDisplay.Settings.MaxHeight = KLFCommon.BytesToInt(data, 1); UpdateInterval = ((float)KLFCommon.BytesToInt(data, 5))/1000.0f; //Read username PlayerName = Encoder.GetString(data, 9, data.Length - 9); } break; case KLFCommon.ClientInteropMessageID.PluginUpdate: if (data != null) HandleUpdate(KSP.IO.IOUtils.DeserializeFromBinary(data)); break; case KLFCommon.ClientInteropMessageID.ScreenshotReceive: if (data != null) { Debug.Log("Received screenshot"); KLFScreenshotDisplay.Screenshot.SetFromByteArray(data); if (KLFScreenshotDisplay.Screenshot.Image.Length <= KLFScreenshotDisplay.Settings.MaxNumBytes) { if(KLFScreenshotDisplay.Texture == null) KLFScreenshotDisplay.Texture = new Texture2D(4, 4, TextureFormat.RGB24, false, true); if(KLFScreenshotDisplay.Texture.LoadImage(KLFScreenshotDisplay.Screenshot.Image)) { KLFScreenshotDisplay.Texture.Apply(); //Make sure the screenshot texture does not exceed the size limits if(KLFScreenshotDisplay.Texture.width > KLFScreenshotDisplay.Settings.MaxWidth || KLFScreenshotDisplay.Texture.height > KLFScreenshotDisplay.Settings.MaxHeight) KLFScreenshotDisplay.Screenshot.Clear(); } else KLFScreenshotDisplay.Screenshot.Clear(); KLFScreenshotDisplay.Screenshot.Image = null; } } break; } }
private void CrewTestProto(int REASON, ProtoPartSnapshot p, double l) { int CUR_CWLS = IFICWLS; CUR_CWLS += (Convert.ToInt16(l) * 10); float rand; ProtoCrewMember iCrew; for (int i = 0; i < p.protoModuleCrew.Count; i++) { rand = UnityEngine.Random.Range(0.0f, 100.0f); IFIDebug.IFIMess("!!!!!!!!"); IFIDebug.IFIMess("Testing Crew Death Crewmember=" + p.protoModuleCrew[i].name); IFIDebug.IFIMess("Crew Death Chance = " + Convert.ToString(CUR_CWLS)); IFIDebug.IFIMess("Crew Death Roll = " + Convert.ToString(rand)); IFIDebug.IFIMess("!!!!!!!!"); if (CUR_CWLS > rand) { iCrew = p.protoModuleCrew[i]; iCrew.rosterStatus = ProtoCrewMember.RosterStatus.Dead; p.RemoveCrew(iCrew); IFIDebug.IFIMess(p.pVesselRef.vesselName + " POD Kerbal Killed due to no LS - " + iCrew.name); string message = ""; message += p.pVesselRef.vesselName + "\n\n"; message += iCrew.name + "\n Was killed due to ::"; message += "No Life Support Remaining"; message += "::"; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death from LifeSupport Failure", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); } } }
void Update() { // Detect if there are any new messages if (MessageSystem.Instance != null) { // Derive the internal message list if (messageList == null) { messageList = (List <MessageSystemButton>)messageListField.GetValue(MessageSystem.Instance); } // Go through new messages if (messageList.Count > lastMessageCount) { for (int i = (messageList.Count - lastMessageCount); i-- > 0;) { LoggingUtil.LogVerbose(this, "Message list count = {0}, message {3} = {1} + {2}", messageList.Count, messageList[i].message.message, messageList[i].message.messageTitle, i); if (LocalizationUtil.IsLocalizedString(messageList[i].message.message, deployedScienceTag)) { // Pull out the parameters IList <string> parameters = LocalizationUtil.UnLocalizeString(messageList[i].message.message, deployedScienceTag); // Identify the subject ScienceSubject subject = null; foreach (ScienceSubject sub in recentScience) { if (sub.title == parameters[0]) { subject = sub; break; } } // Subject identified if (subject != null) { LoggingUtil.LogVerbose(this, "Subject identified as {0}", subject.id); // Delete the old message MessageSystem.Instance.DiscardMessage(messageList[i].message.button); // Check for an existing summary level message MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == deployedScienceMessageTitle).FirstOrDefault(); if (message != null) { message.IsRead = false; trackedSubjects.Clear(); } trackedSubjects.Add(subject); trackedSubjects.Sort((ss1, ss2) => string.Compare(ss1.title, ss2.title)); StringBuilder sb = StringBuilderCache.Acquire(); sb.Append(string.Format("<b>{0}</b>:\n", deployedScienceMessageTitle)); foreach (ScienceSubject s in trackedSubjects) { sb.Append(string.Format(" {0}: <color=#6DCFF6><sprite=\"CurrencySpriteAsset\" name=\"Science\" tint=1> {1}</color> / <color=#6DCFF6><sprite=\"CurrencySpriteAsset\" name=\"Science\" tint=1> {2}</color>\n", s.title, s.science.ToString("F1"), s.scienceCap.ToString("F1"))); } if (message != null) { message.message = sb.ToStringAndRelease(); } else { MessageSystem.Instance.AddMessage(new MessageSystem.Message(deployedScienceMessageTitle, sb.ToStringAndRelease(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.ALERT)); } } else { LoggingUtil.LogWarning(this, "Couldn't identify subject for deployed experiment with title '{0}'", parameters[0]); } } } recentScience.Clear(); } lastMessageCount = messageList.Count; // Check for active screen messages screenMessagesToRemove.Clear(); foreach (ScreenMessage message in ScreenMessages.Instance.ActiveMessages) { if (LocalizationUtil.IsLocalizedString(message.message, deployedScienceTag)) { screenMessagesToRemove.Add(message); } } // Remove the messages foreach (ScreenMessage message in screenMessagesToRemove) { ScreenMessages.RemoveMessage(message); } } }
private void CrewTest(int REASON, Part p, double l) { int CUR_CWLS = IFICWLS; CUR_CWLS += (Convert.ToInt16(l) * 10); float rand; ProtoCrewMember iCrew; for (int i = 0; i < p.protoModuleCrew.Count; i++) { rand = UnityEngine.Random.Range(0.0f, 100.0f); IFIDebug.IFIMess("!!!!!!!!"); IFIDebug.IFIMess("Testing Crew Death Crewmember=" + p.protoModuleCrew[i].name); IFIDebug.IFIMess("Crew Death Chance = " + Convert.ToString(CUR_CWLS)); IFIDebug.IFIMess("Crew Death Roll = " + Convert.ToString(rand)); IFIDebug.IFIMess("!!!!!!!!"); if (CUR_CWLS > rand) { iCrew = p.protoModuleCrew[i]; p.RemoveCrewmember(iCrew);// Remove crew from part iCrew.Die(); // Kill crew after removal or death will reset to active. IFIDebug.IFIMess(p.vessel.vesselName + " POD Kerbal Killed due to no LS - " + iCrew.name); string message = ""; message += p.vessel.vesselName + "\n\n"; message += iCrew.name + "\n Was killed due to ::"; message += "No Life Support Remaining"; message += "::"; MessageSystem.Message m = new MessageSystem.Message("Kerbal Death from LifeSupport System", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT); MessageSystem.Instance.AddMessage(m); } } }
private void Report(ScienceExperiment experiment, float gain) { StringBuilder msg = new StringBuilder(); string[] template; if (File.Exists<KEI>(experiment.id + ".msg")) { template = File.ReadAllLines<KEI>(experiment.id + ".msg"); } else { template = File.ReadAllLines<KEI>("unknownExperiment.msg"); msg.AppendLine("Top Secret info! Project " + experiment.experimentTitle); msg.AppendLine("Eat after reading"); msg.AppendLine("And drink some coffee"); msg.AppendLine("****"); } foreach (var line in template) { msg.AppendLine(line); } msg.AppendLine(""); msg.AppendLine(string.Format("<color=#B4D455>Total science gain: {0}</color>", gain.ToString("0.00"))); MessageSystem.Message message = new MessageSystem.Message( "New Email", msg.ToString(), MessageSystemButton.MessageButtonColor.GREEN, MessageSystemButton.ButtonIcons.MESSAGE ); MessageSystem.Instance.AddMessage(message); }
public static void PostMessage(string sTitle, string sMessage, MessageSystemButton.MessageButtonColor cColor, MessageSystemButton.ButtonIcons bIcon) { MessageSystem.Message m = new MessageSystem.Message(sTitle, sMessage, cColor, bIcon); MessageSystem.Instance.AddMessage(m); }
// Returns the nearest open Launchsite to a position and range to the Launchsite in m // The basic ATC feature is in here for now public static void getNearestOpenBase(Vector3 position, out string sBase, out float flRange, out LaunchSite lNearest) { SpaceCenter KSC = SpaceCenter.Instance; var smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position); string sNearestBase = ""; string sOpenCloseState = ""; LaunchSite lNearestBase = null; LaunchSite lKSC = null; List<LaunchSite> basesites = LaunchSiteManager.getLaunchSites(); foreach (LaunchSite site in basesites) { sOpenCloseState = site.openclosestate; if (!MiscUtils.isCareerGame()) sOpenCloseState = "Open"; if (sOpenCloseState == "Open") { var radialposition = site.GameObject.transform.position; var dist = Vector3.Distance(position, radialposition); if (site.name == "Runway") { if (lNearestBase == null) lNearestBase = site; lKSC = site; } else if (site.name != "LaunchPad") { if ((float)dist < (float)smallestDist) { { sNearestBase = site.name; lNearestBase = site; smallestDist = dist; } } } else { lKSC = site; } } } if (sNearestBase == "") { sNearestBase = "KSC"; lNearestBase = lKSC; } RangeNearestOpenBase = (float)smallestDist; // Air traffic control messaging if (KerbalKonstructs.instance.enableATC) { if (sNearestBase != NearestOpenBase) { if (RangeNearestOpenBase < 25000) { NearestOpenBase = sNearestBase; MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.BLUE; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You have entered the airspace of " + sNearestBase + " ATC. Please keep this channel open and obey all signal lights. Thank you. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } else if (NearestOpenBase != "") { // you have left ... MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.GREEN; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You are now leaving the airspace of " + sNearestBase + ". Safe journey. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); NearestOpenBase = ""; } } } sBase = sNearestBase; flRange = RangeNearestOpenBase; lNearest = lNearestBase; }
private void handleInteropMessage(KLFCommon.ClientInteropMessageID id, byte[] data) { switch (id) { case KLFCommon.ClientInteropMessageID.CHAT_RECEIVE: if (data != null) { string NNmessage = encoder.GetString(data); if (!KLFGlobalSettings.instance.chatWindowEnabled || !KLFInfoDisplay.infoDisplayActive) { KLF_Button.SetTexture(KLF_button_alert); KLF_button_alert_anim = 1; if (KLFGlobalSettings.instance.SendNotifications) { MessageSystem.Message m = new MessageSystem.Message("Kerbal Live Feed Activity", NNmessage, MessageSystemButton.MessageButtonColor.YELLOW, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } } KLFChatDisplay.enqueueChatLine(NNmessage); } break; case KLFCommon.ClientInteropMessageID.CLIENT_DATA: if (data != null && data.Length > 9) { //Read inactive vessels per update count inactiveVesselsPerUpdate = data[0]; //Read screenshot height KLFScreenshotDisplay.screenshotSettings.maxHeight = KLFCommon.intFromBytes(data, 1); updateInterval = ((float)KLFCommon.intFromBytes(data, 5)) / 1000.0f; //Read username playerName = encoder.GetString(data, 9, data.Length - 9); } break; case KLFCommon.ClientInteropMessageID.PLUGIN_UPDATE: if (data != null) { //De-serialize and handle the update handleUpdate(KSP.IO.IOUtils.DeserializeFromBinary(data)); } break; case KLFCommon.ClientInteropMessageID.SCREENSHOT_RECEIVE: if (data != null) { Debug.Log("Received screenshot"); KLFScreenshotDisplay.screenshot.setFromByteArray(data); if (KLFScreenshotDisplay.screenshot.image.Length <= KLFScreenshotDisplay.screenshotSettings.maxNumBytes) { if (KLFScreenshotDisplay.texture == null) KLFScreenshotDisplay.texture = new Texture2D(4, 4, TextureFormat.RGB24, false, true); if (KLFScreenshotDisplay.texture.LoadImage(KLFScreenshotDisplay.screenshot.image)) { KLFScreenshotDisplay.texture.Apply(); //Make sure the screenshot texture does not exceed the size limits if (KLFScreenshotDisplay.texture.width > KLFScreenshotDisplay.screenshotSettings.maxWidth || KLFScreenshotDisplay.texture.height > KLFScreenshotDisplay.screenshotSettings.maxHeight) { KLFScreenshotDisplay.screenshot.clear(); } else { KLFScreenshotDisplay.watchPlayerIndex = KLFScreenshotDisplay.screenshot.index; } } else { KLFScreenshotDisplay.screenshot.clear(); } KLFScreenshotDisplay.screenshot.image = null; } } break; } }
//This posts either a success or failure message to the Stock Message system public void PostStockMessage() { StringBuilder msg = new StringBuilder(); if (recovered && Settings.Instance.ShowSuccessMessages) { //Start adding some in-game display messages about the return msg.AppendLine("<color=#8BED8B>Stage '" + StageName + "' recovered " + Math.Round(KSCDistance / 1000, 2) + " km from KSC</color>"); //msg.AppendLine("\n"); //List the percent returned and break it down into distance and speed percentages msg.AppendLine("Recovery percentage: <color=#8BED8B>" + Math.Round(100 * RecoveryPercent, 1) + "%</color>"); msg.AppendLine("<color=#8BED8B>" + Math.Round(100 * DistancePercent, 1) + "%</color> distance"); msg.AppendLine("<color=#8BED8B>" + Math.Round(100 * SpeedPercent, 1) + "%</color> speed"); msg.AppendLine(""); //List the total refunds for parts, fuel, and the combined total msg.AppendLine("Total refunds: <color=#B4D455>£" + FundsReturned + "</color>"); msg.AppendLine("Total refunded for parts: <color=#B4D455>£" + DryReturns + "</color>"); msg.AppendLine("Total refunded for fuel: <color=#B4D455>£" + FuelReturns + "</color>"); msg.AppendLine("Stage value: <color=#B4D455>£" + FundsOriginal + "</color>"); if (KerbalsOnboard.Count > 0) { msg.AppendLine("\nKerbals recovered:"); foreach (ProtoCrewMember kerbal in KerbalsOnboard) msg.AppendLine("<color=#E0D503>" + kerbal.name + "</color>"); } if (ScienceExperiments.Count > 0) { msg.AppendLine("\nScience recovered: "+ScienceRecovered); foreach (string science in ScienceExperiments) msg.AppendLine(science); } //By this point all the real work is done. Now we just display a bit of information msg.AppendLine("\nAdditional Information:"); //Display which module was used for recovery msg.AppendLine(ParachuteModule + " Module used."); //Display the terminal velocity (Vt) and what is needed to have any recovery if (Settings.Instance.FlatRateModel) msg.AppendLine("Terminal velocity of <color=#8BED8B>" + Math.Round(Vt, 2) + "</color> (less than " + Settings.Instance.CutoffVelocity + " needed)"); else msg.AppendLine("Terminal velocity of <color=#8BED8B>" + Math.Round(Vt, 2) + "</color> (less than " + Settings.Instance.HighCut + " needed)"); if (poweredRecovery) { msg.AppendLine("Propulsive landing. Check SR Flight GUI for information about amount of propellant consumed."); } msg.AppendLine("\nStage contained the following parts:"); for (int i = 0; i < PartsRecovered.Count; i++) { msg.AppendLine(PartsRecovered.Values.ElementAt(i) + " x " + PartsRecovered.Keys.ElementAt(i) + ": <color=#B4D455>£" + (PartsRecovered.Values.ElementAt(i) * Costs.Values.ElementAt(i) * RecoveryPercent) + "</color>"); } //Setup and then post the message MessageSystem.Message m = new MessageSystem.Message("Stage Recovered", msg.ToString(), MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } else if (!recovered && Settings.Instance.ShowFailureMessages) { msg.AppendLine("<color=#FF9900>Stage '" + StageName + "' destroyed " + Math.Round(KSCDistance / 1000, 2) + " km from KSC</color>"); //If we're career mode (MONEY!) then we also let you know the (why do I say 'we'? It's only me working on this) total cost of the parts if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { float totalCost = 0; //Cycle through all the parts foreach (ProtoPartSnapshot pps in vessel.protoVessel.protoPartSnapshots) { float dry, wet; //Add the max of 0 or the part cost (in case they're negative, looking at you MKS and TweakScale!) totalCost += Math.Max(ShipConstruction.GetPartCosts(pps, pps.partInfo, out dry, out wet), 0); } //Alert the user to what the total value was (without modifiers) msg.AppendLine("It was valued at <color=#FF9900>" + totalCost + "</color> Funds."); //ED0B0B } //By this point all the real work is done. Now we just display a bit of information msg.AppendLine("\nAdditional Information:"); //Display which module was used for recovery msg.AppendLine(ParachuteModule + " Module used."); //Display the terminal velocity (Vt) and what is needed to have any recovery msg.AppendLine("Terminal velocity of <color=#FF9900>" + Math.Round(Vt, 2) + "</color> (less than " + (Settings.Instance.FlatRateModel ? Settings.Instance.CutoffVelocity : Settings.Instance.HighCut) + " needed)"); //If it failed because of burning up (can be in addition to speed) then we'll let you know if (burnedUp) msg.AppendLine("The stage burned up in the atmosphere! It was travelling at " + vessel.srfSpeed + " m/s."); if (poweredRecovery && !burnedUp) { msg.AppendLine("Attempted propulsive landing but could not reduce velocity enough for safe touchdown. Check the SR Flight GUI for additonal info."); } if (noControl) { msg.AppendLine("Attempted propulsive landing but could not find a point of control. Add a pilot or probe core with SAS for propulsive landings."); } msg.AppendLine("\nStage contained the following parts:"); for (int i = 0; i < PartsRecovered.Count; i++) { msg.AppendLine(PartsRecovered.Values.ElementAt(i) + " x " + PartsRecovered.Keys.ElementAt(i)); } //Now we actually create and post the message MessageSystem.Message m = new MessageSystem.Message("Stage Destroyed", msg.ToString(), MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } }
public static void DisplayMessage(String title, StringBuilder text, MessageSystemButton.MessageButtonColor color, MessageSystemButton.ButtonIcons icon) { MessageSystem.Message m = new MessageSystem.Message(title, text.ToString(), color, icon); MessageSystem.Instance.AddMessage(m); }
// Get the nearest open base and range to it public static void getNearestOpenBase(Vector3 position, out string sBase, out float flRange, out LaunchSite lNearest) { SpaceCenter KSC = SpaceCenter.Instance; var smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position); string sNearestBase = ""; string sOpenCloseState = ""; LaunchSite lNearestBase = null; LaunchSite lKSC = null; List <LaunchSite> basesites = LaunchSiteManager.getLaunchSites(); foreach (LaunchSite site in basesites) { sOpenCloseState = site.openclosestate; if (!MiscUtils.isCareerGame()) { sOpenCloseState = "Open"; } //if (site.recoveryfactor == 0) continue; if (sOpenCloseState == "Open") { var radialposition = site.GameObject.transform.position; var dist = Vector3.Distance(position, radialposition); if (site.name == "Runway") { if (lNearestBase == null) { lNearestBase = site; } lKSC = site; } else if (site.name != "LaunchPad") { if ((float)dist < (float)smallestDist) { { sNearestBase = site.name; lNearestBase = site; smallestDist = dist; } } } else { lKSC = site; } } } if (sNearestBase == "") { sNearestBase = "KSC"; lNearestBase = lKSC; } RangeNearestOpenBase = (float)smallestDist; // Air traffic control messaging if (KerbalKonstructs.instance.enableATC) { if (sNearestBase != NearestOpenBase) { if (RangeNearestOpenBase < 25000) { NearestOpenBase = sNearestBase; MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.BLUE; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You have entered the airspace of " + sNearestBase + " ATC. Please keep this channel open and obey all signal lights. Thank you. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); } else if (NearestOpenBase != "") { // you have left ... MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.GREEN; MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You are now leaving the airspace of " + sNearestBase + ". Safe journey. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE); MessageSystem.Instance.AddMessage(m); NearestOpenBase = ""; } } } sBase = sNearestBase; flRange = RangeNearestOpenBase; lNearest = lNearestBase; }