public virtual void UpdateModList()
        {
            if (!inited)
            {
                gameManager.ConsoleWindow.WriteLine("ModLoader was not initialized, can't update mod list.");
                return;
            }

            modList.Clear();

            // Create a list of the mods we have in the mod directory.
            if (modDirectory.HasMods)
            {
                foreach (string modName in modDirectory.GetModNames())
                {
                    ModInfo mi = new ModInfo();
                    mi.path     = modDirectory.GetModPath(modName);
                    mi.fileName = modName;
                    IModInfo modInfo = modDirectory.GetMod(mi.fileName);
                    mi.modName    = modInfo.NameInfo.ModName;
                    mi.identifier = $"{modInfo.ModAuthor.ToLower()}.{modInfo.NameInfo.ModName.ToLower()}";
                    modList.Add(mi);
                }
            }

            // Add mods from the command line.
            if (Mod.CommandLine.HasMods)
            {
                foreach (Uri modPath in Mod.CommandLine.AllMods)
                {
                    ModInfo mi = new ModInfo();
                    mi.commandLine = true;
                    mi.path        = modPath;
                    mi.fileName    = System.IO.Path.GetFileName(modPath.LocalPath);
                    IModInfo modInfo = ModDirectory.GetMod(new FileInfo(mi.path.LocalPath));
                    mi.modName    = modInfo.NameInfo.ModName;
                    mi.identifier = $"{modInfo.ModAuthor.ToLower()}.{modInfo.NameInfo.ModName.ToLower()}";
                    modList.Add(mi);
                }
            }
        }
        public virtual bool LoadMod(ModInfo modInfo)
        {
            if (loadedMods.ContainsKey(modInfo.identifier))
            {
                gameManager.ConsoleWindow.WriteLine($"Mod {modInfo.identifier} is already loaded.");
                return(false);
            }

            ModHost mod = Mod.Load(modInfo.path);

            try
            {
                if (mod.IsModLoaded)
                {
                    if (mod.Assets.Exists("ModDefinition"))
                    {
                        ModDefinition modDefinition = mod.Assets.Load("ModDefinition") as ModDefinition;
                        loadedMods.Add(modInfo.identifier, mod);
                        modManager.mods.Add(modInfo.identifier, modDefinition);
                        gameManager.ConsoleWindow.WriteLine($"Loaded mod {modInfo.identifier}.");
                        CheckLoadedModList();
                        return(true);
                    }
                    throw new Exception($"No ModDefinition found.");
                }
                throw new Exception($"{mod.LoadResult.Error}");
            }catch (Exception e)
            {
                gameManager.ConsoleWindow.WriteLine($"Failed loading mod {modInfo.identifier}: {e.Message}");
                if (mod.IsModLoaded)
                {
                    mod.UnloadMod();
                }
                CheckLoadedModList();
                return(false);
            }
        }
 public IModInfo GetModInfo(ModInfo modInfo)
 {
     return(ModDirectory.GetMod(new FileInfo(modInfo.path.LocalPath)));
 }