public static AssetRef LoadBinary(Pack pack, BinaryStream stream)
        {
            AssetRef assetRef;

            assetRef = new AssetRef(pack);

            uint count = stream.ReadUInt32();

            assetRef.Name           = stream.ReadString((int)count);
            assetRef.DisplayName    = assetRef.Name + " (" + pack.DisplayName + ')';
            assetRef.AbsoluteOffset = stream.ReadUInt32();
            assetRef.Size           = stream.ReadUInt32();
            assetRef.Crc32          = stream.ReadUInt32();

            // Set the type of the asset based on the extension
            // First get the extension without the leading '.'
            string extension = Path.GetExtension(assetRef.Name).Substring(1);

            try
            {
                assetRef.AssetType = (AssetType)Enum.Parse(typeof(AssetType), extension, true);
            }
            catch (ArgumentException)
            {
                // This extension isn't mapped in the enum
                Debug.LogWarningFormat("Ignoring Unknown Forgelight File Type: {0}", extension);
                assetRef.AssetType = AssetType.Unknown;
            }

            return(assetRef);
        }
예제 #2
0
        public AssetStream(Stream baseStream, AssetRef assetRef, bool leaveOpen = false)
        {
            this.BaseStream = baseStream;
            this.AssetRef   = assetRef;
            this.leaveOpen  = leaveOpen;

            Initialize();
        }
예제 #3
0
        public AssetStream CreateAssetStream(AssetRef assetRef)
        {
            Assert.IsNotNull(assetRef, "No asset reference was provided!");

            FileStream file = File.Open(assetRef.Pack.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

            return(new AssetStream(file, assetRef));
        }
예제 #4
0
        public bool Deserialize(BinaryStream stream, AssetManager assetManager)
        {
            uint nextChunkAbsoluteOffset = 0;

            do
            {
                stream.Seek(nextChunkAbsoluteOffset, SeekOrigin.Begin);

                nextChunkAbsoluteOffset = stream.ReadUInt32();
                uint fileCount = stream.ReadUInt32();

                for (uint i = 0; i < fileCount; ++i)
                {
                    AssetRef file = AssetRef.LoadBinary(this, stream);
                    Assets[file.Name] = file;
                }
            } while (nextChunkAbsoluteOffset != 0);

            return(true);
        }