Esempio n. 1
0
        public override string GetInfo()
        {
            string output = "<b>Max Rated Thrust:</b> " + thrustUpperLimit.ToString("N2") + " kN\n";

            output += "<b>Area:</b> " + Area + "\n";

            output += "\n<b><color=#99ff00ff>Propellants:</color></b>\n";
            Propellant p;
            string     pName;

            for (int i = 0; i < propellants.Count; ++i)
            {
                p     = propellants[i];
                pName = KSPUtil.PrintModuleName(p.name);

                output += "- <b>" + pName + "</b>: " + getMaxFuelFlow(p).ToString("0.0##") + "/sec. Max.\n";
                output += p.GetFlowModeDescription();
            }
            output += "<b>Flameout under: </b>" + (ignitionThreshold * 100f).ToString("0.#") + "%\n";

            if (!allowShutdown)
            {
                output += "\n" + "<b><color=orange>Engine cannot be shut down!</color></b>";
            }
            if (!allowRestart)
            {
                output += "\n" + "<b><color=orange>If shutdown, engine cannot restart.</color></b>";
            }

            return(output);
        }
        private void ApplyLateSpecifics(PartModule module, bool enable)
        {
            // Update staging icon visibility
            if (disableModule && module.IsStageable())
            {
                module.stagingEnabled = !enable;
                module.part.UpdateStageability(false, true);
            }

            if (!(disableModule && enable))
            {
                // Unfortunatly ModuleDataTransmitter OnLoad create the reshandler on the prefab
                // and never again because it checks for part.partInfo == null
                if (module is ModuleDataTransmitter && module.resHandler.inputResources.Count == 0)
                {
                    string value = "ElectricCharge";
                    if (modifiersNode != null && !modifiersNode.TryGetValue("requiredResource", ref value))
                    {
                        moduleNode.TryGetValue("requiredResource", ref value);
                    }
                    ModuleResource moduleResource = new ModuleResource();
                    moduleResource.name  = value;
                    moduleResource.title = KSPUtil.PrintModuleName(value);
                    moduleResource.id    = value.GetHashCode();
                    moduleResource.rate  = 1.0;
                    module.resHandler.inputResources.Add(moduleResource);
                }
                else if (module is ModuleEngines && HighLogic.LoadedSceneIsFlight)
                {
                    FixEnginesFX((ModuleEngines)module);
                }
            }
        }
        public override string GetInfo()
        {
            string infoThrust = GetInfoThrust(true);
            string str        = infoThrust;

            string[] obj = new string[2];
            float    num = atmosphereCurve.Evaluate(1f);

            obj[0] = num.ToString("0.###");
            float num2 = atmosphereCurve.Evaluate(0f);

            obj[1]      = num2.ToString("0.###");
            infoThrust  = str + Localizer.Format("#autoLOC_220745", obj); // isp
            infoThrust += Localizer.Format("#autoLOC_220748");            // propellants

            Propellant propellant = propellants[propIndx];
            string     text       = KSPUtil.PrintModuleName(propellant.displayName);
            string     str2       = infoThrust;

            infoThrust = str2 + text + ": <color=orange>Variable: uses directly attached segments.</color>\n";

            infoThrust += Localizer.Format("#autoLOC_220759", (ignitionThreshold * 100f).ToString("0.#"));

            return(infoThrust);
        }
Esempio n. 4
0
        // See CompilePartInfo
        public static AvailablePart.ModuleInfo GetModuleInfo(PartModule pm)
        {
            AvailablePart.ModuleInfo moduleInfo = new AvailablePart.ModuleInfo();
            if (pm is IModuleInfo)
            {
                IModuleInfo iModuleInfo = pm as IModuleInfo;
                moduleInfo.moduleName  = iModuleInfo.GetModuleTitle();
                moduleInfo.info        = iModuleInfo.GetInfo().Trim();
                moduleInfo.primaryInfo = iModuleInfo.GetPrimaryField();
            }
            else
            {
                moduleInfo.moduleName = (pm.GUIName ?? KSPUtil.PrintModuleName(pm.moduleName));
                moduleInfo.info       = pm.GetInfo().Trim();
            }

            if (pm.showUpgradesInModuleInfo && pm.HasUpgrades())
            {
                moduleInfo.info += "\n" + pm.PrintUpgrades();
            }

            moduleInfo.moduleDisplayName = pm.GetModuleDisplayName();
            if (moduleInfo.moduleDisplayName == string.Empty)
            {
                moduleInfo.moduleDisplayName = moduleInfo.moduleName;
            }
            return(moduleInfo);
        }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     resHandler.outputResources.Add(new ModuleResource()
     {
         name  = resourceName,
         title = KSPUtil.PrintModuleName(resourceName),
         rate  = chargeRate,
         id    = resourceName.GetHashCode()
     });
 }
