bool GetCFG() { var ship = EditorLogic.fetch.ship; var TCA_Modules = ModuleTCA.AllTCA(ship); if (TCA_Modules.Count == 0) { Reset(); return(false); } CFG = null; foreach (var tca in TCA_Modules) { if (tca.CFG == null) { continue; } CFG = NamedConfig.FromVesselConfig(ship.shipName, tca.CFG); break; } if (CFG == null) { CFG = NamedConfig.FromVesselConfig(ship.shipName, TCAScenario.GetDefaultConfig(ship.shipFacility)); if (CFG.EnginesProfiles.Empty) { CFG.EnginesProfiles.AddProfile(Engines); } } else { CFG.ActiveProfile.Apply(Engines); } UpdateCFG(TCA_Modules); return(true); }
bool GetCFG(ShipConstruct ship) { var TCA_Modules = ModuleTCA.AllTCA(ship); if (TCA_Modules.Count == 0) { Reset(); return(false); } CFG = null; foreach (var tca in TCA_Modules) { if (tca.CFG == null) { continue; } CFG = NamedConfig.FromVesselConfig(ship.shipName, tca.CFG); break; } if (CFG == null) { CFG = new NamedConfig(ship.shipName); CFG.EnginesProfiles.AddProfile(Engines); } else { CFG.ActiveProfile.Apply(Engines); } CFG.ActiveProfile.Update(Engines); UpdateCFG(TCA_Modules); return(true); }
public static bool SaveNamedConfig(string name, VesselConfig config, bool overwrite = false) { if (name == string.Empty || //do not allow empty name NamedConfigs.ContainsKey(name) && !overwrite) { return(false); } NamedConfigs[name] = NamedConfig.FromVesselConfig(name, config); return(true); }