コード例 #1
0
 /// <summary>Initializes a new instance of the <see cref="ObjectUpdatePositionCommand" /> class.</summary>
 /// <param name="objectId">The object identifier.</param>
 /// <param name="targetPosition">The target position x.</param>
 /// <param name="targetOrientation">The quaternion .</param>
 /// <param name="startFrameTick">The start frame tick.</param>
 /// <param name="stopFrameTick">The stop frame tick.</param>
 public ObjectUpdatePositionCommand(
     ulong objectId,
     AVector3 targetPosition,
     AQuaternion targetOrientation,
     ulong startFrameTick,
     ulong stopFrameTick)
     : this(
         objectId,
         targetPosition,
         targetOrientation,
         AVector3.Zero,
         AVector3.Zero,
         startFrameTick,
         stopFrameTick)
 {
 }
コード例 #2
0
        /// <summary>
        /// Writes a vector 3 instance.
        /// </summary>
        /// <param name="bw">Binary write to byte buffer.</param>
        /// <param name="quaternion">Quaternion to write.</param>
        protected static void Write(BinaryWriter bw, AQuaternion quaternion)
        {
            if (bw == null)
            {
                throw new ArgumentNullException(nameof(bw));
            }

            if (quaternion == null)
            {
                throw new ArgumentNullException(nameof(quaternion));
            }

            bw.Write(quaternion.X);
            bw.Write(quaternion.Y);
            bw.Write(quaternion.Z);
            bw.Write(quaternion.W);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectCreateCommand"/> class.
        /// </summary>
        /// <param name="frameTick">Frame tick when the object was created.</param>
        /// <param name="objectId">Id of the new object.</param>
        /// <param name="parentObjectId">Id of the objects parent.</param>
        /// <param name="ownerId">Id of the owner.</param>
        /// <param name="typeId">Type of the object.</param>
        /// <param name="targetPosition">Position where object is located.</param>
        /// <param name="targetOrientation">Quaternion orientation of object.</param>
        public ObjectCreateCommand(
            ulong frameTick,
            ulong objectId,
            ulong parentObjectId,
            uint ownerId,
            uint typeId,
            AVector3 targetPosition,
            AQuaternion targetOrientation)
            : base(CommandType.ObjectCreate)
        {
            if (targetPosition == null)
            {
                throw new ArgumentNullException(nameof(targetPosition));
            }

            if (targetOrientation == null)
            {
                throw new ArgumentNullException(nameof(targetOrientation));
            }

            this.FrameTick         = frameTick;
            this.ObjectId          = objectId;
            this.ParentObjectId    = parentObjectId;
            this.OwnerId           = ownerId;
            this.TypeId            = typeId;
            this.TargetPosition    = targetPosition;
            this.TargetOrientation = targetOrientation;
            int floatSize = sizeof(float) * 7;

            using (MemoryStream stream = new MemoryStream(sizeof(ulong) + floatSize))
            {
                using (BinaryWriter bw = new BinaryWriter(stream))
                {
                    bw.Write(this.FrameTick);
                    bw.Write(this.ObjectId);
                    bw.Write(this.ParentObjectId);
                    bw.Write(this.OwnerId);
                    bw.Write(this.TypeId);
                    Write(bw, this.TargetPosition);
                    Write(bw, this.TargetOrientation);
                }

                stream.Flush();
                this.Body = stream.ToArray();
            }
        }
コード例 #4
0
        /// <summary>Initializes a new instance of the <see cref="ObjectUpdatePositionCommand" /> class.</summary>
        /// <param name="objectId">The object identifier.</param>
        /// <param name="targetPosition">The target position.</param>
        /// <param name="targetOrientation">The quaternion.</param>
        /// <param name="velocity">The velocity.</param>
        /// <param name="angularVelocity">The angular velocity.</param>
        /// <param name="startFrameTick">The start frame tick.</param>
        /// <param name="stopFrameTick">The stop frame tick.</param>
        public ObjectUpdatePositionCommand(
            ulong objectId,
            AVector3 targetPosition,
            AQuaternion targetOrientation,
            AVector3 velocity,
            AVector3 angularVelocity,
            ulong startFrameTick,
            ulong stopFrameTick)
            : base(CommandType.ObjectUpdatePosition)
        {
            this.ObjectId          = objectId;
            this.TargetPosition    = targetPosition;
            this.TargetOrientation = targetOrientation;
            this.Velocity          = velocity;
            this.AngularVelocity   = angularVelocity;
            this.StartFrameTick    = startFrameTick;
            this.StopFrameTick     = stopFrameTick;
            int sizeUlongs = sizeof(ulong) * 2;
            int sizeFloats = sizeof(float) * 13;
            int size       = sizeUlongs + sizeFloats;

            using (MemoryStream stream = new MemoryStream(size))
            {
                using (BinaryWriter bw = new BinaryWriter(stream))
                {
                    bw.Write(this.ObjectId);
                    Write(bw, this.TargetPosition);
                    Write(bw, this.TargetOrientation);
                    Write(bw, this.Velocity);
                    Write(bw, this.AngularVelocity);
                    bw.Write(this.StartFrameTick);
                    bw.Write(this.StopFrameTick);
                }

                stream.Flush();
                this.Body = stream.ToArray();
            }
        }