Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,11 @@ KSP_COMMUNITY_FIXES
// the examples and documentation in the patch source.
BaseFieldListUseFieldHost = true

// Adds Unity Profiler markers to EventData.Fire() methods, making game event dispatch and
// individual subscriber callbacks visible in the Unity Profiler. Useful for identifying
// expensive event handlers.
EventProfilerMarkers = false

// ##########################
// Localization tools
// ##########################
Expand Down
11 changes: 7 additions & 4 deletions KSPCommunityFixes/BasePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ protected void AddPatch(PatchType patchType, Type patchedMethodType, string patc
patches.Add(new PatchInfo(patchType, AccessTools.Method(patchedMethodType, patchedMethodName, patchedMethodArgs), patchMethodName, patchPriority));
}

protected void AddPatch(PatchInfo patch)
{
patches.Add(patch);
}

public bool IsVersionValid => KSPCommunityFixes.KspVersion >= VersionMin && KSPCommunityFixes.KspVersion <= VersionMax;

private bool ApplyHarmonyPatch()
Expand All @@ -209,10 +214,8 @@ private bool ApplyHarmonyPatch()
continue;
}

if (patch.patchMethodName == null)
patch.patchMethodName = patch.patchedMethod.DeclaringType.Name + "_" + patch.patchedMethod.Name + "_" + patch.patchType;

patch.patchMethod = AccessTools.Method(GetType(), patch.patchMethodName);
patch.patchMethodName ??= patch.patchedMethod.DeclaringType.Name + "_" + patch.patchedMethod.Name + "_" + patch.patchType;
patch.patchMethod ??= AccessTools.Method(GetType(), patch.patchMethodName);

if (patch.patchMethod == null)
{
Expand Down
1 change: 1 addition & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<Compile Include="Modding\DockingPortLockedEvents.cs" />
<Compile Include="Modding\OnSymmetryFieldChanged.cs" />
<Compile Include="Modding\ReflectionTypeLoadExceptionHandler.cs" />
<Compile Include="Modding\EventProfilerMarkers.cs" />
<Compile Include="Performance\FewerSaves.cs" />
<Compile Include="Performance\ConfigNodePerf.cs" />
<Compile Include="Performance\MinorPerfTweaks.cs" />
Expand Down
Loading