/// <summary> /// Parses the superbundle layout for Frostbite 2013.2 (Battlefield 4) superbundles /// Reads out the bundle, chunk entries /// </summary> /// <param name="p_Object">DbObject of the superbundle's table of contents (.toc)</param> protected override void ParseLayout(DbObject p_Object) { // Read out all of the bundles var s_Bundles = p_Object["bundles"].Value as DbObject; if (s_Bundles != null) { for (var i = 0; i < s_Bundles.Count; ++i) { var s_BundleEntry = new BundleEntry(s_Bundles[i].Value as DbObject, this); BundleEntries.TryAdd(s_BundleEntry.ID.ToLowerInvariant(), s_BundleEntry); } } // Read out all of the chunks var s_Chunks = p_Object["chunks"].Value as DbObject; if (s_Chunks != null) { for (var i = 0; i < s_Chunks.Count; ++i) { var s_ChunkEntry = new ChunkEntry(s_Chunks[i].Value as DbObject, this); ChunkEntries.TryAdd(s_ChunkEntry.ID, s_ChunkEntry); } } }
public GeometryResource(Stream s) : base(s) { if (ChunkEntries.Count != 1) { throw new InvalidDataException(String.Format("Expected one chunk, found {0}.", ChunkEntries.Count)); } ChunkEntry chunk = ChunkEntries[0]; ChunkEntries.Remove(chunk); using (MemoryStream ms = new MemoryStream()) { new BinaryWriter(ms).Write(chunk.RCOLBlock.AsBytes); ms.Flush(); ms.Position = 0; GEOM geom = new GEOM(OnResourceChanged, ms); ChunkEntries.Add(new ChunkEntry(OnResourceChanged, chunk.TGIBlock, geom)); } }