Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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;
            }

            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)
                    {
                        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);
        }