Exemple #1
0
        public CoordInt Offset(Face face)
        {
            CoordInt c = this.Clone();

            switch (face)
            {
            case Face.Down:
                c.Y--;
                break;

            case Face.Up:
                c.Y++;
                break;

            case Face.North:
                c.Z--;
                break;

            case Face.South:
                c.Z++;
                break;

            case Face.West:
                c.X--;
                break;

            case Face.East:
                c.X++;
                break;
            }
            return(c);
        }
Exemple #2
0
 public static CoordInt Decode(long val)
 {
     var p = new CoordInt();
     p.X = (int)((val >> 38) & 0x3FFFFFF);
     p.Y = (int)((val >> 26) & 0xFFF);
     p.Z = (int)(val & 0x3FFFFFF);
     return p;
 }
Exemple #3
0
        public CoordInt Clone()
        {
            CoordInt c = new CoordInt();

            c.X = X;
            c.Y = Y;
            c.Z = Z;
            return(c);
        }
Exemple #4
0
        public static CoordInt Decode(long val)
        {
            var p = new CoordInt();

            p.X = (int)((val >> 38) & 0x3FFFFFF);
            p.Y = (int)((val >> 26) & 0xFFF);
            p.Z = (int)(val & 0x3FFFFFF);
            return(p);
        }
Exemple #5
0
        public static CoordInt MaxComponent(CoordInt a, CoordInt b)
        {
            CoordInt c = new CoordInt();

            c.X = Math.Max(a.X, b.X);
            c.Y = Math.Max(a.Y, b.Y);
            c.Z = Math.Max(a.Z, b.Z);
            return(c);
        }
Exemple #6
0
        public static CoordInt AbsComponent(CoordInt a)
        {
            CoordInt c = new CoordInt();

            c.X = Math.Abs(a.X);
            c.Y = Math.Abs(a.Y);
            c.Z = Math.Abs(a.Z);
            return(c);
        }
Exemple #7
0
        public CoordInt CloneInt()
        {
            CoordInt c = new CoordInt();

            c.X = (int)X;
            c.Y = (int)Y;
            c.Z = (int)Z;
            return(c);
        }
Exemple #8
0
 public double DistanceTo(CoordInt other)
 {
     if (other == null)
         return this.Abs;
     
     double dx = X - other.X;
     double dy = Y - other.Y;
     double dz = Z - other.Z;
     return Math.Sqrt(dx * dx + dy * dy + dz * dz);
 }
Exemple #9
0
        public double DistanceToXZ(CoordInt other)
        {
            if (other == null)
            {
                return(this.Abs);
            }

            double dx = X - other.X;
            double dz = Z - other.Z;

            return(Math.Sqrt(dx * dx + dz * dz));
        }
Exemple #10
0
 public CoordInt SizeTo(CoordInt other)
 {
     if (other == null)
         return this.Clone();
     
     int dx = X - other.X;
     int dy = Y - other.Y;
     int dz = Z - other.Z;
     return new CoordInt(
         Math.Abs(dx) + 1,
         Math.Abs(dy) + 1,
         Math.Abs(dz) + 1);
 }
Exemple #11
0
        public CoordInt SizeTo(CoordInt other)
        {
            if (other == null)
            {
                return(this.Clone());
            }

            int dx = X - other.X;
            int dy = Y - other.Y;
            int dz = Z - other.Z;

            return(new CoordInt(
                       Math.Abs(dx) + 1,
                       Math.Abs(dy) + 1,
                       Math.Abs(dz) + 1));
        }
Exemple #12
0
        public override bool Equals(object obj)
        {
            CoordInt b = obj as CoordInt;

            if (b == null)
            {
                return(false);
            }
            if (X != b.X)
            {
                return(false);
            }
            if (Y != b.Y)
            {
                return(false);
            }
            if (Z != b.Z)
            {
                return(false);
            }
            return(true);
        }
Exemple #13
0
 public CoordInt CloneInt()
 {
     CoordInt c = new CoordInt();
     c.X = (int)X;
     c.Y = (int)Y;
     c.Z = (int)Z;
     return c;
 }
Exemple #14
0
 /// <summary>
 /// Termvis multiplikation
 /// </summary>
 public CoordInt TermProd(CoordInt o)
 {
     return new CoordInt(X * o.X, Y * o.Y, Z * o.Z);
 }
Exemple #15
0
 public CoordInt Clone()
 {
     CoordInt c = new CoordInt();
     c.X = X;
     c.Y = Y;
     c.Z = Z;
     return c;
 }
Exemple #16
0
 public static CoordInt MaxComponent(CoordInt a, CoordInt b)
 {
     CoordInt c = new CoordInt();
     c.X = Math.Max(a.X, b.X);
     c.Y = Math.Max(a.Y, b.Y);
     c.Z = Math.Max(a.Z, b.Z);
     return c;
 }
Exemple #17
0
 public static CoordInt AbsComponent(CoordInt a)
 {
     CoordInt c = new CoordInt();
     c.X = Math.Abs(a.X);
     c.Y = Math.Abs(a.Y);
     c.Z = Math.Abs(a.Z);
     return c;
 }
Exemple #18
0
 /// <summary>
 /// Termvis multiplikation
 /// </summary>
 public CoordInt TermProd(CoordInt o)
 {
     return(new CoordInt(X * o.X, Y * o.Y, Z * o.Z));
 }
        private bool FilterDirection(CoordInt block)
        {
            if (block.X == -1 && block.Y == 255 && block.Z == -1)
                return false;
                    
            //Player view is 1.5 above its position
            CoordDouble offset = block - this.Position + new CoordDouble(0.5, -1, 0.5);
            CoordDouble unit = new CoordDouble(
                                   -Math.Cos(Pitch * Math.PI / 180) * Math.Sin(Yaw * Math.PI / 180),
                                   -Math.Sin(Pitch * Math.PI / 180),
                                   Math.Cos(Pitch * Math.PI / 180) * Math.Cos(Yaw * Math.PI / 180));
            double viewDist = offset.Scalar(unit);
            double perDist = (offset - unit * viewDist).Abs;
#if DEBUG
            /*this.Tell ("Block: " + block +
                //"Offset: " + offset.ToString ("0.0") +
                //" Unit: " + unit.ToString ("0.0") +
                " Dist: " + viewDist.ToString ("0.0") +
                " Per: " + perDist.ToString ("0.0"));
                */
#endif
            //Ignore extreme values
            if (perDist > 20)
                return false;
            if (viewDist > 20)
                return false;
            
            //Logical max i 0.87
            //Dont block anymore since client does not restore uncomfirmed blocks
            
            if (perDist > 1.5)
            {
                //Log.WritePlayer (this, "Aimed sideways: " + perDist.ToString ("0.00") + " > 0.87");
                //return true;
            }
            if (viewDist > 6)
            {
                //Log.WritePlayer (this, "Aimed too far: " + viewDist.ToString ("0.0") + " > 6.0, " + block);
                //return true;
            }
            if (viewDist < -0.1)
            {
                //Log.WritePlayer (this, "Aimed behind: " + viewDist.ToString ("0.0") + " < 0");
                //return true;
            }
            return false;
        }