public override bool Initialize(PartModule pm) { base.Initialize(pm); engines = pm.GetComponents <ModuleEnginesFX>(); multiEngine = pm.GetComponent <MultiModeEngine>(); return(true); }
// Finds a list of all fission containers List <FissionContainer> FindFissionContainers() { List <FissionContainer> fissionContainers = new List <FissionContainer>(); List <Part> allParts = this.vessel.parts; foreach (Part pt in allParts) { PartModuleList pml = pt.Modules; for (int i = 0; i < pml.Count; i++) { PartModule curModule = pml.GetModule(i); FissionContainer candidate = curModule.GetComponent <FissionContainer>(); if (candidate != null) { fissionContainers.Add(candidate); } } } if (fissionContainers.Count == 0) { ScreenMessages.PostScreenMessage(new ScreenMessage("No nuclear fuel containers attached to this ship.", 4f, ScreenMessageStyle.UPPER_CENTER)); } return(fissionContainers); }
public override bool Initialize(PartModule pm) { base.Initialize(pm); harvester = (ModuleResourceHarvester)pm; core = pm.GetComponent <ModuleCoreHeat>(); return(harvester.GeneratesHeat); }
public void FindCapacitors() { activeVessel = FlightGlobals.ActiveVessel; partCount = activeVessel.parts.Count; //Debug.Log("NFE: Capacitor Manager: Finding Capcitors"); List <DischargeCapacitor> unsortedCapacitorList = new List <DischargeCapacitor>(); // Get all parts List <Part> allParts = FlightGlobals.ActiveVessel.parts; foreach (Part pt in allParts) { PartModuleList modules = pt.Modules; for (int i = 0; i < modules.Count; i++) { PartModule curModule = modules.GetModule(i); if (curModule.ClassName == "DischargeCapacitor") { unsortedCapacitorList.Add(curModule.GetComponent <DischargeCapacitor>()); } } } //sort capacitorList = unsortedCapacitorList.OrderByDescending(x => x.dischargeActual).ToList(); capacitorList = unsortedCapacitorList; // Debug.Log("NFE: Capacitor Manager: Found " + capacitorList.Count() + " capacitors"); }
void sumForces(List <PartModule> moduleList, Transform refTransform, ref Vector3 translation, ref Vector3 torque) { List <PartModule> .Enumerator em = moduleList.GetEnumerator(); while (em.MoveNext()) { PartModule mod = em.Current; if (mod == null) { continue; } ModuleForces mf = mod.GetComponent <ModuleForces> (); if (mf == null || !mf.enabled) { continue; } for (int t = 0; t < mf.vectors.Length; t++) { Vector3 force = -1 * mf.vectors [t].value; /* vectors represent exhaust force, * so -1 for actual thrust */ translation += force; torque += calcTorque(mf.vectors [t].transform, refTransform, force); } } }
void addForce <T>(PartModule module) where T : ModuleForces { T force = module.GetComponent <T>(); if (force == null) { module.gameObject.AddComponent <T>(); } }
void addForce <T> (PartModule module) where T : ModuleForces { T force = module.GetComponent <T> (); if (force == null) { module.gameObject.AddComponent <T> (); } else if (!force.enabled) { force.Enable(); } }
// Finds vVariablePowerEngines on the ship private void SetupVariableEngines() { allVariableEngines = new List <VariablePowerEngine>(); for (int j = 0; j < this.vessel.parts.Count; j++) { PartModuleList pml = this.vessel.parts[j].Modules; for (int i = 0; i < pml.Count; i++) { PartModule curModule = pml.GetModule(i); VariablePowerEngine candidate = curModule.GetComponent <VariablePowerEngine>(); if (candidate != null && candidate != this && !allVariableEngines.Contains(candidate)) { allVariableEngines.Add(candidate); } } } }
private void SetupVariableEngines() { allVariableEngines = new List <VariableISPEngine>(); List <Part> allParts = this.vessel.parts; foreach (Part pt in allParts) { PartModuleList pml = pt.Modules; for (int i = 0; i < pml.Count; i++) { PartModule curModule = pml.GetModule(i); VariableISPEngine candidate = curModule.GetComponent <VariableISPEngine>(); if (candidate != null && candidate != this && !allVariableEngines.Contains(candidate)) { allVariableEngines.Add(candidate); } } } }
// Finds all reactors on ship public void FindReactors() { //Debug.Log("NFT: Reactor UI: Finding reactors"); reactorList = new List <FissionGenerator>(); // Get all parts List <Part> allParts = FlightGlobals.ActiveVessel.parts; foreach (Part pt in allParts) { PartModuleList modules = pt.Modules; for (int i = 0; i < modules.Count; i++) { PartModule curModule = modules.GetModule(i); if (curModule.ClassName == "FissionGenerator") { reactorList.Add(curModule.GetComponent <FissionGenerator>()); } } } //Debug.Log("NFT: Reactor UI: Found " + reactorList.Count() + " reactors"); }
// Gets all attached radiators private void SetupRadiators() { Debug.Log("NFPP: Fission Reactor: begin radiator check...."); radiators = new List <FissionRadiator>(); // Get attached radiators Part[] children = this.part.FindChildParts <Part>(); // Debug.Log("NFPP: Reactor has " + children.Length.ToString()+" children"); foreach (Part pt in children) { PartModuleList modules = pt.Modules; for (int i = 0; i < modules.Count; i++) { PartModule curModule = modules.GetModule(i); FissionRadiator candidate = curModule.GetComponent <FissionRadiator>(); if (candidate != null) { radiators.Add(candidate); } } } Debug.Log("NFPP: Fission Reactor: Completed radiator check"); }
void sumForces(List <PartModule> moduleList, Transform refTransform, ref Vector3 translation, ref Vector3 torque) { for (int i = 0; i < moduleList.Count; i++) { PartModule mod = moduleList [i]; if (mod == null) { continue; } ModuleForces mf = mod.GetComponent <ModuleForces> (); if (mf == null || !mf.enabled) { continue; } for (int t = 0; t < mf.vectors.Length; t++) { /* vectors represent exhaust force, so -1 for actual thrust */ Vector3 force = -1 * mf.vectors [t].value; translation += force; torque += calcTorque(mf.vectors [t].transform, refTransform, force); } } }
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; } } }
public override void OnStart(PartModule.StartState state) { if (state != StartState.Editor) { started = true; } else { started = false; } // Get moduleEngines PartModuleList pml = this.part.Modules; for (int i = 0; i < pml.Count; i++) { PartModule curModule = pml.GetModule(i); engine = curModule.GetComponent <ModuleEnginesFX>(); } if (engine != null) { Debug.Log("NFPP: Engine Check Passed"); } foreach (Propellant prop in engine.propellants) { if (prop.name == FuelName) { fuelPropellant = prop; } if (prop.name == "ElectricCharge") { ecPropellant = prop; } } if (UseDirectThrottle) { ChangeIspAndThrust(engine.requestedThrottle); } else { ChangeIspAndThrust(CurThrustSetting / 100f); } if (state != StartState.Editor) { SetupVariableEngines(); } CalculateCurves(); Debug.Log("NFPP: Variable ISP engine setup complete"); if (UseDirectThrottle) { Debug.Log("NFPP: Using direct throttle method"); } }