Class used for rapid check if user is in range of Door
Beispiel #1
0
 public Door(String world, Vector3I[] affectedBlocks, String Name, String Creator)
 {
     this.World          = world;
     this.AffectedBlocks = affectedBlocks;
     this.Range          = Door.CalculateRange(this);
     this.Name           = Name;
     this.Creator        = Creator;
     this.Created        = DateTime.UtcNow;
 }
Beispiel #2
0
        public static DoorRange CalculateRange(Door Door)
        {
            DoorRange range = new DoorRange(0, 0, 0, 0, 0, 0);

            foreach (Vector3I block in Door.AffectedBlocks)
            {
                if (range.Xmin == 0)
                {
                    range.Xmin = block.X;
                }
                else
                {
                    if (block.X < range.Xmin)
                    {
                        range.Xmin = block.X;
                    }
                }

                if (range.Xmax == 0)
                {
                    range.Xmax = block.X;
                }
                else
                {
                    if (block.X > range.Xmax)
                    {
                        range.Xmax = block.X;
                    }
                }

                if (range.Ymin == 0)
                {
                    range.Ymin = block.Y;
                }
                else
                {
                    if (block.Y < range.Ymin)
                    {
                        range.Ymin = block.Y;
                    }
                }

                if (range.Ymax == 0)
                {
                    range.Ymax = block.Y;
                }
                else
                {
                    if (block.Y > range.Ymax)
                    {
                        range.Ymax = block.Y;
                    }
                }

                if (range.Zmin == 0)
                {
                    range.Zmin = block.Z;
                }
                else
                {
                    if (block.Z < range.Zmin)
                    {
                        range.Zmin = block.Z;
                    }
                }

                if (range.Zmax == 0)
                {
                    range.Zmax = block.Z;
                }
                else
                {
                    if (block.Z > range.Zmax)
                    {
                        range.Zmax = block.Z;
                    }
                }
            }

            return(range);
        }
Beispiel #3
0
        public static DoorRange CalculateRange( Door Door )
        {
            DoorRange range = new DoorRange( 0, 0, 0, 0, 0, 0 );

            foreach ( Vector3I block in Door.AffectedBlocks ) {
                if ( range.Xmin == 0 ) {
                    range.Xmin = block.X;
                } else {
                    if ( block.X < range.Xmin ) {
                        range.Xmin = block.X;
                    }
                }

                if ( range.Xmax == 0 ) {
                    range.Xmax = block.X;
                } else {
                    if ( block.X > range.Xmax ) {
                        range.Xmax = block.X;
                    }
                }

                if ( range.Ymin == 0 ) {
                    range.Ymin = block.Y;
                } else {
                    if ( block.Y < range.Ymin ) {
                        range.Ymin = block.Y;
                    }
                }

                if ( range.Ymax == 0 ) {
                    range.Ymax = block.Y;
                } else {
                    if ( block.Y > range.Ymax ) {
                        range.Ymax = block.Y;
                    }
                }

                if ( range.Zmin == 0 ) {
                    range.Zmin = block.Z;
                } else {
                    if ( block.Z < range.Zmin ) {
                        range.Zmin = block.Z;
                    }
                }

                if ( range.Zmax == 0 ) {
                    range.Zmax = block.Z;
                } else {
                    if ( block.Z > range.Zmax ) {
                        range.Zmax = block.Z;
                    }
                }
            }

            return range;
        }