Exemplo n.º 1
0
        public static void loadPlanetaryResourceData(int body)
        {
            string celestial_body_name = FlightGlobals.Bodies[body].bodyName;

            UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("PLANETARY_RESOURCE_DEFINITION");
            Debug.Log("[ORS] Loading Planetary Resource Data. Length: " + configs.Length);
            foreach (ORSHeatMapOverlay abundance_marker in abundance_markers)
            {
                removeAbundanceSphere(abundance_marker.getPlanetarySphere());
                removeAbundanceSphere(abundance_marker.getScaledSphere());
            }
            sphere         = null;
            sphere_texture = null;
            body_resource_maps.Clear();
            body_abudnance_angles.Clear();
            map_body     = -1;
            current_body = -1;
            foreach (UrlDir.UrlConfig config in configs)
            {
                ConfigNode planetary_resource_config_node = config.config;
                if (planetary_resource_config_node.GetValue("celestialBodyName") == celestial_body_name && planetary_resource_config_node != null)
                {
                    Debug.Log("[ORS] Loading Planetary Resource Data for " + celestial_body_name);
                    Texture2D map = GameDatabase.Instance.GetTexture(planetary_resource_config_node.GetValue("mapUrl"), false);
                    if (map == null)
                    {
                        continue;
                    }
                    string         resource_gui_name = planetary_resource_config_node.GetValue("name");
                    ORSHeatMapInfo resource_info     = new ORSHeatMapInfo(resource_gui_name, map, body);
                    if (planetary_resource_config_node.HasValue("resourceName"))
                    {
                        string resource_name = planetary_resource_config_node.GetValue("resourceName");
                        resource_info.setResourceName(resource_name);
                    }
                    if (planetary_resource_config_node.HasValue("resourceScale"))
                    {
                        string resource_scale = planetary_resource_config_node.GetValue("resourceScale");
                        resource_info.setResourceScale(resource_scale);
                    }
                    if (planetary_resource_config_node.HasValue("scaleFactor"))
                    {
                        string scale_factorstr = planetary_resource_config_node.GetValue("scaleFactor");
                        double scale_factor    = double.Parse(scale_factorstr);
                        resource_info.setScaleFactor(scale_factor);
                    }
                    if (planetary_resource_config_node.HasValue("scaleMultiplier"))
                    {
                        string scale_multstr = planetary_resource_config_node.GetValue("scaleMultiplier");
                        double scale_mult    = double.Parse(scale_multstr);
                        resource_info.setScaleMultiplier(scale_mult);
                    }
                    //if (planetary_resource_config_node.HasValue("displayTexture"))
                    //{
                    //    string tex_path = planetary_resource_config_node.GetValue("displayTexture");
                    //    resource_info.setDisplayTexture(tex_path);
                    //}
                    //else
                    //{
                    //    string tex_path = planetary_resource_config_node.GetValue("WarpPlugin/resource_point");
                    //    resource_info.setDisplayTexture(tex_path);
                    //}
                    string tex_path = planetary_resource_config_node.GetValue("mapUrl");
                    resource_info.setDisplayTexture(tex_path);
                    if (planetary_resource_config_node.HasValue("displayThreshold"))
                    {
                        string display_threshold_str = planetary_resource_config_node.GetValue("displayThreshold");
                        double display_threshold     = double.Parse(display_threshold_str);
                        resource_info.setDisplayThreshold(display_threshold);
                    }
                    body_resource_maps.Add(resource_gui_name, resource_info);
                    List <Vector2d> abundance_points_list = new List <Vector2d>();

                    //for (int i = 0; i < map.height; ++i)
                    //{
                    //    for (int j = 0; j < map.width; ++j)
                    //    {
                    //        if (getPixelAbundanceValue(j, i, resource_info) >= resource_info.getDisplayThreshold())
                    //        {
                    //            //high value location, mark it
                    //            double theta = (j - map.width / 2) * 2.0 * 180.0 / map.width;
                    //            double phi = (i - map.height / 2) * 2.0 * 90.0 / map.height;
                    //            Vector2d angles = new Vector2d(theta, phi);
                    //            //body_abudnance_angles.Add(resource_gui_name, angles);
                    //            abundance_points_list.Add(angles);
                    //        }
                    //    }
                    //}
                    //TEMP
                    abundance_points_list.Add(new Vector2d(90, 0));


                    body_abudnance_angles.Add(resource_gui_name, abundance_points_list.ToArray());
                    Debug.Log("[ORS] " + abundance_points_list.Count + " high value " + resource_gui_name + " locations detected");
                }
            }
            current_body = body;
        }
