diff --git a/RasterPropMonitor/Core/UtilityFunctions.cs b/RasterPropMonitor/Core/UtilityFunctions.cs index f8032b42..0feef1b0 100644 --- a/RasterPropMonitor/Core/UtilityFunctions.cs +++ b/RasterPropMonitor/Core/UtilityFunctions.cs @@ -25,6 +25,7 @@ using System.Linq; using System.Reflection; using System.Text; +using Expansions.Missions; using KSP.UI.Screens.Flight; using UnityEngine; using UnityEngine.Profiling; @@ -1449,6 +1450,19 @@ public static double MassageToDouble(this object thatValue) return double.NaN; } + internal static InternalModule FindInternalModuleByName(InternalProp prop, string className) + { + foreach (InternalModule potentialModule in prop.internalModules) + { + if (potentialModule.ClassName == className) + { + return potentialModule; + } + } + + return null; + } + internal static Delegate GetMethod(string packedMethod, InternalProp internalProp, Type delegateType) { string moduleName, stateMethod; @@ -1461,26 +1475,26 @@ internal static Delegate GetMethod(string packedMethod, InternalProp internalPro moduleName = tokens[0]; stateMethod = tokens[1]; - InternalModule thatModule = null; - foreach (InternalModule potentialModule in internalProp.internalModules) + // First look on the prop + InternalModule thatModule = FindInternalModuleByName(internalProp, moduleName); + + // then on the internal as a whole + if (thatModule == null) { - if (potentialModule.ClassName == moduleName) + foreach (var prop in internalProp.internalModel.props) { - thatModule = potentialModule; - break; + // this really means "was this a MODULE placed directly in the INTERNAL" + if (!prop.hasModel) + { + thatModule = FindInternalModuleByName(prop, moduleName); + if (thatModule != null) + { + break; + } + } } } - if (thatModule == null) - { - // The module hasn't been instantiated on this part, so let's do so now. - // MOARdV TODO: This actually causes an exception, because - // it's added during InternalProp.OnUpdate. One thing I could - // do is add the internal modules when I instantiate RPMC. - var handlerConfiguration = new ConfigNode("MODULE"); - handlerConfiguration.SetValue("name", moduleName, true); - thatModule = internalProp.AddModule(handlerConfiguration); - } if (thatModule == null) { JUtil.LogErrorMessage(internalProp, "Failed finding module {0} for method {1}", moduleName, stateMethod); diff --git a/SharedAssemblyInfo.cs b/SharedAssemblyInfo.cs index c2b8e031..95ca81a9 100644 --- a/SharedAssemblyInfo.cs +++ b/SharedAssemblyInfo.cs @@ -12,7 +12,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. // Revision number is altered automatically. -[assembly: AssemblyVersion("0.31.13.3")] +[assembly: AssemblyVersion("0.31.13.5")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing.