public void AddModule(ModuleMeta module)
 {
     if (module.PartName != Name)
     {
         Utils.Log("PartMeta[{}]: trying to add {} that belongs to the {}",
                   Name, module.Module.Name, module.PartName);
         return;
     }
     Modules.Add(module);
 }
        void Awake()
        {
            //register modules
            foreach (var module in ValidModules)
            {
                var meta = new ModuleMeta(module);
                if (!meta.Valid)
                {
                    continue;
                }
                RegisteredModules.Add(module, meta);
            }
            //add inputs
            RegisteredModules.ForEach(m => m.Value.Input.ForEach(inp => add_optional(m.Key, inp)));
            //topo-sort modules
            SortModules();
            //register techtree parts
            foreach (var module in RegisteredModules.Values)
            {
                if (string.IsNullOrEmpty(module.PartName))
                {
                    continue;
                }
                TCAPart part = null;
                if (TechTreeParts.TryGetValue(module.PartName, out part))
                {
                    part.AddModule(module);
                }
                else
                {
                    part = new TCAPart(module.PartName);
                    part.AddModule(module);
                    TechTreeParts.Add(part.Name, part);
                }
            }

                        #if DEBUG
            Utils.Log("\nTCA Modules in the ModulesDatabase:\n{}",
                      RegisteredModules.Aggregate("", (s, t) => s + t.Value + "\n\n"));
            Utils.Log("Pipeline: {}", Pipeline.Aggregate("", (s, t) => s + t.Name + "->"));
            Utils.Log("AP Pipeline: {}", Pipeline.Where(m => m.IsSubclassOf(typeof(AutopilotModule))).Aggregate("", (s, t) => s + t.Name + "->"));
            File.WriteAllText("ModuleDatabase.csv",
                              RegisteredModules.Aggregate("", (s, t) => s + t.Value.ToCSV() + "\n"));
                        #endif
        }
        public static ModuleMeta GetModuleMeta(Type t)
        {
            ModuleMeta meta = null;

            return(RegisteredModules.TryGetValue(t, out meta)? meta : null);
        }