Skip to content

Commit 28c3ebd

Browse files
Merge pull request #50 from Scherub/add-planning-extended-support
Added PlanningExtended support
2 parents 713be34 + c10baa3 commit 28c3ebd

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

Progress-Renderer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<Compile Include="Source\Harmony_Patches\Harmony_OptionListingUtility.cs" />
128128
<Compile Include="Source\Harmony_Patches\Harmony_OverlayDrawer.cs" />
129129
<Compile Include="Source\Harmony_Patches\Harmony_OverlayDrawHandler.cs" />
130+
<Compile Include="Source\Harmony_Patches\Harmony_PlanDesignation_DesignationDraw.cs" />
130131
<Compile Include="Source\Harmony_Patches\Harmony_RoofGrid.cs" />
131132
<Compile Include="Source\Harmony_Patches\Harmony_ScreenshotModeHandler.cs" />
132133
<Compile Include="Source\Harmony_Patches\Harmony_Targeter.cs" />

Source/Harmony_Patches/HarmonySetup.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
namespace ProgressRenderer
66
{
7-
87
[StaticConstructorOnStartup]
98
static class HarmonySetup
109
{
1110
static HarmonySetup()
1211
{
1312
var harmony = new Harmony("rimworld.neptimus7.progressrenderer");
14-
harmony.PatchAll(Assembly.GetExecutingAssembly());
13+
14+
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "scherub.planningextended"))
15+
harmony.PatchCategory("PlanningExtended");
16+
17+
harmony.PatchAllUncategorized(Assembly.GetExecutingAssembly());
1518
}
1619
}
1720
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using HarmonyLib;
3+
using Verse;
4+
5+
namespace ProgressRenderer
6+
{
7+
[HarmonyPatchCategory("PlanningExtended")]
8+
[HarmonyPatch("PlanDesignation", nameof(Designation.DesignationDraw))]
9+
public static class Harmony_PlanDesignation_DesignationDraw
10+
{
11+
public static bool Prefix(Designation __instance)
12+
{
13+
try
14+
{
15+
if (__instance.def == null) return true;
16+
17+
var target = __instance.target;
18+
19+
Map map = target.HasThing ? target.Thing.MapHeld : Find.CurrentMap;
20+
21+
var renderManager = map?.GetComponent<MapComponent_RenderManager>();
22+
23+
if (renderManager?.Rendering == false) return true;
24+
25+
return PrModSettings.RenderDesignations;
26+
}
27+
catch (Exception ex)
28+
{
29+
// 1.6 UPDATE: Enhanced error reporting
30+
Log.Error($"[ProgressRenderer] DesignationDraw patch error in 1.6: {ex}\n{ex.StackTrace}");
31+
return true;
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)