public static bool UpgradeAvailable(string id) { if (string.IsNullOrEmpty(id)) { return(false); } if (id == "true" || id == "always") { return(true); } if (id == "false" || id == "none") { return(false); } if (PartUpgradeByName.TryGetValue(id, out var partUpgrade)) { id = partUpgrade.techRequired; } if (HighLogic.CurrentGame != null) { return(!TechnologyIsInUse || HasTech(id)); } else { return(true); } }
public static string GetTechTitleById(string id) { if (string.IsNullOrEmpty(id)) { return(id); } var result = ResearchAndDevelopment.GetTechnologyTitle(id); if (!string.IsNullOrEmpty(result)) { return(result); } if (PartUpgradeByName.TryGetValue(id, out var partUpgrade)) { if (partUpgrade != null && !string.IsNullOrEmpty(partUpgrade.techRequired)) { if (RDTechByName.TryGetValue(partUpgrade.techRequired, out var upgradeTechNode)) { return(upgradeTechNode?.title); } } else if (partUpgrade == null) { Debug.LogError("[KSPI]: GetTechTitleById - partUpgrade is null"); } else { Debug.LogError("[KSPI]: GetTechTitleById - partUpgrade.techRequired is null"); } } if (RDTechByName.TryGetValue(id, out var techNode)) { return(techNode.title); } return(id); }