private void SetPropellant(bool moveNext)
        {
            int attempts = _propellants.Count;

            do
            {
                CurrentPropellant = _propellants[fuel_mode];
                fuel_mode_name    = CurrentPropellant.PropellantName;

                var    propellant = CurrentPropellant.Propellant;
                string propName   = propellant.name;
                if ((!HighLogic.LoadedSceneIsFlight || part.GetConnectedResources(propName).
                     Any()) && PartResourceLibrary.Instance.GetDefinition(propName) != null)
                {
                    propNameStr = CurrentPropellant.PropellantGUIName;
                    LoadConfig();
                    break;
                }
                else
                {
                    Debug.Log("[KSPI]: ElectricRCSController switching mode, cannot use " + propName);
                    MovePropellant(moveNext);
                }
            } while (--attempts >= 0);
        }
        public override void OnStart(StartState state)
        {
            var rcs = part.FindModulesImplementing <ModuleRCSFX>();
            int fm;

            _attachedRcs = (rcsIndex >= rcs.Count) ? null : rcs[rcsIndex];

            if (partMass == 0)
            {
                partMass = part.mass;
            }

            resourcesToSupply = new [] { ResourceSettings.Config.WasteHeatInMegawatt };

            _oldPowerEnabled = powerEnabled;
            efficiencyStr    = efficiency.ToString("P1");

            if (!string.IsNullOrEmpty(AnimationName))
            {
                _rcsStates = PluginHelper.SetUpAnimation(AnimationName, part);
            }

            // Only allow _propellants that are compatible with this engine type
            _propellants.Clear();
            foreach (var propellant in ElectricEnginePropellant.GetPropellantsEngineForType(type))
            {
                if ((propellant.SupportedEngines & type) != 0)
                {
                    _propellants.Add(propellant);
                }
            }

            if (_propellants.Count < 1)
            {
                Debug.LogError("[KSPI]: No _propellants available for RCS type " + type + "!");
            }

            _delayedVerificationPropellant = true;
            // find correct fuel mode index
            if (!string.IsNullOrEmpty(fuel_mode_name))
            {
                foreach (var propellant in _propellants)
                {
                    if (propellant.PropellantName != fuel_mode_name)
                    {
                        continue;
                    }

                    Debug.Log("[KSPI]: ElectricRCSController set fuel mode " + fuel_mode_name);
                    CurrentPropellant = propellant;
                    break;
                }
            }

            if (CurrentPropellant != null && (fm = _propellants.IndexOf(CurrentPropellant)) >= 0)
            {
                fuel_mode = fm;
            }
            SetPropellant(true);

            base.OnStart(state);

            _powerConsumptionStrField           = Fields[nameof(powerConsumptionStr)];
            _powerConsumptionStrField.guiActive = showConsumption;

            maxStoredPower = bufferMult * maxThrust * powerMult * maxIsp * PhysicsGlobals.GravitationalAcceleration / (efficiency * 1000.0);
        }