diff --git a/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt b/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt index c88c7d8..f3b44dc 100644 --- a/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt +++ b/Distribution/GameData/REPOSoftTech/DeepFreeze/Changelog.txt @@ -1,4 +1,10 @@ -V0.23.2.0 +V0.23.3.0 +Fix Kerbalism Integration. +Freeze Tourists! +DeepFreeze stock application button is not shown in flight unless the active vessel has a DeepFreezer part. +Fixed log spam when RPM occlusion fails. +Work-around for integration issue/bug in USI LS. +V0.23.2.0 Compile for KSP 1.2.2 Remove need for RSTKSPEvents and utilize new KSP 1.2.2 GameEvents extension. Update Community Resource Pack to 0.6.3.0. diff --git a/Source/APIs/DFGameEvents.cs b/Source/APIs/DFGameEvents.cs index 9fdac58..ca63037 100644 --- a/Source/APIs/DFGameEvents.cs +++ b/Source/APIs/DFGameEvents.cs @@ -11,26 +11,26 @@ class DFGameEvents /// Fires when DeepFreeze Completes the Freezing process on a Kerbal. /// Part is the DeepFreeze Freezer Part and ProtoCrewMember is the Kerbal. /// - public static EventData onKerbalFrozen = new EventData("onKerbalFrozen"); + public static EventData onKerbalFrozen;// = new EventData("onKerbalFrozen"); /// /// Fires when DeepFreeze Completes the Thawing process on a Kerbal. /// Part is the DeepFreeze Freezer Part and ProtoCrewMember is the Kerbal. /// - public static EventData onKerbalThaw = new EventData("onKerbalThaw"); + public static EventData onKerbalThaw;// = new EventData("onKerbalThaw"); /// /// Fires when DeepFreeze sets a Kerbal to Comatose Status. /// Part is the DeepFreeze Freezer Part and ProtoCrewMember is the Kerbal. /// - public static EventData onKerbalSetComatose = new EventData("onKerbalSetComatose"); + public static EventData onKerbalSetComatose;// = new EventData("onKerbalSetComatose"); /// /// Fires when DeepFreeze Unsets a Kerbal from Comatose Status. /// Part is the DeepFreeze Freezer Part and ProtoCrewMember is the Kerbal. /// - public static EventData onKerbalUnSetComatose = new EventData("onKerbalUnSetComatose"); + public static EventData onKerbalUnSetComatose;// = new EventData("onKerbalUnSetComatose"); /// /// Fires when DeepFreeze has to Kill a Frozen Kerbal. /// - public static EventData onFrozenKerbalDied = new EventData("onFrozenKerbalDied"); + public static EventData onFrozenKerbalDied;// = new EventData("onFrozenKerbalDied"); } } diff --git a/Source/APIs/KBWrapper.cs b/Source/APIs/KBWrapper.cs index 04e7cd6..b4c71b6 100644 --- a/Source/APIs/KBWrapper.cs +++ b/Source/APIs/KBWrapper.cs @@ -76,7 +76,7 @@ public static Boolean InitKBWrapper() LogFormatted_DebugOnly("Attempting to Grab KB LS Types..."); //find the base type - KBType = getType("KERBALISM.Kerbalism"); + KBType = getType("KERBALISM.API"); if (KBType == null) { @@ -127,7 +127,7 @@ internal KBAPI() //WORK OUT THE STUFF WE NEED TO HOOK FOR PEOPLE HERE //Methods LogFormatted_DebugOnly("Getting hook_DisableKerbal Method"); - KBhook_DisableKerbalMethod = KBType.GetMethod("hook_DisableKerbal", BindingFlags.Public | BindingFlags.Static); + KBhook_DisableKerbalMethod = KBType.GetMethod("DisableKerbal", BindingFlags.Public | BindingFlags.Static); LogFormatted_DebugOnly("Success: " + (KBhook_DisableKerbalMethod != null)); } diff --git a/Source/DFIntMemory.cs b/Source/DFIntMemory.cs index a1c7a70..66ff0fd 100644 --- a/Source/DFIntMemory.cs +++ b/Source/DFIntMemory.cs @@ -496,8 +496,10 @@ private void ChkUnknownFrozenKerbals() kerbalInfo.experienceTraitName = enumerator.Current.experienceTrait.Title; try { - Utilities.Log("Adding dead unknown kerbal " + enumerator.Current.name + " AKA FROZEN kerbal to DeepFreeze List"); - DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Add(enumerator.Current.name, kerbalInfo); + Utilities.Log("Adding dead unknown kerbal " + enumerator.Current.name + + " AKA FROZEN kerbal to DeepFreeze List"); + DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Add(enumerator.Current.name, + kerbalInfo); } catch (Exception ex) { diff --git a/Source/DeepFreeze.cs b/Source/DeepFreeze.cs index 5507961..b0f30d3 100644 --- a/Source/DeepFreeze.cs +++ b/Source/DeepFreeze.cs @@ -418,14 +418,6 @@ internal bool setComatoseKerbal(Part part, ProtoCrewMember crew, ProtoCrewMember if (!start) { - if (type == ProtoCrewMember.KerbalType.Crew) - { - KerbalRoster.SetExperienceTrait(crew, ""); - } - else - { - KerbalRoster.SetExperienceTrait(crew, "Tourist"); - } crew.RegisterExperienceTraits(part); DFGameEvents.onKerbalUnSetComatose.Fire(part, crew); ScreenMessages.PostScreenMessage( diff --git a/Source/DeepFreezeGUI.cs b/Source/DeepFreezeGUI.cs index a706127..3638536 100644 --- a/Source/DeepFreezeGUI.cs +++ b/Source/DeepFreezeGUI.cs @@ -167,9 +167,10 @@ private void FixedUpdate() } } } - + private void Update() { + if (Time.timeSinceLevelLoad < 2f) return; //Wait 2 seconds on level load before executing if (switchNextUpdate) { //Jump to vessel code here. @@ -197,6 +198,29 @@ private void Update() } } } + if (Useapplauncher == false || !HighLogic.LoadedSceneIsFlight) + { + return; + } + if (DFIntMemory.Instance != null) + { + if (DFIntMemory.Instance.DpFrzrActVsl.Count == 0) + { + DFMenuAppLToolBar.setAppLSceneVisibility(ApplicationLauncher.AppScenes.SPACECENTER | + ApplicationLauncher.AppScenes.SPH | + ApplicationLauncher.AppScenes.VAB | + ApplicationLauncher.AppScenes.TRACKSTATION); + } + else + { + DFMenuAppLToolBar.setAppLSceneVisibility(ApplicationLauncher.AppScenes.SPACECENTER | + ApplicationLauncher.AppScenes.FLIGHT | + ApplicationLauncher.AppScenes.MAPVIEW | + ApplicationLauncher.AppScenes.SPH | + ApplicationLauncher.AppScenes.VAB | + ApplicationLauncher.AppScenes.TRACKSTATION); + } + } } #region GUI @@ -585,25 +609,32 @@ private void windowDF(int id) } foreach (DeepFreezer frzr in DFIntMemory.Instance.DpFrzrActVsl) { - foreach (ProtoCrewMember crewMember in frzr.part.protoModuleCrew.FindAll(a => a.type == ProtoCrewMember.KerbalType.Crew)) + List crew = new List(); + for (int i = 0; i < frzr.part.protoModuleCrew.Count; i++) { + if (!DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.ContainsKey(frzr.part.protoModuleCrew[i].name)) + { + crew.Add(frzr.part.protoModuleCrew[i]); + } + } + for (int i =0; i < crew.Count; i++) + { GUILayout.BeginHorizontal(); - GUILayout.Label(crewMember.name, Textures.statusStyle, GUILayout.Width(DFtxtWdthName)); - GUILayout.Label(crewMember.experienceTrait.Title, Textures.statusStyle, GUILayout.Width(DFtxtWdthProf)); + GUILayout.Label(crew[i].name, Textures.statusStyle, GUILayout.Width(DFtxtWdthName)); + GUILayout.Label(crew[i].experienceTrait.Title, Textures.statusStyle, GUILayout.Width(DFtxtWdthProf)); GUILayout.Label(frzr.part.vessel.vesselName, Textures.statusStyle, GUILayout.Width(DFtxtWdthVslN)); - if (crewMember.type != ProtoCrewMember.KerbalType.Tourist) + + if (frzr.DFIcrewXferFROMActive || frzr.DFIcrewXferTOActive || (DFInstalledMods.IsSMInstalled && frzr.IsCrewXferRunning) + || frzr.IsFreezeActive || frzr.IsThawActive || (DFInstalledMods.IsRTInstalled && !DFInstalledMods.RTVesselConnected(DFIntMemory.Instance.ActVslID))) { - if (frzr.DFIcrewXferFROMActive || frzr.DFIcrewXferTOActive || (DFInstalledMods.IsSMInstalled && frzr.IsCrewXferRunning) - || 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; + GUI.enabled = false; + } + if (GUILayout.Button(new GUIContent("Freeze", "Freeze this Kerbal"), GUILayout.Width(50f))) + { + frzr.beginFreezeKerbal(crew[i]); } + GUI.enabled = true; + GUILayout.EndHorizontal(); } } diff --git a/Source/DeepFreezerPart.cs b/Source/DeepFreezerPart.cs index 06026d5..d29efb8 100644 --- a/Source/DeepFreezerPart.cs +++ b/Source/DeepFreezerPart.cs @@ -26,6 +26,7 @@ namespace DF { + [KSPModule("DeepFreeze Freezer Part")] public class DeepFreezer : PartModule, IResourceConsumer { private float lastUpdate; // time since we last updated the part menu @@ -271,6 +272,8 @@ public bool DFIIsThawActive public string transparentTransforms = string.Empty; //Set by part.cfg. contains list of transforms that should be transparent | separated. private bool hasJSITransparentPod; + private bool checkRPMPodTransparencySettingError = false; + private bool RPMPodOccluderProcessingError = false; [KSPEvent(active = false, guiActive = true, guiActiveUnfocused = true, guiActiveEditor = true, unfocusedRange = 5f, name = "eventOpenDoors", guiName = "Open Doors")] public void eventOpenDoors() @@ -702,10 +705,14 @@ private void checkRPMPodTransparencySetting() } } } - catch (Exception) + catch (Exception ex) { - Utilities.Log("DeepFreezer Error checking RPM TransparentPod Setting"); - //Utilities.Log("DeepFreezer ", ex.Message); + if (!checkRPMPodTransparencySettingError) + { + Utilities.Log("DeepFreezer Error checking RPM TransparentPod Setting"); + Utilities.Log("DeepFreezer ", ex.Message); + checkRPMPodTransparencySettingError = true; + } } } @@ -925,10 +932,14 @@ private void RPMPodOccluderProcessing() } } } - catch (Exception) + catch (Exception ex) { - Utilities.Log("DeepFreezer Error setting RPM Occluders"); - //Utilities.Log("DeepFreezer ", ex.Message); + if (!RPMPodOccluderProcessingError) + { + Utilities.Log("DeepFreezer Error setting RPM Occluders"); + Utilities.Log("DeepFreezer ", ex.Message); + RPMPodOccluderProcessingError = true; + } } } @@ -1638,8 +1649,7 @@ private void UpdateEvents() { foreach (var CrewMember in part.protoModuleCrew) // We Add Freeze Events for all active crew in the part { - if (CrewMember.type != ProtoCrewMember.KerbalType.Tourist) - addFreezeEvent(CrewMember); + 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) @@ -1658,8 +1668,7 @@ private void addFreezeEvent(ProtoCrewMember CrewMember) try { BaseEvent item = Events.Find(v => v.name == "Freeze " + CrewMember.name); // Search to see if there isn't already a Freeze Event for this CrewMember - if (item == null && CrewMember.type == ProtoCrewMember.KerbalType.Crew) // Did we find one? and CrewMember is type=Crew? if so, add new Event. - //***** Could change this to Tourists as well but needs more changes. + if (item == null && (CrewMember.type == ProtoCrewMember.KerbalType.Crew || CrewMember.type == ProtoCrewMember.KerbalType.Tourist)) // Did we find one? and CrewMember is type=Crew? if so, add new Event. { Events.Add(new BaseEvent(Events, "Freeze " + CrewMember.name, () => { @@ -2136,23 +2145,7 @@ private void FreezeKerbalConfirm(ProtoCrewMember CrewMember) ToFrzeKerbal = ""; // Set the Active Freeze Kerbal to null ActiveFrzKerbal = null; // Set the Active Freeze Kerbal to null removeFreezeEvent(CrewMember.name); // Remove the Freeze Event for this kerbal. - if (DFInstalledMods.IsUSILSInstalled) // IF USI LS Installed, remove tracking. - { - Utilities.Log_Debug("USI/LS installed untrack kerbal=" + CrewMember.name); - try - { - USIUntrackKerbal(CrewMember.name); - //if (this.part.vessel.GetVesselCrew().Count == 0) - //{ - // USIUntrackVessel(this.part.vessel.id.ToString()); - //} - } - catch (Exception ex) - { - Utilities.Log("DeepFreeze Exception attempting to untrack a kerbal and/or vessel in USI/LS. Report this error on the Forum Thread."); - Utilities.Log("DeepFreeze Err: " + ex); - } - } + if (DFInstalledMods.IskerbalismInstalled) // IF Kerbalism Installed, remove tracking. { Utilities.Log_Debug("kerbalism installed untrack kerbal=" + CrewMember.name); @@ -2169,10 +2162,30 @@ private void FreezeKerbalConfirm(ProtoCrewMember CrewMember) ScreenMessages.PostScreenMessage(CrewMember.name + " frozen", 5.0f, ScreenMessageStyle.UPPER_CENTER); onvslchgInternal = true; + vessel.RebuildCrewList(); DFGameEvents.onKerbalFrozen.Fire(this.part, CrewMember); CrewHatchController.fetch.EnableInterface(); GameEvents.onVesselChange.Fire(vessel); GameEvents.onVesselWasModified.Fire(vessel); + + if (DFInstalledMods.IsUSILSInstalled) // IF USI LS Installed, remove tracking. + { + Utilities.Log_Debug("USI/LS installed untrack kerbal=" + CrewMember.name); + try + { + USIUntrackKerbal(CrewMember.name); + if (this.part.vessel.GetVesselCrew().Count == 0) + { + Utilities.Log_Debug("USI/LS installed untrack vessel=" + this.part.vessel.id.ToString()); + USIUntrackVessel(this.part.vessel.id.ToString()); + } + } + catch (Exception ex) + { + Utilities.Log("DeepFreeze Exception attempting to untrack a kerbal and/or vessel in USI/LS. Report this error on the Forum Thread."); + Utilities.Log("DeepFreeze Err: " + ex); + } + } } Utilities.Log_Debug("FreezeCompleted"); } @@ -2196,6 +2209,25 @@ private void USIUntrackKerbal(string crewmember) } } + private void USIUntrackVessel(string vesselId) + //This will remove tracking of a frozen kerbal from USI Life Support MOD, so that they don't consume resources when they are thawed. + { + if (USIWrapper.APIReady && USIWrapper.InstanceExists) + { + USIWrapper.USIActualAPI.UntrackVessel(vesselId); + bool checkTracked = USIWrapper.USIActualAPI.IsVesselTracked(vesselId); + if (checkTracked) + { + Debug.Log("DeepFreeze has been unable to untrack vessel " + vesselId + " in USI LS mod. Report this error on the Forum Thread."); + } + + } + else + { + Debug.Log("DeepFreeze has been unable to connect to USI LS mod. API is not ready. Report this error on the Forum Thread."); + } + } + private void KBDisableKerbal(string crewmember, bool disable) //This will remove tracking of a frozen kerbal from USI Life Support MOD, so that they don't consume resources when they are thawed. { @@ -2924,7 +2956,8 @@ private bool RemoveKerbal(ProtoCrewMember kerbal, int SeatIndx) private bool AddKerbal(ProtoCrewMember kerbal, int SeatIndx) //Adds a just thawed kerbal to the vessel. { - Utilities.Log_Debug("Start AddKerbal " + kerbal.name); + Utilities.Log_Debug("Start AddKerbal " + kerbal.name); + ProtoCrewMember.KerbalType originaltype = ProtoCrewMember.KerbalType.Crew; try { try @@ -2956,6 +2989,11 @@ private bool AddKerbal(ProtoCrewMember kerbal, int SeatIndx) { if (DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.ContainsKey(kerbal.name)) { + KerbalInfo tmpFrzCrew = DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals[kerbal.name]; + if (tmpFrzCrew.experienceTraitName == "Tourist") + { + originaltype = ProtoCrewMember.KerbalType.Tourist; + } DeepFreeze.Instance.DFgameSettings.KnownFrozenKerbals.Remove(kerbal.name); } if (DeepFreeze.Instance.DFsettings.debugging) DeepFreeze.Instance.DFgameSettings.DmpKnownFznKerbals(); @@ -2969,13 +3007,11 @@ private bool AddKerbal(ProtoCrewMember kerbal, int SeatIndx) } if (partHasInternals && ExternalDoorActive) Utilities.setHelmetshaders(kerbal.KerbalRef, true); + + // Set our newly thawed Popsicle, er Kerbal, to Original type and Assigned status. + kerbal.type = originaltype; + kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned; - // Set our newly thawed Popsicle, er Kerbal, to Crew type and Assigned status. - if (kerbal.type != ProtoCrewMember.KerbalType.Crew) - { - kerbal.type = ProtoCrewMember.KerbalType.Crew; - kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Assigned; - } if (partHasInternals) { if (kerbal.seat != part.internalModel.seats[SeatIndx]) diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 403e1dd..ca5fa5e 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -31,6 +31,6 @@ // 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.23.2.0")] -[assembly: AssemblyFileVersion("0.23.2.0")] +[assembly: AssemblyVersion("0.23.3.0")] +[assembly: AssemblyFileVersion("0.23.3.0")] [assembly: KSPAssembly("DeepFreeze", 0, 23)] \ No newline at end of file diff --git a/Source/Textures.cs b/Source/Textures.cs index 889248b..1925501 100644 --- a/Source/Textures.cs +++ b/Source/Textures.cs @@ -33,6 +33,11 @@ public void Awake() public void Start() { //GameEvents.onGameSceneSwitchRequested.Add(onGameSceneSwitchRequested); + DFGameEvents.onKerbalFrozen = new EventData("onKerbalFrozen"); + DFGameEvents.onKerbalThaw = new EventData("onKerbalThaw"); + DFGameEvents.onKerbalSetComatose = new EventData("onKerbalSetComatose"); + DFGameEvents.onKerbalUnSetComatose = new EventData("onKerbalUnSetComatose"); + DFGameEvents.onFrozenKerbalDied = new EventData("onFrozenKerbalDied"); } public void OnDestroy()