Exemple #1
0
        private void InternalCheckCellsInMemory()
        {
            for (int y = -c_CellsInMemory; y <= c_CellsInMemory; y++)
            {
                int cellY = (CenterPosition.Y / 8) + y;
                if (cellY < 0)
                {
                    cellY += Height / 8;
                }
                for (int x = -c_CellsInMemory; x <= c_CellsInMemory; x++)
                {
                    int cellX = (CenterPosition.X / 8) + x;
                    if (cellX < 0)
                    {
                        cellX += Width / 8;
                    }

                    int cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + cellX % c_CellsInMemorySpan;
                    if (m_Blocks[cellIndex] == null || m_Blocks[cellIndex].X != cellX || m_Blocks[cellIndex].Y != cellY)
                    {
                        if (m_Blocks[cellIndex] != null)
                        {
                            m_Blocks[cellIndex].Unload();
                        }
                        m_Blocks[cellIndex] = new MapBlock(cellX, cellY);
                        m_Blocks[cellIndex].Load(m_MapData, this);
                        Multi.AnnounceMapBlockLoaded(m_Blocks[cellIndex]);
                    }
                }
            }
        }
Exemple #2
0
        public MapTile GetMapTile(int x, int y)
        {
            int cellX = x / 8, cellY = y / 8;
            int cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + (cellX % c_CellsInMemorySpan);

            MapBlock cell = m_Blocks[cellIndex];

            if (cell == null)
            {
                return(null);
            }
            return(cell.Tiles[(y % 8) * 8 + (x % 8)]);
        }