protected void FixedUpdate() { if (HighLogic.LoadedSceneIsFlight) { fuelAmount = GetResourceAmount(FuelName); // If we have no fuel, no need to do any calculations if (fuelAmount == 0.0) { if (offAnimator) { offAnimator.SetScalar(1f); } if (onAnimator) { onAnimator.SetScalar(0f); } if (alertAnimator) { alertAnimator.SetScalar(0f); } ContainmentStatus = Localizer.Format("#LOC_FFT_ModuleAntimatterTank_Field_ContainmentStatus_None"); return; } // If the cooling cost is zero, we must boil off if (ContainmentCost == 0f) { if (offAnimator) { offAnimator.SetScalar(1f); } if (onAnimator) { onAnimator.SetScalar(0f); } DetonationOccuring = true; DetonationStatus = Localizer.Format("#LOC_FFT_ModuleAntimatterTank_Field_DetonationStatus_Uncontained", DetonationRate.ToString("F2")); } // else check for available power else { if (!ContainmentEnabled) { if (offAnimator) { offAnimator.SetScalar(1f); } if (onAnimator) { onAnimator.SetScalar(0f); } DetonationOccuring = true; DetonationStatus = Localizer.Format("#LOC_FFT_ModuleAntimatterTank_Field_DetonationStatus_Uncontained", DetonationRate.ToString("F2")); ContainmentStatus = Localizer.Format("#LOC_FFT_ModuleAntimatterTank_Field_ContainmentStatus_Disabled"); } else { if (offAnimator) { offAnimator.SetScalar(0f); } if (onAnimator) { onAnimator.SetScalar(1f); } } } ConsumeCharge(); if (DetonationOccuring) { if (alertAnimator) { if (alertAnimator.GetScalar > 1f) { alertDirection = -1f; } if (alertAnimator.GetScalar < 0f) { alertDirection = 1f; } alertAnimator.SetScalar(alertAnimator.GetScalar + TimeWarp.fixedDeltaTime * AlertRate * alertDirection); } DetonationFrameTimer++; DoDetonation(); } else { DetonationFrameTimer = 0; if (alertAnimator) { alertAnimator.SetScalar(0f); } } if (part.vessel.missionTime > 0.0) { //LastUpdateTime = part.vessel.missionTime; } } }
void LateUpdate() { if (HighLogic.LoadedSceneIsFlight) { if (waterfallEffect == null) { FindWaterfallEffect(); } if (!engine) { return; } scaledPulseInterval = PulseInterval.Evaluate(engine.requestedThrottle); scaledPulseSpeed = PulseSpeed.Evaluate(engine.requestedThrottle); scaledPulseDuration = scaledPulseSpeed * PulseDuration; float curveValue = pulseProgress / scaledPulseSpeed; if (engine.EngineIgnited) { if (engine.requestedThrottle > 0f && !engine.flameout) { // At start of pulse if (pulseProgress == 0f) { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { pulseState.normalizedTime = 0f; pulseState.speed = 1.0f / scaledPulseSpeed; } } //part.Effect(engine.runningEffectName, 1f); pulseProgress = pulseProgress + TimeWarp.deltaTime; if (laserPulseDone) { laserPulseDone = false; } } // During pulse else if (pulseProgress < scaledPulseDuration) { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { //pulseState.normalizedTime = Mathf.MoveTowards(pulseState.normalizedTime, 1.0f, TimeWarp.fixedDeltaTime * scaledPulseSpeed); pulseState.speed = 1.0f / scaledPulseSpeed; } } pulseProgress = pulseProgress + TimeWarp.deltaTime; } // after pulse but during wait period else if (pulseProgress >= scaledPulseDuration && pulseProgress < (scaledPulseDuration + scaledPulseInterval)) { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { pulseState.normalizedTime = 0f; pulseState.speed = 0f; } } //part.Effect(engine.runningEffectName, 0f); pulseProgress = pulseProgress + TimeWarp.deltaTime; } // After pulse wait period else { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { pulseState.normalizedTime = 0f; pulseState.speed = 0f; } } // part.Effect(engine.runningEffectName, 0f); pulseProgress = 0f; if (LaserAnimations && !laserPulseDone) { laserPulseDone = true; laserAnimatorIndex++; if (laserAnimatorIndex > laserFX.Count - 1) { laserAnimatorIndex = 0; } } } part.Effect(pulseEffectName, soundIntensityCurve.Evaluate(curveValue)); waterfallEffect.SetControllerValue(plumeFXControllerID, plumeFXIntensityCurve.Evaluate(curveValue)); waterfallEffect.SetControllerValue(flareFXControllerID, flareFXIntensityCurve.Evaluate(curveValue)); if (light != null) { light.intensity = lightIntensityCurve.Evaluate(curveValue); } emissiveAnimator.SetScalar(lightIntensityCurve.Evaluate(curveValue)); if (LaserAnimations) { laserFX[laserAnimatorIndex].Set(this.part, curveValue); } } else { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { pulseState.normalizedTime = 0f; pulseState.speed = 0f; } } pulseProgress = 0f; part.Effect(pulseEffectName, 0f); waterfallEffect.SetControllerValue(flareFXControllerID, flareFXIntensityCurve.Evaluate(curveValue)); waterfallEffect.SetControllerValue(plumeFXControllerID, plumeFXIntensityCurve.Evaluate(curveValue)); if (light != null) { light.intensity = lightIntensityCurve.Evaluate(curveValue); } emissiveAnimator.SetScalar(lightIntensityCurve.Evaluate(curveValue)); if (LaserAnimations) { laserFX[laserAnimatorIndex].Set(this.part, curveValue); } } } else { if (multiEngine == null || (multiEngine && multiEngine.runningPrimary && multiEngine.primaryEngineID == engineID) || (multiEngine && !multiEngine.runningPrimary && multiEngine.secondaryEngineID == engineID)) { if (PulseAnimation != "") { foreach (AnimationState pulseState in pulseStates) { pulseState.normalizedTime = 0f; pulseState.speed = 0f; } } pulseProgress = 0f; part.Effect(pulseEffectName, soundIntensityCurve.Evaluate(curveValue)); waterfallEffect.SetControllerValue(flareFXControllerID, flareFXIntensityCurve.Evaluate(curveValue)); waterfallEffect.SetControllerValue(plumeFXControllerID, plumeFXIntensityCurve.Evaluate(curveValue)); if (light != null) { light.intensity = lightIntensityCurve.Evaluate(curveValue); } emissiveAnimator.SetScalar(lightIntensityCurve.Evaluate(curveValue)); if (LaserAnimations) { laserFX[laserAnimatorIndex].Set(this.part, curveValue); } } } } }