public override void OnLoad(ConfigNode node) { base.OnLoad(node); ColonizationResearchScenario.LoadResourcesIfNeeded(); this.categoryToBodyToProgressMap = new Dictionary <ResearchCategory, Dictionary <string, TechProgress> >(); foreach (var category in ColonizationResearchScenario.researchCategories.Values) { if (category.Type == ProductionRestriction.Space) { ConfigNode hydroponicsNode = null; if (node.TryGetNode(category.Name, ref hydroponicsNode) && TryCreateFromNode(hydroponicsNode, out TechProgress hydroponicsProgress)) { this.categoryToBodyToProgressMap.Add( category, new Dictionary <string, TechProgress>() { { "", hydroponicsProgress } }); } } else { ConfigNode childNode = null; if (node.TryGetNode(category.Name, ref childNode) && TryCreateFromNode(childNode, out Dictionary <string, TechProgress> map)) { this.categoryToBodyToProgressMap.Add(category, map); } } } }
public static TieredResource GetTieredResourceByName(string name) { ColonizationResearchScenario.LoadResourcesIfNeeded(); if (!resources.ContainsKey(name)) { throw new Exception($"Key not found: {name}"); } return(ColonizationResearchScenario.resources[name]); }
public override void OnSave(ConfigNode node) { base.OnSave(node); ColonizationResearchScenario.LoadResourcesIfNeeded(); // Update valid bodies if possible if (ProgressTracking.Instance != null && ProgressTracking.Instance.celestialBodyNodes != null) { StringBuilder validBodies = new StringBuilder(); foreach (var body in ProgressTracking.Instance.celestialBodyNodes) { if (body.returnFromSurface != null && body.returnFromSurface.IsComplete) { if (validBodies.Length != 0) { validBodies.Append('|'); } validBodies.Append(body.Id); } } this.unlockedBodies = validBodies.ToString(); } foreach (var category in ColonizationResearchScenario.researchCategories.Values) { if (category.Type == ProductionRestriction.Space && this.categoryToBodyToProgressMap.TryGetValue(category, out var progress) && progress.TryGetValue("", out TechProgress techProgress)) { node.AddNode(category.Name, ToNode(techProgress)); } else if (category.Type != ProductionRestriction.Space && this.categoryToBodyToProgressMap.TryGetValue(category, out var stringToProgressMap)) { node.AddNode(category.Name, ToNode(stringToProgressMap)); } } }
public ColonizationResearchScenario() { Instance = this; }
public TieredResource TryGetTieredResourceByName(string name) { ColonizationResearchScenario.LoadResourcesIfNeeded(); resources.TryGetValue(name, out var resource); return(resource); }
public TechTier GetMaxUnlockedScanningTier(string atBody) { ColonizationResearchScenario.LoadResourcesIfNeeded(); return(this.GetMaxUnlockedTier(ColonizationResearchScenario.resources["ScanningData"], atBody)); }