示例#1
0
        public void CreateCache()
        {
            // Cache depots
            _depots = _depotRegistry
                      .GetDepots()
                      .OrderBy(d => d.Body)
                      .ThenBy(d => d.Biome)
                      .ToList();

            // Retain previously selected bodies
            var selectedOriginBody      = string.Empty;
            var selectedDestinationBody = string.Empty;

            if (_selectedOriginBodyIndex > 0)
            {
                selectedOriginBody = _depotBodies[_selectedOriginBodyIndex];
            }
            if (_selectedDestinationBodyIndex > 0)
            {
                selectedDestinationBody = _depotBodies[_selectedDestinationBodyIndex];
            }

            // Cache bodies with depots
            var depotBodies = _depots
                              .Select(d => d.Body)
                              .Distinct();

            _depotBodies = new List <string> {
                "---"
            };
            _depotBodies.AddRange(depotBodies);
            _depotBodyNames = _depotBodies
                              .Select(b => new GUIContent(b))
                              .ToArray();

            // Reindex previously selected bodies
            if (!string.IsNullOrEmpty(selectedOriginBody))
            {
                _selectedOriginBodyIndex = _depotBodies.FindIndex(b => b == selectedOriginBody);
            }
            if (!string.IsNullOrEmpty(selectedDestinationBody))
            {
                _selectedDestinationBodyIndex = _depotBodies.FindIndex(b => b == selectedDestinationBody);
            }

            // Cache biomes
            CacheOriginBiomes();
            CacheDestinationBiomes();
        }
示例#2
0
        private void CreateCache()
        {
            // Cache depots and depot body:biome names
            _depots = _depotRegistry
                      .GetDepots()
                      .OrderBy(d => d.Body)
                      .ThenBy(d => d.Biome)
                      .ToList();

            _depotNames = _depots
                          .Select(d => new GUIContent(d.Body + ":" + d.Biome))
                          .ToArray();

            // Default to KSC
            var kscIndex = _depots.FindIndex(d => d.Body == "Kerbin" && d.Biome == "KSC");

            if (kscIndex >= 0)
            {
                SelectDepot(kscIndex);
            }
        }