Beispiel #1
0
        private void InternalQueueMapBlock(Map map, uint cellx, uint celly)
        {
            uint chunkIndex = (cellx % BlockCacheWidth) + (celly % BlockCacheHeight) * BlockCacheWidth;

            MiniMapChunk chunk = m_BlockCache[chunkIndex];

            if (chunk == null || chunk.X != cellx || chunk.Y != celly)
            {
                // the chunk is not in our cache! Try loading it from the map?
                MapChunk mapBlock = map.GetMapChunk(cellx, celly);
                if (mapBlock == null)
                {
                    // if the chunk is not loaded in memory, load it from the filesystem.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(cellx, celly, map.MapData);
                }
                else
                {
                    // get the colors for this chunk from the map chunk, which will have already sorted the objects.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(mapBlock);
                }
            }
            else
            {
                m_BlockColors = chunk.Colors;
            }

            m_QueuedToDrawBlocks.Add(chunkIndex);
        }
Beispiel #2
0
        private void InternalDrawQueuedMapBlocks()
        {
            IEnumerator <uint> chunks = m_QueuedToDrawBlocks.GetEnumerator();

            for (int i = 0; i < m_QueuedToDrawBlocks.Count; i++)
            {
                MiniMapChunk chunk = m_BlockCache[m_QueuedToDrawBlocks[i]];

                uint cellX32 = chunk.X % 32, cellY32 = chunk.Y % 32;
                m_BlockColors = chunk.Colors;

                // now draw the chunk
                if (cellX32 == 0 && cellY32 == 0)
                {
                    // draw the chunk split out over four corners of the texture.
                    int chunkindex = 0;
                    for (uint tiley = 0; tiley < 8; tiley++)
                    {
                        uint drawy = (cellX32 * 8 + cellY32 * 8 - 8 + tiley) % Stride;
                        uint drawx = (cellX32 * 8 - cellY32 * 8 - tiley) % Stride;
                        for (uint tilex = 0; tilex < 8; tilex++)
                        {
                            uint color = m_BlockColors[chunkindex++];
                            m_TextureData[drawy * Stride + drawx] = color;
                            if (drawy == 255)
                            {
                                m_TextureData[drawx] = color;
                            }
                            else
                            {
                                m_TextureData[drawy * Stride + Stride + drawx] = color;
                            }
                            drawx = (drawx + 1) % Stride;
                            drawy = (drawy + 1) % Stride;
                        }
                    }
                }
                else if (cellX32 + cellY32 == 32)
                {
                    // draw the chunk split on the top and bottom of the texture.
                    int chunkindex = 0;
                    for (uint tiley = 0; tiley < 8; tiley++)
                    {
                        uint drawy = (cellX32 * 8 + cellY32 * 8 - 8 + tiley) % Stride;
                        uint drawx = (cellX32 * 8 - cellY32 * 8 - tiley) % Stride;
                        for (uint tilex = 0; tilex < 8; tilex++)
                        {
                            uint color = m_BlockColors[chunkindex++];
                            m_TextureData[drawy * Stride + drawx] = color;
                            if (drawy == 255)
                            {
                                m_TextureData[drawx] = color;
                            }
                            else
                            {
                                m_TextureData[drawy * Stride + Stride + drawx] = color;
                            }
                            drawx = (drawx + 1) % Stride;
                            drawy = (drawy + 1) % Stride;
                        }
                    }
                }
                else if (cellX32 == cellY32)
                {
                    // draw the chunk split on the left and right side of the texture.
                    int chunkindex = 0;
                    for (uint tiley = 0; tiley < 8; tiley++)
                    {
                        uint drawy = (cellX32 * 8 + cellY32 * 8 - 8 + tiley) % Stride;
                        uint drawx = (cellX32 * 8 - cellY32 * 8 - tiley) % Stride;
                        for (uint tilex = 0; tilex < 8; tilex++)
                        {
                            uint color = m_BlockColors[chunkindex++];
                            m_TextureData[drawy * Stride + drawx]          = color;
                            m_TextureData[drawy * Stride + Stride + drawx] = color;
                            drawx = (drawx + 1) % Stride;
                            drawy = (drawy + 1) % Stride;
                        }
                    }
                }
                else
                {
                    // draw the chunk normally.
                    int chunkindex = 0;
                    for (uint tiley = 0; tiley < 8; tiley++)
                    {
                        uint drawy = (cellX32 * 8 + cellY32 * 8 - 8 + tiley) % Stride;
                        uint drawx = (cellX32 * 8 - cellY32 * 8 - tiley) % Stride;
                        for (uint tilex = 0; tilex < 8; tilex++)
                        {
                            uint color = m_BlockColors[chunkindex++];
                            m_TextureData[drawy * Stride + drawx]          = color;
                            m_TextureData[drawy * Stride + Stride + drawx] = color;
                            drawx = (drawx + 1) % Stride;
                            drawy = (drawy + 1) % Stride;
                        }
                    }
                }
            }

            m_QueuedToDrawBlocks.Clear();
        }
Beispiel #3
0
        private void InternalQueueMapBlock(Map map, uint cellx, uint celly)
        {
            uint chunkIndex = (cellx % BlockCacheWidth) + (celly % BlockCacheHeight) * BlockCacheWidth;

            MiniMapChunk chunk = m_BlockCache[chunkIndex];
            if (chunk == null || chunk.X != cellx || chunk.Y != celly)
            {
                // the chunk is not in our cache! Try loading it from the map?
                MapChunk mapBlock = map.GetMapChunk(cellx, celly);
                if (mapBlock == null)
                {
                    // if the chunk is not loaded in memory, load it from the filesystem.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(cellx, celly, map.MapData);
                }
                else
                {
                    // get the colors for this chunk from the map chunk, which will have already sorted the objects.
                    m_BlockCache[chunkIndex] = new MiniMapChunk(mapBlock);
                }
            }
            else
            {
                m_BlockColors = chunk.Colors;
            }

            m_QueuedToDrawBlocks.Add(chunkIndex);
        }