/// <summary> /// Sets up heat related parameters /// </summary> void SetupHeat() { if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) { heatModule = part.GetComponents <ModuleSystemHeat>().ToList().Find(x => x.moduleID == HeatModuleID); } }
public void SetupLoop(HeatLoop lp, ModuleSystemHeat sh, bool visible) { SetupComponents(); loop = lp; heatModule = sh; // Utils.Log($"{loop} {heatModule}, {colorRing}, {infoPanelTitle}"); infoPanelTitle.text = heatModule.part.partInfo.title; colorRing.color = SystemHeatSettings.GetLoopColor(loop.ID); Transform xform = transform.FindDeepChild(heatModule.iconName); if (xform != null) { systemIcon.sprite = xform.GetComponent <Image>().sprite; } SetVisibility(visible); }
public void UpdateLoop(HeatLoop lp, ModuleSystemHeat sh, bool visible) { loop = lp; heatModule = sh; Transform xform; if (heatModule != null && heatModule.part != null) { infoPanelTitle.text = heatModule.part.partInfo.title; xform = transform.FindDeepChild(heatModule.iconName); if (xform != null) { systemIcon.sprite = xform.GetComponent <Image>().sprite; } } colorRing.color = SystemHeatSettings.GetLoopColor(loop.ID); SetVisibility(visible); }
/// <summary> /// Test to see if this part can transfter resources /// </summary> /// <param name="nm"></param> /// <returns></returns> protected bool CheckPartRequirements() { // Some modules need to be off. ModuleSystemHeat heat = GetComponent <ModuleSystemHeat>(); ModuleSystemHeatConverter[] converters = GetComponents <ModuleSystemHeatConverter>(); ModuleSystemHeatFissionReactor reactor = GetComponent <ModuleSystemHeatFissionReactor>(); ModuleSystemHeatFissionEngine engine = GetComponent <ModuleSystemHeatFissionEngine>(); // Fail if a converter is on foreach (ModuleSystemHeatConverter converter in converters) { if (converter != null && converter.ModuleIsActive()) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Message_AbortFromRunningConverter"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } } // Fail if a reactor is on if (reactor != null && reactor.Enabled) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Message_AbortFromRunningReactor"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } //Fail if an nuclear engine is on if (engine != null && engine.Enabled) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Message_AbortFromRunningReactor"), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } // Fail if the part is too hot if (heat != null && heat.LoopTemperature > MaxTemperatureForRefuel) { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionFuelContainer_Message_AbortTooHot", MaxTemperatureForRefuel.ToString("F0")), 5.0f, ScreenMessageStyle.UPPER_CENTER)); return(false); } return(true); }
public void SetReactor(PartModule m) { if (rect == null) { FindComponents(); } if (SystemHeatSettings.DebugUI) { Utils.Log($"[ReactorWidget]: Setting up widget for PM {m}"); } module = m; reactorName.text = m.part.partInfo.title; datafields = new Dictionary <string, ReactorDataField>(); // Set the data depending on the reactor type iconRoot.gameObject.SetActive(false); heatModule = module.GetComponent <ModuleSystemHeat>(); if (SystemHeatSettings.DebugUI) { Utils.Log($"[ReactorWidget]: Setting up specifc properties for for PM {m}"); } if (m.moduleName == "ModuleSystemHeatFissionReactor") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FissionReactorIcon").gameObject.SetActive(true); AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; spacer.SetActive(false); chargeElement.SetActive(false); } if (m.moduleName == "ModuleSystemHeatFissionEngine") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FissionEngineIcon").gameObject.SetActive(true); AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; spacer.SetActive(false); chargeElement.SetActive(false); } if (m.moduleName == "ModuleFusionEngine") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FusionEngineIcon").gameObject.SetActive(true); AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); bool isOn = false; bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out isOn); onToggle.isOn = isOn; bool chargeOn = false; bool.TryParse(module.Fields.GetValue("Charging").ToString(), out chargeOn); spacer.SetActive(true); chargeElement.SetActive(true); if (chargeOn) { chargeToggle.isOn = chargeOn; } } if (m.moduleName == "FusionReactor") { iconRoot.gameObject.SetActive(true); iconRoot.FindDeepChild("FusionReactorIcon").gameObject.SetActive(true); AddDataWidget("heatGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_HeatGeneratedTitle")); AddDataWidget("powerGenerated", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_PowerGeneratedTitle")); AddDataWidget("lifetime", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreLifeTitle")); AddDataWidget("temperature", Localizer.Format("#LOC_SystemHeat_ReactorPanel_Field_CoreTemperatureTitle")); Utils.Log($"x"); Utils.Log($"{spacer}"); bool.TryParse(module.Fields.GetValue("Enabled").ToString(), out bool isOn); onToggle.isOn = isOn; bool.TryParse(module.Fields.GetValue("Charging").ToString(), out bool chargeOn); Utils.Log($"{chargeElement}"); Utils.Log($"{chargeToggle}"); spacer.SetActive(true); chargeElement.SetActive(true); if (chargeOn) { chargeToggle.isOn = chargeOn; } } }