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); }
public AssetStream(Stream baseStream, AssetRef assetRef, bool leaveOpen = false) { this.BaseStream = baseStream; this.AssetRef = assetRef; this.leaveOpen = leaveOpen; Initialize(); }
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)); }
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); }