private void setState(PowerMeterState newState) { switch (newState) { case PowerMeterState.Off: base.gameObject.SetActive(value: false); animator.SetBool("MaxPower", value: false); break; case PowerMeterState.PreCharge: timer = 0f; PowerMeterCanvasGroup.alpha = 0f; PowerMeterImage.fillAmount = 0f; base.gameObject.SetActive(value: true); break; case PowerMeterState.Charging: PowerMeterCanvasGroup.alpha = 1f; PowerMeterImage.fillAmount = Mathf.Lerp(0f, MaxMeterFill, timer / maxChargeTime); break; case PowerMeterState.MaxPower: animator.SetBool("MaxPower", value: true); PowerMeterImage.fillAmount = 1f; PowerMeterImage.color = MeterColors[MeterColors.Length - 1].Color; break; case PowerMeterState.Fading: animator.SetBool("MaxPower", value: false); break; } currentState = newState; }
public void TickTelemetry(IDataMiner data) { Enabled = true; switch (State) { case PowerMeterState.Idle: if (Main.GetButtonIn(JoyControls.MeasurePower) && false) { integralRevver = 0; State = PowerMeterState.Prearm; this.Active = true; } else { this.Active = false; } break; case PowerMeterState.Prearm: preArmThr = (1000 - data.Telemetry.EngineRpm) / 1500; if (Math.Abs(data.Telemetry.EngineRpm - 1000) < 100) { integralRevver += (1000 - data.Telemetry.EngineRpm) / 750000.0f; } else { integralRevver = 0; } preArmThr += integralRevver; if (preArmThr > 0.7f) { preArmThr = 0.7f; } if (preArmThr < 0) { preArmThr = 0; } if (Math.Abs(data.Telemetry.EngineRpm - 1000) < 5) { prearmSettler++; if (prearmSettler > 200) { startRevup = DateTime.Now; State = PowerMeterState.Revup; } } else { prearmSettler = 0; } break; case PowerMeterState.Revup: if (data.Telemetry.EngineRpm >= 2000) { endRevup = DateTime.Now; startRevdown = DateTime.Now; State = PowerMeterState.Revdown; revdownRpm = data.Telemetry.EngineRpm; } break; case PowerMeterState.Revdown: if (data.Telemetry.EngineRpm <= 1000) { endRevdown = DateTime.Now; State = PowerMeterState.Cooldown; var fallTime = endRevdown.Subtract(startRevdown).TotalMilliseconds / 1000.0; var fallRpm = revdownRpm - data.Telemetry.EngineRpm; Console.WriteLine("Rev up: " + (endRevup.Subtract(startRevup).TotalMilliseconds) + "ms, rev down: " + (fallTime) + "ms (" + (fallRpm / fallTime) + "rpm/s"); } break; case PowerMeterState.Cooldown: Active = false; if (data.Telemetry.EngineRpm < 700) { State = PowerMeterState.Idle; } break; } }
public void TickTelemetry(IDataMiner data) { Enabled = true; switch (State) { case PowerMeterState.Idle: if (Main.GetButtonIn(JoyControls.MeasurePower) && false) { integralRevver = 0; State = PowerMeterState.Prearm; this.Active = true; } else { this.Active = false; } break; case PowerMeterState.Prearm: preArmThr = (1000 - data.Telemetry.EngineRpm)/1500; if (Math.Abs(data.Telemetry.EngineRpm - 1000) < 100) { integralRevver += (1000 - data.Telemetry.EngineRpm)/750000.0f; } else { integralRevver = 0; } preArmThr += integralRevver; if (preArmThr > 0.7f) preArmThr = 0.7f; if (preArmThr < 0) preArmThr = 0; if (Math.Abs(data.Telemetry.EngineRpm - 1000) < 5) { prearmSettler++; if (prearmSettler > 200) { startRevup = DateTime.Now; State = PowerMeterState.Revup; } } else { prearmSettler = 0; } break; case PowerMeterState.Revup: if (data.Telemetry.EngineRpm >= 2000) { endRevup = DateTime.Now; startRevdown = DateTime.Now; State = PowerMeterState.Revdown; revdownRpm = data.Telemetry.EngineRpm; } break; case PowerMeterState.Revdown: if (data.Telemetry.EngineRpm <=1000) { endRevdown = DateTime.Now; State = PowerMeterState.Cooldown; var fallTime = endRevdown.Subtract(startRevdown).TotalMilliseconds/1000.0; var fallRpm = revdownRpm - data.Telemetry.EngineRpm; Console.WriteLine("Rev up: " + (endRevup.Subtract(startRevup).TotalMilliseconds) + "ms, rev down: " + (fallTime) + "ms (" + (fallRpm/fallTime)+"rpm/s"); } break; case PowerMeterState.Cooldown: Active = false; if (data.Telemetry.EngineRpm < 700) { State = PowerMeterState.Idle; } break; } }