Skip to content

Commit 905c916

Browse files
committed
patch stock fairings
1 parent 3cf9463 commit 905c916

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

Source/DynamicProperties/MaterialPropertyManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private void OnDestroy()
4646
PartPatch.ClearOnSceneSwitch();
4747
MaterialColorUpdaterPatch.ClearOnSceneSwitch();
4848
ModuleColorChangerPatch.ClearOnSceneSwitch();
49+
FairingPanelPatch.ClearOnSceneSwitch();
4950

5051
this.LogMessage("destroyed");
5152
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using HarmonyLib;
2+
using ProceduralFairings;
3+
4+
namespace Shabby.DynamicProperties;
5+
6+
[HarmonyPatch(typeof(FairingPanel))]
7+
internal class FairingPanelPatch : StockPatchBase<FairingPanel>
8+
{
9+
[HarmonyPrefix]
10+
[HarmonyPatch(nameof(FairingPanel.SetOpacity))]
11+
private static bool SetOpacity_Transpiler(FairingPanel __instance, float o)
12+
{
13+
__instance.opacity = o;
14+
15+
if (!Props.TryGetValue(__instance, out var props)) {
16+
props = Props[__instance] = new Props(0);
17+
MaterialPropertyManager.Instance?.Set(__instance.mr, props);
18+
if (__instance.attachedFlagParts is { Count: > 0 }) {
19+
foreach (var flagPart in __instance.attachedFlagParts) {
20+
foreach (var flagRenderer in flagPart.flagMeshRenderers) {
21+
MaterialPropertyManager.Instance?.Set(flagRenderer, props);
22+
}
23+
}
24+
}
25+
}
26+
27+
props.SetFloat(PropertyIDs._Opacity, o);
28+
29+
return false;
30+
}
31+
32+
[HarmonyPostfix]
33+
[HarmonyPatch(nameof(FairingPanel.Despawn))]
34+
private static void FairingPanel_Despawn(FairingPanel __instance)
35+
{
36+
if (Props.Remove(__instance, out var props)) props.Dispose();
37+
}
38+
}

Source/Shabby.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
<Publicize Include="Assembly-CSharp:Part.highlightRenderer"/>
5252
<Publicize Include="Assembly-CSharp:Part.modelRenderersCache"/>
5353
<Publicize Include="Assembly-CSharp:Part.temperatureRenderer"/>
54+
<Publicize Include="Assembly-CSharp:ProceduralFairings.FairingPanel.mpb"/>
55+
<Publicize Include="Assembly-CSharp:ProceduralFairings.FairingPanel.mr"/>
56+
<Publicize Include="Assembly-CSharp:ProceduralFairings.FairingPanel.opacity"/>
5457
</ItemGroup>
5558

5659
<!-- Version Files -->

0 commit comments

Comments
 (0)