Пример #1
0
 /// <summary>
 /// Sets the entity angles.
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public EntityPos SetAngles(EntityPos pos)
 {
     this.Roll  = pos.Roll;
     this.Yaw   = pos.Yaw;
     this.Pitch = pos.Pitch;
     return(this);
 }
Пример #2
0
 /// <summary>
 /// Sets the entity position.
 /// </summary>
 public EntityPos SetPos(EntityPos pos)
 {
     this.X = pos.X;
     this.Y = pos.Y;
     this.Z = pos.Z;
     return(this);
 }
Пример #3
0
        /// <summary>
        /// Returns the squared distance of the entity to this position
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        public float SquareDistanceTo(EntityPos pos)
        {
            double dx = x - pos.X;
            double dy = y - pos.Y;
            double dz = z - pos.Z;

            return((float)(dx * dx + dy * dy + dz * dz));
        }
Пример #4
0
        /*===== All below methods have been updated to use the x/y/z fields instead of the X/Y/Z properties for higher performance (verified by profiler to gain notable performance) =====*/

        /// <summary>
        /// Returns true if the entity is within given distance of the other entity
        /// </summary>
        /// <param name="position"></param>
        /// <param name="squareDistance"></param>
        /// <returns></returns>
        public bool InRangeOf(EntityPos position, int squareDistance)
        {
            double dx = this.x - position.X;
            double dy = this.y - position.Y;
            double dz = this.z - position.Z;

            return(dx * dx + dy * dy + dz * dz <= squareDistance);
        }
Пример #5
0
 /// <summary>
 /// Makes a "basiclly equals" check on position and motions using a small tolerance of epsilon=0.0001f. Ignores the entities angles.
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="epsilon"></param>
 /// <returns></returns>
 public bool BasicallySameAsIgnoreAngles(EntityPos pos, float epsilon = 0.0001f)
 {
     return
         (Math.Abs(X - pos.x) < epsilon &&
          Math.Abs(Y - pos.y) < epsilon &&
          Math.Abs(Z - pos.z) < epsilon &&
          Math.Abs(Motion.X - pos.Motion.X) < epsilon &&
          Math.Abs(Motion.Y - pos.Motion.Y) < epsilon &&
          Math.Abs(Motion.Z - pos.Motion.Z) < epsilon
         );
 }
Пример #6
0
 /// <summary>
 /// Makes a "basiclly equals" check on the position, motions and angles using a small tolerance of epsilon=0.0001f. Ignores motion
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="epsilon"></param>
 /// <returns></returns>
 public bool BasicallySameAsIgnoreMotion(EntityPos pos, float epsilon = 0.0001f)
 {
     return
         (Math.Abs(X - pos.x) < epsilon &&
          Math.Abs(Y - pos.y) < epsilon &&
          Math.Abs(Z - pos.z) < epsilon &&
          Math.Abs(roll - pos.roll) < epsilon &&
          Math.Abs(yaw - pos.yaw) < epsilon &&
          Math.Abs(pitch - pos.pitch) < epsilon
         );
 }
Пример #7
0
 /// <summary>
 /// Loads the position and angles from given entity position.
 /// </summary>
 /// <param name="pos"></param>
 public void SetFrom(EntityPos pos)
 {
     X        = pos.X;
     Y        = pos.Y;
     Z        = pos.Z;
     Roll     = pos.Roll;
     Yaw      = pos.Yaw;
     Pitch    = pos.Pitch;
     Motion.X = pos.Motion.X;
     Motion.Y = pos.Motion.Y;
     Motion.Z = pos.Motion.Z;
 }
Пример #8
0
        /// <summary>
        /// Creates a full copy
        /// </summary>
        /// <returns></returns>
        public EntityPos Copy()
        {
            EntityPos ret = new EntityPos()
            {
                X      = X,
                Y      = Y,
                Z      = Z,
                Yaw    = Yaw,
                Pitch  = Pitch,
                Roll   = Roll,
                Stance = Stance,
                Motion = new Vec3d(Motion.X, Motion.Y, Motion.Z)
            };

            return(ret);
        }