public static GameObjectMoverType GetMoverType(MovementController.IGameObjectMover mover)
 {
     if (mover is MovementController.CharacterControllerMover)
     {
         return(GameObjectMoverType.CharacterController);
     }
     else if (mover is MovementController.SimulatedRigidbodyMover)
     {
         return(GameObjectMoverType.SimulatedRigidbody);
     }
     else if (mover is MovementController.DirectRigidBodyMover)
     {
         return(GameObjectMoverType.DirectRigidbody);
     }
     else if (mover is MovementController.DumbMover)
     {
         return(GameObjectMoverType.DumbMover);
     }
     else if (mover is MovementController.RagdollBodyMover)
     {
         return(GameObjectMoverType.Ragdoll);
     }
     else if (mover is MovementController.EmulatedCharacterControllerBodyMover)
     {
         return(GameObjectMoverType.Emulated);
     }
     else
     {
         return(GameObjectMoverType.Unknown);
     }
 }
        public void Ragdoll(bool movementControllerAbsent = false)
        {
            if (_ragdolled)
            {
                return;
            }

            _cachedController = null;
            if (!movementControllerAbsent)
            {
                _cachedController = this.FindComponent <MovementController>();
            }
            if (_cachedController != null)
            {
                var ragdollMover = new MovementController.RagdollBodyMover();
                _cachedMover = _cachedController.SwapMover(ragdollMover);
            }
            else
            {
                this.SetJointsKinematic(false);
                this.SetCollidersEnabled(true);
                _falseJointCoroutine = this.StartRadicalCoroutine(this.FalseRootJointUpdate(), RadicalCoroutineDisableMode.Pauses);
            }

            var mecanim = this.GetComponent <Animator>();

            if (mecanim != null)
            {
                _mecanimEnabledCache = mecanim.enabled;
                mecanim.enabled      = false;
            }

            var anim = this.GetComponent <Animation>();

            if (anim != null)
            {
                _animatorEnabledCache = anim.enabled;
                anim.Stop();
                anim.enabled = false;
            }


            _ragdolled = true;
        }
        public void UndoRagdoll()
        {
            if (!_ragdolled)
            {
                return;
            }

            if (_cachedController != null)
            {
                _cachedController.ChangeMover(_cachedMover);
            }
            else
            {
                this.SetJointsKinematic(true);
                this.SetCollidersEnabled(false);
                if (_falseJointCoroutine != null)
                {
                    _falseJointCoroutine.Cancel();
                }
            }

            var mecanim = this.GetComponent <Animator>();

            if (mecanim != null)
            {
                mecanim.enabled = _mecanimEnabledCache;
            }

            var anim = this.GetComponent <Animator>();

            if (anim != null)
            {
                anim.enabled = _animatorEnabledCache;
            }

            _cachedController     = null;
            _cachedMover          = null;
            _falseJointCoroutine  = null;
            _mecanimEnabledCache  = false;
            _animatorEnabledCache = false;

            _ragdolled = false;
        }