コード例 #1
0
        /// <summary>
        /// Writes a specific section for the specific Map
        /// </summary>
        /// <param name="map">The map to write a section for</param>
        private void WriteMap(Map map)
        {
            _logger.Information($"Writing map {map.Name}");
            var mapKey          = GetMapKey(map);
            var newSection      = new SectionData(mapKey);
            var existingSection = _mpMapsData.GetSectionData(mapKey) ?? new SectionData(mapKey);

            // newSection.Merge(existingSection); // for testing only

            // Write the name/description
            newSection.SetKeyValue(Keys.Description, existingSection.GetKeyValue(Keys.Description) ?? map.GetSectionKeyValue(Keys.Basic, Keys.Name));

            // Write the author, prioritizing existing MPMaps.ini, then the Map file, then Unknown
            newSection.SetKeyValue(Keys.Author, existingSection.GetKeyValue(Keys.Author) ?? map.GetSectionKeyValue(Keys.Basic, Keys.Author) ?? DEFAULT_AUTHOR);

            WriteBriefing(newSection, existingSection, map);
            WriteGameModes(newSection, existingSection, map);
            WriteCoopMissionData(newSection, existingSection, map, out List <string> coopEnemyWaypoints);
            WriteWaypoints(newSection, map, coopEnemyWaypoints, out int waypointIter);

            newSection.SetKeyValue(Keys.MinPlayers, 1);
            newSection.SetKeyValue(Keys.MaxPlayers, waypointIter - coopEnemyWaypoints.Count);
            newSection.SetKeyValue(Keys.EnforceMaxPlayers, Keys.True);

            WriteForceOptions(newSection, map);

            newSection.SetKeyValue(Keys.Size, map.GetSectionKeyValue(Keys.Map, Keys.Size));
            newSection.SetKeyValue(Keys.LocalSize, map.GetSectionKeyValue(Keys.Map, Keys.LocalSize));

            WritePreviewSize(newSection, map);
            WriteTeamStartMappings(newSection, existingSection, map);

            _mpMapsBaseData.SetSectionData(mapKey, newSection);
        }