public bool ConfigUnlocked(string cfgName) { EngineConfigUpgrade cfg = null; if (configUpgrades.TryGetValue(cfgName, out cfg)) { return(cfg.unlocked); } Debug.LogError("*RFUM: ERROR: upgrade " + cfgName + " does not exist!"); return(false); }
public double ConfigSciEntryCost(string cfgName) { EngineConfigUpgrade cfg = null; if (configUpgrades.TryGetValue(cfgName, out cfg)) { return(cfg.SciEntryCost()); } Debug.LogError("*RFUM: ERROR: upgrade " + cfgName + " does not exist!"); return(0d); }
public void SetConfigUnlock(string cfgName, bool newVal) { EngineConfigUpgrade cfg = null; if (configUpgrades.TryGetValue(cfgName, out cfg)) { cfg.unlocked = newVal; } else { Debug.LogError("*RFUM: ERROR: upgrade " + cfgName + " does not exist!"); } }
public double ConfigSciEntryCost(string cfgName) { EngineConfigUpgrade cfg = null; if (configUpgrades.TryGetValue(cfgName, out cfg)) { return(cfg.SciEntryCost()); } else { return(0d); } }
public bool ConfigUnlocked(string cfgName) { EngineConfigUpgrade cfg = null; if (configUpgrades.TryGetValue(cfgName, out cfg)) { return(cfg.unlocked); } else { return(true); } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { foreach (ConfigNode n in node.GetNodes("EngineConfigUpgrade")) { EngineConfigUpgrade eCfg = null; if (n.HasValue("name")) { string cfgName = n.GetValue("name"); if (configUpgrades.TryGetValue(cfgName, out eCfg)) { eCfg.Load(n); } else { eCfg = new EngineConfigUpgrade(n); configUpgrades[cfgName] = eCfg; } } } foreach (ConfigNode n in node.GetNodes("TLUpgrade")) { TLUpgrade tU = null; if (n.HasValue("name")) { string tlName = n.GetValue("name"); if (techLevelUpgrades.TryGetValue(tlName, out tU)) { tU.Load(n); } else { tU = new TLUpgrade(n); techLevelUpgrades[tlName] = tU; } } } } }
public static void FillUpgrades() { if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null) { Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!"); return; } configUpgrades = new Dictionary <string, EngineConfigUpgrade>(); techLevelUpgrades = new Dictionary <string, TLUpgrade>(); for (int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a) { AvailablePart ap = PartLoader.LoadedPartsList[a]; if (ap == null) { continue; } Part part = ap.partPrefab; if (part != null) { if (part.Modules == null) { continue; } for (int i = part.Modules.Count - 1; i >= 0; --i) { PartModule m = part.Modules[i]; if (m is ModuleEngineConfigs) { ModuleEngineConfigs mec = m as ModuleEngineConfigs; mec.CheckConfigs(); for (int j = mec.configs.Count - 1; j >= 0; --j) { ConfigNode cfg = mec.configs[j]; if (cfg.HasValue("name")) { string cfgName = cfg.GetValue("name"); if (RFSettings.Instance.usePartNameInConfigUnlock) { cfgName = Utilities.GetPartName(ap) + cfgName; } // config upgrades EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName); configUpgrades[cfgName] = eConfig; eConfig.unlocked = false; // TL upgrades if (mec.techLevel >= 0) { TLUpgrade tU = new TLUpgrade(cfg, mec); techLevelUpgrades[tU.name] = tU; } } } } } } } }
public static void FillUpgrades() { if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null) { Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!"); return; } configUpgrades = new Dictionary<string, EngineConfigUpgrade>(); techLevelUpgrades = new Dictionary<string, TLUpgrade>(); for(int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a) { AvailablePart ap = PartLoader.LoadedPartsList[a]; if (ap == null) { continue; } Part part = ap.partPrefab; if(part != null) { if (part.Modules == null) continue; for(int i = part.Modules.Count - 1; i >= 0; --i) { PartModule m = part.Modules[i]; if(m is ModuleEngineConfigs) { ModuleEngineConfigs mec = m as ModuleEngineConfigs; mec.CheckConfigs(); for(int j = mec.configs.Count - 1; j >= 0; --j) { ConfigNode cfg = mec.configs[j]; if(cfg.HasValue("name")) { string cfgName = cfg.GetValue("name"); if (RFSettings.Instance.usePartNameInConfigUnlock) cfgName = Utilities.GetPartName(ap) + cfgName; // config upgrades EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName); configUpgrades[cfgName] = eConfig; eConfig.unlocked = false; // TL upgrades if (mec.techLevel >= 0) { TLUpgrade tU = new TLUpgrade(cfg, mec); techLevelUpgrades[tU.name] = tU; } } } } } } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { foreach (ConfigNode n in node.GetNodes("EngineConfigUpgrade")) { EngineConfigUpgrade eCfg = null; if (n.HasValue("name")) { string cfgName = n.GetValue("name"); if (configUpgrades.TryGetValue(cfgName, out eCfg)) eCfg.Load(n); else { eCfg = new EngineConfigUpgrade(n); configUpgrades[cfgName] = eCfg; } } } foreach (ConfigNode n in node.GetNodes("TLUpgrade")) { TLUpgrade tU = null; if (n.HasValue("name")) { string tlName = n.GetValue("name"); if (techLevelUpgrades.TryGetValue(tlName, out tU)) tU.Load(n); else { tU = new TLUpgrade(n); techLevelUpgrades[tlName] = tU; } } } } }
public void FillUpgrades() { if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null) { Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!"); return; } for (int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a) { AvailablePart ap = PartLoader.LoadedPartsList[a]; if (ap == null) { continue; } Part part = ap.partPrefab; if (part != null) { if (part.Modules == null) { continue; } for (int i = part.Modules.Count - 1; i >= 0; --i) { PartModule m = part.Modules[i]; if (m is ModuleEngineConfigs) { ModuleEngineConfigs mec = m as ModuleEngineConfigs; mec.CheckConfigs(); for (int j = mec.configs.Count - 1; j >= 0; --j) { ConfigNode cfg = mec.configs[j]; if (cfg.HasValue("name")) { string cfgName = cfg.GetValue("name"); if (RFSettings.Instance.usePartNameInConfigUnlock) { cfgName = Utilities.GetPartName(ap) + cfgName; } // config upgrades EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName); configUpgrades[cfgName] = eConfig; if (ResearchAndDevelopment.Instance != null && ap.TechRequired != null) { if (ResearchAndDevelopment.PartModelPurchased(ap)) { if (cfg.HasValue("techRequired")) { string tech = cfg.GetValue("techRequired"); if (tech != "" && tech != ap.TechRequired) { continue; } } bool unlocked = false; if (cfg.HasValue("unlocked")) { bool.TryParse(cfg.GetValue("unlocked"), out unlocked); } if (mec.autoUnlock || unlocked) { eConfig.unlocked = true; } } else { eConfig.unlocked = false; } // TL upgrades if (mec.techLevel >= 0) { TLUpgrade tU = new TLUpgrade(cfg, mec); techLevelUpgrades[tU.name] = tU; } } } } } } } } }
public void FillUpgrades() { if (PartLoader.Instance == null || PartLoader.LoadedPartsList == null) { Debug.LogError("*RFUM: ERROR: Partloader instance null or list null!"); return; } for(int a = PartLoader.LoadedPartsList.Count - 1; a >= 0; --a) { AvailablePart ap = PartLoader.LoadedPartsList[a]; if (ap == null) { continue; } Part part = ap.partPrefab; if(part != null) { if (part.Modules == null) continue; for(int i = part.Modules.Count - 1; i >= 0; --i) { PartModule m = part.Modules[i]; if(m is ModuleEngineConfigs) { ModuleEngineConfigs mec = m as ModuleEngineConfigs; mec.CheckConfigs(); for(int j = mec.configs.Count - 1; j >= 0; --j) { ConfigNode cfg = mec.configs[j]; if(cfg.HasValue("name")) { string cfgName = cfg.GetValue("name"); if (RFSettings.Instance.usePartNameInConfigUnlock) cfgName = Utilities.GetPartName(ap) + cfgName; // config upgrades EngineConfigUpgrade eConfig = new EngineConfigUpgrade(cfg, cfgName); configUpgrades[cfgName] = eConfig; if (ResearchAndDevelopment.Instance != null && ap.TechRequired != null) { if(ResearchAndDevelopment.PartModelPurchased(ap)) { if (cfg.HasValue("techRequired")) { string tech = cfg.GetValue("techRequired"); if (tech != "" && tech != ap.TechRequired) continue; } bool unlocked = false; if (cfg.HasValue("unlocked")) bool.TryParse(cfg.GetValue("unlocked"), out unlocked); if (mec.autoUnlock || unlocked) eConfig.unlocked = true; } else eConfig.unlocked = false; // TL upgrades if (mec.techLevel >= 0) { TLUpgrade tU = new TLUpgrade(cfg, mec); techLevelUpgrades[tU.name] = tU; } } } } } } } } }