コード例 #1
0
        //=========== READING ============
        #region Reading

        /**<summary>Reads the specified number of string entries.</summary>*/
        public void Read(BinaryReader reader, int numEntries = 1)
        {
            for (int i = 0; i < numEntries; i++)
            {
                StringEntry entry = new StringEntry();
                entry.Read(reader);
                this.Entries.Add(entry);
            }
        }
コード例 #2
0
        //=========== HELPERS ============
        #region Helpers

        /**<summary>Reads and decodes the chunk.</summary>*/
        private static void ReadInfoFromChunk(BinaryReader chunkReader, ref ObjectDataInfo objInfo, Languages language)
        {
            ChunkHeader chunkHeader = new ChunkHeader();

            chunkHeader.Read(chunkReader);
            byte[] decodedChunkData = Chunk.Read(chunkReader, chunkHeader);

            using (MemoryStream stream = new MemoryStream(decodedChunkData)) {
                BinaryReader reader = new BinaryReader(stream);
                switch (objInfo.Type)
                {
                case ObjectTypes.Attraction:    objInfo.Header = new AttractionHeader(); break;

                case ObjectTypes.SmallScenery:  objInfo.Header = new SmallSceneryHeader(); break;

                case ObjectTypes.LargeScenery:  objInfo.Header = new LargeSceneryHeader(); break;

                case ObjectTypes.Wall:                  objInfo.Header = new WallHeader(); break;

                case ObjectTypes.PathBanner:    objInfo.Header = new PathBannerHeader(); break;

                case ObjectTypes.Footpath:              objInfo.Header = new FootpathHeader(); break;

                case ObjectTypes.PathAddition:  objInfo.Header = new PathAdditionHeader(); break;

                case ObjectTypes.SceneryGroup:  objInfo.Header = new SceneryGroupHeader(); break;

                case ObjectTypes.ParkEntrance:  objInfo.Header = new ParkEntranceHeader(); break;

                case ObjectTypes.Water:                 objInfo.Header = new WaterHeader(); break;

                case ObjectTypes.ScenarioText:  objInfo.Header = new ScenarioTextHeader(); break;
                }

                // Get the object's header
                objInfo.Header.Read(reader);

                // Get the object's subtype for better classification
                objInfo.Subtype = objInfo.Header.ObjectSubtype;

                // Get the object's name in the specified language
                StringEntry entry = new StringEntry();
                entry.Read(reader);
                objInfo.Name = entry.GetWithFallback(language);
            }
        }