public static GfxObj ReadFromDat(uint fileId) { // Check the FileCache so we don't need to hit the FileSystem repeatedly if (DatManager.PortalDat.FileCache.ContainsKey(fileId)) { return((GfxObj)DatManager.PortalDat.FileCache[fileId]); } else { DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId); GfxObj obj = new GfxObj(); obj.Id = datReader.ReadUInt32(); obj.Flags = datReader.ReadUInt32(); short num_surfaces = datReader.ReadPackedByte(); for (short i = 0; i < num_surfaces; i++) { obj.Surfaces.Add(datReader.ReadUInt32()); } obj.VertexArray = CVertexArray.Read(datReader); // Has Physics if ((obj.Flags & 1) > 0) { short num_physics_polygons = datReader.ReadPackedByte(); for (ushort i = 0; i < num_physics_polygons; i++) { ushort poly_id = datReader.ReadUInt16(); obj.PhysicsPolygons.Add(poly_id, Polygon.Read(datReader)); } obj.PhysicsBSP = BSPTree.Read(datReader, BSPType.Physics); } obj.SortCenter = PositionExtensions.ReadPositionFrame(datReader); // Has Drawing if ((obj.Flags & 2) > 0) { short num_polygons = datReader.ReadPackedByte(); for (ushort i = 0; i < num_polygons; i++) { ushort poly_id = datReader.ReadUInt16(); obj.Polygons.Add(poly_id, Polygon.Read(datReader)); } obj.DrawingBSP = BSPTree.Read(datReader, BSPType.Drawing); } if ((obj.Flags & 8) > 0) { obj.DIDDegrade = datReader.ReadUInt32(); } // Store this object in the FileCache DatManager.PortalDat.FileCache[fileId] = obj; return(obj); } }
public static ParticleEmitterInfo ReadFromDat(uint fileId) { // Check the FileCache so we don't need to hit the FileSystem repeatedly if (DatManager.PortalDat.FileCache.ContainsKey(fileId)) { return((ParticleEmitterInfo)DatManager.PortalDat.FileCache[fileId]); } else { DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId); ParticleEmitterInfo obj = new ParticleEmitterInfo(); obj.Id = datReader.ReadUInt32(); uint unknown = datReader.ReadUInt32(); obj.EmitterType = (EmitterType)datReader.ReadInt32(); obj.ParticleType = (ParticleType)datReader.ReadInt32(); obj.GfxObjId = datReader.ReadUInt32(); obj.HwGfxObjId = datReader.ReadUInt32(); obj.Birthrate = datReader.ReadDouble(); obj.MaxParticles = datReader.ReadInt32(); obj.InitialParticles = datReader.ReadInt32(); obj.TotalParticles = datReader.ReadInt32(); obj.TotalSeconds = datReader.ReadDouble(); obj.LifespanRand = datReader.ReadDouble(); obj.Lifespan = datReader.ReadDouble(); obj.SortingSphere = datReader.ReadUInt32(); obj.OffsetDir = PositionExtensions.ReadPositionFrame(datReader); obj.MinOffset = datReader.ReadSingle(); obj.MaxOffset = datReader.ReadSingle(); obj.A = PositionExtensions.ReadPositionFrame(datReader); obj.B = PositionExtensions.ReadPositionFrame(datReader); obj.C = PositionExtensions.ReadPositionFrame(datReader); obj.MinA = datReader.ReadSingle(); obj.MaxA = datReader.ReadSingle(); obj.MinB = datReader.ReadSingle(); obj.MaxB = datReader.ReadSingle(); obj.MinC = datReader.ReadSingle(); obj.MaxC = datReader.ReadSingle(); obj.ScaleRand = datReader.ReadSingle(); obj.StartScale = datReader.ReadSingle(); obj.FinalScale = datReader.ReadSingle(); obj.TransRand = datReader.ReadSingle(); obj.StartTrans = datReader.ReadSingle(); obj.FinalTrans = datReader.ReadSingle(); // Store this object in the FileCache DatManager.PortalDat.FileCache[fileId] = obj; return(obj); } }