Пример #1
0
        public override void OnFixedUpdate()
        {
            CelestialBody             body      = vessel.mainBody;
            ORSPlanetaryResourcePixel res_pixel = ORSPlanetaryResourceMapData.getResourceAvailability(vessel.mainBody.flightGlobalsIndex, resourceName, body.GetLatitude(vessel.transform.position), body.GetLongitude(vessel.transform.position));

            abundance = res_pixel.getAmount();
        }
Пример #2
0
 public override void OnUpdate()
 {
     ORSPlanetaryResourceMapData.updatePlanetaryResourceMap();
     if (resourceInfo == null)
     {
         if (ORSPlanetaryResourceMapData.getPlanetaryResourceMapData.ContainsKey(resourceName))
         {
             resourceInfo = ORSPlanetaryResourceMapData.getPlanetaryResourceMapData[resourceName];
         }
     }
     Events["DisplayResource"].active  = Events["DisplayResource"].guiActive = !ORSPlanetaryResourceMapData.resourceIsDisplayed(resourceName) && mapViewAvailable;
     Events["DisplayResource"].guiName = "Display " + resourceName + " hotspots";
     Events["HideResource"].active     = Events["HideResource"].guiActive = ORSPlanetaryResourceMapData.resourceIsDisplayed(resourceName) && mapViewAvailable;
     Events["HideResource"].guiName    = "Hide " + resourceName + " hotspots";
     Fields["Ab"].guiName = resourceName + " abundance";
     if (resourceInfo != null)
     {
         if (resourceInfo.getResourceScale() == 1)
         {
             Ab = (abundance * 100.0).ToString("0.00") + "%";
         }
         else
         {
             Ab = (abundance * 1000000.0).ToString("0.0") + "ppm";
         }
     }
     else
     {
         Ab = "Broken:(";
     }
 }
        public override void OnUpdate()
        {
            //double resource_abundance = 0;
            bool resource_available = false;

            if (vessel.Landed)
            {
                ORSPlanetaryResourcePixel current_resource_abundance_pixel = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(vessel.mainBody.flightGlobalsIndex, resourceName, vessel.latitude, vessel.longitude);
                resource_abundance = (float)current_resource_abundance_pixel.getAmount();
            }
            else if (vessel.checkSplashed())
            {
                resource_abundance = (float)ORSOceanicResourceHandler.getOceanicResourceContent(vessel.mainBody.flightGlobalsIndex, resourceName);
            }

            if (resource_abundance > 0)
            {
                resource_available = true;
            }

            Events["startResourceExtraction"].active = !IsEnabled && resource_available;
            Events["stopResourceExtration"].active   = IsEnabled;

            if (IsEnabled)
            {
                Fields["powerStr"].guiActive     = true;
                Fields["resourceRate"].guiActive = true;
                statusTitle = "Active";

                double power_required = 0;
                if (vessel.Landed)
                {
                    power_required = powerConsumptionLand;
                }
                else if (vessel.Splashed)
                {
                    power_required = powerConsumptionOcean;
                }

                powerStr = (power_required * electrical_power_ratio).ToString("0.000") + " MW / " + power_required.ToString("0.000") + " MW";
                double resource_density       = PartResourceLibrary.Instance.GetDefinition(resourceName).density;
                double resource_rate_per_hour = extraction_rate_d * resource_density * 3600;
                resourceRate = formatMassStr(resource_rate_per_hour);
            }
            else
            {
                Fields["powerStr"].guiActive     = false;
                Fields["resourceRate"].guiActive = false;
                statusTitle = "Offline";
            }
        }
 public override void OnUpdate()
 {
     Events["DisplayResource"].active  = Events["DisplayResource"].guiActive = !ORSPlanetaryResourceMapData.resourceIsDisplayed(resourceName) && mapViewAvailable;
     Events["DisplayResource"].guiName = "Display " + resourceName + " hotspots";
     Events["HideResource"].active     = Events["HideResource"].guiActive = ORSPlanetaryResourceMapData.resourceIsDisplayed(resourceName) && mapViewAvailable;
     Events["HideResource"].guiName    = "Hide " + resourceName + " hotspots";
     Fields["Ab"].guiName = resourceName + " abundance";
     if (abundance > 0.001)
     {
         Ab = (abundance * 100.0).ToString("0.00") + "%";
     }
     else
     {
         Ab = (abundance * 1000000.0).ToString("0.0") + "ppm";
     }
     ORSPlanetaryResourceMapData.updatePlanetaryResourceMap();
 }
Пример #5
0
 public void FixedUpdate()
 {
     if (IsEnabled && HighLogic.LoadedSceneIsFlight)
     {
         double power_requirements = 0;
         double extraction_time    = 0;
         if (vessel.Landed)
         {
             power_requirements = powerConsumptionLand;
             extraction_time    = extractionRateLandPerTon;
         }
         else if (vessel.Splashed)
         {
             power_requirements = powerConsumptionOcean;
             extraction_time    = extractionRateOceanPerTon;
         }
         else
         {
             IsEnabled = false;
             return;
         }
         double electrical_power_provided = 0;
         if (resourceManaged)
         {
             electrical_power_provided = consumeFNResource(power_requirements * TimeWarp.fixedDeltaTime, resourceToUse);
         }
         else
         {
             electrical_power_provided = part.RequestResource(resourceToUse, power_requirements * TimeWarp.fixedDeltaTime);
         }
         if (power_requirements > 0)
         {
             electrical_power_ratio = electrical_power_provided / TimeWarp.fixedDeltaTime / power_requirements;
         }
         else
         {
             if (power_requirements < 0)
             {
                 IsEnabled = false;
                 return;
             }
             else
             {
                 electrical_power_ratio = 1;
             }
         }
         double resource_abundance = 0;
         if (vessel.Landed)
         {
             ORSPlanetaryResourcePixel current_resource_abundance_pixel = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(vessel.mainBody.flightGlobalsIndex, resourceName, vessel.latitude, vessel.longitude);
             resource_abundance = current_resource_abundance_pixel.getAmount();
         }
         else if (vessel.Splashed)
         {
             resource_abundance = ORSOceanicResourceHandler.getOceanicResourceContent(vessel.mainBody.flightGlobalsIndex, resourceName);
         }
         double extraction_rate = resource_abundance * extraction_time * electrical_power_ratio;
         if (resource_abundance > 0)
         {
             double resource_density = PartResourceLibrary.Instance.GetDefinition(resourceName).density;
             //extraction_rate_d = -part.RequestResource(resourceName, -extraction_rate / resource_density * TimeWarp.fixedDeltaTime) / TimeWarp.fixedDeltaTime;
             extraction_rate_d = -ORSHelper.fixedRequestResource(part, resourceName, -extraction_rate / resource_density * TimeWarp.fixedDeltaTime) / TimeWarp.fixedDeltaTime;
         }
         else
         {
             IsEnabled = false;
         }
     }
 }
Пример #6
0
 public void HideResource()
 {
     ORSPlanetaryResourceMapData.setDisplayedResource("");
 }
Пример #7
0
 public void DisplayResource()
 {
     ORSPlanetaryResourceMapData.setDisplayedResource(resourceName);
 }