diff --git a/KSPCommunityFixes/KSPCommunityFixes.cs b/KSPCommunityFixes/KSPCommunityFixes.cs index 5e094c9..6cde182 100644 --- a/KSPCommunityFixes/KSPCommunityFixes.cs +++ b/KSPCommunityFixes/KSPCommunityFixes.cs @@ -63,7 +63,7 @@ void Start() Destroy(Instance); Instance = null; } - + if (Instance.IsNullOrDestroyed()) { Instance = this; @@ -77,9 +77,17 @@ void Start() #endif LocalizationUtils.GenerateLocTemplateIfRequested(); LocalizationUtils.ParseLocalization(); + + // Insert KSPCF as the first entry in the explicit callback list. + // This guarantees that KSPCF will run before all other post load callbacks. + // Note that this is cumbersome to access via publicizer because it references + // assemblies via file name, and ModuleManager's dll is versioned. + AccessTools + .StaticFieldRefAccess>(typeof(ModuleManager.PostPatchLoader), "postPatchCallbacks") + .Insert(0, MMPostLoadCallback); } - public void ModuleManagerPostLoad() + public void MMPostLoadCallback() { if (Instance.IsNullOrDestroyed() || !Instance.RefEquals(this)) return; @@ -106,7 +114,7 @@ public void ModuleManagerPostLoad() if (!type.IsAbstract && type.IsSubclassOf(basePatchType)) { patchesTypes.Add(type); - + } } diff --git a/KSPCommunityFixes/KSPCommunityFixes.csproj b/KSPCommunityFixes/KSPCommunityFixes.csproj index 5ccec49..7dc8389 100644 --- a/KSPCommunityFixes/KSPCommunityFixes.csproj +++ b/KSPCommunityFixes/KSPCommunityFixes.csproj @@ -84,6 +84,10 @@ Harmony False + + ModuleManager + False + @@ -407,4 +411,4 @@ - \ No newline at end of file + diff --git a/KSPCommunityFixes/Properties/AssemblyInfo.cs b/KSPCommunityFixes/Properties/AssemblyInfo.cs index 4d1d068..029bdff 100644 --- a/KSPCommunityFixes/Properties/AssemblyInfo.cs +++ b/KSPCommunityFixes/Properties/AssemblyInfo.cs @@ -34,3 +34,4 @@ [assembly: KSPAssembly("KSPCommunityFixes", 1, 35, 2)] [assembly: KSPAssemblyDependency("MultipleModulePartAPI", 1, 0, 0)] +[assembly: KSPAssemblyDependency("ModuleManager", 1, 0)]