GetSectionX() public static method

public static GetSectionX ( int x ) : int
x int
return int
Ejemplo n.º 1
0
 public bool SectionRange(int size, int firstX, int firstY)
 {
     for (int index = 0; index < 4; ++index)
     {
         int x = firstX;
         int y = firstY;
         if (index == 1)
         {
             x += size;
         }
         if (index == 2)
         {
             y += size;
         }
         if (index == 3)
         {
             x += size;
             y += size;
         }
         if (this.TileSections[Netplay.GetSectionX(x), Netplay.GetSectionY(y)])
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 public bool SectionRange(int size, int firstX, int firstY)
 {
     for (int i = 0; i < 4; i++)
     {
         int num  = firstX;
         int num2 = firstY;
         if (i == 1)
         {
             num += size;
         }
         if (i == 2)
         {
             num2 += size;
         }
         if (i == 3)
         {
             num  += size;
             num2 += size;
         }
         int sectionX = Netplay.GetSectionX(num);
         int sectionY = Netplay.GetSectionY(num2);
         if (this.tileSection[sectionX, sectionY])
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public static void CheckSection(int who, Vector2 position)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - 1; i < sectionX + 2; i++)
            {
                for (int j = sectionY - 1; j < sectionY + 2; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num > 0)
            {
                int num2 = num * 150;
                NetMessage.SendData(9, who, -1, "Receiving tile data", num2, 0f, 0f, 0f, 0);
                Netplay.serverSock[who].statusText2 = "is receiving tile data";
                Netplay.serverSock[who].statusMax  += num2;
                for (int k = sectionX - 1; k < sectionX + 2; k++)
                {
                    for (int l = sectionY - 1; l < sectionY + 2; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[k, l])
                        {
                            NetMessage.SendSection(who, k, l);
                            NetMessage.SendData(11, who, -1, "", k, (float)l, (float)k, (float)l, 0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        // Token: 0x06000140 RID: 320 RVA: 0x00029B00 File Offset: 0x00027D00
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num > 0)
            {
                int num2 = num;
                NetMessage.SendData(9, playerIndex, -1, Lang.inter[44].ToNetworkText(), num2, 0f, 0f, 0f, 0, 0, 0);
                Netplay.Clients[playerIndex].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
                Netplay.Clients[playerIndex].StatusMax  += num2;
                for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
                {
                    for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[k, l])
                        {
                            NetMessage.SendSection(playerIndex, k, l, false);
                            NetMessage.SendData(11, playerIndex, -1, null, k, (float)l, (float)k, (float)l, 0, 0, 0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public bool SectionRange(int size, int firstX, int firstY)
        {
            for (int i = 0; i < 4; i++)
            {
                int x = firstX;
                int y = firstY;
                switch (i)
                {
                case 1:
                    x += size;
                    break;

                case 2:
                    y += size;
                    break;

                case 3:
                    x += size;
                    y += size;
                    break;
                }
                int sectionX = Netplay.GetSectionX(x);
                int sectionY = Netplay.GetSectionY(y);
                if (this.tileSection[sectionX, sectionY])
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 6
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            var index1    = playerIndex;
            var sectionX  = Netplay.GetSectionX((int)((double)position.X / 16.0));
            var sectionY1 = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            var num       = 0;

            for (var index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (var index3 = sectionY1 - fluff; index3 < sectionY1 + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) &&
                        !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }

            if (num <= 0)
            {
                return;
            }
            var number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44].ToNetworkText(), number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[index1].StatusMax  += number;
            for (var index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (var sectionY2 = sectionY1 - fluff; sectionY2 < sectionY1 + fluff + 1; ++sectionY2)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX &&
                        (sectionY2 >= 0 && sectionY2 < Main.maxSectionsY) &&
                        !Netplay.Clients[index1].TileSections[index2, sectionY2])
                    {
                        NetMessage.SendSection(index1, index2, sectionY2, false);
                        NetMessage.SendData(11, index1, -1, (NetworkText)null, index2, (float)sectionY2,
                                            (float)index2, (float)sectionY2, 0, 0, 0);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int index1   = playerIndex;
            int sectionX = Netplay.GetSectionX((int)((double)position.X / 16.0));
            int sectionY = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            int num      = 0;

            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY - fluff; index3 < sectionY + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44].ToNetworkText(), number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[index1].StatusMax  += number;
            RemoteClient._pendingSectionFraming.Clear();
            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY - fluff; index3 < sectionY + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        NetMessage.SendSection(index1, index2, index3, false);
                        RemoteClient._pendingSectionFraming.Add(new Point(index2, index3));
                    }
                }
            }
            foreach (Point point in RemoteClient._pendingSectionFraming)
            {
                NetMessage.SendData(11, index1, -1, (NetworkText)null, point.X, (float)point.Y, (float)point.X, (float)point.Y, 0, 0, 0);
            }
        }
Ejemplo n.º 8
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int num2 = num;

            NetMessage.SendData(9, playerIndex, -1, Lang.inter[44].ToNetworkText(), num2);
            Netplay.Clients[playerIndex].StatusText2 = Language.GetTextValue("Net.IsReceivingTileData");
            Netplay.Clients[playerIndex].StatusMax  += num2;
            _pendingSectionFraming.Clear();
            for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
            {
                for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                {
                    if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[k, l])
                    {
                        NetMessage.SendSection(playerIndex, k, l);
                        _pendingSectionFraming.Add(new Point(k, l));
                    }
                }
            }
            foreach (Point item in _pendingSectionFraming)
            {
                NetMessage.SendData(11, playerIndex, -1, null, item.X, item.Y, item.X, item.Y);
            }
        }
Ejemplo n.º 9
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int num      = playerIndex;
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num1     = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[num].TileSections[i, j])
                    {
                        num1++;
                    }
                }
            }
            if (num1 > 0)
            {
                int num2 = num1;
                Netplay.Clients[num].StatusText2 = "is receiving tile data";
                RemoteClient clients = Netplay.Clients[num];
                clients.StatusMax = clients.StatusMax + num2;

                NetMessage.SendData(9, num, -1, Lang.inter[44], num2, 0f, 0f, 0f, 0, 0, 0);

                for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
                {
                    for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                    {
                        if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[num].TileSections[k, l])
                        {
                            NetMessage.SendSection(num, k, l, false);
                            NetMessage.SendData(11, num, -1, "", k, (float)l, (float)k, (float)l, 0, 0, 0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int index1    = playerIndex;
            int sectionX  = Netplay.GetSectionX((int)((double)position.X / 16.0));
            int sectionY1 = Netplay.GetSectionY((int)((double)position.Y / 16.0));
            int num       = 0;

            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int index3 = sectionY1 - fluff; index3 < sectionY1 + fluff + 1; ++index3)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (index3 >= 0 && index3 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, index3])
                    {
                        ++num;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int number = num;

            NetMessage.SendData(9, index1, -1, Lang.inter[44], number, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            Netplay.Clients[index1].StatusText2 = "is receiving tile data";
            Netplay.Clients[index1].StatusMax  += number;
            for (int index2 = sectionX - fluff; index2 < sectionX + fluff + 1; ++index2)
            {
                for (int sectionY2 = sectionY1 - fluff; sectionY2 < sectionY1 + fluff + 1; ++sectionY2)
                {
                    if (index2 >= 0 && index2 < Main.maxSectionsX && (sectionY2 >= 0 && sectionY2 < Main.maxSectionsY) && !Netplay.Clients[index1].TileSections[index2, sectionY2])
                    {
                        NetMessage.SendSection(index1, index2, sectionY2, false);
                        NetMessage.SendData(11, index1, -1, "", index2, (float)sectionY2, (float)index2, (float)sectionY2, 0, 0, 0);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public static void CheckSection(int playerIndex, Vector2 position, int fluff = 1)
        {
            int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
            int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
            int num      = 0;

            for (int i = sectionX - fluff; i < sectionX + fluff + 1; i++)
            {
                for (int j = sectionY - fluff; j < sectionY + fluff + 1; j++)
                {
                    if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[i, j])
                    {
                        num++;
                    }
                }
            }
            if (num <= 0)
            {
                return;
            }
            int num2 = num;

            NetMessage.SendData(9, playerIndex, -1, Lang.inter[44].Value, num2);
            Netplay.Clients[playerIndex].StatusText2 = "is receiving tile data";
            Netplay.Clients[playerIndex].StatusMax  += num2;
            for (int k = sectionX - fluff; k < sectionX + fluff + 1; k++)
            {
                for (int l = sectionY - fluff; l < sectionY + fluff + 1; l++)
                {
                    if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.Clients[playerIndex].TileSections[k, l])
                    {
                        NetMessage.SendSection(playerIndex, k, l);
                        NetMessage.SendData(11, playerIndex, -1, "", k, l, k, l);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public bool GetNextTileFrame(Vector2 playerPos, out int x, out int y)
        {
            if (this.frameSectionsLeft <= 0)
            {
                x = -1;
                y = -1;
                return(false);
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num1    = 0;
            int     num2    = 0;
            Vector2 vector2 = this.prevFrame.centerPos;

            playerPos *= 1f / 16f;
            int sectionX = Netplay.GetSectionX((int)playerPos.X);
            int sectionY = Netplay.GetSectionY((int)playerPos.Y);
            int num3     = Netplay.GetSectionX((int)vector2.X);
            int num4     = Netplay.GetSectionY((int)vector2.Y);
            int num5;

            if (num3 != sectionX || num4 != sectionY)
            {
                vector2 = playerPos;
                num3    = sectionX;
                num4    = sectionY;
                num5    = 4;
                x       = sectionX;
                y       = sectionY;
            }
            else
            {
                num5 = this.prevFrame.leg;
                x    = this.prevFrame.X;
                y    = this.prevFrame.Y;
                num1 = this.prevFrame.xDir;
                num2 = this.prevFrame.yDir;
            }
            int num6 = (int)((double)playerPos.X - ((double)num3 + 0.5) * 200.0);
            int num7 = (int)((double)playerPos.Y - ((double)num4 + 0.5) * 150.0);

            if (num1 == 0)
            {
                num1 = num6 <= 0 ? 1 : -1;
                num2 = num7 <= 0 ? 1 : -1;
            }
            int  num8  = 0;
            bool flag1 = false;
            bool flag2 = false;

            while (true)
            {
                if (num8 == 4)
                {
                    if (!flag2)
                    {
                        flag2 = true;
                        x     = num3;
                        y     = num4;
                        num6  = (int)((double)vector2.X - ((double)num3 + 0.5) * 200.0);
                        num7  = (int)((double)vector2.Y - ((double)num4 + 0.5) * 150.0);
                        num1  = num6 <= 0 ? 1 : -1;
                        num2  = num7 <= 0 ? 1 : -1;
                        num5  = 4;
                        num8  = 0;
                    }
                    else
                    {
                        break;
                    }
                }
                if (y >= 0 && y < this.height && (x >= 0 && x < this.width))
                {
                    flag1 = false;
                    if (this.data[y * this.width + x][0] && !this.data[y * this.width + x][1])
                    {
                        goto label_14;
                    }
                }
                int num9  = x - num3;
                int num10 = y - num4;
                if (num9 == 0 || num10 == 0)
                {
                    if (num5 == 4)
                    {
                        if (num9 == 0 && num10 == 0)
                        {
                            if (Math.Abs(num6) > Math.Abs(num7))
                            {
                                y -= num2;
                            }
                            else
                            {
                                x -= num1;
                            }
                        }
                        else
                        {
                            if (num9 != 0)
                            {
                                x += num9 / Math.Abs(num9);
                            }
                            if (num10 != 0)
                            {
                                y += num10 / Math.Abs(num10);
                            }
                        }
                        num5  = 0;
                        num8  = 0;
                        flag1 = true;
                    }
                    else
                    {
                        if (num9 == 0)
                        {
                            num2 = num10 <= 0 ? 1 : -1;
                        }
                        else
                        {
                            num1 = num9 <= 0 ? 1 : -1;
                        }
                        x += num1;
                        y += num2;
                        ++num5;
                    }
                    if (flag1)
                    {
                        ++num8;
                    }
                    else
                    {
                        flag1 = true;
                    }
                }
                else
                {
                    x += num1;
                    y += num2;
                }
            }
            throw new Exception("Infinite loop in WorldSections.GetNextTileFrame");
label_14:
            this.data[y * this.width + x][1] = true;
            --this.frameSectionsLeft;
            this.prevFrame.centerPos = playerPos;
            this.prevFrame.X         = x;
            this.prevFrame.Y         = y;
            this.prevFrame.leg       = num5;
            this.prevFrame.xDir      = num1;
            this.prevFrame.yDir      = num2;
            stopwatch.Stop();
            return(true);
        }
Ejemplo n.º 13
0
        public bool GetNextTileFrame(Vector2 playerPos, out int x, out int y)
        {
            if (frameSectionsLeft <= 0)
            {
                x = -1;
                y = -1;
                return(false);
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num    = 0;
            int     num2   = 0;
            Vector2 vector = prevFrame.centerPos;

            playerPos *= 0.0625f;
            int sectionX = Netplay.GetSectionX((int)playerPos.X);
            int sectionY = Netplay.GetSectionY((int)playerPos.Y);
            int num3     = Netplay.GetSectionX((int)vector.X);
            int num4     = Netplay.GetSectionY((int)vector.Y);
            int num5;

            if (num3 != sectionX || num4 != sectionY)
            {
                vector = playerPos;
                num3   = sectionX;
                num4   = sectionY;
                num5   = 4;
                x      = sectionX;
                y      = sectionY;
            }
            else
            {
                num5 = prevFrame.leg;
                x    = prevFrame.X;
                y    = prevFrame.Y;
                num  = prevFrame.xDir;
                num2 = prevFrame.yDir;
            }
            int num6 = (int)(playerPos.X - ((float)num3 + 0.5f) * 200f);
            int num7 = (int)(playerPos.Y - ((float)num4 + 0.5f) * 150f);

            if (num == 0)
            {
                num  = ((num6 <= 0) ? 1 : (-1));
                num2 = ((num7 <= 0) ? 1 : (-1));
            }
            int  num8  = 0;
            bool flag  = false;
            bool flag2 = false;

            while (true)
            {
                if (num8 == 4)
                {
                    if (flag2)
                    {
                        throw new Exception("Infinite loop in WorldSections.GetNextTileFrame");
                    }
                    flag2 = true;
                    x     = num3;
                    y     = num4;
                    num6  = (int)(vector.X - ((float)num3 + 0.5f) * 200f);
                    num7  = (int)(vector.Y - ((float)num4 + 0.5f) * 150f);
                    num   = ((num6 <= 0) ? 1 : (-1));
                    num2  = ((num7 <= 0) ? 1 : (-1));
                    num5  = 4;
                    num8  = 0;
                }
                if (y >= 0 && y < height && x >= 0 && x < width)
                {
                    flag = false;
                    if (data[y * width + x][0] && !data[y * width + x][1])
                    {
                        break;
                    }
                }
                int num9  = x - num3;
                int num10 = y - num4;
                if (num9 == 0 || num10 == 0)
                {
                    if (num5 == 4)
                    {
                        if (num9 == 0 && num10 == 0)
                        {
                            if (Math.Abs(num6) > Math.Abs(num7))
                            {
                                y -= num2;
                            }
                            else
                            {
                                x -= num;
                            }
                        }
                        else
                        {
                            if (num9 != 0)
                            {
                                x += num9 / Math.Abs(num9);
                            }
                            if (num10 != 0)
                            {
                                y += num10 / Math.Abs(num10);
                            }
                        }
                        num5 = 0;
                        num8 = 0;
                        flag = true;
                    }
                    else
                    {
                        if (num9 != 0)
                        {
                            num = ((num9 <= 0) ? 1 : (-1));
                        }
                        else
                        {
                            num2 = ((num10 <= 0) ? 1 : (-1));
                        }
                        x += num;
                        y += num2;
                        num5++;
                    }
                    if (flag)
                    {
                        num8++;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                else
                {
                    x += num;
                    y += num2;
                }
            }
            data[y * width + x][1] = true;
            frameSectionsLeft--;
            prevFrame.centerPos = playerPos;
            prevFrame.X         = x;
            prevFrame.Y         = y;
            prevFrame.leg       = num5;
            prevFrame.xDir      = num;
            prevFrame.yDir      = num2;
            stopwatch.Stop();
            return(true);
        }
Ejemplo n.º 14
0
        // Token: 0x0600086C RID: 2156 RVA: 0x003ABFB0 File Offset: 0x003AA1B0
        public bool GetNextMapDraw(Vector2 playerPos, out int x, out int y)
        {
            if (this.mapSectionsLeft <= 0)
            {
                x = -1;
                y = -1;
                return(false);
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num    = 0;
            int     num2   = 0;
            Vector2 vector = this.prevMap.centerPos;

            playerPos *= 0.0625f;
            int sectionX = Netplay.GetSectionX((int)playerPos.X);
            int sectionY = Netplay.GetSectionY((int)playerPos.Y);
            int num3     = Netplay.GetSectionX((int)vector.X);
            int num4     = Netplay.GetSectionY((int)vector.Y);
            int num5;

            if (num3 != sectionX || num4 != sectionY)
            {
                vector = playerPos;
                num3   = sectionX;
                num4   = sectionY;
                num5   = 4;
                x      = sectionX;
                y      = sectionY;
            }
            else
            {
                num5 = this.prevMap.leg;
                x    = this.prevMap.X;
                y    = this.prevMap.Y;
                num  = this.prevMap.xDir;
                num2 = this.prevMap.yDir;
            }
            int num6 = (int)(playerPos.X - ((float)num3 + 0.5f) * 200f);
            int num7 = (int)(playerPos.Y - ((float)num4 + 0.5f) * 150f);

            if (num == 0)
            {
                if (num6 > 0)
                {
                    num = -1;
                }
                else
                {
                    num = 1;
                }
                if (num7 > 0)
                {
                    num2 = -1;
                }
                else
                {
                    num2 = 1;
                }
            }
            int  num8  = 0;
            bool flag  = false;
            bool flag2 = false;

            while (true)
            {
                if (num8 == 4)
                {
                    if (flag2)
                    {
                        break;
                    }
                    flag2 = true;
                    x     = num3;
                    y     = num4;
                    num6  = (int)(vector.X - ((float)num3 + 0.5f) * 200f);
                    num7  = (int)(vector.Y - ((float)num4 + 0.5f) * 150f);
                    if (num6 > 0)
                    {
                        num = -1;
                    }
                    else
                    {
                        num = 1;
                    }
                    if (num7 > 0)
                    {
                        num2 = -1;
                    }
                    else
                    {
                        num2 = 1;
                    }
                    num5 = 4;
                    num8 = 0;
                }
                if (y >= 0 && y < this.height && x >= 0 && x < this.width)
                {
                    flag = false;
                    if (!this.data[y * this.width + x][2])
                    {
                        goto Block_14;
                    }
                }
                int num9  = x - num3;
                int num10 = y - num4;
                if (num9 == 0 || num10 == 0)
                {
                    if (num5 == 4)
                    {
                        if (num9 == 0 && num10 == 0)
                        {
                            if (Math.Abs(num6) > Math.Abs(num7))
                            {
                                y -= num2;
                            }
                            else
                            {
                                x -= num;
                            }
                        }
                        else
                        {
                            if (num9 != 0)
                            {
                                x += num9 / Math.Abs(num9);
                            }
                            if (num10 != 0)
                            {
                                y += num10 / Math.Abs(num10);
                            }
                        }
                        num5 = 0;
                        num8 = -2;
                        flag = true;
                    }
                    else
                    {
                        if (num9 == 0)
                        {
                            if (num10 > 0)
                            {
                                num2 = -1;
                            }
                            else
                            {
                                num2 = 1;
                            }
                        }
                        else if (num9 > 0)
                        {
                            num = -1;
                        }
                        else
                        {
                            num = 1;
                        }
                        x += num;
                        y += num2;
                        num5++;
                    }
                    if (flag)
                    {
                        num8++;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                else
                {
                    x += num;
                    y += num2;
                }
            }
            throw new Exception("Infinite loop in WorldSections.GetNextMapDraw");
Block_14:
            this.data[y * this.width + x][2] = true;
            this.mapSectionsLeft--;
            this.prevMap.centerPos = playerPos;
            this.prevMap.X         = x;
            this.prevMap.Y         = y;
            this.prevMap.leg       = num5;
            this.prevMap.xDir      = num;
            this.prevMap.yDir      = num2;
            stopwatch.Stop();
            return(true);
        }
Ejemplo n.º 15
0
        public bool GetNextMapDraw(Vector2 playerPos, out int x, out int y)
        {
            int num;

            if (this.mapSectionsLeft <= 0)
            {
                x = -1;
                y = -1;
                return(false);
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            int     num1    = 0;
            int     num2    = 0;
            Vector2 vector2 = this.prevMap.centerPos;

            playerPos = playerPos * 0.0625f;
            int sectionX  = Netplay.GetSectionX((int)playerPos.X);
            int sectionY  = Netplay.GetSectionY((int)playerPos.Y);
            int sectionX1 = Netplay.GetSectionX((int)vector2.X);
            int sectionY1 = Netplay.GetSectionY((int)vector2.Y);

            if (sectionX1 != sectionX || sectionY1 != sectionY)
            {
                vector2   = playerPos;
                sectionX1 = sectionX;
                sectionY1 = sectionY;
                num       = 4;
                x         = sectionX;
                y         = sectionY;
            }
            else
            {
                num  = this.prevMap.leg;
                x    = this.prevMap.X;
                y    = this.prevMap.Y;
                num1 = this.prevMap.xDir;
                num2 = this.prevMap.yDir;
            }
            int num3 = (int)(playerPos.X - ((float)sectionX1 + 0.5f) * 200f);
            int num4 = (int)(playerPos.Y - ((float)sectionY1 + 0.5f) * 150f);

            if (num1 == 0)
            {
                num1 = (num3 <= 0 ? 1 : -1);
                num2 = (num4 <= 0 ? 1 : -1);
            }
            int  num5  = 0;
            bool flag  = false;
            bool flag1 = false;

            while (true)
            {
                if (num5 == 4)
                {
                    if (flag1)
                    {
                        throw new Exception("Infinite loop in WorldSections.GetNextMapDraw");
                    }
                    flag1 = true;
                    x     = sectionX1;
                    y     = sectionY1;
                    num3  = (int)(vector2.X - ((float)sectionX1 + 0.5f) * 200f);
                    num4  = (int)(vector2.Y - ((float)sectionY1 + 0.5f) * 150f);
                    num1  = (num3 <= 0 ? 1 : -1);
                    num2  = (num4 <= 0 ? 1 : -1);
                    num   = 4;
                    num5  = 0;
                }
                if (y >= 0 && y < this.height && x >= 0 && x < this.width)
                {
                    flag = false;
                    if (!this.data[y * this.width + x][2])
                    {
                        break;
                    }
                }
                int num6 = x - sectionX1;
                int num7 = y - sectionY1;
                if (num6 == 0 || num7 == 0)
                {
                    if (num != 4)
                    {
                        if (num6 != 0)
                        {
                            num1 = (num6 <= 0 ? 1 : -1);
                        }
                        else
                        {
                            num2 = (num7 <= 0 ? 1 : -1);
                        }
                        x = x + num1;
                        y = y + num2;
                        num++;
                    }
                    else
                    {
                        if (num6 != 0 || num7 != 0)
                        {
                            if (num6 != 0)
                            {
                                x = x + num6 / Math.Abs(num6);
                            }
                            if (num7 != 0)
                            {
                                y = y + num7 / Math.Abs(num7);
                            }
                        }
                        else if (Math.Abs(num3) <= Math.Abs(num4))
                        {
                            x = x - num1;
                        }
                        else
                        {
                            y = y - num2;
                        }
                        num  = 0;
                        num5 = -2;
                        flag = true;
                    }
                    if (!flag)
                    {
                        flag = true;
                    }
                    else
                    {
                        num5++;
                    }
                }
                else
                {
                    x = x + num1;
                    y = y + num2;
                }
            }
            this.data[y * this.width + x][2] = true;
            WorldSections worldSection = this;

            worldSection.mapSectionsLeft = worldSection.mapSectionsLeft - 1;
            this.prevMap.centerPos       = playerPos;
            this.prevMap.X    = x;
            this.prevMap.Y    = y;
            this.prevMap.leg  = num;
            this.prevMap.xDir = num1;
            this.prevMap.yDir = num2;
            stopwatch.Stop();
            return(true);
        }