Exemplo n.º 2
0
        public static void loadPlanetaryResourceData(int body)
        {
            string celestial_body_name = FlightGlobals.Bodies[body].bodyName;
            UrlDir.UrlConfig[] configs = GameDatabase.Instance.GetConfigs("PLANETARY_RESOURCE_DEFINITION");
            Debug.Log("[ORS] Loading Planetary Resource Data. Length: " + configs.Length);
            foreach (ORSHeatMapOverlay abundance_marker in abundance_markers)
            {
                removeAbundanceSphere(abundance_marker.getPlanetarySphere());
                removeAbundanceSphere(abundance_marker.getScaledSphere());
            }
            sphere = null;
            sphere_texture = null;
            body_resource_maps.Clear();
            body_abudnance_angles.Clear();
            map_body = -1;
            current_body = -1;
            foreach (UrlDir.UrlConfig config in configs)
            {
                ConfigNode planetary_resource_config_node = config.config;
                if (planetary_resource_config_node.GetValue("celestialBodyName") == celestial_body_name && planetary_resource_config_node != null)
                {
                    Debug.Log("[ORS] Loading Planetary Resource Data for " + celestial_body_name);
                    Texture2D map = GameDatabase.Instance.GetTexture(planetary_resource_config_node.GetValue("mapUrl"), false);
                    if (map == null)
                    {
                        continue;
                    }
                    string resource_gui_name = planetary_resource_config_node.GetValue("name");
                    ORSHeatMapInfo resource_info = new ORSHeatMapInfo(resource_gui_name, map, body);
                    if (planetary_resource_config_node.HasValue("resourceName"))
                    {
                        string resource_name = planetary_resource_config_node.GetValue("resourceName");
                        resource_info.setResourceName(resource_name);
                    }
                    if (planetary_resource_config_node.HasValue("resourceScale"))
                    {
                        string resource_scale = planetary_resource_config_node.GetValue("resourceScale");
                        resource_info.setResourceScale(resource_scale);
                    }
                    if (planetary_resource_config_node.HasValue("scaleFactor"))
                    {
                        string scale_factorstr = planetary_resource_config_node.GetValue("scaleFactor");
                        double scale_factor = double.Parse(scale_factorstr);
                        resource_info.setScaleFactor(scale_factor);
                    }
                    if (planetary_resource_config_node.HasValue("scaleMultiplier"))
                    {
                        string scale_multstr = planetary_resource_config_node.GetValue("scaleMultiplier");
                        double scale_mult = double.Parse(scale_multstr);
                        resource_info.setScaleMultiplier(scale_mult);
                    }
                    //if (planetary_resource_config_node.HasValue("displayTexture"))
                    //{
                    //    string tex_path = planetary_resource_config_node.GetValue("displayTexture");
                    //    resource_info.setDisplayTexture(tex_path);
                    //}
                    //else
                    //{
                    //    string tex_path = planetary_resource_config_node.GetValue("WarpPlugin/resource_point");
                    //    resource_info.setDisplayTexture(tex_path);
                    //}
                    string tex_path = planetary_resource_config_node.GetValue("mapUrl");
                    resource_info.setDisplayTexture(tex_path);
                    if (planetary_resource_config_node.HasValue("displayThreshold"))
                    {
                        string display_threshold_str = planetary_resource_config_node.GetValue("displayThreshold");
                        double display_threshold = double.Parse(display_threshold_str);
                        resource_info.setDisplayThreshold(display_threshold);
                    }
                    body_resource_maps.Add(resource_gui_name, resource_info);
                    List<Vector2d> abundance_points_list = new List<Vector2d>();

                    //for (int i = 0; i < map.height; ++i)
                    //{
                    //    for (int j = 0; j < map.width; ++j)
                    //    {
                    //        if (getPixelAbundanceValue(j, i, resource_info) >= resource_info.getDisplayThreshold())
                    //        {
                    //            //high value location, mark it
                    //            double theta = (j - map.width / 2) * 2.0 * 180.0 / map.width;
                    //            double phi = (i - map.height / 2) * 2.0 * 90.0 / map.height;
                    //            Vector2d angles = new Vector2d(theta, phi);
                    //            //body_abudnance_angles.Add(resource_gui_name, angles);
                    //            abundance_points_list.Add(angles);
                    //        }
                    //    }
                    //}
                    //TEMP
                    abundance_points_list.Add(new Vector2d(90,0));

                    body_abudnance_angles.Add(resource_gui_name, abundance_points_list.ToArray());
                    Debug.Log("[ORS] " + abundance_points_list.Count + " high value " + resource_gui_name + " locations detected");
                }
            }
            current_body = body;
        }