Exemplo n.º 1
0
        public MiniMapBlock(MapBlock block)
        {
            X = (uint)block.BlockX;
            Y = (uint)block.BlockY;
            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 = IO.RadarColorData.Colors[(e as Ground).LandDataID];
                        break;
                    }
                    else if (e is StaticItem)
                    {
                        color = IO.RadarColorData.Colors[(e as StaticItem).ItemID + 0x4000];
                        break;
                    }
                    eIndex--;
                }
                Colors[tile] = color;
            }
        }
Exemplo n.º 2
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]);
                    }
                }
            }
        }
Exemplo n.º 3
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)]);
        }
Exemplo n.º 4
0
 public static void AnnounceMapBlockLoaded(MapBlock block)
 {
     for (int i = 0; i < s_RegisteredMultis.Count; i++)
         if (!s_RegisteredMultis[i].IsDisposed)
             s_RegisteredMultis[i].PlaceTilesIntoNewlyLoadedBlock(block);
 }
Exemplo n.º 5
0
        private void PlaceTilesIntoNewlyLoadedBlock(MapBlock block)
        {
            int px = Position.X;
            int py = Position.Y;

            Rectangle bounds = new Rectangle((int)block.BlockX * 8, (int)block.BlockY * 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 block?
                    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);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
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.BlockHeight;
                for (int x = -c_CellsInMemory; x <= c_CellsInMemory; x++)
                {
                    uint cellX = (uint)(centerX + x) % MapData.BlockWidth;

                    uint cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + cellX % c_CellsInMemorySpan;
                    if (m_Blocks[cellIndex] == null || m_Blocks[cellIndex].BlockX != cellX || m_Blocks[cellIndex].BlockY != cellY)
                    {
                        if (m_Blocks[cellIndex] != null)
                            m_Blocks[cellIndex].Unload();
                        m_Blocks[cellIndex] = new MapBlock(cellX, cellY);
                        m_Blocks[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_Blocks[cellIndex], Season);
                        // let any active multis know that a new map block is ready, so they can load in their pieces.
                        Multi.AnnounceMapBlockLoaded(m_Blocks[cellIndex]);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void TranslateMapBlock(MapBlock block, Seasons season)
        {
            if (block == null)
                return;

            for (int tile = 0; tile < 64; tile++)
            {
                foreach (AEntity e in block.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];
                    }
                }
            }
        }