diff --git a/DeepFreeze.zip b/DeepFreeze.zip index 027877c..499aaff 100644 Binary files a/DeepFreeze.zip and b/DeepFreeze.zip differ diff --git a/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version b/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version index 265fee6..c43efce 100644 --- a/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version +++ b/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version @@ -2,7 +2,7 @@ "NAME":"DeepFreeze Continued...", "URL":"http://ksp-avc.cybutek.net/version.php?id=183", "DOWNLOAD":"https://kerbalstuff.com/mod/895/DeepFreeze%20Continued...", -"VERSION":{"MAJOR":0,"MINOR":19,"PATCH":0,"BUILD":0}, +"VERSION":{"MAJOR":0,"MINOR":19,"PATCH":1,"BUILD":0}, "KSP_VERSION":{"MAJOR":1,"MINOR":0,"PATCH":4}, "KSP_VERSION_MIN":{"MAJOR":1,"MINOR":0,"PATCH":0}, "KSP_VERSION_MAX":{"MAJOR":1,"MINOR":0,"PATCH":4} diff --git a/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg b/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg index 30eb596..5f6dae0 100644 --- a/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg +++ b/GameData/REPOSoftTech/DeepFreeze/Plugins/Config.cfg @@ -2,9 +2,11 @@ DFSettings { DFwindowPosX = 40 DFwindowPosY = 50 - CFwindowPosX = 450 - CFwindowPosY = 50 + CFwindowPosX = 500 + CFwindowPosY = 140 ECreqdForFreezer = False + fatalOption = True + comatoseTime = 300 UseAppLauncher = True debugging = False AutoRecoverFznKerbals = True diff --git a/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll index f41db9e..933a741 100644 Binary files a/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll and b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll differ diff --git a/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll.mdb b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll.mdb new file mode 100644 index 0000000..6c2c2c5 Binary files /dev/null and b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll.mdb differ diff --git a/Source/Changelog.txt b/Source/Changelog.txt index dc191f5..953f11a 100644 --- a/Source/Changelog.txt +++ b/Source/Changelog.txt @@ -1,4 +1,8 @@ -[B]V0.19.0.0 "Bug fixes & Enhancements"[/B] +[B]V0.19.1.0 "Bug fixes & Enhancements"[/B] +Added comatose function for when EC or Heat options are ON and Fatal option is OFF. Now when you run out of EC or overheat with these options set kerbals will be emergency thawed +and become comatose (tourists) for a period of 5 minutes (can be changed in the settings menu). +Fixed bug with new pop-up windows when EC is critical or overheat - this pop-up will now NOT appear if the active vessel is the vessel that has run out of EC or overheat. +[B]V0.19.0.0 "Bug fixes & Enhancements"[/B] Added Fatal EC/Heat option. If this is ON kerbals will die if EC runs out or it gets too hot (if you are using the EC and Heat options). If this is OFF the Kerbals will be emergency thawed and become available again, and start consuming LS resources again. (to-do - expand this to perhaps make them unusable for a period of time due to emergency thaw effects, but not in this version) Default setting (for compatibility) is set to ON. - IE: running out of EC or over-heating will Kill kerbals. diff --git a/Source/DFIntMemory.cs b/Source/DFIntMemory.cs index fa1646c..8544060 100644 --- a/Source/DFIntMemory.cs +++ b/Source/DFIntMemory.cs @@ -90,7 +90,7 @@ private void Awake() if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null) onVesselChange(FlightGlobals.ActiveVessel); } - catch (Exception ex) + catch (Exception) { this.Log_Debug("Invalid Freezer Cam Code in settings. Settings value=" + DeepFreeze.Instance.DFsettings.internalFrzrCamCode); keyFrzrCam = (KeyCode)100; @@ -303,7 +303,7 @@ private void Update() { kerbalname = ActFrzrCams[lastFrzrCam].FrzrCamPart.part.internalModel.seats[lastFrzrCam].kerbalRef.name; } - catch (Exception ex) + catch (Exception) { kerbalname = string.Empty; } @@ -317,10 +317,23 @@ private void FixedUpdate() { if (HighLogic.LoadedSceneIsEditor || Time.timeSinceLevelLoad < 5f) return; //Wait 5 seconds on level load before executing + //We check/update kerbal Dictionary for comatose kerbals in EVERY Game Scene. + try + { + if (DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Count() > 0) + CheckComaUpdate(); + } + catch (Exception ex) + { + this.Log("FixedUpdate failed to update DeepFreeze Internal Comatose Kerbals Memory"); + this.Log("Err: " + ex); + } + //We check/update Vessel and Part Dictionary in EVERY Game Scene. try { - CheckVslUpdate(); + if (DeepFreeze.Instance.DFgameSettings.knownVessels.Count() > 0) + CheckVslUpdate(); } catch (Exception ex) { @@ -343,6 +356,32 @@ private void FixedUpdate() } } + private void CheckComaUpdate() + { + // Check the knownfrozenkerbals for any tourists kerbals (IE: Comatose) if their time is up and reset them if it is. + var keysToDelete = new List(); + foreach (KeyValuePair comaKerbals in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals) + { + if (comaKerbals.Value.type == ProtoCrewMember.KerbalType.Tourist) + { + if (Planetarium.GetUniversalTime() - comaKerbals.Value.lastUpdate > (double)DeepFreeze.Instance.DFsettings.comatoseTime) // Is time up? + { + ProtoCrewMember crew = HighLogic.CurrentGame.CrewRoster.Tourist.FirstOrDefault(a => a.name == comaKerbals.Key); + if (crew != null) + { + Utilities.setComatoseKerbal(crew, ProtoCrewMember.KerbalType.Crew); + keysToDelete.Add(comaKerbals.Key); + } + else + { + this.Log("Unable to set comatose crew member " + comaKerbals.Key + " back to crew status."); + } + } + } + } + keysToDelete.ForEach(id => DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(id)); + } + private void ChkUnknownFrozenKerbals() { // Check the roster list for any unknown dead kerbals (IE: Frozen) that were not in the save file and add them. @@ -612,7 +651,7 @@ private void resetFreezerCams() } } } - catch (Exception ex) + catch (Exception) { this.Log("Failed to resetFreezerCams"); //this.Log("Err: " + ex); @@ -724,13 +763,13 @@ private void UpdatePredictedVesselEC(VesselInfo vesselInfo, Vessel vessel, doubl frznChargeRequired = (int)frzr.Value.frznChargeRequired; ECreqdsincelastupdate += ((frznChargeRequired / 60.0f) * timeperiod * frzr.Value.numFrznCrew); frzr.Value.deathCounter = currentTime; - this.Log_Debug("predicted EC part " + frzr.Value.vesselID + " " + frzr.Value.PartName + " FrznChargeRequired " + frznChargeRequired + " timeperiod " + timeperiod + " #frzncrew " + frzr.Value.numFrznCrew); + //this.Log_Debug("predicted EC part " + frzr.Value.vesselID + " " + frzr.Value.PartName + " FrznChargeRequired " + frznChargeRequired + " timeperiod " + timeperiod + " #frzncrew " + frzr.Value.numFrznCrew); } double ECafterlastupdate = vesselInfo.storedEC - ECreqdsincelastupdate; double predictedMinutes = ECafterlastupdate / frznChargeRequired; // This probably should be per PART, but for simplicity we will do for the whole vessel vesselInfo.predictedECOut = predictedMinutes * 60; - this.Log_Debug("UpdatePredictedVesselEC vessel " + vessel.id + " " + vessel.name + " StoredEC=" + vesselInfo.storedEC + " ECreqd=" + ECreqdsincelastupdate + " Prediction Secs=" + vesselInfo.predictedECOut); - this.Log_Debug("ECafterlastupdate " + ECafterlastupdate + " FrznChargeRequired " + frznChargeRequired + " predictedMinutes " + predictedMinutes); + //this.Log_Debug("UpdatePredictedVesselEC vessel " + vessel.id + " " + vessel.name + " StoredEC=" + vesselInfo.storedEC + " ECreqd=" + ECreqdsincelastupdate + " Prediction Secs=" + vesselInfo.predictedECOut); + //this.Log_Debug("ECafterlastupdate " + ECafterlastupdate + " FrznChargeRequired " + frznChargeRequired + " predictedMinutes " + predictedMinutes); } private void UpdateVesselInfo(VesselInfo vesselInfo, Vessel vessel, double currentTime) diff --git a/Source/DFSettings.cs b/Source/DFSettings.cs index f1eb8e1..774c46d 100644 --- a/Source/DFSettings.cs +++ b/Source/DFSettings.cs @@ -32,6 +32,7 @@ internal class DFSettings internal bool debugging { get; set; } internal bool ECreqdForFreezer { get; set; } internal bool fatalOption { get; set; } + internal float comatoseTime { get; set; } internal bool AutoRecoverFznKerbals { get; set; } internal float KSCcostToThawKerbal { get; set; } internal int ECReqdToFreezeThaw { get; set; } @@ -59,14 +60,15 @@ internal DFSettings() { DFwindowPosX = 40; DFwindowPosY = 50; - CFwindowPosX = 380; - CFwindowPosY = 50; + CFwindowPosX = 500; + CFwindowPosY = 140; DFKACwindowPosX = 600; DFKACwindowPosY = 50; UseAppLauncher = true; debugging = true; ECreqdForFreezer = true; fatalOption = true; + comatoseTime = 300; AutoRecoverFznKerbals = true; KSCcostToThawKerbal = 10000f; ECReqdToFreezeThaw = 3000; @@ -106,6 +108,7 @@ internal void Load(ConfigNode node) DFKACwindowPosY = Utilities.GetNodeValue(DFsettingsNode, "DFKACwindowPosY", DFKACwindowPosY); ECreqdForFreezer = Utilities.GetNodeValue(DFsettingsNode, "ECreqdForFreezer", ECreqdForFreezer); fatalOption = Utilities.GetNodeValue(DFsettingsNode, "fatalOption", fatalOption); + comatoseTime = Utilities.GetNodeValue(DFsettingsNode, "comatoseTime", comatoseTime); UseAppLauncher = Utilities.GetNodeValue(DFsettingsNode, "UseAppLauncher", UseAppLauncher); debugging = Utilities.GetNodeValue(DFsettingsNode, "debugging", debugging); AutoRecoverFznKerbals = Utilities.GetNodeValue(DFsettingsNode, "AutoRecoverFznKerbals", AutoRecoverFznKerbals); @@ -154,6 +157,7 @@ internal void Save(ConfigNode node) settingsNode.AddValue("DFKACwindowPosY", DFKACwindowPosY); settingsNode.AddValue("ECreqdForFreezer", ECreqdForFreezer); settingsNode.AddValue("fatalOption", fatalOption); + settingsNode.AddValue("comatoseTime", comatoseTime); settingsNode.AddValue("UseAppLauncher", UseAppLauncher); settingsNode.AddValue("debugging", debugging); settingsNode.AddValue("AutoRecoverFznKerbals", AutoRecoverFznKerbals); diff --git a/Source/DeepFreezeGUI.cs b/Source/DeepFreezeGUI.cs index 3cae239..cce110a 100644 --- a/Source/DeepFreezeGUI.cs +++ b/Source/DeepFreezeGUI.cs @@ -45,7 +45,7 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable private static int KACwindowID = 2000001; private static int VSwindowID = 2000002; private static int VSFwindowID = 2000003; - private GUIStyle statusStyle, frozenStyle, sectionTitleStyle, resizeStyle, StatusOKStyle, StatusWarnStyle, StatusRedStyle, StatusGrayStyle, ButtonStyle; + private GUIStyle statusStyle, frozenStyle, comaStyle, sectionTitleStyle, resizeStyle, StatusOKStyle, StatusWarnStyle, StatusRedStyle, StatusGrayStyle, ButtonStyle; private Vector2 GUIscrollViewVector, GUIscrollViewVector2, GUIscrollViewVectorKAC, GUIscrollViewVectorKACKerbals = Vector2.zero; private bool mouseDownDF = false; private bool mouseDownKAC = false; @@ -101,6 +101,8 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable private bool InputVTempinKelvin = true; private bool InputStripLightsOn = true; private bool InputfatalOption = false; + private string InputScomatoseTime = ""; + private float InputVcomatoseTime = 0f; //Settings vars private bool ECreqdForFreezer; @@ -110,6 +112,7 @@ internal class DeepFreezeGUI : MonoBehaviour, Savable private float KSCcostToThawKerbal; private int ECReqdToFreezeThaw; private bool fatalOption; + private float comatoseTime; private int GlykerolReqdToFreeze; private bool RegTempReqd; private double RegTempFreeze; @@ -311,7 +314,7 @@ private void onDraw() } if (switchVesselManual) { - if (Planetarium.GetUniversalTime() - switchVesselManualTimer > 30) + if (Planetarium.GetUniversalTime() - switchVesselManualTimer > 120) { switchVesselManualTimer = 0; switchVesselManual = false; @@ -339,6 +342,8 @@ private void onDraw() InputScostThawKerbal = KSCcostToThawKerbal.ToString(); InputSecReqdToFreezeThaw = ECReqdToFreezeThaw.ToString(); InputfatalOption = fatalOption; + InputScomatoseTime = comatoseTime.ToString(); + InputVcomatoseTime = comatoseTime; InputSglykerolReqdToFreeze = GlykerolReqdToFreeze.ToString(); InputVRegTempReqd = RegTempReqd; InputSRegTempFreeze = RegTempFreeze.ToString(); @@ -383,6 +388,11 @@ private void windowDF(int id) frozenStyle.stretchWidth = true; frozenStyle.normal.textColor = Color.cyan; + comaStyle = new GUIStyle(GUI.skin.label); + comaStyle.alignment = TextAnchor.MiddleLeft; + comaStyle.stretchWidth = true; + comaStyle.normal.textColor = Color.gray; + StatusOKStyle = new GUIStyle(GUI.skin.label); StatusOKStyle.alignment = TextAnchor.MiddleLeft; StatusOKStyle.stretchWidth = true; @@ -464,7 +474,13 @@ private void windowDF(int id) GUILayout.Label(TempVar, StatusRedStyle, GUILayout.Width(DFvslPrtTmp)); switchVessel = FlightGlobals.Vessels.Find(a => a.id == frzr.Value.vesselID); showSwitchVesselStr = "Vessel " + switchVessel.vesselName + " is Over-Heating."; - showSwitchVessel = true; + if (HighLogic.LoadedSceneIsFlight) + { + if (FlightGlobals.ActiveVessel.id != frzr.Value.vesselID && !switchVesselManual) + { + showSwitchVessel = true; + } + } break; } } @@ -487,7 +503,13 @@ private void windowDF(int id) GUILayout.Label("OUT", StatusRedStyle, GUILayout.Width(DFvslPrtElec)); switchVessel = FlightGlobals.Vessels.Find(a => a.id == frzr.Value.vesselID); showSwitchVesselStr = "Vessel " + switchVessel.vesselName + " is out of ElectricCharge.\n Situation Critical."; - showSwitchVessel = true; + if (HighLogic.LoadedSceneIsFlight) + { + if (FlightGlobals.ActiveVessel.id != frzr.Value.vesselID && !switchVesselManual) + { + showSwitchVessel = true; + } + } } else { @@ -496,7 +518,13 @@ private void windowDF(int id) GUILayout.Label("ALRT", StatusRedStyle, GUILayout.Width(DFvslPrtElec)); switchVessel = FlightGlobals.Vessels.Find(a => a.id == frzr.Value.vesselID); showSwitchVesselStr = "Vessel " + switchVessel.vesselName + " is almost out of ElectricCharge."; - showSwitchVessel = true; + if (HighLogic.LoadedSceneIsFlight) + { + if (FlightGlobals.ActiveVessel.id != frzr.Value.vesselID && !switchVesselManual) + { + showSwitchVessel = true; + } + } } else { @@ -649,48 +677,52 @@ private void windowDF(int id) foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals) { GUILayout.BeginHorizontal(); - GUILayout.Label(kerbal.Key, frozenStyle, GUILayout.Width(DFtxtWdthName)); - GUILayout.Label(kerbal.Value.experienceTraitName, frozenStyle, GUILayout.Width(DFtxtWdthProf)); - GUILayout.Label(kerbal.Value.vesselName, frozenStyle, GUILayout.Width(DFtxtWdthVslN)); - if (HighLogic.LoadedScene == GameScenes.FLIGHT && DFIntMemory.Instance.ActVslHasDpFrezr) - //if in flight and active vessel has a Freezer part check if kerbal is part of this vessel and add a Thaw button to the GUI + GUIStyle dispstyle = (kerbal.Value.type != ProtoCrewMember.KerbalType.Tourist ? frozenStyle : comaStyle); + GUILayout.Label(kerbal.Key, dispstyle, GUILayout.Width(DFtxtWdthName)); + GUILayout.Label(kerbal.Value.experienceTraitName, dispstyle, GUILayout.Width(DFtxtWdthProf)); + GUILayout.Label(kerbal.Value.vesselName, dispstyle, GUILayout.Width(DFtxtWdthVslN)); + if (kerbal.Value.type != ProtoCrewMember.KerbalType.Tourist) { - //foreach (DeepFreezer frzr in DFIntMemory.Instance.DpFrzrActVsl) - //{ - //if (frzr.DFIStoredCrewList.FirstOrDefault(a => a.CrewName == kerbal.Key) != null) - if (kerbal.Value.vesselID == FlightGlobals.ActiveVessel.id) + if (HighLogic.LoadedScene == GameScenes.FLIGHT && DFIntMemory.Instance.ActVslHasDpFrezr) + //if in flight and active vessel has a Freezer part check if kerbal is part of this vessel and add a Thaw button to the GUI { - if (DFInstalledMods.IsRTInstalled && !DFInstalledMods.RTVesselConnected(DFIntMemory.Instance.ActVslID)) - { - GUI.enabled = false; - } - if (GUILayout.Button(new GUIContent("Thaw", "Thaw this Kerbal"), GUILayout.Width(50f))) + //foreach (DeepFreezer frzr in DFIntMemory.Instance.DpFrzrActVsl) + //{ + //if (frzr.DFIStoredCrewList.FirstOrDefault(a => a.CrewName == kerbal.Key) != null) + if (kerbal.Value.vesselID == FlightGlobals.ActiveVessel.id && kerbal.Value.type != ProtoCrewMember.KerbalType.Tourist) { - DeepFreezer frzr = DFIntMemory.Instance.DpFrzrActVsl.FirstOrDefault(a => a.part.flightID == kerbal.Value.partID); - if (frzr != null) - frzr.beginThawKerbal(kerbal.Key); + if (DFInstalledMods.IsRTInstalled && !DFInstalledMods.RTVesselConnected(DFIntMemory.Instance.ActVslID)) + { + GUI.enabled = false; + } + if (GUILayout.Button(new GUIContent("Thaw", "Thaw this Kerbal"), GUILayout.Width(50f))) + { + DeepFreezer frzr = DFIntMemory.Instance.DpFrzrActVsl.FirstOrDefault(a => a.part.flightID == kerbal.Value.partID); + if (frzr != null) + frzr.beginThawKerbal(kerbal.Key); + } + GUI.enabled = true; } - GUI.enabled = true; + //} } - //} - } - if (HighLogic.LoadedScene == GameScenes.SPACECENTER) - { - if (GUILayout.Button(new GUIContent("Thaw", "Thaw this Kerbal"), GUILayout.Width(50f))) + if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { - // We need to check kerbal isn't in a vessel still out there somewhere.... - Vessel vessel = FlightGlobals.Vessels.Find(v => v.id == kerbal.Value.vesselID); - if (vessel != null) - { - this.Log_Debug("Cannot thaw, vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName); - ScreenMessages.PostScreenMessage("Cannot thaw " + kerbal.Key + " from KSC. Vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName, 5.0f, ScreenMessageStyle.UPPER_CENTER); - } - else + if (GUILayout.Button(new GUIContent("Thaw", "Thaw this Kerbal"), GUILayout.Width(50f))) { - ThawKeysToDelete.Add(new KeyValuePair(kerbal.Key, kerbal.Value)); + // We need to check kerbal isn't in a vessel still out there somewhere.... + Vessel vessel = FlightGlobals.Vessels.Find(v => v.id == kerbal.Value.vesselID); + if (vessel != null) + { + this.Log_Debug("Cannot thaw, vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName); + ScreenMessages.PostScreenMessage("Cannot thaw " + kerbal.Key + " from KSC. Vessel still exists " + vessel.situation.ToString() + " at " + vessel.mainBody.bodyName, 5.0f, ScreenMessageStyle.UPPER_CENTER); + } + else + { + ThawKeysToDelete.Add(new KeyValuePair(kerbal.Key, kerbal.Value)); + } } } - } + } GUILayout.EndHorizontal(); //} } @@ -719,16 +751,19 @@ private void windowDF(int id) GUILayout.Label(crewMember.name, statusStyle, GUILayout.Width(DFtxtWdthName)); GUILayout.Label(crewMember.experienceTrait.Title, statusStyle, GUILayout.Width(DFtxtWdthProf)); GUILayout.Label(frzr.part.vessel.vesselName, statusStyle, GUILayout.Width(DFtxtWdthVslN)); - if (frzr.DFIcrewXferFROMActive || frzr.DFIcrewXferTOActive || (DFInstalledMods.SMInstalled && frzr.IsSMXferRunning()) - || frzr.IsFreezeActive || frzr.IsThawActive || (DFInstalledMods.IsRTInstalled && !DFInstalledMods.RTVesselConnected(DFIntMemory.Instance.ActVslID))) + if (crewMember.type != ProtoCrewMember.KerbalType.Tourist) { - GUI.enabled = false; - } - if (GUILayout.Button(new GUIContent("Freeze", "Freeze this Kerbal"), GUILayout.Width(50f))) - { - frzr.beginFreezeKerbal(crewMember); - } - GUI.enabled = true; + if (frzr.DFIcrewXferFROMActive || frzr.DFIcrewXferTOActive || (DFInstalledMods.SMInstalled && frzr.IsSMXferRunning()) + || frzr.IsFreezeActive || frzr.IsThawActive || (DFInstalledMods.IsRTInstalled && !DFInstalledMods.RTVesselConnected(DFIntMemory.Instance.ActVslID))) + { + GUI.enabled = false; + } + if (GUILayout.Button(new GUIContent("Freeze", "Freeze this Kerbal"), GUILayout.Width(50f))) + { + frzr.beginFreezeKerbal(crewMember); + } + GUI.enabled = true; + } GUILayout.EndHorizontal(); } } @@ -801,6 +836,18 @@ private void windowCF(int id) GUILayout.EndHorizontal(); GUI.enabled = true; + if (InputfatalOption) GUI.enabled = false; + GUILayout.BeginHorizontal(); + GUILayout.Box(new GUIContent("Non Fatal Kerbal Comatose Time(in secs)", "The time in seconds a kerbal is comatose if fatal EC/Heat option is off"), statusStyle, GUILayout.Width(250)); + InputScomatoseTime = Regex.Replace(GUILayout.TextField(InputScomatoseTime, 5, GUILayout.MinWidth(30.0F)), "[^.0-9]", ""); //you can play with the width of the text box + GUILayout.EndHorizontal(); + GUI.enabled = true; + + if (!float.TryParse(InputScomatoseTime, out InputVcomatoseTime)) + { + InputVcomatoseTime = comatoseTime; + } + GUILayout.BeginHorizontal(); GUILayout.Box(new GUIContent("AutoRecover Frozen Kerbals at KSC", "If on, will AutoRecover Frozen Kerbals at the KSC and deduct the Cost from your funds"), statusStyle, GUILayout.Width(280)); InputVautoRecover = GUILayout.Toggle(InputVautoRecover, "", GUILayout.MinWidth(30.0F)); //you can play with the width of the text box @@ -1159,7 +1206,7 @@ private void windowKAC(int id) GUILayout.EndHorizontal(); } //Frozen Crew List - List> frzncrew = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Where(f => f.Value.partID == frzr.Key).ToList(); + List> frzncrew = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Where(f => f.Value.partID == frzr.Key && f.Value.type != ProtoCrewMember.KerbalType.Tourist).ToList(); foreach (KeyValuePair crew in frzncrew) { GUILayout.BeginHorizontal(); @@ -1253,7 +1300,7 @@ private void windowVS(int id) //Pause the game TimeWarp.SetRate(0, true); - if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready) + if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && !FlightDriver.Pause) FlightDriver.SetPause(true); GUILayout.BeginVertical(); @@ -1263,7 +1310,7 @@ private void windowVS(int id) GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - if (GUILayout.Button(new GUIContent("Switch to Vessel", "Switch to Vessel"), GUILayout.Width(320))) + if (GUILayout.Button(new GUIContent("Switch to Vessel", "Switch to Vessel"), GUILayout.Width(160))) { showSwitchVessel = false; if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready) @@ -1289,6 +1336,14 @@ private void windowVS(int id) } } } + if (GUILayout.Button(new GUIContent("Not Now", "Don't switch vessel now"), GUILayout.Width(160))) + { + showSwitchVessel = false; + switchVesselManual = true; + switchVesselManualTimer = Planetarium.GetUniversalTime(); + if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready) + FlightDriver.SetPause(false); + } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(); @@ -1433,6 +1488,7 @@ public void Load(ConfigNode globalNode) debugging = DeepFreeze.Instance.DFsettings.debugging; ECreqdForFreezer = DeepFreeze.Instance.DFsettings.ECreqdForFreezer; fatalOption = DeepFreeze.Instance.DFsettings.fatalOption; + comatoseTime = DeepFreeze.Instance.DFsettings.comatoseTime; KSCcostToThawKerbal = DeepFreeze.Instance.DFsettings.KSCcostToThawKerbal; ECReqdToFreezeThaw = DeepFreeze.Instance.DFsettings.ECReqdToFreezeThaw; GlykerolReqdToFreeze = DeepFreeze.Instance.DFsettings.GlykerolReqdToFreeze; @@ -1460,6 +1516,7 @@ public void Save(ConfigNode globalNode) DeepFreeze.Instance.DFsettings.debugging = debugging; DeepFreeze.Instance.DFsettings.ECreqdForFreezer = ECreqdForFreezer; DeepFreeze.Instance.DFsettings.fatalOption = fatalOption; + DeepFreeze.Instance.DFsettings.comatoseTime = comatoseTime; DeepFreeze.Instance.DFsettings.KSCcostToThawKerbal = KSCcostToThawKerbal; DeepFreeze.Instance.DFsettings.ECReqdToFreezeThaw = ECReqdToFreezeThaw; DeepFreeze.Instance.DFsettings.GlykerolReqdToFreeze = GlykerolReqdToFreeze; diff --git a/Source/DeepFreezerPart.cs b/Source/DeepFreezerPart.cs index 1158283..fbdcc72 100644 --- a/Source/DeepFreezerPart.cs +++ b/Source/DeepFreezerPart.cs @@ -681,7 +681,7 @@ private void checkRPMPodTransparencySetting() } } } - catch (Exception ex) + catch (Exception) { Utilities.Log("DeepFreezer", " Error checking RPM TransparentPod Setting"); //Utilities.Log("DeepFreezer ", ex.Message); @@ -959,7 +959,7 @@ private void ChkOngoingEC(PartInfo partInfo) FrznChargeUsage = (float)ResAvail; } } - Debug.Log("DeepFreezer Ran out of EC to run the freezer"); + //Debug.Log("DeepFreezer Ran out of EC to run the freezer"); if (!partInfo.ECWarning) { if (TimeWarp.CurrentRateIndex > 1) Utilities.stopWarp(); @@ -1310,7 +1310,8 @@ private void UpdateEvents() { foreach (var CrewMember in part.protoModuleCrew) // We Add Freeze Events for all active crew in the part { - addFreezeEvent(CrewMember); + if (CrewMember.type != ProtoCrewMember.KerbalType.Tourist) + addFreezeEvent(CrewMember); } } if ((part.protoModuleCrew.Count < part.CrewCapacity) || part.CrewCapacity <= 0) // If part is not full or zero (should always be true, think this is redundant line) @@ -1688,7 +1689,7 @@ private void FreezeKerbal(ProtoCrewMember CrewMember) { ToFrzeKerbalSeat = CrewMember.seatIdx; } - catch (Exception ex) + catch (Exception) { Debug.Log("Unable to find internal seat index for " + CrewMember.name); //Debug.Log("Err: " + ex); @@ -1851,7 +1852,7 @@ private void ProcessThawKerbal() { case 0: //Begin - this.Log_Debug("Thaw Step 0"); + //this.Log_Debug("Thaw Step 0"); ThawKerbalStep0(ToThawKerbal); if (vesselisinInternal) { @@ -1865,7 +1866,7 @@ private void ProcessThawKerbal() case 1: //Get EC and Glykerol - this.Log_Debug("Thaw Step 1"); + //this.Log_Debug("Thaw Step 1"); if (skipThawStep1) { this.Log_Debug("Skipping step 1 of Thaw process"); @@ -1901,7 +1902,7 @@ private void ProcessThawKerbal() case 2: //thaw the cryopod window - this.Log_Debug("Thaw Step 2"); + //this.Log_Debug("Thaw Step 2"); if (partHasInternals && !isPartAnimated) // Part has no animated cryopods but has internals. Set window to off and skip to step 4. { @@ -1930,7 +1931,7 @@ private void ProcessThawKerbal() { if (_windowAnimation.IsPlaying("CryopodWindowOpen")) { - this.Log_Debug("waiting for the pod animation to complete the thaw"); + //this.Log_Debug("waiting for the pod animation to complete the thaw"); ThawWindowAnimPlaying = true; } else @@ -1960,7 +1961,7 @@ private void ProcessThawKerbal() case 3: //open the Pod door Hal - this.Log_Debug("Thaw Step 3"); + //this.Log_Debug("Thaw Step 3"); if (partHasInternals && isPartAnimated) { if (!OpenPodAnimPlaying) // If animation not already playing start it playing. @@ -1979,7 +1980,7 @@ private void ProcessThawKerbal() { if (_animation.IsPlaying("Open")) { - this.Log_Debug("waiting for the pod animation to complete the thaw"); + //this.Log_Debug("waiting for the pod animation to complete the thaw"); OpenPodAnimPlaying = true; } else @@ -2008,7 +2009,7 @@ private void ProcessThawKerbal() case 4: //Finalise - this.Log_Debug("Thaw Step 4"); + //this.Log_Debug("Thaw Step 4"); ThawKerbalStep4(ToThawKerbal); break; } @@ -2269,8 +2270,7 @@ private void TexReplacerPersonaliseKerbal(Kerbal kerbal) //This will re-personalise a kerbal who has been personalised using Texture replacer mod. try { - this.Log_Debug("Texture Replacer installed. Re-PersonliseKerbal"); - //global::TextureReplacer.Personaliser.instance.personaliseIva(kerbal); + this.Log_Debug("Texture Replacer installed. Re-PersonliseKerbal"); if (TRWrapper.APIReady && TRWrapper.InstanceExists) { TRWrapper.TexRepPersonaliser.personaliseIva(kerbal); @@ -2362,8 +2362,44 @@ private void ThawKerbalStep4(String frozenkerbal) ScreenMessages.PostScreenMessage(frozenkerbal + " thawed out", 5.0f, ScreenMessageStyle.UPPER_CENTER); if (emergencyThawInProgress) { - ScreenMessages.PostScreenMessage(frozenkerbal + " was thawed out due to lack of Electrical Charge to run cryogenics", 10.0f, ScreenMessageStyle.UPPER_CENTER); + ScreenMessages.PostScreenMessage(frozenkerbal + " was thawed out due to lack of Electrical Charge to run cryogenics", 5.0f, ScreenMessageStyle.UPPER_CENTER); Debug.Log("DeepFreezer - kerbal " + frozenkerbal + " was thawed out due to lack of Electrical charge to run cryogenics"); + Utilities.setComatoseKerbal(kerbal, ProtoCrewMember.KerbalType.Tourist); + + // Update the saved frozen kerbals dictionary + KerbalInfo kerbalInfo = new KerbalInfo(Planetarium.GetUniversalTime()); + kerbalInfo.vesselID = CrntVslID; + kerbalInfo.vesselName = CrntVslName; + kerbalInfo.experienceTraitName = kerbal.experienceTrait.Title; + kerbalInfo.type = ProtoCrewMember.KerbalType.Tourist; + kerbalInfo.status = ProtoCrewMember.RosterStatus.Assigned; + if (partHasInternals) + { + kerbalInfo.seatName = ToFrzeKerbalXformNme; + kerbalInfo.seatIdx = ToFrzeKerbalSeat; + } + else + { + kerbalInfo.seatName = "Unknown"; + kerbalInfo.seatIdx = -1; + } + kerbalInfo.partID = CrntPartID; + this.Log_Debug("Adding New Comatose Crew to dictionary"); + try + { + if (!DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.ContainsKey(kerbal.name)) + { + DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Add(kerbal.name, kerbalInfo); + } + if (DeepFreeze.Instance.DFsettings.debugging) DeepFreeze.Instance.DFgameSettings.DmpKnownFznKerbals(); + } + catch (Exception ex) + { + this.Log("Unable to add to knownfrozenkerbals comatose crewmember " + kerbal.name); + this.Log("Err: " + ex); + ScreenMessages.PostScreenMessage("DeepFreezer mechanical failure", 5.0f, ScreenMessageStyle.UPPER_CENTER); + } + } Debug.Log("Thawed out: " + frozenkerbal); UpdateCounts(); // Update the Crew counts @@ -3148,9 +3184,8 @@ internal void resetFrozenKerbals() // Iterate through the dictionary of all known frozen kerbals foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals) { - // if the known kerbal is in this part in this vessel - - if (kerbal.Value.vesselID == CrntVslID && kerbal.Value.partID == CrntPartID) + // if the known kerbal is in this part in this vessel & they are not comatose/tourist + if (kerbal.Value.vesselID == CrntVslID && kerbal.Value.partID == CrntPartID && kerbal.Value.type != ProtoCrewMember.KerbalType.Tourist) { FrznCrewMbr fzncrew = new FrznCrewMbr(kerbal.Key, kerbal.Value.seatIdx, CrntVslID, CrntVslName); FrznCrewMbr tmpcrew = _StoredCrewList.Find(a => a.CrewName == kerbal.Key); @@ -3158,7 +3193,6 @@ internal void resetFrozenKerbals() { //add them to our storedcrewlist for this part. Utilities.Log_Debug("DeepFreezer", "Adding frozen kerbal to this part storedcrewlist " + kerbal.Key); - _StoredCrewList.Add(fzncrew); } @@ -3186,7 +3220,7 @@ internal void resetFrozenKerbals() crewmember.KerbalRef.showHelmet = false; crewmember.KerbalRef.ShowHelmet(false); } - this.Log_Debug("Kerbal kerbalref = " + crewmember.KerbalRef.GetInstanceID()); + //this.Log_Debug("Kerbal kerbalref = " + crewmember.KerbalRef.GetInstanceID()); } else { @@ -3206,7 +3240,7 @@ internal void resetFrozenKerbals() crewmember.KerbalRef.showHelmet = false; crewmember.KerbalRef.ShowHelmet(false); } - this.Log_Debug("Kerbal kerbalref = " + crewmember.KerbalRef.GetInstanceID()); + //this.Log_Debug("Kerbal kerbalref = " + crewmember.KerbalRef.GetInstanceID()); } seatTakenbyFrznKerbal[crewmember.seatIdx] = true; //setup seat and part settings for frozen kerbal. @@ -3255,7 +3289,7 @@ private void UpdateCounts() FreezerSpace = (FreezerSize - _StoredCrewList.Count); TotalFrozen = _StoredCrewList.Count; PartFull = (TotalFrozen + this.part.protoModuleCrew.Count >= this.part.CrewCapacity); - Utilities.Log_Debug("DeepFreezer", "UpdateCounts FreezerSpace=" + FreezerSpace + ",TotalFrozen=" + TotalFrozen + ",Partfull=" + PartFull); + //Utilities.Log_Debug("DeepFreezer", "UpdateCounts FreezerSpace=" + FreezerSpace + ",TotalFrozen=" + TotalFrozen + ",Partfull=" + PartFull); // Reset the seat status for frozen crew to taken - true, because it seems to reset by something?? So better safe than sorry. if (partHasInternals) { @@ -3326,7 +3360,7 @@ private void UpdateCounts() //Utilities.Log_Debug("DeepFreezer", "Frozen Crew SeatIdx= " + lst.SeatIdx + ",Seattaken=" + this.part.internalModel.seats[lst.SeatIdx].taken + ",KerbalRef=" + kerblrefstring); } } - Utilities.Log_Debug("DeepFreezer", "UpdateCounts end"); + //Utilities.Log_Debug("DeepFreezer", "UpdateCounts end"); } } catch (Exception ex) @@ -3452,10 +3486,10 @@ public void resetCryopods(bool resetall) //Create a temporary array and set entries to true where that seat index contains a frozen kerbal. bool[] closedpods = new bool[FreezerSize]; - for (int i = 0; i < FreezerSize; i++) - { - this.Log_Debug("cryopodstate closed=" + cryopodstateclosed[i].ToString() + " checking pod " + i); - } + //for (int i = 0; i < FreezerSize; i++) + //{ + // this.Log_Debug("cryopodstate closed=" + cryopodstateclosed[i].ToString() + " checking pod " + i); + //} foreach (FrznCrewMbr frzncrew in _StoredCrewList) { closedpods[frzncrew.SeatIdx] = true; @@ -3476,9 +3510,9 @@ public void resetCryopods(bool resetall) this.Log_Debug("pod is open so close it"); closeCryopod(i, float.MaxValue); cryopodstateclosed[i] = true; - this.Log_Debug("Time freezewindow started " + Planetarium.GetUniversalTime()); + //this.Log_Debug("Time freezewindow started " + Planetarium.GetUniversalTime()); freezeCryopodWindow(i, float.MaxValue); - this.Log_Debug("Time freezewindow finished make them invisible " + Planetarium.GetUniversalTime()); + //this.Log_Debug("Time freezewindow finished make them invisible " + Planetarium.GetUniversalTime()); } else { @@ -3528,17 +3562,17 @@ public void resetCryopods(bool resetall) string windowname = "Cryopod-" + (SeatIndx + 1).ToString() + "-Window"; try { - Debug.Log("setCryoWindowOff for " + windowname + " on partid=" + this.part.flightID); + //Debug.Log("setCryoWindowOff for " + windowname + " on partid=" + this.part.flightID); renderer = this.part.internalModel.FindModelComponent(windowname); //renderer.enabled = false; GameObject objfnd = renderer.gameObject; objfnd.layer = 21; - Debug.Log("setcryoff set renderergo to layer 21 ok"); + //Debug.Log("setcryoff set renderergo to layer 21 ok"); Component parobj = objfnd.GetComponentUpwards("Component"); parobj.gameObject.layer = 21; - Debug.Log("setcryoff set rendererparentgo to layer 21 ok"); + //Debug.Log("setcryoff set rendererparentgo to layer 21 ok"); } - catch (Exception ex) + catch (Exception) { Debug.Log("Unable to find Renderer in internal model for this part called " + windowname); } @@ -3550,17 +3584,17 @@ public void resetCryopods(bool resetall) string windowname = "Cryopod-" + (SeatIndx + 1).ToString() + "-Window"; try { - Debug.Log("setCryoWindowOn for " + windowname + " on partid=" + this.part.flightID); + //Debug.Log("setCryoWindowOn for " + windowname + " on partid=" + this.part.flightID); renderer = this.part.internalModel.FindModelComponent(windowname); //renderer.enabled = true; GameObject objfnd = renderer.gameObject; objfnd.layer = 16; - Debug.Log("setcryon set renderergo to layer 16 ok"); + //Debug.Log("setcryon set renderergo to layer 16 ok"); Component parobj = objfnd.GetComponentUpwards("Component"); parobj.gameObject.layer = 16; - Debug.Log("setcryon set rendererparentgo to layer 16 ok"); + //Debug.Log("setcryon set rendererparentgo to layer 16 ok"); } - catch (Exception ex) + catch (Exception) { Debug.Log("Unable to find Renderer in internal model for this part called " + windowname); } @@ -3601,7 +3635,6 @@ private void thawCryopodWindow(int seatIndx, float speed) { setCryopodWindowOpaque(seatIndx); string windowname = "Animated-Cryopod-" + (seatIndx + 1).ToString() + "-Window"; - //Animation[] animators = this.part.internalModel.FindModelAnimators("CryopodWindowOpen"); _windowAnimation = this.part.internalModel.FindModelComponent(windowname); if (_windowAnimation == null) { @@ -3641,7 +3674,7 @@ private void setCryopodWindowSpecular(int seatIndx) private void startStripLightFlash(int seatIndx) { string stripname = "lightStrip-Animated-Cryopod-" + (seatIndx + 1).ToString(); - this.Log_Debug("playing animation PodActive " + stripname); + //this.Log_Debug("playing animation PodActive " + stripname); try { Animation strip_animation = this.part.internalModel.FindModelComponent(stripname); @@ -3728,7 +3761,7 @@ private void setCryopodWindowTransparent(int seatIndx) private void stopStripLightFlash(int seatIndx) { string stripname = "lightStrip-Animated-Cryopod-" + (seatIndx + 1).ToString(); - this.Log_Debug("playing animation LightStrip " + stripname); + //this.Log_Debug("playing animation LightStrip " + stripname); try { Animation strip_animation = this.part.internalModel.FindModelComponent(stripname); @@ -3740,7 +3773,10 @@ private void stopStripLightFlash(int seatIndx) strip_animation.wrapMode = WrapMode.Loop; strip_animation.Play("LightStrip"); } - this.Log_Debug("animation LightStrip not found for " + stripname); + else + { + this.Log_Debug("animation LightStrip not found for " + stripname); + } } catch (Exception ex) { @@ -3753,7 +3789,7 @@ private void stopStripLightFlash(int seatIndx) private void setIVAFrzrCam(int seatIndx) { string camname = "FrzCam" + (seatIndx + 1).ToString(); - this.Log_Debug("Setting FrzrCam " + camname); + //this.Log_Debug("Setting FrzrCam " + camname); Camera cam = this.part.internalModel.FindModelComponent(camname); if (cam != null) { @@ -3969,7 +4005,7 @@ public static void FixedBackgroundUpdate(Vessel v, uint partFlightID, Func(); foreach (KeyValuePair kerbal in DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals) { - if (kerbal.Value.partID == partFlightID && kerbal.Value.vesselID == v.id) + if (kerbal.Value.partID == partFlightID && kerbal.Value.vesselID == v.id && kerbal.Value.type != ProtoCrewMember.KerbalType.Tourist) { kerbalsToDelete.Add(kerbal.Key); } diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index ea9ca3c..0b11676 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -31,7 +31,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.19.0.0")] -[assembly: AssemblyFileVersion("0.19.0.0")] +[assembly: AssemblyVersion("0.19.1.0")] +[assembly: AssemblyFileVersion("0.19.1.0")] [assembly: KSPAssembly("DeepFreeze", 0, 19)] [assembly: KSPAssemblyDependency("DFInterface", 0, 3)] \ No newline at end of file diff --git a/Source/utilities.cs b/Source/utilities.cs index 0926b8f..bf1cb92 100644 --- a/Source/utilities.cs +++ b/Source/utilities.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Text; using UnityEngine; namespace DF @@ -349,7 +350,7 @@ internal static void setHelmets(this Part thisPart, bool helmetOn) // If bodyOnly is true only the "body01" mesh is changed (to be replaced by placeholder mesh lying down as kerbals in IVA are always in sitting position). internal static void setFrznKerbalLayer(ProtoCrewMember kerbal, bool setVisible, bool bodyOnly) { - Log_Debug("setFrznKerbalLayer " + kerbal.name + " visible " + setVisible); + //Log_Debug("setFrznKerbalLayer " + kerbal.name + " visible " + setVisible); int layer = 16; if (!setVisible) { @@ -362,7 +363,7 @@ internal static void setFrznKerbalLayer(ProtoCrewMember kerbal, bool setVisible, { if (renderer.gameObject.layer == layer) { - Log_Debug("Layers already set"); + //Log_Debug("Layers already set"); break; } //Log_Debug("Renderer: " + renderer.name + " set to layer " + layer); @@ -376,7 +377,7 @@ internal static void setFrznKerbalLayer(ProtoCrewMember kerbal, bool setVisible, internal static void CheckPortraitCams(Vessel vessel) { // Only the pods in the active vessel should be doing it since the list refers to them. - Log_Debug("DeepFreeze CheckPortraitCams vessel " + vessel.name + "(" + vessel.id + ") activevessel " + FlightGlobals.ActiveVessel.name + "(" + FlightGlobals.ActiveVessel.id + ")"); + //Log_Debug("DeepFreeze CheckPortraitCams vessel " + vessel.name + "(" + vessel.id + ") activevessel " + FlightGlobals.ActiveVessel.name + "(" + FlightGlobals.ActiveVessel.id + ")"); // First, We check through the list of portaits and remove everyone who is from some other vessel, or NO vessel. var stowaways = new List(); @@ -384,15 +385,15 @@ internal static void CheckPortraitCams(Vessel vessel) { if (thatKerbal.InPart == null) { - Log_Debug("kerbal " + thatKerbal.name + " Invessel = null add stowaway"); + //Log_Debug("kerbal " + thatKerbal.name + " Invessel = null add stowaway"); stowaways.Add(thatKerbal); } else { - Log_Debug("kerbal " + thatKerbal.name + " Invessel = " + thatKerbal.InVessel + " InvesselID = " + thatKerbal.InVessel.id); + //Log_Debug("kerbal " + thatKerbal.name + " Invessel = " + thatKerbal.InVessel + " InvesselID = " + thatKerbal.InVessel.id); if (thatKerbal.InVessel.id != FlightGlobals.ActiveVessel.id) { - Log_Debug("Adding stowaway"); + //Log_Debug("Adding stowaway"); stowaways.Add(thatKerbal); } } @@ -408,25 +409,25 @@ internal static void CheckPortraitCams(Vessel vessel) List crewparts = (from p in vessel.parts where (p.CrewCapacity > 0 && p.internalModel != null) select p).ToList(); foreach (Part part in crewparts) { - Log_Debug("Check Portraits for part " + part.name); + //Log_Debug("Check Portraits for part " + part.name); foreach (InternalSeat seat in part.internalModel.seats) { - Log_Debug("checking Seat " + seat.seatTransformName); - if (seat.kerbalRef != null) Log_Debug("kerbalref=" + seat.kerbalRef.crewMemberName); - else Log_Debug("Seat kerbalref is null"); + //Log_Debug("checking Seat " + seat.seatTransformName); + //if (seat.kerbalRef != null) Log_Debug("kerbalref=" + seat.kerbalRef.crewMemberName); + //else Log_Debug("Seat kerbalref is null"); if (seat.kerbalRef != null && !KerbalGUIManager.ActiveCrew.Contains(seat.kerbalRef)) { - Log_Debug("Checking crewstatus " + seat.kerbalRef.protoCrewMember.rosterStatus + " " + seat.kerbalRef.protoCrewMember.type); + //Log_Debug("Checking crewstatus " + seat.kerbalRef.protoCrewMember.rosterStatus + " " + seat.kerbalRef.protoCrewMember.type); if (seat.kerbalRef.protoCrewMember.rosterStatus != ProtoCrewMember.RosterStatus.Dead || seat.kerbalRef.protoCrewMember.type != ProtoCrewMember.KerbalType.Unowned) { - Log_Debug("Adding missing Portrait for " + seat.kerbalRef.crewMemberName); + //Log_Debug("Adding missing Portrait for " + seat.kerbalRef.crewMemberName); KerbalGUIManager.AddActiveCrew(seat.kerbalRef); } } } } } - else Log_Debug("Vessel is not active vessel"); + //else Log_Debug("Vessel is not active vessel"); } // The following method is taken from RasterPropMonitor as-is. Which is covered by GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -539,6 +540,31 @@ internal static void reinvigerateIVAKerbalAnimations(Kerbal kerbal) } } + internal static bool setComatoseKerbal(ProtoCrewMember crew, ProtoCrewMember.KerbalType type) + { + try + { + crew.type = type; + if (type == ProtoCrewMember.KerbalType.Crew) + { + KerbalRoster.SetExperienceTrait(crew, ""); + ScreenMessages.PostScreenMessage(crew.name + " has recovered from emergency thaw and resumed normal duties.", 5.0f, ScreenMessageStyle.UPPER_CENTER); + } + else + { + KerbalRoster.SetExperienceTrait(crew, "Tourist"); + ScreenMessages.PostScreenMessage(crew.name + " has been emergency thawed and cannot perform duties for " + (DeepFreeze.Instance.DFsettings.comatoseTime / 60).ToString() + " minutes.", 5.0f, ScreenMessageStyle.UPPER_CENTER); + } + return true; + } + catch (Exception) + { + Log("DeepFreeze", " Failed to set " + crew.name + " to status of " + type.ToString() + " during emergency thaw processing."); + return false; + } + + } + // The following method is taken from Kerbal Alarm Clock as-is. Which is covered by MIT license. internal static int getVesselIdx(Vessel vtarget) { @@ -592,6 +618,29 @@ internal static Rect MakeWindowVisible(Rect winpos) return winpos; } + // The following method is taken from RasterPropMonitor as-is. Which is covered by GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 + public static string WordWrap(string text, int maxLineLength) + { + var sb = new StringBuilder(); + char[] prc = { ' ', ',', '.', '?', '!', ':', ';', '-' }; + char[] ws = { ' ' }; + + foreach (string line in text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) + { + int currentIndex; + int lastWrap = 0; + do + { + currentIndex = lastWrap + maxLineLength > line.Length ? line.Length : (line.LastIndexOfAny(prc, Math.Min(line.Length - 1, lastWrap + maxLineLength)) + 1); + if (currentIndex <= lastWrap) + currentIndex = Math.Min(lastWrap + maxLineLength, line.Length); + sb.AppendLine(line.Substring(lastWrap, currentIndex - lastWrap).Trim(ws)); + lastWrap = currentIndex; + } while (currentIndex < line.Length); + } + return sb.ToString(); + } + // Get Config Node Values out of a config node Methods internal static bool GetNodeValue(ConfigNode confignode, string fieldname, bool defaultValue)