diff --git a/TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs b/TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs index 34e7990..e719688 100644 --- a/TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs +++ b/TestFlightCore/TestFlightCore/Framework/PartModuleExtended.cs @@ -352,60 +352,6 @@ public virtual void OnDestroy() #endregion - #region OnGuiStuff - //flag to mark when OnceOnly has been done - private Boolean _OnGUIOnceOnlyHasRun = false; - - /// - /// Unity: OnGUI is called for rendering and handling GUI events. - /// - /// Trigger: This is called multiple times per frame to lay stuff out etc. - /// Code here ignores the F2 key that disables user interface. So if you are making something to be user hidable then use the RenderingManager.PostDrawQueue functions in here - /// Alternatively you could use the MonoBehaviourWindow Type and its DrawWindow Function - /// - public void OnGUI() - { - if (!_OnGUIOnceOnlyHasRun) - { - //set theflag so this only runs once - _OnGUIOnceOnlyHasRun = true; - //set up the skins library - if (!SkinsLibrary._Initialized) - SkinsLibrary.InitSkinList(); - - //then pass it on to the downstream derivatives - OnGUIOnceOnly(); - } - - OnGUIEvery(); - } - - /// - /// Extension Function - OnGUIEvery is wrapped in OnGUI with some stuff to facilitate the OnGUIOnceOnly functionality, basically this is the OnGUI function - /// - /// Unity: OnGUI is called for rendering and handling GUI events. - /// - /// Trigger: This is called multiple times per frame to lay stuff out etc. - /// Code here ignores the F2 key that disables user interface. So if you are making something to be user hidable then use the RenderingManager.PostDrawQueue functions in here - /// Alternatively you could use the MonoBehaviourWindow Type and its DrawWindow Function - /// - internal virtual void OnGUIEvery() - { - - } - - /// - /// Extension Function - this will run only once each time the monobehaviour is awakened - /// - /// Added this so you can put your GUI initialisation code in here. Running GUI initialisation stuff in Awake/Start will throw an error - /// - internal virtual void OnGUIOnceOnly() - { - LogFormatted_DebugOnly("Running OnGUI OnceOnly Code"); - - } - #endregion - #region Assembly/Class Information /// /// Name of the Assembly that is running this MonoBehaviour diff --git a/TestFlightCore/TestFlightCore/TestFlight.cs b/TestFlightCore/TestFlightCore/TestFlight.cs index 682729e..b5bc3ef 100644 --- a/TestFlightCore/TestFlightCore/TestFlight.cs +++ b/TestFlightCore/TestFlightCore/TestFlight.cs @@ -422,7 +422,7 @@ internal void Log(string message) internal void LogCareerFailure(Vessel vessel, string part, string failureType) { - if (!rp1Available || !careerLogging) + if (!rp1Available || !careerLogging || HighLogic.CurrentGame?.Mode != Game.Modes.CAREER) { Log("Unable to log career failure. RP1 or Career Logging is unavailable"); return; diff --git a/TestFlightCore/TestFlightCore/TestFlightCore.cs b/TestFlightCore/TestFlightCore/TestFlightCore.cs index 8e122d1..7445ae4 100644 --- a/TestFlightCore/TestFlightCore/TestFlightCore.cs +++ b/TestFlightCore/TestFlightCore/TestFlightCore.cs @@ -65,7 +65,6 @@ public class TestFlightCore : PartModuleExtended, ITestFlightCore public List configs = new List(8); public ConfigNode currentConfig; - public string configNodeData; bool initialized = false; float transferData; @@ -216,14 +215,13 @@ public override void OnLoad(ConfigNode node) { configs.Clear(); - foreach (ConfigNode subNode in cNodes) { + foreach (ConfigNode subNode in cNodes) + { var newNode = new ConfigNode("CONFIG"); subNode.CopyTo(newNode); configs.Add(newNode); } } - - configNodeData = node.ToString(); } internal void Log(string message) @@ -833,13 +831,13 @@ public override void OnDestroy() public override void OnAwake() { initialized = false; - - if (!string.IsNullOrEmpty(configNodeData)) + + TestFlightCore pm = GetCoreFromPrefab(); + if (pm != null) { - var node = ConfigNode.Parse(configNodeData); - OnLoad(node); + configs = pm.configs; } - + // poll failure modules for any existing failures foreach (ITestFlightFailure failure in TestFlightUtil.GetFailureModules(this.part, Alias)) { @@ -851,6 +849,22 @@ public override void OnAwake() } } + private TestFlightCore GetCoreFromPrefab() + { + Part prefab = part?.partInfo?.partPrefab; + if (prefab != null) + { + int index = part.Modules.IndexOf(this); + if (index < 0) + index = part.Modules.Count; + + var pm = prefab.Modules.Count > index ? prefab.Modules[index] as TestFlightCore : null; + return pm ?? prefab.FindModuleImplementing(); + } + + return null; + } + public void OnCrewChange(GameEvents.HostedFromToAction e) => _OnCrewChange(); private void _OnCrewChange() { diff --git a/TestFlightFailure_IgnitionFail.cs b/TestFlightFailure_IgnitionFail.cs index a1f10c4..44fa22a 100644 --- a/TestFlightFailure_IgnitionFail.cs +++ b/TestFlightFailure_IgnitionFail.cs @@ -278,7 +278,7 @@ public override void DoFailure() if (!TestFlightEnabled) return; Failed = true; - float multiplier = 0; + float multiplier = 1f; ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration); if (core != null) {