public static List <ORSX_AtmosphericResource> getAtmosphericCompositionForBody(int refBody) { List <ORSX_AtmosphericResource> bodyAtmosphericComposition = new List <ORSX_AtmosphericResource>(); try { if (body_atmospheric_resource_list.ContainsKey(refBody)) { return(body_atmospheric_resource_list[refBody]); } else { ConfigNode[] bodyAtmosphericResourceList = GameDatabase.Instance.GetConfigNodes("ORSX_ATMOSPHERIC_RESOURCE").Where(res => res.GetValue("celestialBodyName") == FlightGlobals.Bodies[refBody].name).ToArray(); foreach (ConfigNode bodyAtmosphericConfig in bodyAtmosphericResourceList) { string resourcename = null; if (bodyAtmosphericConfig.HasValue("resourceName")) { resourcename = bodyAtmosphericConfig.GetValue("resourceName"); } double resourceabundance = double.Parse(bodyAtmosphericConfig.GetValue("abundance")); string displayname = bodyAtmosphericConfig.GetValue("guiName"); ORSX_AtmosphericResource bodyAtmosphericResource = new ORSX_AtmosphericResource(resourcename, resourceabundance, displayname); bodyAtmosphericComposition.Add(bodyAtmosphericResource); } if (bodyAtmosphericComposition.Count > 1) { bodyAtmosphericComposition = bodyAtmosphericComposition.OrderByDescending(bacd => bacd.getResourceAbundance()).ToList(); } } } catch (Exception ex) { } return(bodyAtmosphericComposition); }
public static List<ORSX_AtmosphericResource> getAtmosphericCompositionForBody(int refBody) { List<ORSX_AtmosphericResource> bodyAtmosphericComposition = new List<ORSX_AtmosphericResource>(); try { if (body_atmospheric_resource_list.ContainsKey(refBody)) { return body_atmospheric_resource_list[refBody]; } else { ConfigNode[] bodyAtmosphericResourceList = GameDatabase.Instance.GetConfigNodes("ORSX_ATMOSPHERIC_RESOURCE").Where(res => res.GetValue("celestialBodyName") == FlightGlobals.Bodies[refBody].name).ToArray(); foreach (ConfigNode bodyAtmosphericConfig in bodyAtmosphericResourceList) { string resourcename = null; if (bodyAtmosphericConfig.HasValue("resourceName")) { resourcename = bodyAtmosphericConfig.GetValue("resourceName"); } double resourceabundance = double.Parse(bodyAtmosphericConfig.GetValue("abundance")); string displayname = bodyAtmosphericConfig.GetValue("guiName"); ORSX_AtmosphericResource bodyAtmosphericResource = new ORSX_AtmosphericResource(resourcename, resourceabundance, displayname); bodyAtmosphericComposition.Add(bodyAtmosphericResource); } if (bodyAtmosphericComposition.Count > 1) { bodyAtmosphericComposition = bodyAtmosphericComposition.OrderByDescending(bacd => bacd.getResourceAbundance()).ToList(); } } } catch (Exception ex) { } return bodyAtmosphericComposition; }