6
6
namespace Shabby . DynamicProperties ;
7
7
8
8
[ HarmonyPatch ( typeof ( Part ) ) ]
9
- internal static class PartPatch
9
+ internal class PartPatch : StockPatchBase < Part >
10
10
{
11
- private static readonly Dictionary < Part , Props > rimHighlightProps = [ ] ;
12
-
13
11
[ HarmonyPostfix ]
14
12
[ HarmonyPatch ( "Awake" ) ]
15
13
private static void Awake_Postfix ( Part __instance )
16
14
{
17
- rimHighlightProps [ __instance ] = new Props ( int . MinValue + 1 ) ;
15
+ Props [ __instance ] = new Props ( int . MinValue + 1 ) ;
18
16
}
19
17
20
18
[ HarmonyPostfix ]
21
19
[ HarmonyPatch ( "CreateRendererLists" ) ]
22
20
private static void CreateRendererLists_Postfix ( Part __instance )
23
21
{
24
- var props = rimHighlightProps [ __instance ] ;
22
+ var props = Props [ __instance ] ;
25
23
props . SetFloat ( PropertyIDs . _RimFalloff , 2f ) ;
26
24
props . SetColor ( PropertyIDs . _RimColor , Part . defaultHighlightNone ) ;
27
25
foreach ( var renderer in __instance . HighlightRenderer ) {
@@ -35,13 +33,13 @@ private static bool SetOpacity_Prefix(Part __instance, float opacity)
35
33
{
36
34
__instance . CreateRendererLists ( ) ;
37
35
__instance . mpb . SetFloat ( PropertyIDs . _Opacity , opacity ) ;
38
- rimHighlightProps [ __instance ] . SetFloat ( PropertyIDs . _Opacity , opacity ) ;
36
+ Props [ __instance ] . SetFloat ( PropertyIDs . _Opacity , opacity ) ;
39
37
return false ;
40
38
}
41
39
42
40
private static void Highlight_SetRimColor ( Part part , Color color )
43
41
{
44
- rimHighlightProps [ part ] . SetColor ( PropertyIDs . _RimColor , color ) ;
42
+ Props [ part ] . SetColor ( PropertyIDs . _RimColor , color ) ;
45
43
}
46
44
47
45
[ HarmonyTranspiler ]
@@ -122,7 +120,7 @@ private static IEnumerable<CodeInstruction> Highlight_Transpiler(
122
120
[ HarmonyPatch ( "OnDestroy" ) ]
123
121
private static void OnDestroy_Postfix ( Part __instance )
124
122
{
125
- if ( rimHighlightProps . Remove ( __instance , out var props ) ) {
123
+ if ( Props . Remove ( __instance , out var props ) ) {
126
124
props . Dispose ( ) ;
127
125
}
128
126
}
0 commit comments