public void FixedUpdate() { if (!HighLogic.LoadedSceneIsFlight) { return; } double kw = Math.Abs(this.part.thermalRadiationFlux); Part rPart = MPFunctions.GetResourcePart(FlightGlobals.ActiveVessel, resourceName); if (rPart != null) { int id = MPFunctions.GetResourceID(rPart, resourceName); double rTotal = MPFunctions.GetResourceTotal(FlightGlobals.ActiveVessel, resourceName); double rMax = MPFunctions.GetResourceMax(FlightGlobals.ActiveVessel, resourceName); transAmt = resourceAmt * kw; if (actRad == true) // look for active radiator { for (int i = this.part.Modules.Count - 1; i >= 0; --i) { PartModule M = this.part.Modules[i]; if (M is ModuleActiveRadiator) { if ((M as ModuleActiveRadiator).IsCooling) { rPart.TransferResource(id, transAmt); } } } } else { rPart.TransferResource(id, transAmt); } } }
public void FixedUpdate() { if (!HighLogic.LoadedSceneIsFlight) { return; } if (myEngine == null && myIntake == null && partType != "Throttle" && partType != "Stirling" && partType != "Battery" || animationName == "null" || !vessel.isActiveVessel) { return; } else if (vessel.isActiveVessel) { double thisenergy = 0; if (partType == "Stirling") { thisenergy = Math.Abs(this.part.thermalRadiationFlux) / 100; if (thisenergy > 1) { thisenergy = 1; } if (thisenergy < 0) { thisenergy = 0; } Play_Anim(animationName, (float)thisenergy, 0.0f); return; } if (partType == "Battery") { double rTotal = MPFunctions.GetResourceTotal(FlightGlobals.ActiveVessel, "ElectricCharge"); double rMax = MPFunctions.GetResourceMax(FlightGlobals.ActiveVessel, "ElectricCharge"); thisenergy = rTotal / rMax; } else { thisenergy = FlightInputHandler.state.mainThrottle; } if ((partType == "Engine" && !myEngine.EngineIgnited) || (partType == "Engine" && myEngine.getFlameoutState == true) || (partType == "Intake" && !myIntake.intakeEnabled)) //Intake or Engine shut down, reverse animation { if (syncThrust) { if (syncThrust) { float direction = CheckDirection(); thisenergy = myEngine.normalizedThrustOutput; Play_Anim(animationName, (float)thisenergy * direction, 0.0f); return; } } if (lastThrottle != 0.0f) { if (syncThrottle) { if (smoothThrottle) { lastThrottle = lastThrottle - 0.02f; if (lastThrottle < 0.0f) { lastThrottle = 0.0f; } } else { lastThrottle = 0.0f; } if (loopAnim == true) { Play_Anim(animationName, lastThrottle); } else { Play_Anim(animationName, 0.0f, lastThrottle); } } else //not synced to play at full speed from the end to the beginning { if (!aniEngine.isPlaying) { if (loopAnim == true) { Play_Anim(animationName, 0.0f); } else { Play_Anim(animationName, -1.0f, 1.0f); } lastThrottle = 0.0f; } } } } else //engine ignited or it's another type, run animation { if (syncThrust) { float direction = CheckDirection(); thisenergy = myEngine.normalizedThrustOutput; if (loopAnim == true) { Play_Anim(animationName, (float)thisenergy, 0.0f); } else { Play_Anim(animationName, 0.0f, (float)thisenergy); } return; } if (syncThrottle) { if (smoothThrottle) { if (thisenergy > lastThrottle) { if (thisenergy + lastThrottle > 0.02f) { lastThrottle = lastThrottle + 0.02f; if (lastThrottle > 1.0f) { lastThrottle = 1.0f; } } else { lastThrottle = (float)thisenergy; } } if (thisenergy < lastThrottle) { if (lastThrottle - thisenergy > 0.02f || thisenergy == 0 && lastThrottle != 0) { lastThrottle = lastThrottle - 0.02f; if (lastThrottle < 0.0f) { lastThrottle = 0.0f; } } else { lastThrottle = (float)thisenergy; } } if (loopAnim == true) { Play_Anim(animationName, lastThrottle, 0.0f); } else { Play_Anim(animationName, 0.0f, lastThrottle); } } else { if (loopAnim == true) { Play_Anim(animationName, (float)thisenergy); } else { Play_Anim(animationName, 0.0f, (float)thisenergy); } } } else //not synced so play at full speed from the beginning { if (!aniEngine.isPlaying && lastThrottle != 1.0f) { Play_Anim(animationName, 1.0f, 0.0f); lastThrottle = 1.0f; } } } } }