diff --git a/GameData/KSPCommunityFixes/Settings.cfg b/GameData/KSPCommunityFixes/Settings.cfg
index b45f6ec..c990842 100644
--- a/GameData/KSPCommunityFixes/Settings.cfg
+++ b/GameData/KSPCommunityFixes/Settings.cfg
@@ -203,6 +203,11 @@ KSP_COMMUNITY_FIXES
// decent performance gains in games having a large amount of celestial bodies and/or vessels.
DisableMapUpdateInFlight = true
+ // Reduce constant overhead of ModuleAsteroidDrill and ModuleCometDrill by using the cached
+ // asteroid/comet part lookup results from ModuleResourceHarvester. Improves performance with
+ // large part count vessels having at least one drill part.
+ AsteroidAndCometDrillCache = true
+
// Fix a bunch of managed memory leaks, mainly by proactively removing GameEvents delegates
// originating from destroyed UnityEngine.Object instances. Will log detected leaks and memory
// usage on scene switches.
@@ -247,13 +252,6 @@ KSP_COMMUNITY_FIXES
packedInterval = 0.5 // interval when the active vessel is timewarping
}
- // The stock ModuleAsteroidDrill and ModuleCometDrill do a lot of unnecessary iterating over all
- // PartModules on the vessel to see if an asteroid or comet is attached.
- // ModuleResourceHarvester already keeps a cache of this information, and all the stock drills
- // have all 3 modules. This patch replaces the logic in the asteroid and comet drills with
- // lookups in the cache. This has a bigger effect the more drills and parts/partmodules on the ship.
- DrillPerformance = true
-
// ##########################
// Modding
// ##########################
diff --git a/KSPCommunityFixes/KSPCommunityFixes.csproj b/KSPCommunityFixes/KSPCommunityFixes.csproj
index 540e281..51b398f 100644
--- a/KSPCommunityFixes/KSPCommunityFixes.csproj
+++ b/KSPCommunityFixes/KSPCommunityFixes.csproj
@@ -94,7 +94,7 @@
-
+
diff --git a/KSPCommunityFixes/Performance/DrillPerformance.cs b/KSPCommunityFixes/Performance/AsteroidAndCometDrillCache.cs
similarity index 83%
rename from KSPCommunityFixes/Performance/DrillPerformance.cs
rename to KSPCommunityFixes/Performance/AsteroidAndCometDrillCache.cs
index 58d5dad..0ba1201 100644
--- a/KSPCommunityFixes/Performance/DrillPerformance.cs
+++ b/KSPCommunityFixes/Performance/AsteroidAndCometDrillCache.cs
@@ -1,14 +1,26 @@
-using HarmonyLib;
+// see https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/67
+
+// The stock ModuleAsteroidDrill and ModuleCometDrill do a lot of unnecessary iterating over all
+// PartModules on the vessel to see if an asteroid or comet is attached.
+// ModuleResourceHarvester already keeps a cache of this information, and all the stock drills
+// have all 3 modules. This patch replaces the logic in the asteroid and comet drills with
+// lookups in the cache. This has a bigger effect the more drills and parts/partmodules on the ship.
+
+// Note from @Got : this introduce a behavior change in which asteroid/comet will be selected by drills
+// on a multi-asteroid vessel when a new asteroid is attached. But since the whole multi-asteroid
+// situation isn't handled correctly by stock anyway (all drills on the vessel will mine the first
+// found one regardless of which asteroid part the drill is actually in contact with), we don't care.
+
using System;
+using HarmonyLib;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace KSPCommunityFixes.Performance
{
- class DrillPerformance : BasePatch
+ class AsteroidAndCometDrillCache : BasePatch
{
+ protected override Version VersionMin => new Version(1, 12, 3);
+
protected override void ApplyPatches(List patches)
{
patches.Add(
diff --git a/README.md b/README.md
index 83770aa..6ade702 100644
--- a/README.md
+++ b/README.md
@@ -96,6 +96,7 @@ User options are available from the "ESC" in-game settings menu :