Esempio n. 6
0
 public override void OnLoad(ConfigNode node)
 {
     if (resHandler.inputResources.Count == 0)
     {
         ModuleResource moduleResource = new ModuleResource();
         moduleResource.name  = resourceName;
         moduleResource.title = KSPUtil.PrintModuleName(resourceName);
         moduleResource.id    = resourceName.GetHashCode();
         moduleResource.rate  = (double)resourceAmount;
         resHandler.inputResources.Add(moduleResource);
     }
 }
        public override string GetInfo()
        {
            string output = GetThrustInfo();

            output += "<b>Engine Isp: </b>" + (atmosphereCurve.Evaluate(1f)).ToString("0.###") + " (ASL) - " + (atmosphereCurve.Evaluate(0f)).ToString("0.###") + " (Vac.)\n";

            output += GetUllageIgnition();

            output += "\n<b><color=#99ff00ff>Propellants:</color></b>\n";
            Propellant p;
            string     pName;

            for (int i = 0; i < propellants.Count; ++i)
            {
                p     = propellants[i];
                pName = KSPUtil.PrintModuleName(p.name);
                string units = "L";
                string rate  = " per second";
                if (p.name == "ElectricCharge")
                {
                    units = "kW";
                    rate  = string.Empty;
                }
                float  unitsSec  = getMaxFuelFlow(p);
                string unitsUsed = unitsSec.ToString("N4") + units;
                if (PartResourceLibrary.Instance != null)
                {
                    PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(p.name);
                    if (def != null && def.density > 0)
                    {
                        unitsUsed += " (" + (unitsSec * def.density * 1000f).ToString("N4") + " kg)";
                    }
                }
                unitsUsed += rate;
                output    += "- <b>" + pName + "</b>: " + unitsUsed + " maximum.\n";
                output    += p.GetFlowModeDescription();
            }
            output += "<b>Flameout under: </b>" + (ignitionThreshold * 100f).ToString("0.#") + "% of requirement remaining.\n";

            if (!allowShutdown)
            {
                output += "\n" + "<b><color=orange>Engine cannot be shut down!</color></b>";
            }
            if (!allowRestart)
            {
                output += "\n" + "<b><color=orange>If shutdown, engine cannot restart.</color></b>";
            }

            currentThrottle = 0f;

            return(output);
        }
 public override void OnLoad(ConfigNode node)
 {
     if (base.resHandler.inputResources.Count == 0 && (node.HasValue("resourceName") || node.HasValue("powerConsumption") || base.part.partInfo == null || (UnityEngine.Object)base.part.partInfo.partPrefab == (UnityEngine.Object)null))
     {
         string text             = "ElectricCharge";
         float  powerConsumption = 0.0075f;
         node.TryGetValue("resourceName", ref text);
         node.TryGetValue("powerConsumption", ref powerConsumption);
         ModuleResource moduleResource = new ModuleResource();
         moduleResource.name  = text;
         moduleResource.title = KSPUtil.PrintModuleName(text);
         moduleResource.id    = text.GetHashCode();
         moduleResource.rate  = (double)powerConsumption;
         base.resHandler.inputResources.Add(moduleResource);
     }
 }
Esempio n. 9
0
        /// <inheritdoc/>
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            if (resHandler.inputResources.Count == 0)
            {
                var moduleResource = new ModuleResource();
                moduleResource.name  = StockResourceNames.ElectricCharge;
                moduleResource.title = KSPUtil.PrintModuleName(StockResourceNames.ElectricCharge);
                moduleResource.id    = StockResourceNames.ElectricCharge.GetHashCode();
                moduleResource.rate  = (double)motorPowerDrain;
                resHandler.inputResources.Add(moduleResource);
            }

            sndMotor      = SpatialSounds.Create3dSound(part.gameObject, sndPathMotor, loop: true);
            sndMotorStart = SpatialSounds.Create3dSound(part.gameObject, sndPathMotorStart);
            sndMotorStop  = SpatialSounds.Create3dSound(part.gameObject, sndPathMotorStop);
        }
