Beispiel #1
0
        public void ReadTile(sbyte[] heights, Tile[] tiles, uint offsetX, uint offsetY, uint chunkX, uint chunkY)
        {
            // load the ground data into the tiles.
            var groundData      = _tileData.GetLandChunk(chunkX, chunkY);
            var groundDataIndex = 0;

            for (uint x = 0; x < 8; x++)
            {
                for (uint y = 0; y < 8; y++)
                {
                    var tileId = (short)(groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8));
                    var tileZ  = (sbyte)groundData[groundDataIndex++];
                    var data   = TileData.LandData[tileId & 0x3FFF];
                    var idx    = ((offsetY + y) * STRIDE0) + offsetX + x;
                    heights[idx] = tileZ;
                    tiles[idx]   = new Tile
                    {
                        //X = (int)chunkX * 8 + x,
                        //Y = (int)chunkY * 8 + y,
                        TileId    = tileId,
                        Flags     = data.Flags,
                        TextureId = data.TextureID,
                        Ignored   = tileId == 2 || tileId == 0x1DB || (tileId >= 0x1AE && tileId <= 0x1B5),
                    };
                }
            }
        }
Beispiel #2
0
        public void LoadStatics(TileMatrixData tileData, Map map)
        {
            // get data from the tile Matrix
            var groundData  = tileData.GetLandChunk(ChunkX, ChunkY);
            var staticsData = tileData.GetStaticChunk(ChunkX, ChunkY, out int staticLength);
            // load the ground data into the tiles.
            var groundDataIndex = 0;

            for (var i = 0; i < 64; i++)
            {
                var tileID = groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8);
                var tileZ  = (sbyte)groundData[groundDataIndex++];
                var ground = new Ground(tileID, map);
                ground.Position.Set((int)ChunkX * 8 + i % 8, (int)ChunkY * 8 + (i / 8), tileZ);
            }
            // load the statics data into the tiles
            var countStatics    = staticLength / 7;
            var staticDataIndex = 0;

            for (var i = 0; i < countStatics; i++)
            {
                var tileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                var x      = staticsData[staticDataIndex++];
                var y      = staticsData[staticDataIndex++];
                var tileZ  = (sbyte)staticsData[staticDataIndex++];
                var hue    = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);
                var item   = new StaticItem(tileID, hue, i, map);
                item.Position.Set((int)ChunkX * 8 + x, (int)ChunkY * 8 + y, tileZ);
            }
        }
Beispiel #3
0
        private void ParseMapBlock(TileMatrixData tileData, uint x, uint y)
        {
            byte[] groundData = tileData.GetLandChunk(x, y);
            int    staticLength;

            byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength);

            // load the statics data
            int countStatics    = staticLength / 7;
            int staticDataIndex = 0;

            for (int i = 0; i < countStatics; i++)
            {
                int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int iX      = staticsData[staticDataIndex++];
                int iY      = staticsData[staticDataIndex++];
                int iTileZ  = (sbyte)staticsData[staticDataIndex++];
                int hue     = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);

                if (m_StaticCounts.ContainsKey(iTileID))
                {
                    m_StaticCounts[iTileID]++;
                }
                else
                {
                    m_StaticCounts.Add(iTileID, 1);
                }
            }
        }
        private static sbyte[] m_Zs = new sbyte[64]; // shared between all instances of MiniMapChunk.

        public MiniMapChunk(uint x, uint y, TileMatrixData tileData)
        {
            X      = x;
            Y      = y;
            Colors = new uint[64];

            // get data from the tile Matrix
            byte[] groundData = tileData.GetLandChunk(x, y);
            int    staticLength;

            byte[] staticsData = tileData.GetStaticChunk(x, y, out staticLength);

            // get the ground colors
            int groundDataIndex = 0;

            for (int i = 0; i < 64; i++)
            {
                Colors[i] = RadarColorData.Colors[groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8)];
                m_Zs[i]   = (sbyte)groundData[groundDataIndex++];
            }

            // get the static colors
            int countStatics    = staticLength / 7;
            int staticDataIndex = 0;

            for (int i = 0; i < countStatics; i++)
            {
                int   itemID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int   tile   = staticsData[staticDataIndex++] + staticsData[staticDataIndex++] * 8;
                sbyte z      = (sbyte)staticsData[staticDataIndex++];
                int   hue    = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256); // is this used?

                ItemData data = TileData.ItemData[itemID];
                int      iz   = z + data.Height + (data.IsRoof || data.IsSurface ? 1 : 0);

                if ((x * 8 + (tile % 8) == 1480) && (y * 8 + (tile / 8) == 1608))
                {
                    if (iz > m_Zs[tile])
                    {
                        Colors[tile] = RadarColorData.Colors[itemID + 0x4000];
                        m_Zs[tile]   = (sbyte)iz;
                    }
                }

                if (iz > m_Zs[tile])
                {
                    Colors[tile] = RadarColorData.Colors[itemID + 0x4000];
                    m_Zs[tile]   = (sbyte)iz;
                }
            }
        }
Beispiel #5
0
        public void LoadStatics(TileMatrixData tileData, Map map)
        {
            // get data from the tile Matrix
            byte[] groundData = tileData.GetLandChunk(ChunkX, ChunkY);
            int    staticLength;

            byte[] staticsData = tileData.GetStaticChunk(ChunkX, ChunkY, out staticLength);

            // load the ground data into the tiles.
            int groundDataIndex = 0;

            for (int i = 0; i < 64; i++)
            {
                int tileID = groundData[groundDataIndex++] + (groundData[groundDataIndex++] << 8);
                int tileZ  = (sbyte)groundData[groundDataIndex++];

                Ground ground = new Ground(tileID, map);
                ground.Position.Set((int)ChunkX * 8 + i % 8, (int)ChunkY * 8 + (i / 8), tileZ);
            }

            // load the statics data into the tiles
            int countStatics    = staticLength / 7;
            int staticDataIndex = 0;

            for (int i = 0; i < countStatics; i++)
            {
                int iTileID = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8);
                int iX      = staticsData[staticDataIndex++];
                int iY      = staticsData[staticDataIndex++];
                int iTileZ  = (sbyte)staticsData[staticDataIndex++];
                int hue     = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);

                StaticItem item = new StaticItem(iTileID, hue, i, map);
                item.Position.Set((int)ChunkX * 8 + iX, (int)ChunkY * 8 + iY, iTileZ);
            }
        }