File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
LabExtended/Patches/Fixes Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ using AdminToys ;
2+
3+ using HarmonyLib ;
4+
5+ namespace LabExtended . Patches . Fixes
6+ {
7+ /// <summary>
8+ /// Fixes a null reference exception caused by interactable toys being destroyed while being interacted with.
9+ /// </summary>
10+ public static class InteractableToySearchNreFix
11+ {
12+ [ HarmonyPatch ( typeof ( InvisibleInteractableToy . InteractableToySearchCompletor ) , nameof ( InvisibleInteractableToy . InteractableToySearchCompletor . ValidateDistance ) ) ]
13+ private static bool Prefix ( InvisibleInteractableToy . InteractableToySearchCompletor __instance , ref bool __result )
14+ {
15+ __result = false ;
16+
17+ if ( __instance == null )
18+ return false ;
19+
20+ if ( __instance . Hub == null )
21+ return false ;
22+
23+ if ( __instance . _target == null || __instance . _target . gameObject == null )
24+ return false ;
25+
26+ __result = ( __instance . _target . transform . position - __instance . Hub . transform . position ) . sqrMagnitude <= __instance . _maxDistanceSqr ;
27+ return false ;
28+ }
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments