static bool Prefix(Vagon __instance)
            {
                if (!__instance.m_nview.IsValid())
                {
                    logger.LogDebug("m_nview invalid");
                    return(false);
                }

                // Attempt to attach the cart
                __instance.UpdateAudio(Time.fixedDeltaTime);
                if (__instance.m_nview.IsOwner())
                {
                    if ((bool)__instance.m_useRequester)
                    {
                        if (__instance.IsAttached())
                        {
                            // If attached detach
                            __instance.Detach();
                        }
                        else
                        {
                            /// Determine if there is a valid animal in range and if so attempt to attach to it.
                            /// If not attempt to attach to player
                            Character closest_tamed = FindClosestAttachableAnimal(__instance);
                            if (closest_tamed != null)
                            {
                                AttachCartTo(closest_tamed, __instance);
                            }
                            else if (__instance.CanAttach(__instance.m_useRequester.gameObject))
                            {
                                AttachCartTo(__instance.m_useRequester, __instance);
                            }
                            else
                            {
                                __instance.m_useRequester.Message(MessageHud.MessageType.Center, "Not in the right position");
                            }
                        }
                        __instance.m_useRequester = null;
                    }
                    if (__instance.IsAttached())
                    {
                        // Update detach distance before check if it should be detached
                        __instance.m_detachDistance = GetCartDetachDistance(AttachedCharacter(__instance));
                        if (!__instance.CanAttach(((Component)(object)((Joint)__instance.m_attachJoin).connectedBody).gameObject))
                        {
                            __instance.Detach();
                            logger.LogDebug("Cart no longer attachable.");
                        }
                    }
                }
                else if (__instance.IsAttached())
                {
                    __instance.Detach();
                }
                return(false);
            }
 static void Prefix(ref Vagon __instance, ref ConfigurableJoint ___m_attachJoin, ref Rigidbody ___m_body)
 {
     if (___m_attachJoin != null && ___m_attachJoin.connectedBody == null)
     {
         __instance.Detach();
     }
 }