private void LoadMod(Type modClass) { TerraTechMod mod = EnsureModInstance(modClass); Console.WriteLine($"Loading mod: {mod.Name} (v{mod.Version})"); mod.Load(); }
private string GetModConfigFilePath(TerraTechMod mod) { string configName = mod.Name; if (configName == null) { throw new ArgumentException("TerraTechMod.Name is null", nameof(mod)); } configName = configName.ToLower(); string path = Path.Combine(Folder, configName) + FileExtension; return(path); }
public JObject LoadModConfig(TerraTechMod mod) { if (mod == null) { throw new ArgumentNullException(nameof(mod)); } string path = GetModConfigFilePath(mod); if (File.Exists(path)) { string json = File.ReadAllText(path); return(JObject.Parse(json)); } else { JObject fallback = mod.CreateDefaultConfiguration(); File.WriteAllText(path, fallback.ToString(Formatting.Indented)); return(fallback); } }