Ejemplo n.º 1
0
        public static byte[] GetBytes(TileGroup obj, bool withTiles = false)
        {
            var data = new byte[4];

            BitConverter.GetBytes(obj.Unknown).CopyTo(data, 0);

            if (withTiles && (obj.LandTiles != null || obj.StaticTiles != null))
            {
                if (obj.LandTiles != null)
                {
                    foreach (var landTile in obj.LandTiles.OrderBy(kvPair => kvPair.Key))
                    {
                        var landTileData = LandTiledata.GetBytes(landTile.Value);
                        Array.Resize(ref data, data.Length + landTileData.Length);
                        landTileData.CopyTo(data, data.Length - landTileData.Length);
                    }
                }
                else if (obj.StaticTiles != null)
                {
                    foreach (var staticTile in obj.StaticTiles.OrderBy(kvPair => kvPair.Key))
                    {
                        var staticTileData = StaticTiledata.GetBytes(staticTile.Value);
                        Array.Resize(ref data, data.Length + staticTileData.Length);
                        staticTileData.CopyTo(data, data.Length - staticTileData.Length);
                    }
                }
            }
            return(data);
        }
Ejemplo n.º 2
0
        public static byte[] GetBytes(LandTiledata obj)
        {
            var data = new byte[26];

            BitConverter.GetBytes((int)obj.Flags).CopyTo(data, 0);
            BitConverter.GetBytes(obj.TextureID).CopyTo(data, 4);
            var trimmedTileName = obj.TileName;

            if (trimmedTileName.Length > 20)
            {
                trimmedTileName.Substring(0, 20);
            }
            Encoding.Default.GetBytes(trimmedTileName).CopyTo(data, 6);

            return(data);
        }