예제 #1
0
        private void MoveKerbal(KerbalEVA kerbalEva, ref MotionSettings currentMotion)
        {
            Animation currentAnimation = null;

            kerbalEva.GetComponentCached <Animation>(ref currentAnimation);

            Rigidbody rigidbody = null;

            kerbalEva.GetComponentCached <Rigidbody>(ref rigidbody);

            if ((currentAnimation == null) || (rigidbody == null))
            {
                return;
            }

            currentMotion = GetNewMotionSettings(kerbalEva, currentMotion);

            var orientation   = kerbalEva.part.vessel.transform.rotation;
            var deltaPosition = orientation * Vector3.forward.normalized * (TimeWarp.deltaTime * currentMotion.Speed);

            currentAnimation.CrossFade(currentMotion.Animation);
            rigidbody.interpolation = RigidbodyInterpolation.Extrapolate;
            RemoveRBAnchor(kerbalEva);
            rigidbody.MovePosition(rigidbody.position + deltaPosition);
        }
예제 #2
0
        private bool AbleToMove()
        {
            Rigidbody rigidbody = null;

            eva.GetComponentCached <Rigidbody>(ref rigidbody);
            return((!eva.isEnabled) | (!eva.isRagdoll) | (!rigidbody.isKinematic));
        }
예제 #3
0
        public static void RecoverFromRagdoll(this KerbalEVA eva)
        {
            Rigidbody rigidbody = null;

            eva.GetComponentCached <Rigidbody> (ref rigidbody);
            if (rigidbody != null)
            {
                if (rigidbody.isKinematic)
                {
                    return;
                }
            }

            if (!eva.isEnabled)
            {
                return;
            }

            //Much Kudos to Razchek for finally slaying the Ragdoll Monster!
            if (eva.canRecover && eva.fsm.TimeAtCurrentState > 1.21f && !eva.part.GroundContact)
            {
                foreach (KFSMEvent stateEvent in eva.fsm.CurrentState.StateEvents)
                {
                    if (stateEvent.name == "Recover Start")
                    {
                        eva.fsm.RunEvent(stateEvent);
                        break;
                    }
                }
            }
        }
예제 #4
0
        public void AnimState(AnimationState state)
        {
            string _animState = "idle";

            if (kerbal.part.WaterContact)
            {
                _animState = "swim_idle";
            }
            else if (kerbal.JetpackDeployed)
            {
                _animState = "jp_suspended";
            }

            switch (state)
            {
            case AnimationState.Swim: { _animState = "swim_forward"; } break;

            case AnimationState.Run: { _animState = "wkC_run"; } break;

            case AnimationState.Walk: { _animState = "wkC_forward"; } break;

            case AnimationState.Bounds: { _animState = "wkC_Log_forward"; } break;

            case AnimationState.Idle: { _animState = "idle"; } break;
            }

            Animation _anim = null;

            kerbal.GetComponentCached <Animation>(ref _anim);
            if (_anim != null)
            {
                _anim.CrossFade(_animState);
            }
        }
예제 #5
0
        private bool AbleToMove()
        {
            Rigidbody rigidbody = null;

            eva.GetComponentCached <Rigidbody>(ref rigidbody);

            if (rigidbody != null)
            {
                return((!eva.isEnabled) | (!eva.isRagdoll) | (!rigidbody.isKinematic));
            }
            else
            {
                Debug.LogError("[OrX Chase Container] RigidBody not found .......... ERROR");
                return((false) | (true) | (true));
            }
        }
예제 #6
0
        public static void Animate(this KerbalEVA eva, AnimationState state)
        {
            string anim = "Idle";

            switch (state)
            {
            case AnimationState.None: { } break;

            case AnimationState.Swim: { anim = "swim_forward"; } break;

            case AnimationState.Run: { anim = "wkC_run"; } break;

            case AnimationState.Walk: { anim = "wkC_forward"; } break;

            case AnimationState.BoundSpeed: { anim = "wkC_loG_forward"; } break;

            case AnimationState.Idle:
            {
                if (eva.part.WaterContact)
                {
                    anim = "swim_idle";
                }
                else if (eva.JetpackDeployed)
                {
                    anim = "jp_suspended";
                }
                else
                {
                    anim = "idle";
                }
            }
            break;
            }

            Animation _animation = null;

            eva.GetComponentCached <Animation>(ref _animation);
            if (_animation != null)
            {
                _animation.CrossFade(anim);
            }
        }