Example #1
0
        private void LoadMod(Type modClass)
        {
            TerraTechMod mod = EnsureModInstance(modClass);

            Console.WriteLine($"Loading mod: {mod.Name} (v{mod.Version})");
            mod.Load();
        }
Example #2
0
        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);
        }
Example #3
0
        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);
            }
        }