/// <summary>
        /// Set the specified MotionParameter to the desired value.
        /// Values have a maximum value of 10, and will be clamped.
        /// </summary>
        /// <param name="id">The id of the MotionParameter.</param>
        /// <param name="value">The value of the MotionParameter.</param>
        public void SetMotionParameter(MotionParameterId id, float value)
        {
            //If the engine is shutdown ignore any incoming calls.
            if (_destroyed)
            {
                return;
            }

            if (_dirty)
            {
                Initialize(false);
            }

            if (_character == null)
            {
                Log.Error <CharacterAnimator>("Unable to retrieve Character from Entity {0} at slot {1}!", Entity.Name, CharacterSlot);
                return;
            }

            if (CapFramerate)
            {
                //If the key isn't assigned yet, prepare it for easier access later on.
                if (!_motionValues.ContainsKey(id))
                {
                    _motionValues[id] = 0;
                }

                switch (id)
                {
                // Most values can have the accumulated values from over multiple frames
                case MotionParameterId.TravelSpeed:
                case MotionParameterId.TurnSpeed:
                case MotionParameterId.TurnAngle:
                case MotionParameterId.TravelDist:
                case MotionParameterId.StopLeg:
                case MotionParameterId.BlendWeight1:
                case MotionParameterId.BlendWeight2:
                case MotionParameterId.BlendWeight3:
                case MotionParameterId.BlendWeight4:
                case MotionParameterId.BlendWeight5:
                case MotionParameterId.BlendWeight6:
                case MotionParameterId.BlendWeight7:
                    _motionValues[id] += value;
                    break;

                // Some values need absolute values
                case MotionParameterId.TravelAngle:
                case MotionParameterId.TravelSlope:
                    _motionValues[id] = value;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                _character.SetAnimationSkeletonParameter(id, value);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Set the <see cref="MotionParameterId"/> to the specified <paramref name="value"/>.
        /// </summary>
        /// <param name="id">The <see cref="MotionParameterId"/> that needs to be set.</param>
        /// <param name="value">The value that will be set to the parameter.</param>
        public void SetAnimationSkeletonParameter(MotionParameterId id, float value)
        {
            var skeleton = AnimationSkeleton;

            if (skeleton == null)
            {
                throw new NullReferenceException(string.Format("The {0} of {1} is null!", nameof(AnimationSkeleton), nameof(Character)));
            }

            skeleton.SetDesiredMotionParam((EMotionParamID)id, value, 0);
        }