Ejemplo n.º 1
0
        public override void OnFixedUpdate()
        {
            if (scoopIsEnabled)
            {
                string atmospheric_resource_name = ORSX_AtmosphericResourceHandler.getAtmosphericResourceName(vessel.mainBody.flightGlobalsIndex, currentresource);
                if (atmospheric_resource_name != null)
                {
                    //Common
                    double resourcedensity = PartResourceLibrary.Instance.GetDefinition(atmospheric_resource_name).density;
                    double respcent        = ORSX_AtmosphericResourceHandler.getAtmosphericResourceContent(vessel.mainBody.flightGlobalsIndex, currentresource);

                    double airdensity = part.vessel.atmDensity / 1000;


                    double powerrequirements = scoopair / 0.15f * ecRequirement;
                    double airspeed          = part.vessel.srf_velocity.magnitude + 40.0;
                    double air = airspeed * airdensity * scoopair / resourcedensity;


                    if (respcent > 0 && vessel.altitude <= ORSX_Helper.getMaxAtmosphericAltitude(vessel.mainBody))
                    {
                        double scoopedAtm    = air * respcent;
                        float  powerreceived = (float)Math.Max(part.RequestResource("ElectricCharge", powerrequirements * TimeWarp.fixedDeltaTime), 0);
                        float  powerpcnt     = (float)(powerreceived / powerrequirements / TimeWarp.fixedDeltaTime);
                        resflowf = (float)ORSX_Helper.fixedRequestResource(part, atmospheric_resource_name, -scoopedAtm * powerpcnt * TimeWarp.fixedDeltaTime);

                        resflowf = -resflowf / TimeWarp.fixedDeltaTime;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void OnUpdate()
 {
     Events["ActivateCollector"].active = (!CollectorIsEnabled) && (!isDisabled);
     Events["DisableCollector"].active = (CollectorIsEnabled) && (!isDisabled);
     Events["ToggleResource"].active = (CollectorIsEnabled) && (!isDisabled);
     Fields["resflow"].guiActive = (CollectorIsEnabled) && (!isDisabled);
     Fields["currentresourceStr"].guiActive = (CollectorIsEnabled) && (!isDisabled);
     double respcent = ORSX_AtmosphericResourceHandler.getAtmosphericResourceContent(vessel.mainBody.flightGlobalsIndex, currentresource) * 100;
     string resname = ORSX_AtmosphericResourceHandler.getAtmosphericResourceDisplayName(vessel.mainBody.flightGlobalsIndex, currentresource);
     if (resname != null)
     {
         currentresourceStr = resname + "(" + respcent + "%)";
     }
     resflow = resflowf.ToString("0.0000");
 }
Ejemplo n.º 3
0
        public void ToggleResource()
        {
            currentresource++;


            if (ORSX_AtmosphericResourceHandler.getAtmosphericResourceName(vessel.mainBody.flightGlobalsIndex, currentresource) == null && ORSX_AtmosphericResourceHandler.getAtmosphericResourceContent(vessel.mainBody.flightGlobalsIndex, currentresource) > 0 && currentresource != 0)
            {
                ToggleResource();
            }


            if (currentresource >= ORSX_AtmosphericResourceHandler.getAtmosphericCompositionForBody(vessel.mainBody.flightGlobalsIndex).Count)
            {
                currentresource = 0;
            }
        }
Ejemplo n.º 4
0
        public override void OnFixedUpdate()
        {
            if (CollectorIsEnabled)
            {
                string atmospheric_resource_name = ORSX_AtmosphericResourceHandler.getAtmosphericResourceName(vessel.mainBody.flightGlobalsIndex, currentresource);
                if (atmospheric_resource_name != null)
                {
                    //range is 10% of the atmosphere
                    var range = (ORSX_Helper.getMaxAtmosphericAltitude(vessel.mainBody) * 1.1);
                    range += altitudeBonus;
                    double resourcedensity = PartResourceLibrary.Instance.GetDefinition(atmospheric_resource_name).density;
                    double respcent = ORSX_AtmosphericResourceHandler.getAtmosphericResourceContent(vessel.mainBody.flightGlobalsIndex, currentresource);

                    //If we're in the narrow band of the upper atmosphere
                    if (vessel.altitude <= range 
                        && respcent > 0 
                        && vessel.altitude >= ORSX_Helper.getMaxAtmosphericAltitude(vessel.mainBody))
                    {
                        print("[ORSX] PASS ");
                        /** 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 powerrequirements = particleRate/0.15f*ecRequirement;
                        double desiredPower = powerrequirements * TimeWarp.fixedDeltaTime;
                        double maxPower = powerrequirements * Math.Max(Utilities.ElectricityMaxDeltaTime, TimeWarp.fixedDeltaTime);
                        var powerRequested = Math.Min(desiredPower, maxPower);                        


                        double particles = particleRate/resourcedensity;
                        double CollectedParticles = particles*respcent;
                        float powerreceived =
                            (float)
                                Math.Max(
                                    part.RequestResource("ElectricCharge", powerRequested),
                                    0);
                        float powerpcnt = (float)(powerreceived / desiredPower);
                        resflowf =
                            (float)
                                ORSX_Helper.fixedRequestResource(part, atmospheric_resource_name,
                                    -CollectedParticles*powerpcnt*deltaTime);

                        resflowf = -resflowf/(float)deltaTime;
                    }
                }
            }
        }