Esempio n. 10
0
        /// <inheritdoc/>
        protected override void InitModuleSettings()
        {
            base.InitModuleSettings();
            Destroy(sndMotor);
            sndMotor = SpatialSounds.Create3dSound(part.gameObject, sndPathMotor, loop: true);
            Destroy(sndMotorStart);
            sndMotorStart = SpatialSounds.Create3dSound(part.gameObject, sndPathMotorStart);
            Destroy(sndMotorStop);
            sndMotorStop = SpatialSounds.Create3dSound(part.gameObject, sndPathMotorStop);

            var moduleResource = resHandler.inputResources
                                 .FirstOrDefault(x => x.name == StockResourceNames.ElectricCharge);

            if (moduleResource == null)
            {
                moduleResource      = new ModuleResource();
                moduleResource.name = StockResourceNames.ElectricCharge;
                moduleResource.id   = StockResourceNames.ElectricCharge.GetHashCode();
                resHandler.inputResources.Add(moduleResource);
            }
            moduleResource.title = KSPUtil.PrintModuleName(StockResourceNames.ElectricCharge);
            moduleResource.rate  = (double)motorPowerDrain;
        }
        public override string GetInfo()
        {
            string output = $"{GetThrustInfo()}" +
                            $"<b>Engine Isp: </b>{atmosphereCurve.Evaluate(1):0.###} (ASL) - {atmosphereCurve.Evaluate(0):0.###} (Vac.)\n";

            output += $"{GetUllageIgnition()}\n";
            output += $"<b><color=#99ff00ff>Propellants:</color></b>\n";

            foreach (Propellant p in propellants)
            {
                string units    = (p.name == "ElectricCharge") ? "kW" : "L";
                string rate     = (p.name == "ElectricCharge") ? string.Empty : "/s";
                float  unitsSec = getMaxFuelFlow(p);
                string sUse     = $"{unitsSec:G4}{units}{rate}";
                if (PartResourceLibrary.Instance?.GetDefinition(p.name) is PartResourceDefinition def && def.density > 0)
                {
                    sUse += $" ({unitsSec * def.density * 1000f:G4} kg{rate})";
                }
                output += $"- <b>{KSPUtil.PrintModuleName(p.name)}</b>: {sUse} maximum.\n";
                output += $"{p.GetFlowModeDescription()}";
            }
            output += $"<b>Variance: </b>{localVaryIsp:P2} Isp, {localVaryFlow:P1} flow, {localVaryMixture:P2} MR (stddev).\n";
            output += $"<b>Residuals: min </b>{localResidualsThresholdBase:P1} of propellant.\n";

            if (!allowShutdown)
            {
                output += "\n<b><color=orange>Engine cannot be shut down!</color></b>";
            }
            if (!allowRestart)
            {
                output += "\n<b><color=orange>If shutdown, engine cannot restart.</color></b>";
            }

            currentThrottle = 0f;

            return(output);
        }
Esempio n. 12
0
 protected void SetMODULES(IEnumerable <Type> types)
 {
     modules = types.Select(t => KSPUtil.PrintModuleName(t.Name)).ToList();
 }
Esempio n. 13
0
 public void Add(BulkheadProfileData bp)
 {
     //Debug.Log($"[BulkheadProfileConfigs] Add {bp.name}, {KSPUtil.PrintModuleName (bp.name)}");
     BulkheadProfiles[KSPUtil.PrintModuleName(bp.name)] = bp;
 }
