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 +