public override void OnFixedUpdate() { if (scoopIsEnabled) { string atmospheric_resource_name = ORSAtmosphericResourceHandler.getAtmosphericResourceName(vessel.mainBody.flightGlobalsIndex, currentresource); if (atmospheric_resource_name != null) { //Common double resourcedensity = PartResourceLibrary.Instance.GetDefinition(atmospheric_resource_name).density; double respcent = ORSAtmosphericResourceHandler.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 <= ORSHelper.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)ORSHelper.fixedRequestResource(part, atmospheric_resource_name, -scoopedAtm * powerpcnt * TimeWarp.fixedDeltaTime); resflowf = -resflowf / TimeWarp.fixedDeltaTime; } } } }
public override void OnFixedUpdate() { if (CollectorIsEnabled) { string atmospheric_resource_name = ORSAtmosphericResourceHandler.getAtmosphericResourceName(vessel.mainBody.flightGlobalsIndex, currentresource); if (atmospheric_resource_name != null) { //range is 10% of the atmosphere var range = ORSHelper.getMaxAtmosphericAltitude(vessel.mainBody) * 1.1; double resourcedensity = PartResourceLibrary.Instance.GetDefinition(atmospheric_resource_name).density; double respcent = ORSAtmosphericResourceHandler.getAtmosphericResourceContent(vessel.mainBody.flightGlobalsIndex, currentresource); //If we're in the narrow band of the upper atmosphere if (vessel.altitude <= range && respcent > 0 && vessel.altitude >= ORSHelper.getMaxAtmosphericAltitude(vessel.mainBody)) { /** 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) ORSHelper.fixedRequestResource(part, atmospheric_resource_name, -CollectedParticles * powerpcnt * deltaTime); resflowf = -resflowf / (float)deltaTime; } } } }
public override void OnUpdate() { if (vessel != null) { double airdensity = part.vessel.atmDensity; double airspeed = part.vessel.srf_velocity.magnitude + 40.0; double air = airspeed * airdensity * scoopair; if (vessel.altitude <= ORSHelper.getMaxAtmosphericAltitude(vessel.mainBody)) { double scoopedAtm = air; resflowf = (float) ORSHelper.fixedRequestResource(part, intakeResourceStr, -scoopedAtm * TimeWarp.fixedDeltaTime); resflowf = -resflowf / TimeWarp.fixedDeltaTime; resflow = resflowf.ToString("0.0000"); } } }