public new void parse() { base.parse(); if (isRoot) { // Check version Chunk_Base version = getChunksByID(Chunk_MVER.Magic).FirstOrDefault(); if (version == null || !(version is Chunk_MVER)) { throw new WMOException("File is not a valid WMO file (missing version header)."); } // WMOv4 required. if (((Chunk_MVER)version).fileVersion != 17) { throw new WMOException("Unsupported WMO version!"); } // Root file needs to be a root file. if (!Chunks.Any(c => c.ChunkID == Chunk_MOHD.Magic)) { throw new WMOException("File is not a valid WMO file (missing root header)."); } // Parse all group files and import their chunks. foreach (WMOFile groupFile in groupFiles) { groupFile.parse(); Chunks.AddRange(groupFile.getChunks().Where(c => c.ChunkID != Chunk_MVER.Magic)); groupFile.flush(); } Log.Write("WMO: Root file loaded with {0} group file children.", groupFiles.Count); } }
public bool HasChunk <T>() { Type type = typeof(T); return(Chunks.Any(chunk => chunk != null && type.IsInstanceOfType(chunk))); }