/// <summary> /// Called by Unity API for every physics update. /// </summary> public void FixedUpdate() { try { base.OnFixedUpdate(); if (_electricCharge == null || _resourceConverter == null) { DebugLog(m: "Something is null"); return; // already checked for this in OnStart() } CurrentCharge = _electricCharge.amount / _electricCharge.maxAmount * 100; // compute current EC, in percent DebugLog(m: $"Current Charge = {CurrentCharge:F2}"); if (!GameSettings.ADVANCED_TWEAKABLES || !Automatic) { DebugLog(m: "Automatic Disabled"); return; // don't do anything in manual operation } if (CurrentCharge <= Thresholds.x && !_resourceConverter.IsActivated) { DebugLog(m: "Starting Fuel Cell"); _resourceConverter.StartResourceConverterAction(param: null); // turn on if below minimum setting } else if (CurrentCharge >= Thresholds.y && _resourceConverter.IsActivated) { DebugLog(m: "Stopping Fuel Cell"); _resourceConverter.StopResourceConverterAction(param: null); // automatically turn off if above maximum setting } } catch (Exception e) { DebugLog(m: e); } }
public void ActionShutdown(KSPActionParam param) { //Call Build-in action currentConverter.StopResourceConverterAction(param); }