Exemple #1
0
        public MiniMapChunk(MapChunk block)
        {
            X = (uint)block.ChunkX;
            Y = (uint)block.ChunkY;
            Colors = new uint[64];

            for (uint tile = 0; tile < 64; tile++)
            {
                uint color = 0xffff00ff;
                // get the topmost static item or ground
                int eIndex = block.Tiles[tile].Entities.Count - 1;
                while (eIndex >= 0)
                {
                    AEntity e = block.Tiles[tile].Entities[eIndex];
                    if (e is Ground)
                    {
                        color = RadarColorData.Colors[(e as Ground).LandDataID];
                        break;
                    }
                    else if (e is StaticItem)
                    {
                        color = RadarColorData.Colors[(e as StaticItem).ItemID + 0x4000];
                        break;
                    }
                    eIndex--;
                }
                Colors[tile] = color;
            }
        }
Exemple #2
0
        public MapChunk GetMapChunk(uint x, uint y)
        {
            uint     cellIndex = (y % c_CellsInMemorySpan) * c_CellsInMemorySpan + (x % c_CellsInMemorySpan);
            MapChunk cell      = m_Chunks[cellIndex];

            if (cell == null)
            {
                return(null);
            }
            if (cell.ChunkX != x || cell.ChunkY != y)
            {
                return(null);
            }
            return(cell);
        }
Exemple #3
0
        public MapTile GetMapTile(uint x, uint y)
        {
            uint cellX = (uint)x / 8, cellY = (uint)y / 8;
            uint cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + (cellX % c_CellsInMemorySpan);

            MapChunk cell = m_Chunks[cellIndex];

            if (cell == null)
            {
                return(null);
            }
            if (cell.ChunkX != cellX || cell.ChunkY != cellY)
            {
                return(null);
            }
            return(cell.Tiles[(y % 8) * 8 + (x % 8)]);
        }
        private void TranslateMapChunk(MapChunk chunk, Seasons season)
        {
            if (chunk == null)
                return;

            for (int tile = 0; tile < 64; tile++)
            {
                foreach (AEntity e in chunk.Tiles[tile].Entities)
                {
                    int[] translations;
                    StaticItem si = (e as StaticItem);
                    if (si == null)
                        continue;
                    if (m_TranslationTable.TryGetValue(si.ItemID, out translations))
                    {
                        si.DisplayItemID = (season == Seasons.Spring) ? si.ItemID : translations[(int)season - 1];
                    }
                }
            }
        }
Exemple #5
0
 public static void AnnounceMapChunkLoaded(MapChunk chunk)
 {
     for (int i = 0; i < s_RegisteredMultis.Count; i++)
         if (!s_RegisteredMultis[i].IsDisposed)
             s_RegisteredMultis[i].PlaceTilesIntoNewlyLoadedChunk(chunk);
 }
Exemple #6
0
        private void PlaceTilesIntoNewlyLoadedChunk(MapChunk chunk)
        {
            int px = Position.X;
            int py = Position.Y;

            Rectangle bounds = new Rectangle((int)chunk.ChunkX * 8, (int)chunk.ChunkY * 8, 8, 8);

            foreach (MultiComponentList.MultiItem item in m_Components.Items)
            {
                int x = px + item.OffsetX;
                int y = py + item.OffsetY;

                if (bounds.Contains(x, y))
                {
                    // would it be faster to get the tile from the chunk?
                    MapTile tile = Map.GetMapTile(x, y);
                    if (tile != null)
                    {
                        if (!tile.ItemExists(item.ItemID, item.OffsetZ))
                        {
                            StaticItem staticItem = new StaticItem(item.ItemID, 0, 0, Map);
                            staticItem.Position.Set(x, y, Z + item.OffsetZ);
                        }
                    }
                }
            }
        }
Exemple #7
0
        private void InternalCheckCellsInMemory()
        {
            uint centerX = ((uint)CenterPosition.X / 8);
            uint centerY = ((uint)CenterPosition.Y / 8);
            for (int y = -c_CellsInMemory; y <= c_CellsInMemory; y++)
            {
                uint cellY = (uint)(centerY + y) % MapData.ChunkHeight;
                for (int x = -c_CellsInMemory; x <= c_CellsInMemory; x++)
                {
                    uint cellX = (uint)(centerX + x) % MapData.ChunkWidth;

                    uint cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + (cellX % c_CellsInMemorySpan);
                    if (m_Chunks[cellIndex] == null || m_Chunks[cellIndex].ChunkX != cellX || m_Chunks[cellIndex].ChunkY != cellY)
                    {
                        if (m_Chunks[cellIndex] != null)
                            m_Chunks[cellIndex].Unload();
                        m_Chunks[cellIndex] = new MapChunk(cellX, cellY);
                        m_Chunks[cellIndex].Load(MapData, this);
                        // if we have a translator and it's not spring, change some statics!
                        if (Season != Seasons.Spring && SeasonalTranslator != null)
                            SeasonalTranslator(m_Chunks[cellIndex], Season);
                        // let any active multis know that a new map chunk is ready, so they can load in their pieces.
                        Multi.AnnounceMapChunkLoaded(m_Chunks[cellIndex]);
                    }
                }
            }
        }