Beispiel #1
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 #2
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);
                }
            }
        }
Beispiel #3
0
        public void ReadTile(sbyte[] heights, LANDRecord.Tile[] tiles, List <RefObj> refObjs, uint offsetX, uint offsetY, uint chunkX, uint chunkY)
        {
#if LOADLANDTILES
            // load land tiles
            for (var x = 0U; x < 8; x++)
            {
                for (var y = 0U; y < 8; y++)
                {
                    var idx  = ((offsetY + y) * STRIDE0) + offsetX + x;
                    var tile = tiles[idx];
                    if (tile.Ignored)
                    {
                        continue;
                    }
                    var z = heights[idx];
                    refObjs.Add(new RefObj
                    {
                        Land     = true,
                        TileId   = tile.TileId,
                        Position = new Vector3((int)chunkX * 8 + x, (int)chunkY * 8 + y, z / ConvertUtils.MeterInUnits),
                    });
                }
            }
#endif
            // load the statics data into the tiles
            var staticsData     = _tileData.GetStaticChunk(chunkX, chunkY, out int staticLength);
            var countStatics    = staticLength / 7;
            var staticDataIndex = 0;
            for (var i = 0; i < countStatics; i++)
            {
                var tileId   = (short)(staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] << 8));
                var x        = (sbyte)staticsData[staticDataIndex++];
                var y        = (sbyte)staticsData[staticDataIndex++];
                var z        = (sbyte)staticsData[staticDataIndex++];
                var hue      = staticsData[staticDataIndex++] + (staticsData[staticDataIndex++] * 256);
                var itemData = TileData.ItemData[tileId];
                if (itemData.Ignored)
                {
                    continue;
                }
                //var idx = ((offsetY + y) * STRIDE0) + offsetX + x;
                //z += heights[idx];
                refObjs.Add(new RefObj
                {
                    TileId        = tileId,
                    Hue           = hue,
                    SortInfluence = i,
                    Position      = new Vector3((int)chunkX * 8 + x, (int)chunkY * 8 + y, z / ConvertUtils.MeterInUnits),
                });
            }
        }
        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);
            }
        }