示例#1
0
        public static List <ORSAtmosphericResource> getAtmosphericCompositionForBody(int refBody)
        {
            List <ORSAtmosphericResource> bodyAtmosphericComposition = new List <ORSAtmosphericResource>();

            try {
                if (body_atmospheric_resource_list.ContainsKey(refBody))
                {
                    return(body_atmospheric_resource_list[refBody]);
                }
                else
                {
                    ConfigNode[] bodyAtmosphericResourceList = GameDatabase.Instance.GetConfigNodes("ATMOSPHERIC_RESOURCE_DEFINITION").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");
                        ORSAtmosphericResource bodyAtmosphericResource = new ORSAtmosphericResource(resourcename, resourceabundance, displayname);
                        bodyAtmosphericComposition.Add(bodyAtmosphericResource);
                    }
                    if (bodyAtmosphericComposition.Count > 1)
                    {
                        bodyAtmosphericComposition = bodyAtmosphericComposition.OrderByDescending(bacd => bacd.getResourceAbundance()).ToList();
                    }
                }
            } catch (Exception ex) {
            }
            return(bodyAtmosphericComposition);
        }
示例#2
0
        public static double getAtmosphericResourceContentByDisplayName(int refBody, string resourcename)
        {
            List <ORSAtmosphericResource> bodyAtmosphericComposition = getAtmosphericCompositionForBody(refBody);
            ORSAtmosphericResource        resource = bodyAtmosphericComposition.FirstOrDefault(oor => oor.getDisplayName() == resourcename);

            return(resource != null?resource.getResourceAbundance() : 0);
        }
        public static List<ORSAtmosphericResource> getAtmosphericCompositionForBody(int refBody) {
            List<ORSAtmosphericResource> bodyAtmosphericComposition = new List<ORSAtmosphericResource>();
            try {
                if (body_atmospheric_resource_list.ContainsKey(refBody)) {
                    return body_atmospheric_resource_list[refBody];
                } else {
                    ConfigNode[] bodyAtmosphericResourceList = GameDatabase.Instance.GetConfigNodes("ATMOSPHERIC_RESOURCE_DEFINITION").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");
                        ORSAtmosphericResource bodyAtmosphericResource = new ORSAtmosphericResource(resourcename, resourceabundance, displayname);
                        bodyAtmosphericComposition.Add(bodyAtmosphericResource);
                    }
                    if (bodyAtmosphericComposition.Count > 1) {
                        bodyAtmosphericComposition = bodyAtmosphericComposition.OrderByDescending(bacd => bacd.getResourceAbundance()).ToList();
                    }
                }
            } catch (Exception ex) {

            }
            return bodyAtmosphericComposition;
        }