public static void SaveEntries(this IChunkDICT dict, SaveContext saveContext) { if (dict != null) { foreach (var dictEntry in dict.Entries) { saveContext.SaveAndMarkReference(dictEntry.EntryObject); } } }
protected override void LoadInternal(Utility utility, uint chunkSize) { // The DATA chunk simply has a list that points to DICT chunks. // This can contain up to 16 DICTs, always in the same order: // //0 Models //1 Textures //2 LUTS(Material / Color / Shader look - up tables ?) //3 Materials //4 Shaders //5 Cameras //6 Lights //7 Fog //8 Environments //9 Skeleton animations //10 Texture animations //11 Visibility animations //12 Camera animations //13 Light animations //14 Emitters //15 Unknown // // These entries point to further subchunks that define the specific data. // Each DATA list entry is as follows: // [4B] Number of entries in DICT // [4B] Offset (self-relative) to DICT // NOTE: Any unused entry should be zeroed out // // As noted, we should always have the same number of entries as above, // barring notes that suggest it may vary by revision. // // NOTE: We could possibly look for the first DICT to figure how many // entries we have, but I'm not sure that's 100% reliable... for (var entry = EntryType.Model; entry < EntryType.TotalEntries; entry++) { // Jump to and read DICT... IChunkDICT dict = null; if (entry == EntryType.Model) { dict = utility.LoadDICTFromOffset <ChunkDICTModel>(); } else if (entry == EntryType.Texture) { dict = utility.LoadDICTFromOffset <ChunkDICTTexture>(); } else { var numEntries = utility.ReadU32(); var offsetToDict = utility.ReadOffset(); // It only matters if there's data here to load that we're not handling! if (numEntries > 0) { throw new NotImplementedException($"EntryType {entry} does not have a DICT loader implemented!"); } } Entries[(int)entry] = dict; } }