Skip to content

Commit

Permalink
Nuke the DynamicBatteryStorage VesselModule (#2866)
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Jun 28, 2023
1 parent 8ff1f28 commit 82ac032
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Source/DynamicBatteryStorageNuker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Linq;
using UnityEngine;

namespace RealismOverhaul
{
/// <summary>
/// DynamicBatteryStorage is supposed to disable itself in presence of Kerbalism but the implementation is flawed.
/// In addition to Kerbalism, the mod is also known to cause issues with ROTanks and RealFuels.
/// The code below will remove the problematic VesselModule.
/// </summary>
[KSPAddon(KSPAddon.Startup.Instantly, true)]
internal class DynamicBatteryStorageNuker : MonoBehaviour
{
internal void Start()
{
var la = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == "DynamicBatteryStorage");
if (la != null)
{
var type = la.assembly.GetType("DynamicBatteryStorage.ModuleDynamicBatteryStorage");
bool removed = VesselModuleManager.RemoveModuleOfType(type);
if (!removed)
{
Debug.Log("[RealismOverhaul] Detected DynamicBatteryStorage as installed but failed to remove its VesselModule");
}
}
}
}
}
1 change: 1 addition & 0 deletions Source/RealismOverhaul.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="AdjustableCoMShifter.cs" />
<Compile Include="DebugTools\DebugDrawer.cs" />
<Compile Include="DebugTools\DrawTools.cs" />
<Compile Include="DynamicBatteryStorageNuker.cs" />
<Compile Include="EjectionSeat\CrewEjectionHandler.cs" />
<Compile Include="EventHandlers.cs" />
<Compile Include="HarmonyPatcher.cs" />
Expand Down

0 comments on commit 82ac032

Please sign in to comment.