Пример #1
0
        private AccumulatedAttributeTransform InvokeMotion(AccumulatedAttributeTransform accumulatedTransforms)
        {
            var velocity = (Vector)accumulatedTransforms.CurrentAttributeValue("motion", "velocity");

            if (velocity.x != 0 || velocity.y != 0 || velocity.z != 0)
            {
                lock (ongoingMotion)
                {
                    if (!ongoingMotion.Contains(accumulatedTransforms.Entity))
                    {
                        ongoingMotion.Add(accumulatedTransforms.Entity);
                    }
                }
            }
            else
            {
                lock (ongoingMotion)
                {
                    if (ongoingMotion.Contains(accumulatedTransforms.Entity))
                    {
                        ongoingMotion.Remove(accumulatedTransforms.Entity);
                    }
                }
            }
            return(accumulatedTransforms);
        }
Пример #2
0
        private AccumulatedAttributeTransform InvokeSpin(AccumulatedAttributeTransform accumulatedTransforms)
        {
            var rotVelocity = (AxisAngle)accumulatedTransforms.CurrentAttributeValue("motion", "rotVelocity");

            if (rotVelocity.angle != 0 &&
                !(rotVelocity.axis.x == 0 && rotVelocity.axis.y == 0 && rotVelocity.axis.z == 0))
            {
                lock (ongoingSpin)
                {
                    if (!ongoingSpin.Contains(accumulatedTransforms.Entity))
                    {
                        ongoingSpin.Add(accumulatedTransforms.Entity);
                    }
                }
            }
            else
            {
                lock (ongoingSpin)
                {
                    if (ongoingSpin.Contains(accumulatedTransforms.Entity))
                    {
                        ongoingSpin.Remove(accumulatedTransforms.Entity);
                    }
                }
            }

            return(accumulatedTransforms);
        }
        /// <summary>
        /// Checks if position of entity has changed and sets y attribute to ground level if y and ground level
        /// are different
        /// </summary>
        /// <param name="accumulatedTransforms">Accumulated transformation that happened in the service chain</param>
        /// <returns>Accumulated changes with adaptions added by AvatarCollison</returns>
        internal AccumulatedAttributeTransform Transform(AccumulatedAttributeTransform accumulatedTransforms)
        {
            Vector entityPosition  = (Vector)accumulatedTransforms.CurrentAttributeValue("location", "position");
            Vector adaptedPosition = new Vector(entityPosition.x,
                                                (float)accumulatedTransforms.Entity["avatarCollision"]["groundLevel"].Value,
                                                entityPosition.z);

            accumulatedTransforms.AddAttributeTransformation("location", "position", adaptedPosition);
            return(accumulatedTransforms);
        }