public void Save(ConfigNode node)
        {
            if (node.HasNode("KONSTRUCTION_SETTINGS"))
            {
                SettingsNode = node.GetNode("KONSTRUCTION_SETTINGS");
            }
            else
            {
                SettingsNode = node.AddNode("KONSTRUCTION_SETTINGS");
            }

            if (_settings == null)
            {
                _settings = LoadKonstructionConfig();
            }

            if (_moduleResources != null)
            {
                var count = _moduleResources.Count;
                for (int i = 0; i < count; ++i)
                {
                    var r     = _moduleResources[i];
                    var rNode = new ConfigNode("KONSTRUCTION_MODULE_COST");
                    rNode.AddValue("moduleName", r.moduleName);
                    rNode.AddValue("resourceName", r.resourceName);
                    rNode.AddValue("massMultiplier", r.massMultiplier);
                    SettingsNode.AddNode(rNode);
                }
            }

            if (_costResources != null)
            {
                var count = _costResources.Count;
                for (int i = 0; i < count; ++i)
                {
                    var r     = _costResources[i];
                    var rNode = new ConfigNode("KONSTRUCTION_COST_RESOURCE");
                    rNode.AddValue("resourceName", r.resourceName);
                    rNode.AddValue("maxMass", r.maxMass);
                    SettingsNode.AddNode(rNode);
                }
            }

            if (_settings != null)
            {
                var sNode = new ConfigNode("KONSTRUCTION_SETTINGS");
                sNode.AddValue("massResourceName", _settings.massResourceName);
                sNode.AddValue("massMultiplier", _settings.massMultiplier);
                sNode.AddValue("costResourceName", _settings.costResourceName);
                SettingsNode.AddNode(sNode);
            }
        }
 public void Load(ConfigNode node)
 {
     if (node.HasNode("KONSTRUCTION_SETTINGS"))
     {
         SettingsNode     = node.GetNode("KONSTRUCTION_SETTINGS");
         _moduleResources = LoadModuleResources();
         _costResources   = LoadCostResources();
         _settings        = LoadKonstructionConfig();
     }
     else
     {
         _moduleResources = new List <KonstructionModuleResource>();
         _costResources   = new List <KonstructionCostResource>();
         _settings        = null;
     }
 }
        private KonstructionConfig LoadKonstructionConfig()
        {
            var kNodes        = GameDatabase.Instance.GetConfigNodes("KONSTRUCTION_SETTINGS");
            var finalSettings = new KonstructionConfig
            {
                massResourceName = "MaterialKits",
                massMultiplier   = 2,
                costResourceName = "SpecializedParts"
            };

            foreach (var node in kNodes)
            {
                var settings = ResourceUtilities.LoadNodeProperties <KonstructionConfig>(node);
                finalSettings.massResourceName = settings.massResourceName;
                finalSettings.massMultiplier   = settings.massMultiplier;
                finalSettings.costResourceName = settings.costResourceName;
            }
            return(finalSettings);
        }
 public KonstructionConfig GetSettings()
 {
     return(_settings ?? (_settings = LoadKonstructionConfig()));
 }
 public void SaveConfig(KonstructionConfig config)
 {
     _settings.massResourceName = config.massResourceName;
     _settings.massMultiplier   = config.massMultiplier;
     _settings.costResourceName = config.costResourceName;
 }