private static bool SetupTech() { if (HighLogic.CurrentGame == null) { return(false); } // Cache the tech tree if (allTech == null) { ConfigNode techTreeRoot = ConfigNode.Load(HighLogic.CurrentGame.Parameters.Career.TechTreeUrl); ConfigNode techTree = null; if (techTreeRoot != null) { techTree = techTreeRoot.GetNode("TechTree"); } if (techTreeRoot == null || techTree == null) { LoggingUtil.LogError(typeof(Tech), "Couldn't load tech tree from " + HighLogic.CurrentGame.Parameters.Career.TechTreeUrl); return(false); } allTech = new Dictionary <string, Tech>(); foreach (ConfigNode techNode in techTree.GetNodes("RDNode")) { Tech current = new Tech(techNode.GetValue("id")); current.title = ConfigNodeUtil.ParseValue <string>(techNode, "title"); current.description = ConfigNodeUtil.ParseValue <string>(techNode, "description"); current.cost = ConfigNodeUtil.ParseValue <float>(techNode, "cost"); current.anyToUnlock = ConfigNodeUtil.ParseValue <bool>(techNode, "anyToUnlock"); bool hasParent = false; foreach (ConfigNode parentNode in techNode.GetNodes("Parent")) { string parentID = parentNode.GetValue("parentID"); if (allTech.ContainsKey(parentID)) { hasParent = true; allTech[parentID].children.Add(current); current.level = allTech[parentID].level + 1; } } if (!hasParent) { current.level = 0; } allTech[current.techID] = current; } } return(true); }
public override bool Equals(object obj) { if (obj == null) { return(false); } Tech otherTech = obj as Tech; if (otherTech == null) { return(false); } return(techID.Equals(otherTech.techID)); }
protected override string RequirementText() { string techStr = ""; for (int i = 0; i < techs.Count; i++) { if (i != 0) { if (i == techs.Count - 1) { techStr += " and "; } else { techStr += ", "; } } techStr += Tech.GetTech(techs[i]).title; } return("Must " + (invertRequirement ? "not " : "") + " be able to research (or have already researched) " + techStr); }
protected override string RequirementText() { // Techs if (techs.Count > 0) { return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.tech.x" : "#cc.req.TechResearched.tech", LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, techs, x => { Tech t = Tech.GetTech(x); return t != null ? t.title : x; }))); } // Part module if (partModules.Count > 0) { return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.part.x" : "#cc.req.TechResearched.part", LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModules, x => Parameters.PartValidation.ModuleName(x)))); } // Part module type return(Localizer.Format(invertRequirement ? "#cc.req.TechResearched.part.x" : "#cc.req.TechResearched.part", LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.AND : LocalizationUtil.Conjunction.OR, partModuleTypes, x => Parameters.PartValidation.ModuleTypeName(x)))); }
private static bool SetupTech() { if (HighLogic.CurrentGame == null) { return false; } // Cache the tech tree if (allTech == null) { ConfigNode techTreeRoot = ConfigNode.Load(HighLogic.CurrentGame.Parameters.Career.TechTreeUrl); ConfigNode techTree = null; if (techTreeRoot != null) { techTree = techTreeRoot.GetNode("TechTree"); } if (techTreeRoot == null || techTree == null) { LoggingUtil.LogError(typeof(Tech), "Couldn't load tech tree from " + HighLogic.CurrentGame.Parameters.Career.TechTreeUrl); return false; } allTech = new Dictionary<string, Tech>(); foreach (ConfigNode techNode in techTree.GetNodes("RDNode")) { Tech current = new Tech(techNode.GetValue("id")); current.title = ConfigNodeUtil.ParseValue<string>(techNode, "title"); current.description = ConfigNodeUtil.ParseValue<string>(techNode, "description"); current.cost = ConfigNodeUtil.ParseValue<float>(techNode, "cost"); current.anyToUnlock = ConfigNodeUtil.ParseValue<bool>(techNode, "anyToUnlock"); bool hasParent = false; foreach (ConfigNode parentNode in techNode.GetNodes("Parent")) { string parentID = parentNode.GetValue("parentID"); if (allTech.ContainsKey(parentID)) { hasParent = true; allTech[parentID].children.Add(current); current.level = allTech[parentID].level + 1; } } if (!hasParent) { current.level = 0; } allTech[current.techID] = current; } } return true; }
protected override string RequirementText() { // Techs string techStr = ""; for (int i = 0; i < techs.Count; i++) { if (i != 0) { if (i == techs.Count - 1) { techStr += " and "; } else { techStr += ", "; } } techStr += Tech.GetTech(techs[i]).title; } if (techs.Count > 0) { techStr = "have researched " + techStr; } // Part module string pmStr = ""; for (int i = 0; i < partModules.Count; i++) { if (i != 0) { if (i == partModules.Count - 1) { pmStr += " and "; } else { pmStr += ", "; } } pmStr += partModules[i]; } if (partModules.Count > 0) { if (techs.Count > 0) { techStr += " and"; } pmStr = " have researched tech for " + pmStr; } // Part module type string pmtStr = ""; for (int i = 0; i < partModuleTypes.Count; i++) { if (i != 0) { if (i == partModuleTypes.Count - 1) { pmtStr += " and "; } else { pmtStr += ", "; } } pmtStr += partModuleTypes[i]; } if (partModuleTypes.Count > 0) { if (techs.Count > 0 || partModules.Count > 0) { pmStr += " and"; } pmtStr = " have researched tech for " + pmtStr; } return("Must " + (invertRequirement ? "not " : "") + techStr + pmStr + pmtStr); }
protected override string RequirementText() { string techStr = LocalizationUtil.LocalizeList <string>(invertRequirement ? LocalizationUtil.Conjunction.OR : LocalizationUtil.Conjunction.AND, techs, t => Tech.GetTech(t).title); return(Localizer.Format(invertRequirement ? "#cc.req.CanResearchTech.x" : "#cc.req.CanResearchTech", techStr)); }