Esempio n. 14
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            if (node.HasValue("RTAntennaTarget"))
            {
                try
                {
                    Target = new Guid(node.GetValue("RTAntennaTarget"));
                }
                catch (FormatException)
                {
                    Target = Guid.Empty;
                }
            }
            // Have RTDishRadians as a fallback to avoid corrupting save games
            if (node.HasValue("RTDishRadians"))
            {
                double temp_double;
                RTDishCosAngle = Double.TryParse(node.GetValue("RTDishRadians"), out temp_double) ? temp_double : 1.0;
            }
            if (node.HasValue("DishAngle"))
            {
                RTDishCosAngle = Math.Cos(DishAngle / 2 * Math.PI / 180);
            }
            if (node.HasValue("DeployFxModules"))
            {
                mDeployFxModuleIndices = KSPUtil.ParseArray <Int32>(node.GetValue("DeployFxModules"), new ParserMethod <Int32>(Int32.Parse));
            }
            if (node.HasValue("ProgressFxModules"))
            {
                mProgressFxModuleIndices = KSPUtil.ParseArray <Int32>(node.GetValue("ProgressFxModules"), new ParserMethod <Int32>(Int32.Parse));
            }
            if (node.HasNode("TRANSMITTER"))
            {
                RTLog.Notify("ModuleRTAntenna: Found TRANSMITTER block.");
                mTransmitterConfig = node.GetNode("TRANSMITTER");
                mTransmitterConfig.AddValue("name", "ModuleRTDataTransmitter");

                // workarround for ksp 1.0
                if (mTransmitterConfig.HasValue("PacketInterval"))
                {
                    RTPacketInterval = float.Parse(mTransmitterConfig.GetValue("PacketInterval"));
                }

                if (mTransmitterConfig.HasValue("PacketSize"))
                {
                    RTPacketSize = float.Parse(mTransmitterConfig.GetValue("PacketSize"));
                }

                if (mTransmitterConfig.HasValue("PacketResourceCost"))
                {
                    RTPacketResourceCost = float.Parse(mTransmitterConfig.GetValue("PacketResourceCost"));
                }
            }
            if (this.resHandler.inputResources.Count == 0)
            {
                ModuleResource moduleResource = new ModuleResource();
                moduleResource.name  = this.resourceName;
                moduleResource.title = KSPUtil.PrintModuleName(this.resourceName);
                moduleResource.id    = this.resourceName.GetHashCode();
                moduleResource.rate  = EnergyCost * ConsumptionMultiplier;
                this.resHandler.inputResources.Add(moduleResource);
            }

            //apply the consumption multiplier
            this.resHandler.inputResources.Find(x => x.name == this.resourceName).rate = EnergyCost * ConsumptionMultiplier;
        }
Esempio n. 15
0
 public virtual string GetModuleTitle()
 {
     return(KSPUtil.PrintModuleName(moduleName));
 }
Esempio n. 16
0
        public static string ReqValueFormat(Require req, object reqValue)
        {
            switch (req)
            {
            case Require.OrbitMinEccentricity:
            case Require.OrbitMaxEccentricity:
            case Require.OrbitMinArgOfPeriapsis:
            case Require.OrbitMaxArgOfPeriapsis:
            case Require.AtmosphereAltMin:
            case Require.AtmosphereAltMax:
                return(((double)reqValue).ToString("F2"));

            case Require.SunAngleMin:
            case Require.SunAngleMax:
            case Require.OrbitMinInclination:
            case Require.OrbitMaxInclination:
                return(Lib.HumanReadableAngle((double)reqValue));

            case Require.TemperatureMin:
            case Require.TemperatureMax:
                return(Lib.HumanReadableTemp((double)reqValue));

            case Require.AltitudeMin:
            case Require.AltitudeMax:
            case Require.AltAboveGroundMin:
            case Require.AltAboveGroundMax:
            case Require.MaxAsteroidDistance:
                return(Lib.HumanReadableDistance((double)reqValue));

            case Require.RadiationMin:
            case Require.RadiationMax:
                return(Lib.HumanReadableRadiation((double)reqValue));

            case Require.VolumePerCrewMin:
            case Require.VolumePerCrewMax:
                return(Lib.HumanReadableVolume((double)reqValue));

            case Require.SurfaceSpeedMin:
            case Require.SurfaceSpeedMax:
            case Require.VerticalSpeedMin:
            case Require.VerticalSpeedMax:
            case Require.SpeedMin:
            case Require.SpeedMax:
                return(Lib.HumanReadableSpeed((double)reqValue));

            case Require.DynamicPressureMin:
            case Require.DynamicPressureMax:
            case Require.StaticPressureMin:
            case Require.StaticPressureMax:
            case Require.AtmDensityMin:
            case Require.AtmDensityMax:
                return(Lib.HumanReadablePressure((double)reqValue));

            case Require.CrewMin:
            case Require.CrewMax:
            case Require.CrewCapacityMin:
            case Require.CrewCapacityMax:
            case Require.AstronautComplexLevelMin:
            case Require.AstronautComplexLevelMax:
            case Require.TrackingStationLevelMin:
            case Require.TrackingStationLevelMax:
            case Require.MissionControlLevelMin:
            case Require.MissionControlLevelMax:
            case Require.AdministrationLevelMin:
            case Require.AdministrationLevelMax:
                return(((int)reqValue).ToString());

            case Require.Module:
                return(KSPUtil.PrintModuleName((string)reqValue));

            case Require.Part:
                return(PartLoader.getPartInfoByName((string)reqValue)?.title ?? (string)reqValue);

            default:
                return(string.Empty);
            }
        }