Skip to content

Commit

Permalink
Remove stock part tags that aren't relevant in RO context (#2980)
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav authored Aug 11, 2024
1 parent 069a8ea commit 7883e72
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Source/Harmony/BasePartCategorizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using HarmonyLib;
using KSP.UI.Screens;

namespace RealismOverhaul.Harmony
{
[HarmonyPatch(typeof(BasePartCategorizer))]
internal class PatchBasePartCategorizer
{
/// <summary>
/// Called through GameEvents.onLanguageSwitched
/// </summary>
[HarmonyPostfix]
[HarmonyPatch("LoadAutoTags")]
internal static void LoadAutoTags()
{
PartTagNuker.NukeTags();
}
}
}
25 changes: 25 additions & 0 deletions Source/PartTagNuker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using KSP.UI.Screens;
using UnityEngine;

namespace RealismOverhaul
{
/// <summary>
/// Removes stock part tags that aren't relevant in RO context.
/// Cannot be done in a Harmony patch because the relevant code runs before plugins are initialized.
/// </summary>
[KSPAddon(KSPAddon.Startup.Instantly, true)]
internal class PartTagNuker : MonoBehaviour
{
internal void Start()
{
NukeTags();
}

internal static void NukeTags()
{
BasePartCategorizer.size0Tags = BasePartCategorizer.size1Tags = BasePartCategorizer.size1p5Tags =
BasePartCategorizer.size2Tags = BasePartCategorizer.size3Tags = BasePartCategorizer.size4Tags =
BasePartCategorizer.srfTags = BasePartCategorizer.radialTag = new string[0];
}
}
}
2 changes: 2 additions & 0 deletions Source/RealismOverhaul.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
<Compile Include="AdjustableCoMShifter.cs" />
<Compile Include="DebugTools\DebugDrawer.cs" />
<Compile Include="DebugTools\DrawTools.cs" />
<Compile Include="PartTagNuker.cs" />
<Compile Include="Harmony\BasePartCategorizer.cs" />
<Compile Include="Harmony\ModuleEngines.cs" />
<Compile Include="Harmony\KSPUtil.cs" />
<Compile Include="Harmony\KSPWheel.cs" />
Expand Down

0 comments on commit 7883e72

Please sign in to comment.