public override bool Initialize(PartModule pm) { base.Initialize(pm); converter = (ModuleResourceConverter)pm; core = pm.GetComponent <ModuleCoreHeat>(); return(converter.GeneratesHeat); }
public override bool Initialize(PartModule pm) { base.Initialize(pm); converter = (ModuleResourceConverter)pm; bool toMonitor = false; for (int i = 0; i < converter.inputList.Count; i++) { if (converter.inputList[i].ResourceName == "ElectricCharge") { converterEcRate = converter.inputList[i].Ratio; producer = false; consumer = true; toMonitor = true; } } for (int i = 0; i < converter.outputList.Count; i++) { if (converter.outputList[i].ResourceName == "ElectricCharge") { converterEcRate = converter.outputList[i].Ratio; producer = true; consumer = false; toMonitor = true; } } return(toMonitor); }
protected override void runHeadless(ModuleResourceConverter converter) { if (ShowGUI) { base.runHeadless(converter); } }
public static bool HasBackgroundProcessingData( PartModule m, ProtoPartModuleSnapshot s, Dictionary <String, List <ResourceModuleHandler> > resourceData, HashSet <String> interestingResources ) { bool active = false; Boolean.TryParse(s.moduleValues.GetValue("enabled"), out active); Log.Info("HasBackgroundProcessingData, enabled: " + active); if (active) { ModuleResourceConverter g = (ModuleResourceConverter)m; if (g.resHandler.inputResources.Count <= 0) { foreach (ModuleResource gr in g.resHandler.outputResources) { if (interestingResources.Contains(gr.name)) { return(true); } } } } return(false); }
public override void OnStartFinished(StartState state) { base.OnStartFinished(state); _converterModule = part.Modules.GetModule <ModuleResourceConverter>(); if (_converterModule == null) { Debug.LogError("[FCT] Converter module not found."); return; } if (HighLogic.LoadedScene == GameScenes.EDITOR) { FillLimit = _converterModule.FillAmount; } else { _converterModule.FillAmount = FillLimit; } _fillLimitField = Fields.Cast <BaseField>().FirstOrDefault(f => f.name == FieldName); if (_fillLimitField == null) { Debug.LogError("[FCT] FillLimit field not found."); return; } _fillLimitField.OnValueModified += FillLimitChanged; }
/// <summary> /// Allows enabling/disabling electric generators (and fuel cells) /// </summary> /// <param name="state"></param> public void ButtonEnableElectricGenerator(bool state) { if (vessel != null) { foreach (PartModule pm in ElectricGenerators(vessel)) { if (pm is ModuleGenerator) { ModuleGenerator gen = pm as ModuleGenerator; if (state) { gen.Activate(); } else { gen.Shutdown(); } } else if (pm is ModuleResourceConverter) { ModuleResourceConverter gen = pm as ModuleResourceConverter; if (state) { gen.StartResourceConverter(); } else { gen.StopResourceConverter(); } } } } }
public override void OnUpdate() { base.OnUpdate(); if (converter == null && HighLogic.LoadedSceneIsFlight) { converter = this.part.FindModuleImplementing <ModuleResourceConverter>(); } if (converter.IsActivated == false && particlesEnabled) { particlesEnabled = false; setEmittersVisible(false); } if (converter.IsActivated && particlesEnabled == false && converter.status.Contains("load")) { particlesEnabled = true; setEmittersVisible(true); } else if (converter.IsActivated && particlesEnabled && converter.status.Contains("cap")) { particlesEnabled = false; setEmittersVisible(false); } }
internal static double CalculateOtherPower(Vessel vessel) { double otherPower = 0; List <ModuleGenerator> powerModules = vessel.FindPartModulesImplementing <ModuleGenerator> (); for (int i = 0; i < powerModules.Count; i++) { // Find standard RTGs ModuleGenerator powerModule = powerModules [i]; if (powerModule.generatorIsActive || powerModule.isAlwaysActive) { for (int j = 0; j < powerModule.resHandler.outputResources.Count; ++j) { var resource = powerModule.resHandler.outputResources [j]; if (resource.name == "ElectricCharge") { otherPower += resource.rate * powerModule.efficiency; } } } } for (int i = 0; i < vessel.parts.Count; i++) { var part = vessel.parts [i]; // Search for other generators PartModuleList modules = part.Modules; for (int j = 0; j < modules.Count; j++) { var module = modules [j]; // Near future fission reactors if (module.moduleName == "FissionGenerator") { otherPower += double.Parse(module.Fields.GetValue("CurrentGeneration").ToString()); } } // USI reactors ModuleResourceConverter converterModule = part.FindModuleImplementing <ModuleResourceConverter> (); if (converterModule != null) { if (converterModule.ModuleIsActive() && converterModule.ConverterName == "Reactor") { for (int j = 0; j < converterModule.outputList.Count; ++j) { var resource = converterModule.outputList [j]; if (resource.ResourceName == "ElectricCharge") { otherPower += resource.Ratio * converterModule.GetEfficiencyMultiplier(); } } } } } return(otherPower); } // So many ifs.....
private void AttemptTransfer() { Part targetPart = GetPartClicked(); // No part was clicked if (targetPart == null) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortNoPartSelected"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); EndTransfer(); } else { // part cannot be on another vessel if (!VesselConnected(targetPart)) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortUnconnected"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); EndTransfer(); return; } RadioactiveStorageContainer container = targetPart.GetComponent <RadioactiveStorageContainer>(); if (container == null) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortNoRadStorage"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); EndTransfer(); } else { ModuleResourceConverter converter = container.GetComponent <ModuleResourceConverter>(); FissionReactor reactor = container.GetComponent <FissionReactor>(); if (core != null && core.CoreTemperature > container.MaxTempForTransfer) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortTooHot", container.MaxTempForTransfer.ToString("F0")), 5.0f, ScreenMessageStyle.UPPER_CENTER)); } else if (converter != null && converter.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortToRunningConverter"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); } else if (reactor != null && reactor.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortToRunningReactor"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); } else { // get available space in the target container double availableSpace = container.GetResourceAmount(curTransferType, true) - container.GetResourceAmount(curTransferType); double availableResource = this.GetResourceAmount(curTransferType); // transfer as much as possible double amount = this.part.RequestResource(curTransferType, availableSpace); container.part.RequestResource(curTransferType, -amount); ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_Success", amount.ToString("F1"), curTransferType.ToString()), 5.0f, ScreenMessageStyle.UPPER_CENTER)); transferring = false; curTransferType = ""; } } } }
void onTimeWarpRateChanged() { if (TimeWarp.fetch != null) { //Log.Info("TimeWarp.fetch.current_rate_index: " + TimeWarp.fetch.current_rate_index.ToString() + " New time warp: " + TimeWarp.fetch.warpRates[TimeWarp.fetch.current_rate_index].ToString() + " lastWarpRate: " + lastWarpRate.ToString()); if (lastWarpRateIdx > 0 && TimeWarp.fetch.warpRates[TimeWarp.fetch.current_rate_index] > 1) { foreach (var v in FlightGlobals.fetch.vesselsLoaded) { foreach (var p in v.Parts) { foreach (PartModule tmpPM in p.Modules) { // Find all modules of type BaseConvertor which are inactive switch (tmpPM.moduleName) { case "FissionReactor": case "KFAPUController": case "ModuleResourceConverter": ModuleResourceConverter tmpGen = (ModuleResourceConverter)tmpPM; Log.Info("Module: " + tmpGen.moduleName + " IsActivated: " + tmpGen.IsActivated.ToString()); if (!tmpGen.IsActivated) { if (!resourceConverterParts.Contains(p)) { resourceConverterParts.Add(p); } } else { if (resourceConverterParts.Contains(p)) { resourceConverterParts.Remove(p); FieldInfo fi = tmpGen.GetType().GetField("lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) { Log.Info("Updating lastUpdateTime"); fi.SetValue(tmpGen, Planetarium.GetUniversalTime()); } else { Log.Info("Unable to get pointer to lastUpdateTime"); } } } break; } } } } } lastWarpRateIdx = TimeWarp.fetch.current_rate_index; } }
public void AddConverter(ModuleResourceConverter converter) { if (_multiConverter.converters.Contains(converter) == false) { _multiConverter.converters.Add(converter); if (addedPartModules.Contains(converter)) addedPartModules.Remove(converter); } }
void Process_fission_generator(Part p, PartModule m) { double max_rate = Lib.ReflectionValue<float>(m, "PowerGeneration"); // get fission reactor tweakable, will default to 1.0 for other modules ModuleResourceConverter reactor = p.FindModuleImplementing<ModuleResourceConverter>(); double tweakable = reactor == null ? 1.0 : Lib.ReflectionValue<float>(reactor, "CurrentPowerPercent") * 0.01f; Resource("ElectricCharge").Produce(max_rate * tweakable, "fission generator"); }
public void AddConverter(ModuleResourceConverter converter) { if (_multiConverter.converters.Contains(converter) == false) { _multiConverter.converters.Add(converter); if (addedPartModules.Contains(converter)) { addedPartModules.Remove(converter); } } }
public override void OnUpdate() { base.OnUpdate(); if (converter == null && HighLogic.LoadedSceneIsFlight) { converter = this.part.FindModuleImplementing <ModuleResourceConverter>(); } float powerLevel = converter.IsActivated ? 1.0f : 0.0f; this.part.Effect(exhaustEffect, powerLevel); }
// Load the needed propellants private void loadConverters() { converters.Clear(); for (int i = 0; i < part.Modules.Count; i++) { if (part.Modules[i] is ModuleResourceConverter) { ModuleResourceConverter converter = (ModuleResourceConverter)part.Modules[i]; if (converter.ConverterName != string.Empty) { converters.Add(converter); } } } }
public void SaveConverterState(ModuleResourceConverter converter, ConfigNode node) { //Save the converter's name and activation state. node.AddValue("ConverterName", converter.ConverterName); node.AddValue("IsActivated", converter.IsActivated.ToString()); if (converter.IsActivated) { node.AddValue("lastUpdateTime", Planetarium.GetUniversalTime()); } node.AddValue("HeatThrottle", converter.HeatThrottle); node.AddValue("HeatThrottleSpeed", converter.HeatThrottleSpeed); node.AddValue("avgHeatThrottle", converter.avgHeatThrottle); node.AddValue("DirtyFlag", converter.DirtyFlag); }
/// <summary> /// Called by unity API on game start. /// </summary> /// <param name="state">The state.</param> public override void OnStart(StartState state) { // ReSharper disable once InconsistentNaming const string EC = "ElectricCharge"; try { base.OnStart(state: state); Fields[fieldName : "MinThresholdAxis"].OnValueModified += o => MinThresholdAxis = Thresholds.x = (float)UtilMath.Clamp( value : MinThresholdAxis, min : MinThresholdPercent, max : MaxThresholdAxis ); Fields[fieldName : "MaxThresholdAxis"].OnValueModified += o => MaxThresholdAxis = Thresholds.y = (float)UtilMath.Clamp( value : MaxThresholdAxis, min : MinThresholdAxis + 1.0f, max : MaxThresholdPercent ); // obtain the EC resource _electricCharge = part.Resources?.Get(name: EC); if (_electricCharge == null) { DebugLog(m: "Error: failed to obtain EC resource"); // warn if not found, this module cannot function without. } // find the first converter module that outputs EC _resourceConverter = part.Modules.GetModules <ModuleResourceConverter>() .First( predicate: converter => converter.outputList.Any( predicate: resource => resource.ResourceName.Equals( value: EC, comparisonType: StringComparison .InvariantCultureIgnoreCase ) ) ); if (_resourceConverter == null) { DebugLog(m: "Error: failed to obtain Resource Converter"); // warn if not found, this module cannot function without. } } catch (Exception e) { DebugLog(m: e); } }
protected virtual void runHeadless(ModuleResourceConverter converter) { foreach (BaseEvent baseEvent in converter.Events) { baseEvent.guiActive = false; baseEvent.guiActiveEditor = false; } foreach (BaseField baseField in converter.Fields) { baseField.guiActive = false; baseField.guiActiveEditor = false; } //Dirty the GUI MonoUtilities.RefreshContextWindows(this.part); }
private void CorrectLastUpdateTime(ModuleResourceConverter mrc) { if (mrc is null) { throw new ArgumentNullException(nameof(mrc)); } FieldInfo fi = mrc.GetType().GetField("lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) { fi.SetValue(mrc, Planetarium.GetUniversalTime()); } else { throw new InvalidOperationException("Unable to get a lastUpdateTime field on module " + mrc.moduleName); } }
public override void OnStart(StartState state) { base.OnStart(state); WBIConvertibleStorage storage = this.part.FindModuleImplementing <WBIConvertibleStorage>(); if (storage != null) { storage.Events["ReconfigureStorage"].guiName = "Select Fuel"; storage.SetWindowTitle("Select Fuel"); if (HighLogic.LoadedSceneIsFlight) { storage.onModuleRedecorated += new ModuleRedecoratedEvent(storage_onModuleRedecorated); } converter = this.part.FindModuleImplementing <ModuleResourceConverter>(); } }
public override void OnStart(StartState state) { base.OnStart(state); converter = this.part.FindModuleImplementing <ModuleResourceConverter>(); ResourceRatio[] outputs = converter.outputList.ToArray(); ResourceRatio output; for (int index = 0; index < outputs.Length; index++) { output = outputs[index]; if (output.ResourceName == "ElectricCharge") { ecBaseOutput = output.Ratio; break; } } }
protected override bool CanDoProduction(ModuleResourceConverter resourceConverter, out string reasonWhyNotMessage) { if (!base.CanDoProduction(resourceConverter, out reasonWhyNotMessage)) { return(false); } if (!ResourceLodeScenario.Instance.TryFindResourceLodeInRange(this.vessel, this.Tier, out _)) { if (this.isEnabled) { // Shenanigans! When the scene is first loaded in, the waypoint distance calculation is // broken and reports us as a couple kilometers away from the waypoint. After 3 or 4 // physics frames, that seems to square itself. So this thing basically just holds its // water for 3 seconds. I suppose this could get into trouble if you had some kind of // mod that allows you to warp into a zone with time-warp on. We could fix that, but // folks who run mods like that probably like a little excitement in their lives, so // let's leave it in this way. double now = Planetarium.GetUniversalTime(); if (timeAtFirstDisableAttempt == 0) { timeAtFirstDisableAttempt = now; } else if (now > timeAtFirstDisableAttempt + 3.0) { ScreenMessages.PostScreenMessage("There are no crushins to be found here! Go to your oribiting scanner and find a resource lode.", duration: 20.0f); var converter = this.part.FindModuleImplementing <BaseConverter>(); converter?.StopResourceConverter(); var animation = this.part.FindModuleImplementing <ModuleAnimationGroup>(); animation?.RetractModule(); } } reasonWhyNotMessage = "No loose crushins nearby"; return(false); } timeAtFirstDisableAttempt = 0; return(true); }
// When coming out of warp, fix issue with ResourceConverter void onPartUnpack(Part p) { Log.Info("Unpacking part: " + p.partInfo.name); if (resourceConverterParts.Contains(p)) { resourceConverterParts.Remove(p); foreach (PartModule tmpPM in p.Modules) { // Find all modules of type BaseConvertor // If !IsActivated, then // set lastUpdateTime = Planetarium.GetUniversalTime(); // lastUpdateTime is a protected field, so Reflection was needed to fix this switch (tmpPM.moduleName) { case "FissionReactor": case "KFAPUController": case "ModuleResourceConverter": ModuleResourceConverter tmpGen = (ModuleResourceConverter)tmpPM; Log.Info("Module: " + tmpGen.moduleName + " IsActivated: " + tmpGen.IsActivated.ToString()); // if (!tmpGen.IsActivated) { FieldInfo fi = tmpGen.GetType().GetField("lastUpdateTime", BindingFlags.NonPublic | BindingFlags.Instance); if (fi != null) { Log.Info("Updating lastUpdateTime"); fi.SetValue(tmpGen, Planetarium.GetUniversalTime()); } else { Log.Info("Unable to get pointer to lastUpdateTime"); } } break; } } } }
public void RunHeadless(ModuleResourceConverter converter) { foreach (BaseEvent baseEvent in converter.Events) { baseEvent.guiActive = false; baseEvent.guiActiveEditor = false; } foreach (BaseField baseField in converter.Fields) { baseField.guiActive = false; baseField.guiActiveEditor = false; } //Dirty the GUI UIPartActionWindow tweakableUI = Utils.FindActionWindow(this.part); if (tweakableUI != null) { tweakableUI.displayDirty = true; } }
protected void setConverterState(ModuleResourceConverter converter) { ConfigNode node; string value; if (converterStates.ContainsKey(converter.ConverterName)) { node = converterStates[converter.ConverterName]; if (node != null) { if (node.HasValue("IsActivated")) { value = node.GetValue("IsActivated"); if (value.ToLower() == "true") { converter.StartResourceConverter(); } } } } }
public override void updateMultiMode(bool silentUpdate = false) { GTIDebug.Log("GTI_MultiModeConverter: updateMultiMode() --> Begin", iDebugLevel.High); //FindSelectedMode(); if (silentUpdate == false) { writeScreenMessage(); } bool MAG_isDeployed = true; if (MAG != null && useModuleAnimationGroup == true) { MAG_isDeployed = MAG.isDeployed; } for (int i = 0; i < modes.Count; i++) { if (i == selectedMode && MAG_isDeployed) { GTIDebug.Log("GTI_MultiMode (" + (silentUpdate ? "silent" : "non-silent") + "): Activate Module [" + modes[i].moduleIndex + "] --> " + MRC[modes[i].moduleIndex].ConverterName, iDebugLevel.High); MRC[modes[i].moduleIndex].EnableModule(); currentConverter = MRC[modes[i].moduleIndex]; } else { GTIDebug.Log("GTI_MultiMode (" + (silentUpdate ? "silent" : "non-silent") + "): Deactivate Module [" + modes[i].moduleIndex + "] --> " + MRC[modes[i].moduleIndex].ConverterName, iDebugLevel.High); //Deactivate the converter MRC[modes[i].moduleIndex].DisableModule(); //Stop the converter MRC[modes[i].moduleIndex].StopResourceConverter(); } } MonoUtilities.RefreshContextWindows(part); GTIDebug.Log("GTI_MultiModeConverter: updateMultiMode() --> Finished", iDebugLevel.DebugInfo); }
/// <summary> /// Iterate over the modules in the craft and return all of them that /// implement a ModuleGenerator or ModuleResourceConverter that generates /// electricity that can also be shut down. /// </summary> /// <param name="vessel"></param> /// <returns></returns> private static System.Collections.Generic.IEnumerable <PartModule> ElectricGenerators(Vessel vessel) { foreach (Part part in vessel.Parts) { foreach (PartModule pm in part.Modules) { if (pm is ModuleGenerator) { ModuleGenerator gen = pm as ModuleGenerator; if (gen.isAlwaysActive == false) { for (int i = 0; i < gen.outputList.Count; ++i) { if (gen.outputList[i].name == "ElectricCharge") { yield return(pm); } } } } else if (pm is ModuleResourceConverter) { ModuleResourceConverter gen = pm as ModuleResourceConverter; if (gen.AlwaysActive == false) { ConversionRecipe recipe = gen.Recipe; for (int i = 0; i < recipe.Outputs.Count; ++i) { if (recipe.Outputs[i].ResourceName == "ElectricCharge") { yield return(pm); } } } } } } }
/// <summary> /// Iterate over the modules in the craft and return all of them that /// implement a ModuleGenerator or ModuleResourceConverter that generates /// electricity that can also be shut down. /// </summary> /// <param name="vessel"></param> /// <returns></returns> private static System.Collections.Generic.IEnumerable <PartModule> ElectricGenerators(Vessel vessel) { for (int partID = 0; partID < vessel.Parts.Count; ++partID) { for (int moduleID = 0; moduleID < vessel.Parts[partID].Modules.Count; ++moduleID) { if (vessel.Parts[partID].Modules[moduleID] is ModuleGenerator) { ModuleGenerator gen = vessel.Parts[partID].Modules[moduleID] as ModuleGenerator; if (gen.isAlwaysActive == false) { for (int i = 0; i < gen.outputList.Count; ++i) { if (gen.outputList[i].name == "ElectricCharge") { yield return(vessel.Parts[partID].Modules[moduleID]); } } } } else if (vessel.Parts[partID].Modules[moduleID] is ModuleResourceConverter) { ModuleResourceConverter gen = vessel.Parts[partID].Modules[moduleID] as ModuleResourceConverter; if (gen.AlwaysActive == false) { ConversionRecipe recipe = gen.Recipe; for (int i = 0; i < recipe.Outputs.Count; ++i) { if (recipe.Outputs[i].ResourceName == "ElectricCharge") { yield return(vessel.Parts[partID].Modules[moduleID]); } } } } } } }
public bool PartCanTransferResource(string nm) { // Some modules need to be off. ModuleResourceConverter converter = GetComponent <ModuleResourceConverter>(); FissionReactor reactor = GetComponent <FissionReactor>(); if (converter != null && converter.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage("Cannot transfer from a running converter!", 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } if (reactor != null && reactor.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage("Cannot transfer from a running reactor! Seriously a bad idea!", 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if the part is too hot if (part.temperature > MaxTempForTransfer) { ScreenMessages.PostScreenMessage(new ScreenMessage(String.Format("This part must be below {0:F0} K to transfer!", MaxTempForTransfer), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if that part can't contain this resource if ((GetResourceAmount(nm, true) <= 0d)) { ScreenMessages.PostScreenMessage(new ScreenMessage("This part has no " + nm + " to transfer!", 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if this part has no resource if (GetResourceAmount(nm) <= 0d) { ScreenMessages.PostScreenMessage(new ScreenMessage("This part has no " + nm + " to transfer!", 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } return(true); }
public bool PartCanTransferResource(string nm) { // Some modules need to be off. ModuleResourceConverter converter = GetComponent <ModuleResourceConverter>(); FissionReactor reactor = GetComponent <FissionReactor>(); if (converter != null && converter.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortFromRunningConverter"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } if (reactor != null && reactor.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortFromRunningReactor"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if the part is too hot if (core != null && core.CoreTemperature > MaxTempForTransfer) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortTooHot", MaxTempForTransfer.ToString("F0")), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if that part can't contain this resource if ((GetResourceAmount(nm, true) <= 0d)) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortNoResource", nm), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if this part has no resource if (GetResourceAmount(nm) <= 0d) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_NFElectrical_ModuleRadioactiveStorageContainer_Message_AbortNoResource", nm), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } return(true); }
void Process_converter(ModuleResourceConverter converter, VesselAnalyzer va) { // calculate experience bonus float exp_bonus = converter.UseSpecialistBonus ? converter.EfficiencyBonus * (converter.SpecialistBonusBase + (converter.SpecialistEfficiencyFactor * (va.crew_engineer_maxlevel + 1))) : 1.0f; // use part name as recipe name // - include crew bonus in the recipe name string recipe_name = Lib.BuildString(converter.part.partInfo.title, " (efficiency: ", Lib.HumanReadablePerc(exp_bonus), ")"); // generate recipe SimulatedRecipe recipe = new SimulatedRecipe(converter.part, recipe_name); foreach (ResourceRatio res in converter.inputList) { recipe.Input(res.ResourceName, res.Ratio * exp_bonus); } foreach (ResourceRatio res in converter.outputList) { recipe.Output(res.ResourceName, res.Ratio * exp_bonus, res.DumpExcess); } recipes.Add(recipe); }
public void RunHeadless(ModuleResourceConverter converter) { foreach (BaseEvent baseEvent in converter.Events) { baseEvent.guiActive = false; baseEvent.guiActiveEditor = false; } foreach (BaseField baseField in converter.Fields) { baseField.guiActive = false; baseField.guiActiveEditor = false; } //Dirty the GUI UIPartActionWindow tweakableUI = Utils.FindActionWindow(this.part); if (tweakableUI != null) tweakableUI.displayDirty = true; }
public void SaveConverterState(ModuleResourceConverter converter, ConfigNode node) { //Save the converter's name and activation state. node.AddValue("ConverterName", converter.ConverterName); node.AddValue("IsActivated", converter.IsActivated.ToString()); if (converter.IsActivated) node.AddValue("lastUpdateTime", Planetarium.GetUniversalTime()); node.AddValue("HeatThrottle", converter.HeatThrottle); node.AddValue("HeatThrottleSpeed", converter.HeatThrottleSpeed); node.AddValue("avgHeatThrottle", converter.avgHeatThrottle); node.AddValue("DirtyFlag", converter.DirtyFlag); }
protected void setConverterState(ModuleResourceConverter converter) { ConfigNode node; string value; if (converterStates.ContainsKey(converter.ConverterName)) { node = converterStates[converter.ConverterName]; if (node != null) { if (node.HasValue("IsActivated")) { value = node.GetValue("IsActivated"); if (value.ToLower() == "true") converter.StartResourceConverter(); } } } }
public float GetConverterHeat(ModuleResourceConverter converter) { return converter.TemperatureModifier; }