public void FixedUpdate() { if (HighLogic.LoadedSceneIsFlight) { if (initFrames < 60) { initFrames += 1; } else { AddHeatToReceiverCore(); } // received power code receiver.Spherical(this.part, true, PowerLimiter, recvDiameter, recvEfficiency, false, false, State, out State, out double recvPower); if (engine.getFlameoutState | !engine.getIgnitionState) { recvPower = 0d; State = engineOff; } ReceivedPower = (float)(Math.Round(recvPower, 1)); // code related to engine module float currentisp = engine.realIsp; float ApproxTemp = (IsJetEngine == "True") ? 1100f : 2400f; PropellantName = engine.propellants[0].displayName; string propellantname = engine.propellants[0].name; float shc = PartResourceLibrary.Instance.GetDefinition(propellantname).specificHeatCapacity * 1.5f / 1000f; // in kJ kg^-1 K^-1 // calculate thrust based on power received float Thrust = (ReceivedPower * thermalEfficiency * 0.4f / (shc * ApproxTemp)) * 9.8f * currentisp; // in kN Thrust = (Thrust < 10f) ? 0f : Thrust; // minimum thrust (min received power) below this there isnt enough heat to reach optimum temperature percentThrust = Thrust * thrustMult / engine.maxThrust; engine.thrustPercentage = Mathf.Clamp((float)Math.Round(percentThrust * 100, 2), 0f, 100f); this.vessel.GetConnectedResourceTotals(EChash, out double ECamount, out double maxAmount); if (ECamount / maxAmount < 0.05f) { engine.thrustPercentage = 0f; } LockGimbal(); } }
public void FixedUpdate() { if (HighLogic.LoadedSceneIsFlight) { receiver.Spherical(this.part, true, PowerLimiter, SurfaceArea, 1d, true, true, State, out State, out double recvPower); ReceivedPower = (float)Math.Round(recvPower, 1); AnimationState(); double impulse = ReceivedPower * 1000f * partThrustMult / c; // adding heat to part's skin double heatModifier = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().PercentHeat; this.part.AddSkinThermalFlux((float)((1 - Reflectivity) * ReceivedPower * ((heatModifier / 100) * 0.7))); SkinTemp = (float)Math.Round(this.part.skinTemperature, 1); // code related to the engine module double thrustMult = HighLogic.CurrentGame.Parameters.CustomParams <BPSettings>().photonthrust; float Thrust = (float)(impulse * Reflectivity * (engine.realIsp / 30592000) * thrustMult); // in N ThrustN = (float)Math.Round(engine.GetCurrentThrust() * 1000, 3); float percentThrust = Thrust / (engine.maxThrust * 1000); engine.thrustPercentage = Mathf.Clamp((float)Math.Round(percentThrust * 100, 3), 0f, 100f); this.vessel.GetConnectedResourceTotals(EChash, out double ECamount, out double maxAmount); if (ECamount / maxAmount < 0.01f) { engine.thrustPercentage = 0f; } // replenishes photons resource int fuelId = engine.propellants[0].resourceDef.id; this.part.GetConnectedResourceTotals(fuelId, out double Fuelamount, out _); if (Fuelamount < 10d) { this.part.RequestResource(fuelId, -100d); // increases quantity of the photons resource } ReceivedPower = Math.Abs(ReceivedPower); } }