Ejemplo n.º 1
0
        public override void OnFixedUpdate()
        {
            CelestialBody body = vessel.mainBody;
            ORSX_PlanetaryResourcePixel res_pixel =
                ORSX_PlanetaryResourceMapData.getResourceAvailability(vessel.mainBody.flightGlobalsIndex, resourceName,
                                                                      body.GetLatitude(vessel.transform.position), body.GetLongitude(vessel.transform.position));

            abundance = res_pixel.getAmount();
        }
Ejemplo n.º 2
0
 private void CheckHotSpotDisplay()
 {
     if (ORSX_PlanetaryResourceMapData.resourceIsDisplayed(resourceName))
     {
         ToggleEvent("DisplayResource", false);
         ToggleEvent("HideResource", true);
     }
     else
     {
         ToggleEvent("DisplayResource", true);
         ToggleEvent("HideResource", false);
     }
     ORSX_PlanetaryResourceMapData.updatePlanetaryResourceMap();
 }
 public override void OnUpdate()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         double resource_abundance = 0;
         bool   resource_available = false;
         if (vessel.Landed)
         {
             ORSX_PlanetaryResourcePixel current_resource_abundance_pixel = ORSX_PlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(vessel.mainBody.flightGlobalsIndex, resourceName, vessel.latitude, vessel.longitude);
             resource_abundance = current_resource_abundance_pixel.getAmount();
         }
         else if (vessel.Splashed)
         {
             resource_abundance = ORSX_OceanicResourceHandler.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 OnFixedUpdate()
        {
            if (IsEnabled)
            {
                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;
                }

                /** RAILS **/
                if (Time.timeSinceLevelLoad < 1.0f || !FlightGlobals.ready)
                {
                    return;
                }

                if (lastUpdateTime == 0.0f)
                {
                    // Just started running
                    lastUpdateTime = Planetarium.GetUniversalTime();
                    return;
                }

                double deltaTime = Math.Min(Planetarium.GetUniversalTime() - lastUpdateTime, Utilities.MaxDeltaTime);
                lastUpdateTime += deltaTime;
                /** RAILS **/


                double electrical_power_provided = 0;
                double desiredPower = power_requirements * TimeWarp.fixedDeltaTime;
                double maxPower     = power_requirements * Math.Max(Utilities.ElectricityMaxDeltaTime, TimeWarp.fixedDeltaTime);

                var powerRequested = Math.Min(desiredPower, maxPower);


                electrical_power_provided = part.RequestResource(resourceToUse, powerRequested);
                if (power_requirements > 0)
                {
                    electrical_power_ratio = electrical_power_provided / desiredPower;
                }
                else
                {
                    if (power_requirements < 0)
                    {
                        IsEnabled = false;
                        return;
                    }
                    else
                    {
                        electrical_power_ratio = 1;
                    }
                }
                double resource_abundance = 0;
                if (vessel.Landed)
                {
                    ORSX_PlanetaryResourcePixel current_resource_abundance_pixel = ORSX_PlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(vessel.mainBody.flightGlobalsIndex, resourceName, vessel.latitude, vessel.longitude);
                    resource_abundance = current_resource_abundance_pixel.getAmount();
                }
                else if (vessel.Splashed)
                {
                    resource_abundance = ORSX_OceanicResourceHandler.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 = -ORSX_Helper.fixedRequestResource(part, resourceName, -extraction_rate / resource_density * deltaTime) / deltaTime;
                }
                else
                {
                    IsEnabled = false;
                }
            }
        }
Ejemplo n.º 5
0
 public void HideResource()
 {
     ORSX_PlanetaryResourceMapData.setDisplayedResource("");
     isActive = false;
 }
Ejemplo n.º 6
0
 public void DisplayResource()
 {
     ORSX_PlanetaryResourceMapData.setDisplayedResource(resourceName);
     isActive = true;
 }