Exemple #1
0
        private unsafe void DrawAll()
        {
            const int bmpWidth  = BitmapNumBlocksX * Overworld.Block_NumPixelsX;
            int       bmpHeight = GetBitmapHeight();

            using (ILockedFramebuffer l = Bitmap.Lock())
            {
                uint *bmpAddress = (uint *)l.Address.ToPointer();
                RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, 0, 0, bmpWidth, bmpHeight, 0xFF000000);
                int x = 0;
                int y = 0;
                for (int i = 0; i < Blocks.Count; i++, x++)
                {
                    if (x >= BitmapNumBlocksX)
                    {
                        x = 0;
                        y++;
                    }
                    Blocks[i].Draw(bmpAddress, bmpWidth, bmpHeight, x * Overworld.Block_NumPixelsX, y * Overworld.Block_NumPixelsY);
                }
                for (; x < BitmapNumBlocksX; x++)
                {
                    RenderUtils.DrawCross(bmpAddress, bmpWidth, bmpHeight, x * Overworld.Block_NumPixelsX, y * Overworld.Block_NumPixelsY, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFFFF0000);
                }
            }
            OnDrew?.Invoke(this, EventArgs.Empty);
        }
Exemple #2
0
        private unsafe void DrawFrom(int index)
        {
            const int bmpWidth  = BitmapNumBlocksX * Overworld.Block_NumPixelsX;
            int       bmpHeight = GetBitmapHeight();

            using (ILockedFramebuffer l = Bitmap.Lock())
            {
                uint *bmpAddress = (uint *)l.Address.ToPointer();
                int   x          = index % BitmapNumBlocksX;
                int   y          = index / BitmapNumBlocksX;
                for (; index < Blocks.Count; index++, x++)
                {
                    if (x >= BitmapNumBlocksX)
                    {
                        x = 0;
                        y++;
                    }
                    int bx = x * Overworld.Block_NumPixelsX;
                    int by = y * Overworld.Block_NumPixelsY;
                    RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, bx, by, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFF000000);
                    Blocks[index].Draw(bmpAddress, bmpWidth, bmpHeight, bx, by);
                }
                for (; x < BitmapNumBlocksX; x++)
                {
                    int bx = x * Overworld.Block_NumPixelsX;
                    int by = y * Overworld.Block_NumPixelsY;
                    RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, bx, by, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFF000000);
                    RenderUtils.DrawCross(bmpAddress, bmpWidth, bmpHeight, bx, by, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFFFF0000);
                }
            }
            OnDrew?.Invoke(this, EventArgs.Empty);
        }
Exemple #3
0
            public static readonly List <Block> DrawList = new List <Block>(); // Save allocations
            public unsafe void Draw(bool borderBlocks)
            {
                List <Block> list  = DrawList;
                int          count = list.Count;

                if (count > 0)
                {
                    WriteableBitmap bmp = borderBlocks ? BorderBlocksBitmap : BlocksBitmap;
                    using (ILockedFramebuffer l = bmp.Lock())
                    {
                        uint *bmpAddress = (uint *)l.Address.ToPointer();
                        int   bmpWidth   = (borderBlocks ? BorderWidth : Width) * Overworld.Block_NumPixelsX;
                        int   bmpHeight  = (borderBlocks ? BorderHeight : Height) * Overworld.Block_NumPixelsY;
                        for (int i = 0; i < count; i++)
                        {
                            Block b = list[i];
                            int   x = b.X * Overworld.Block_NumPixelsX;
                            int   y = b.Y * Overworld.Block_NumPixelsY;
                            RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, x, y, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFF000000);
                            b.BlocksetBlock.Draw(bmpAddress, bmpWidth, bmpHeight, x, y);
                        }
                    }
                    list.Clear();
                    OnDrew?.Invoke(this, borderBlocks, false);
                }
            }
Exemple #4
0
        private unsafe void DrawOne(Block block)
        {
            const int bmpWidth  = BitmapNumBlocksX * Overworld.Block_NumPixelsX;
            int       bmpHeight = GetBitmapHeight();

            using (ILockedFramebuffer l = Bitmap.Lock())
            {
                uint *bmpAddress = (uint *)l.Address.ToPointer();
                int   x          = block.Id % BitmapNumBlocksX * Overworld.Block_NumPixelsX;
                int   y          = block.Id / BitmapNumBlocksX * Overworld.Block_NumPixelsY;
                RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, x, y, Overworld.Block_NumPixelsX, Overworld.Block_NumPixelsY, 0xFF000000);
                block.Draw(bmpAddress, bmpWidth, bmpHeight, x, y);
            }
            OnDrew?.Invoke(this, EventArgs.Empty);
        }
Exemple #5
0
            public unsafe void DrawAll(bool borderBlocks, bool wasResized)
            {
                WriteableBitmap bmp = borderBlocks ? BorderBlocksBitmap : BlocksBitmap;

                using (ILockedFramebuffer l = bmp.Lock())
                {
                    uint *bmpAddress = (uint *)l.Address.ToPointer();
                    int   width      = borderBlocks ? BorderWidth : Width;
                    int   height     = borderBlocks ? BorderHeight : Height;
                    int   bmpWidth   = width * Overworld.Block_NumPixelsX;
                    int   bmpHeight  = height * Overworld.Block_NumPixelsY;
                    RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, 0, 0, bmpWidth, bmpHeight, 0xFF000000);
                    Block[][] arr = borderBlocks ? BorderBlocks : Blocks;
                    for (int y = 0; y < height; y++)
                    {
                        Block[] arrY = arr[y];
                        for (int x = 0; x < width; x++)
                        {
                            arrY[x].BlocksetBlock.Draw(bmpAddress, bmpWidth, bmpHeight, x * Overworld.Block_NumPixelsX, y * Overworld.Block_NumPixelsY);
                        }
                    }
                }
                OnDrew?.Invoke(this, borderBlocks, wasResized);
            }