private void updateFuelSetup(int index) { for (int i1 = RTGFuelConfigList.Count - 1; i1 >= 0; i1--) { RTGFuelConfig possibleFuel = RTGFuelConfigList[i1]; var resources = this.part.Resources; for (int i = this.part.Resources.Count - 1; i >= 0; i--) { PartResource r = this.part.Resources[i]; if (r.resourceName == possibleFuel.resourceName) { resources.Remove(r); } } } RTGFuelConfig config = RTGFuelConfigList[index]; this.fuelName = config.resourceName; this.fuelHalflife = config.halflife; this.fuelPep = config.pep; this.fuelDensity = config.density; ConfigNode resourceNode = new ConfigNode("RESOURCE"); resourceNode.AddValue("name", this.fuelName); resourceNode.AddValue("maxAmount", this.volume); resourceNode.AddValue("amount", this.volume); resourceNode.AddValue("isTweakable", false); this.part.AddResource(resourceNode); this.mass = this.part.mass + this.part.GetResourceMass(); this.updateUIOutput(this.fuelPep, this.volume * this.fuelDensity); }
private static void PopulateFuelNames() { string[] names = new string[RTGFuelConfigList.Count]; for (int i = RTGFuelConfigList.Count - 1; i >= 0; i--) { RTGFuelConfig r = RTGFuelConfigList[i]; //names[i] = r.resourceName; names[i] = r.resourceAbbr; } FuelNames = names; }
public override string GetInfo() { StringBuilder sb = new StringBuilder(); sb.Append("Output decays over time.\n\n"); sb.Append(String.Format("Efficiency: {0:##.##}%\n", this.efficiency * 100)); sb.Append(String.Format("Volume: {0:####.##} dL\n\n", this.volume)); if (RTGFuelConfigList == null) { ReadCustomConfigs(); } sb.Append("<color=#99FF00>Available fuels:</color>"); for (int i = RTGFuelConfigList.Count - 1; i >= 0; i--) { RTGFuelConfig c = RTGFuelConfigList[i]; sb.Append("\n <color=#FF6600>" + c.resourceName + "</color>\n"); sb.Append(" half-life: " + c.halflife + " years\n"); sb.Append(" " + PowerDensityLabel + ": " + (c.pep * PowerDensityFactor) + " " + PowerDensityUnits); } return(sb.ToString()); }
private static List <RTGFuelConfig> GetRTGFuelConfigs(ConfigNode[] database_rtgfuelnodes) { Log.Info("Reading RTG Fuel configs..."); List <RTGFuelConfig> config_list = new List <RTGFuelConfig>(); List <string> seen_resources = new List <string>(); foreach (ConfigNode node in database_rtgfuelnodes) { try { RTGFuelConfig c = new RTGFuelConfig(node); if (!seen_resources.Contains(c.resourceName)) { config_list.Add(c); seen_resources.Add(c.resourceName); } } catch (Exception e) { Debug.LogError("[JDimRTG] Could not load RTGFUELCONFIG:\n" + e.ToString()); } } return(config_list); }