Skip to content

Commit 6d4ad90

Browse files
authored
Greatly increase asteroid load and unpack distances (#292)
1 parent 28d8e8b commit 6d4ad90

3 files changed

Lines changed: 53 additions & 0 deletions

File tree

Source/Harmony/Vessel.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using FinePrint.Utilities;
2+
using HarmonyLib;
3+
4+
namespace RealSolarSystem.Harmony
5+
{
6+
[HarmonyPatch(typeof(Vessel))]
7+
internal class PatchVessel
8+
{
9+
[HarmonyPostfix]
10+
[HarmonyPatch("Start")]
11+
internal static void Postfix_Start(Vessel __instance)
12+
{
13+
if (__instance.vesselType == VesselType.SpaceObject ||
14+
(__instance.vesselType != VesselType.Debris &&
15+
VesselUtilities.VesselHasPartName("PotatoRoid", __instance)))
16+
{
17+
ClobberVesselRanges(__instance.vesselRanges.orbit);
18+
ClobberVesselRanges(__instance.vesselRanges.subOrbital);
19+
ClobberVesselRanges(__instance.vesselRanges.escaping);
20+
ClobberVesselRanges(__instance.vesselRanges.flying);
21+
ClobberVesselRanges(__instance.vesselRanges.splashed);
22+
ClobberVesselRanges(__instance.vesselRanges.landed);
23+
}
24+
}
25+
26+
private static void ClobberVesselRanges(VesselRanges.Situation vr)
27+
{
28+
vr.load = 100000f;
29+
vr.unload = 101000f;
30+
vr.pack = 2600f;
31+
vr.unpack = 2500f;
32+
}
33+
}
34+
}

Source/HarmonyPatcher.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using UnityEngine;
2+
3+
namespace RealSolarSystem
4+
{
5+
[KSPAddon(KSPAddon.Startup.Instantly, true)]
6+
public class HarmonyPatcher : MonoBehaviour
7+
{
8+
internal void Start()
9+
{
10+
var harmony = new HarmonyLib.Harmony("RSS.HarmonyPatcher");
11+
harmony.PatchAll();
12+
}
13+
}
14+
}

Source/RealSolarSystem.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
<Compile Include="CameraWrapper.cs" />
4545
<Compile Include="CommNetFixer.cs" />
4646
<Compile Include="GUI.cs" />
47+
<Compile Include="HarmonyPatcher.cs" />
48+
<Compile Include="Harmony\Vessel.cs" />
4749
<Compile Include="InstallationChecker.cs" />
4850
<Compile Include="KopernicusMods\MapSODemandLarge.cs" />
4951
<Compile Include="KopernicusMods\PQSMod_VertexDefineCoastSmooth.cs" />
@@ -58,6 +60,9 @@
5860
<Compile Include="Watchdogs.cs" />
5961
</ItemGroup>
6062
<ItemGroup>
63+
<Reference Include="0Harmony">
64+
<Private>False</Private>
65+
</Reference>
6166
<Reference Include="Assembly-CSharp">
6267
<Private>False</Private>
6368
</Reference>

0 commit comments

Comments
 (0)