Ejemplo n.º 1
0
        public void DrawMap(WorldView view)
        {
            int num = view.SAFE_AREA_OFFSET_L + ((UI.numActiveViews > 1) ? 340 : 290);
            int sAFE_AREA_OFFSET_T = view.SAFE_AREA_OFFSET_T;

            mapDestH = (short)(540 - view.SAFE_AREA_OFFSET_T - view.SAFE_AREA_OFFSET_B - 36);
            int num2 = view.viewWidth - view.SAFE_AREA_OFFSET_R - num;

            if (!isThreadDone)
            {
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, view.screenProjection);
                SpriteSheet <_sheetSprites> .Draw(1012, num + (num2 >> 1), sAFE_AREA_OFFSET_T + (mapDestH >> 1), Color.White, (float)((double)Main.frameCounter * (Math.PI / 30.0)), 1f);

                return;
            }
            alpha += 16;
            if (alpha > 255)
            {
                alpha = 255;
            }
            int    num3  = num + (num2 >> 1);
            int    num4  = sAFE_AREA_OFFSET_T + (mapDestH >> 1);
            Matrix view2 = Matrix.CreateTranslation(-num3, -num4, 0f) * Matrix.CreateScale(mapScale, mapScale, 1f) * Matrix.CreateTranslation(num3, num4, 0f);

            view.screenProjection.View = view2;
            Rectangle scissorRectangle = default(Rectangle);

            if (view.isFullScreen())
            {
                scissorRectangle.X      = num;
                scissorRectangle.Y      = sAFE_AREA_OFFSET_T;
                scissorRectangle.Width  = num2;
                scissorRectangle.Height = mapDestH;
            }
            else
            {
                scissorRectangle.X      = (num >> 1) + view.activeViewport.X;
                scissorRectangle.Y      = (sAFE_AREA_OFFSET_T >> 1) + view.activeViewport.Y;
                scissorRectangle.Width  = num2 >> 1;
                scissorRectangle.Height = mapDestH >> 1;
            }
            WorldView.graphicsDevice.ScissorRectangle = scissorRectangle;
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, WorldView.scissorTest, view.screenProjection);
            int num5 = mapX / texWidth;
            int num6 = (mapX + num2 - 1) / texWidth;

            if (num6 >= mapTexture.Length)
            {
                num6 = mapTexture.Length - 1;
            }
            Vector2   position  = new Vector2(num, sAFE_AREA_OFFSET_T);
            Rectangle rectangle = default(Rectangle);

            rectangle.X      = mapX - num5 * texWidth;
            rectangle.Y      = mapY;
            rectangle.Width  = Math.Min(num2, texWidth - rectangle.X);
            rectangle.Height = mapDestH;
            Color color = new Color(alpha, alpha, alpha, alpha);

            for (int i = num5; i <= num6; i++)
            {
                Main.spriteBatch.Draw(mapTexture[i], position, rectangle, color);
                position.X     += rectangle.Width;
                rectangle.X     = 0;
                rectangle.Width = texWidth;
            }
            switch (Main.magmaBGFrame)
            {
            case 0:
                rectangle.X = 659;
                rectangle.Y = 10;
                break;

            case 1:
                rectangle.X = 659;
                rectangle.Y = 0;
                break;

            default:
                rectangle.X = 759;
                rectangle.Y = 10;
                break;
            }
            rectangle.Width  = 10;
            rectangle.Height = 10;
            for (int num7 = 195; num7 >= 0; num7--)
            {
                NPC nPC = Main.npc[num7];
                if (nPC.active != 0)
                {
                    int num8 = nPC.aabb.X >> 4;
                    int num9 = nPC.aabb.Y >> 4;
                    if (num8 >= 0 && num9 >= 0 && num8 < Main.maxTilesX && num9 < Main.maxTilesY && (Main.tile[num8, num9].flags & Tile.Flags.VISITED) == Tile.Flags.VISITED)
                    {
                        num8 -= 34 + mapX;
                        if (num8 >= 0 && num8 + 4 < num2)
                        {
                            num9 -= 34 + mapY;
                            if (num9 >= 0 && num9 + 4 < mapDestH)
                            {
                                int headTextureId = nPC.getHeadTextureId();
                                if (headTextureId < 0)
                                {
                                    color   = new Color(106, 0, 66, 127);
                                    color.R = (byte)(color.R * UI.cursorColor.A >> 8);
                                    color.G = (byte)(color.G * UI.cursorColor.A >> 8);
                                    color.B = (byte)(color.B * UI.cursorColor.A >> 8);
                                    color.A = (byte)(color.A * UI.cursorColor.A >> 8);
                                    SpriteSheet <_sheetSprites> .DrawCentered(218, num + num8, sAFE_AREA_OFFSET_T + num9, rectangle, color);
                                }
                                else
                                {
                                    SpriteSheet <_sheetSprites> .DrawScaled(1255 + headTextureId, num + num8, sAFE_AREA_OFFSET_T + num9, 0.5f, new Color(248, 248, 248, 248), (nPC.spriteDirection >= 0)?SpriteEffects.FlipHorizontally : SpriteEffects.None);
                                }
                            }
                        }
                    }
                }
            }
            Main.spriteBatch.End();
            Matrix world = view.screenProjection.World;
            float  num10 = (float)(0.6875 + 0.0625 * Math.Sin((double)Main.frameCounter * 0.083333333333333329));

            view2 = Matrix.CreateTranslation(-10f, -8f, 0f) * Matrix.CreateScale(num10, num10, 1f);
            for (int num11 = 7; num11 >= 0; num11--)
            {
                Player player = Main.player[num11];
                if (player.active != 0 && !player.dead)
                {
                    int num12 = player.aabb.X >> 4;
                    int num13 = player.aabb.Y >> 4;
                    if ((Main.tile[num12, num13].flags & Tile.Flags.VISITED) != 0)
                    {
                        num12 -= 34 + mapX;
                        num13 -= 34 + mapY;
                        Vector2 position2 = player.position;
                        player.position.X           = view.screenPosition.X;
                        player.position.Y           = view.screenPosition.Y;
                        view.screenProjection.World = view2 * Matrix.CreateTranslation(num + num12, sAFE_AREA_OFFSET_T + num13, 0f);
                        Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, WorldView.scissorTest, view.screenProjection);
                        player.Draw(view, isMenu: true, isIcon: true);
                        Main.spriteBatch.End();
                        player.position = position2;
                        player.aabb.X   = (int)position2.X;
                        player.aabb.Y   = (int)position2.Y;
                    }
                }
            }
            view.screenProjection.World = world;
            view.screenProjection.View  = Matrix.Identity;
            Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, view.screenProjection);
        }