示例#1
0
 public override void Load(DescriptorList description, AssetManager assets)
 {
     intervalList = new PatchInterval[description.CustomDescriptions.Length];
     for (int x = 0; x < intervalList.Length; x++)
     {
         if (!description.CustomDescriptions[x].ID.ToLower().Equals("mpat"))
         {
             throw new Exception(string.Format("The patch: {0} has an invalid descriptor with id {1}", this.patchName, description.CustomDescriptions[x].ID));
         }
         string     patchName = (string)description.CustomDescriptions[x].Objects[0];
         PatchAsset pAsset    = assets.FindPatch(patchName);
         if (pAsset == null)
         {
             throw new Exception(string.Format("The patch: {0} could not be found. For multi patches all sub patches must be loaded first.", patchName));
         }
         byte sChan = (byte)description.CustomDescriptions[x].Objects[1];
         byte eChan = (byte)description.CustomDescriptions[x].Objects[2];
         byte sKey  = (byte)description.CustomDescriptions[x].Objects[3];
         byte eKey  = (byte)description.CustomDescriptions[x].Objects[4];
         byte sVel  = (byte)description.CustomDescriptions[x].Objects[5];
         byte eVel  = (byte)description.CustomDescriptions[x].Objects[6];
         intervalList[x] = new PatchInterval(pAsset.Patch, sChan, eChan, sKey, eKey, sVel, eVel);
     }
     DetermineIntervalType();
 }
        /// <summary>
        /// 获取资源列表
        /// </summary>
        private List <PatchAsset> GetAllPatchAsset(AssetBundleBuilder.BuildParametersContext buildParameters,
                                                   BuildMapContext buildMapContext, PatchManifest patchManifest)
        {
            List <PatchAsset> result = new List <PatchAsset>(1000);

            foreach (var bundleInfo in buildMapContext.BundleInfos)
            {
                var assetInfos = bundleInfo.GetAllPatchAssetInfos();
                foreach (var assetInfo in assetInfos)
                {
                    PatchAsset patchAsset = new PatchAsset();
                    if (buildParameters.Parameters.EnableAddressable)
                    {
                        patchAsset.Address = assetInfo.Address;
                    }
                    else
                    {
                        patchAsset.Address = string.Empty;
                    }
                    patchAsset.AssetPath = assetInfo.AssetPath;
                    patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
                    patchAsset.BundleID  = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
                    patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
                    result.Add(patchAsset);
                }
            }
            return(result);
        }
示例#3
0
        private void QueueFileUpload(PatchAsset asset, FileCompressionMode compress)
        {
            var info = new FileUploadInfo()
            {
                Asset    = asset,
                Compress = compress
            };

            lock (_uploadQueue)
                _uploadQueue.Enqueue(info);
        }
        /// <summary>
        /// 获取资源对象依赖的所有资源包
        /// </summary>
        private List <string> GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
        {
            List <string> dependBundles = new List <string>(patchAsset.DependIDs.Length);

            foreach (int index in patchAsset.DependIDs)
            {
                string dependBundleName = patchManifest.BundleList[index].BundleName;
                dependBundles.Add(dependBundleName);
            }
            return(dependBundles);
        }
示例#5
0
        /// <summary>
        /// Creates in memory file that is being uploaded to client
        /// </summary>
        /// <param name="data"></param>
        /// <param name="size"></param>
        /// <param name="destination"></param>
        /// <param name="compress"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool CreateUpload(PatchAsset asset, byte[] data, FileCompressionMode compress, FileType type)
        {
            Close();
            _fileHash       = Utils.Adler32(0, data, (ulong)data.Length);
            _filename       = asset.Name;
            _fileSize       = (ulong)data.Length;
            _filenameHash   = asset.Hash;
            Archive         = (Archive)asset.ArchiveId;
            _asset          = asset;
            _compressedSize = _fileSize;
            _oldCrc         = asset.CRC32;
            _compress       = compress;
            _type           = type;
            _closed         = false;
            if (Compress == FileCompressionMode.WHOLE)
            {
                MemoryStream ms         = new MemoryStream();
                BinaryWriter gzipWriter = new BinaryWriter(ms);

                //write DEFLATE header
                gzipWriter.Write((byte)0x78);
                gzipWriter.Write((byte)0x9C);

                using (DeflateStream compressStream = new DeflateStream(ms, CompressionMode.Compress, true))
                    compressStream.Write(data, 0, (int)_fileSize);

                _compressedSize = (ulong)ms.Length;
                _data           = ms.ToArray();
            }
            else
            {
                _data = new byte[_fileSize];
                Buffer.BlockCopy(data, 0, _data, 0, (int)_fileSize);
            }
            return(true);
        }