/** <summary> Constructs the base object data. </summary> */ public ObjectData(ObjectDataHeader objectHeader, ChunkHeader chunkHeader) { this.objectHeader = objectHeader; this.chunkHeader = chunkHeader; this.stringTable = new StringTable(); this.groupInfo = new GroupInfo(); this.imageDirectory = new ImageDirectory(); this.graphicsData = new GraphicsData(); }
/** <summary> Reads and returns object data from a path. </summary> */ public static ObjectData ReadObject(string path) { ObjectData obj = null; ObjectDataHeader objectHeader = new ObjectDataHeader(); ChunkHeader chunkHeader = new ChunkHeader(); try { objectHeader.FileName = path.Substring(path.Replace('/', '\\').LastIndexOf('\\') + 1); objectHeader.FileName = objectHeader.FileName.Substring(0, objectHeader.FileName.Length - 4); BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read), Encoding.Unicode); objectHeader.Read(reader); byte[] data = null; if ((ObjectTypes)(objectHeader.Flags & 0xF) != ObjectTypes.ScenarioText) { data = ObjectData.ReadChunk(reader, chunkHeader); reader.Close(); reader = new BinaryReader(new MemoryStream(data)); } switch ((ObjectTypes)(objectHeader.Flags & 0xF)) { case ObjectTypes.Attraction: obj = new Attraction(objectHeader, chunkHeader); break; case ObjectTypes.SmallScenery: obj = new SmallScenery(objectHeader, chunkHeader); break; case ObjectTypes.LargeScenery: obj = new LargeScenery(objectHeader, chunkHeader); break; case ObjectTypes.Wall: obj = new Wall(objectHeader, chunkHeader); break; case ObjectTypes.PathBanner: obj = new PathBanner(objectHeader, chunkHeader); break; case ObjectTypes.Path: obj = new Pathing(objectHeader, chunkHeader); break; case ObjectTypes.PathAddition: obj = new PathAddition(objectHeader, chunkHeader); break; case ObjectTypes.SceneryGroup: obj = new SceneryGroup(objectHeader, chunkHeader); break; case ObjectTypes.ParkEntrance: obj = new ParkEntrance(objectHeader, chunkHeader); break; case ObjectTypes.Water: obj = new Water(objectHeader, chunkHeader); break; case ObjectTypes.ScenarioText: /*obj = new ScenarioText(objectHeader, chunkHeader);*/ break; default: objectHeader.Flags = (uint)ObjectTypes.None; break; } if (obj != null) { obj.Read(reader); } reader.Close(); } catch (System.Exception) { objectHeader.Flags = (uint)ObjectTypes.None; obj = new ObjectData(objectHeader, chunkHeader); } return(obj); }