Пример #1
0
        /// <summary>
        /// generate the associations between parts and folders, create all the mod categories, get all propellant combinations,
        /// </summary>
        private void GetPartData()
        {
            var modNames = new List <string>();

            Editor.blackListedParts = new HashSet <string>();
            char[] splitter = new char[] { '/', '\\' };
            foreach (AvailablePart p in PartLoader.LoadedPartsList)
            {
                if (p == null)
                {
                    continue;
                }
                else if (string.Equals(p.TechRequired, "Unresearchable", StringComparison.OrdinalIgnoreCase))
                {
                    Logger.Log($"part {p.name} is noted as unreasearchable and will not be visible", Logger.LogLevel.Debug);
                    Editor.blackListedParts.Add(p.name);
                    continue;
                }

                if (string.IsNullOrEmpty(p.partUrl))
                {
                    RepairAvailablePartUrl(p);
                }
                // if the url is still borked, can't associate a mod to the part
                if (!string.IsNullOrEmpty(p.partUrl))
                {
                    // list of GameData folders
                    modNames.AddUnique(p.partUrl.Split(splitter)[0]);
                    // associate the path to the part
                    if (!partPathDict.ContainsKey(p.name))
                    {
                        partPathDict.Add(p.name, p.partUrl);
                    }
                    else
                    {
                        Logger.Log(p.name + " duplicated part key in part path dictionary", Logger.LogLevel.Debug);
                    }
                }
                if (PartType.IsEngine(p))
                {
                    ProcessEnginePropellants(p);
                }
                if (p.partPrefab.Resources != null)
                {
                    foreach (PartResource r in p.partPrefab.Resources)
                    {
                        resources.AddUnique(r.resourceName);
                    }
                }
            }
            GenerateEngineTypes();
            ProcessFilterByManufacturer(modNames);
        }