public override void OnStart(PartModule.StartState state) { // calculate WasteHeat Capacity var wasteheatPowerResource = part.Resources.FirstOrDefault(r => r.resourceName == ResourceManager.FNRESOURCE_WASTEHEAT); if (wasteheatPowerResource != null) { var wasteheat_ratio = Math.Min(wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount, 0.95); wasteheatPowerResource.maxAmount = part.mass * 2.0e+4 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * wasteheat_ratio; } if (state == StartState.Editor) { return; } _attached_engine = this.part.FindModuleImplementing <ModuleEnginesFX>(); _attached_warpable_engine = _attached_engine as ModuleEnginesWarp; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } else { Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); } // first try to look in part _attached_reactor = this.part.FindModuleImplementing <IChargedParticleSource>(); // try to find nearest if (_attached_reactor == null) { _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); } if (_attached_reactor == null) { Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } double joules_per_amu = _attached_reactor.CurrentMeVPerChargedProduct * 1e6 * GameConstants.ELECTRON_CHARGE / GameConstants.dilution_factor; calculatedIsp = Math.Sqrt(joules_per_amu * 2.0 / GameConstants.ATOMIC_MASS_UNIT) / PluginHelper.GravityConstant; minimum_isp = calculatedIsp * _attached_reactor.MinimumChargdIspMult; maximum_isp = calculatedIsp * _attached_reactor.MaximumChargedIspMult; max_power_multiplier = Math.Log10(maximum_isp / minimum_isp); throtleExponent = Math.Abs(Math.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); exchanger_thrust_divisor = radius > _attached_reactor.Radius ? _attached_reactor.Radius * _attached_reactor.Radius / radius / radius : radius * radius / _attached_reactor.Radius / _attached_reactor.Radius; }
public override void OnStart(PartModule.StartState state) { if (maintainsPropellantBuffer) { propellantBufferResourceDefinition = PartResourceLibrary.Instance.GetDefinition(propellantBufferResourceName); } resourceBuffers = new ResourceBuffers(); resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 1.0e+6, true)); resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass); resourceBuffers.Init(this.part); _attached_warpable_engine = this.part.FindModuleImplementing <ModuleEnginesWarp>(); _attached_engine = _attached_warpable_engine; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } ConnectToReactor(); UpdateEngineStats(true); max_power_multiplier = Math.Log10(maximum_isp / minimum_isp); throtleExponent = Math.Abs(Math.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); simulatedThrottleFloatRange = Fields["simulatedThrottle"].uiControlEditor as UI_FloatRange; simulatedThrottleFloatRange.onFieldChanged += UpdateFromGUI; if (_attached_reactor == null) { Debug.LogWarning("[KSPI]: InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } exchanger_thrust_divisor = radius >= _attached_reactor.Radius ? 1 : radius * radius / _attached_reactor.Radius / _attached_reactor.Radius; InitializesPropellantBuffer(); if (_attached_engine != null && _attached_engine is ModuleEnginesFX) { if (!String.IsNullOrEmpty(runningEffectName)) { part.Effect(runningEffectName, 0, -1); } if (!String.IsNullOrEmpty(powerEffectName)) { part.Effect(powerEffectName, 0, -1); } } Fields["partMass"].guiActiveEditor = showPartMass; Fields["partMass"].guiActive = showPartMass; }
public override void OnStart(PartModule.StartState state) { var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT); // calculate WasteHeat Capacity if (wasteheatPowerResource != null) { var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount; wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio; } if (state == StartState.Editor) { return; } _attached_engine = this.part.FindModuleImplementing <ModuleEnginesFX>(); //this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX; _attached_warpable_engine = _attached_engine as ModuleEnginesWarp; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } else { UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); } // first try to look in part _attached_reactor = this.part.FindModuleImplementing <IChargedParticleSource>(); // try to find nearest if (_attached_reactor == null) { _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); } if (_attached_reactor == null) { UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } double joules_per_amu = _attached_reactor.CurrentMeVPerChargedProduct * 1e6 * GameConstants.ELECTRON_CHARGE / GameConstants.dilution_factor; calculatedIsp = Math.Sqrt(joules_per_amu * 2.0 / GameConstants.ATOMIC_MASS_UNIT) / PluginHelper.GravityConstant; throtleExponent = Mathf.Abs(Mathf.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); exchanger_thrust_divisor = radius > _attached_reactor.GetRadius() ? _attached_reactor.GetRadius() * _attached_reactor.GetRadius() / radius / radius : radius * radius / _attached_reactor.GetRadius() / _attached_reactor.GetRadius(); // Does this really need to be done each update? Or at all since it uses particles instead of thermal power? }
public override void OnStart(StartState state) { try { Debug.Log("[KSPI]: Start State: " + state.ToString()); Debug.Log("[KSPI]: Already Launched: " + Launched); curEngineT = this.part.FindModuleImplementing <ModuleEngines>(); curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>(); InitializeGUI(); _fuelConfigurationWithEffect = FuelConfigurations.Where(m => !string.IsNullOrEmpty(m.effectname)).ToList(); _fuelConfigurationWithEffect.ForEach(prop => part.Effect(prop.effectname, 0, -1)); if (state == StartState.Editor) { Debug.Log("[KSPI]: Editor"); hideEmpty = false; selectedTank = selectedFuel; selectedTankName = FuelConfigurations[selectedFuel].ConfigName; //UpdateResources(); } else { hideEmpty = true; if (state == StartState.PreLaunch) // startstate normally == prelaunch,landed { Debug.Log("[KSPI]: PreLaunch"); hideEmpty = true; //UpdateResources(); //UpdateusefulConfigurations(); InitializeFuelSelector(); } else { Debug.Log("[KSPI]: No PreLaunch"); } } Debug.Log("[KSPI]: OnStart calls UpdateFuel"); UpdateFuel(); Events["ShowFuels"].active = hideEmpty; Events["HideFuels"].active = !hideEmpty; } catch (Exception e) { Debug.LogError("EngineECU2 OnStart eception: " + e.Message); } base.OnStart(state); }
public override void OnStart(PartModule.StartState state) { resourceBuffers = new ResourceBuffers(); resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 2.0e+4, true)); resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass); resourceBuffers.Init(this.part); if (state == StartState.Editor) { return; } _attached_warpable_engine = this.part.FindModuleImplementing <ModuleEnginesWarp>(); _attached_engine = _attached_warpable_engine; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } else { Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); } // first try to look in part _attached_reactor = this.part.FindModuleImplementing <IChargedParticleSource>(); // try to find nearest if (_attached_reactor == null) { _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); } if (_attached_reactor == null) { Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } double joules_per_amu = _attached_reactor.CurrentMeVPerChargedProduct * 1e6 * GameConstants.ELECTRON_CHARGE / GameConstants.dilution_factor; calculatedIsp = Math.Sqrt(joules_per_amu * 2.0 / GameConstants.ATOMIC_MASS_UNIT) / PluginHelper.GravityConstant; minimum_isp = calculatedIsp * _attached_reactor.MinimumChargdIspMult; maximum_isp = calculatedIsp * _attached_reactor.MaximumChargedIspMult; max_power_multiplier = Math.Log10(maximum_isp / minimum_isp); throtleExponent = Math.Abs(Math.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); exchanger_thrust_divisor = radius > _attached_reactor.Radius ? _attached_reactor.Radius * _attached_reactor.Radius / radius / radius : radius * radius / _attached_reactor.Radius / _attached_reactor.Radius; }
public override void OnStart(StartState state) { String[] resources_to_supply = { ResourceManager.FNRESOURCE_MEGAJOULES, ResourceManager.FNRESOURCE_WASTEHEAT }; this.resources_to_supply = resources_to_supply; try { Debug.Log("[KSPI]: Start Current State: " + (int)state + " " + state.ToString()); Debug.Log("[KSPI]: OnStart Already Launched: " + Launched); curEngineT = this.part.FindModuleImplementing <ModuleEngines>(); curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>(); if ((state & StartState.PreLaunch) == StartState.PreLaunch) { hideEmpty = true; } InitializeGUI(); _fuelConfigurationWithEffect = FuelConfigurations.Where(m => !string.IsNullOrEmpty(m.effectname)).ToList(); _fuelConfigurationWithEffect.ForEach(prop => part.Effect(prop.effectname, 0, -1)); if (state == StartState.Editor) { hideEmpty = false; selectedTank = selectedFuel; selectedTankName = FuelConfigurations[selectedFuel].ConfigName; } UpdateFuel(); Events["ShowFuels"].active = hideEmpty; Events["HideFuels"].active = !hideEmpty; Fields["upgradeTechReq1"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq1); Fields["upgradeTechReq2"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq2); Fields["upgradeTechReq3"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq3); Fields["upgradeTechReq4"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq4); Fields["maxThrustUpgraded1"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq1); Fields["maxThrustUpgraded2"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq2); Fields["maxThrustUpgraded3"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq3); Fields["maxThrustUpgraded4"].guiActiveEditor = !String.IsNullOrEmpty(upgradeTechReq4); } catch (Exception e) { Debug.LogError("EngineECU2 OnStart eception: " + e.Message); } base.OnStart(state); }
public override void OnStart(StartState state) { try { Debug.Log("[KSPI] - Start State: " + state.ToString()); Debug.Log("[KSPI] - Already Launched: " + Launched); curEngineT = this.part.FindModuleImplementing <ModuleEngines>(); curEngineWarp = this.part.FindModuleImplementing <ModuleEnginesWarp>(); InitializeGUI(); if (state.ToString().Contains(StartState.Editor.ToString())) { Debug.Log("[KSPI] - Editor"); hideEmpty = false; selectedTank = selectedFuel; selectedTankName = FuelConfigurations[selectedFuel].ConfigName; UpdateResources(); Debug.Log("[KSPI] - OnStart calls UpdateFuel"); UpdateFuel(true); } else { hideEmpty = true; if (state.ToString().Contains(StartState.PreLaunch.ToString())) // startstate normally == prelaunch,landed { Debug.Log("[KSPI] - PreLaunch"); hideEmpty = true; UpdateResources(); //UpdateusefulConfigurations(); InitializeFuelSelector(); Debug.Log("[KSPI] - OnStart calls UpdateFuel"); UpdateFuel(); } else { Debug.Log("[KSPI] - No PreLaunch"); } } Events["ShowFuels"].active = hideEmpty; Events["HideFuels"].active = !hideEmpty; } catch (Exception e) { Debug.LogError("EngineECU2 OnStart eception: " + e.Message); } base.OnStart(state); }
public override void OnStart(PartModule.StartState state) { var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT); // calculate WasteHeat Capacity if (wasteheatPowerResource != null) { var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount; wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio; } if (state == StartState.Editor) { return; } _attached_engine = this.part.FindModuleImplementing <ModuleEnginesFX>(); //this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX; _attached_warpable_engine = _attached_engine as ModuleEnginesWarp; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } else { UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); } _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); if (_attached_reactor == null) { UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); } exchanger_thrust_divisor = radius > _attached_reactor.getRadius() ? _attached_reactor.getRadius() * _attached_reactor.getRadius() / radius / radius : radius * radius / _attached_reactor.getRadius() / _attached_reactor.getRadius(); // Does this really need to be done each update? Or at all since it uses particles instead of thermal power? }
public override void OnStart(PartModule.StartState state) { resourceBuffers = new ResourceBuffers(); resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_WASTEHEAT, wasteHeatMultiplier, 1.0e+6, true)); resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_WASTEHEAT, this.part.mass); resourceBuffers.Init(this.part); _attached_warpable_engine = this.part.FindModuleImplementing <ModuleEnginesWarp>(); _attached_engine = _attached_warpable_engine; if (_attached_engine != null) { _attached_engine.Fields["finalThrust"].guiFormat = "F5"; } ConnectToReactor(); UpdateEngineStats(true); max_power_multiplier = Math.Log10(maximum_isp / minimum_isp); throtleExponent = Math.Abs(Math.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); simulatedThrottleFloatRange = Fields["simulatedThrottle"].uiControlEditor as UI_FloatRange; simulatedThrottleFloatRange.onFieldChanged += UpdateFromGUI; Fields["partMass"].guiActiveEditor = showPartMass; if (_attached_reactor == null) { Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } exchanger_thrust_divisor = radius > _attached_reactor.Radius ? _attached_reactor.Radius * _attached_reactor.Radius / radius / radius : radius * radius / _attached_reactor.Radius / _attached_reactor.Radius; }
public override void OnStart(PartModule.StartState state) { var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT); // calculate WasteHeat Capacity if (wasteheatPowerResource != null) { var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount; wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio; } if (state == StartState.Editor) return; _attached_engine = this.part.FindModuleImplementing<ModuleEnginesFX>(); //this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX; _attached_warpable_engine = _attached_engine as ModuleEnginesWarp; if (_attached_engine != null) _attached_engine.Fields["finalThrust"].guiFormat = "F5"; else UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); // first try to look in part _attached_reactor = this.part.FindModuleImplementing<IChargedParticleSource>(); // try to find nearest if (_attached_reactor == null) _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); if (_attached_reactor == null) { UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); return; } double joules_per_amu = _attached_reactor.CurrentMeVPerChargedProduct * 1e6 * GameConstants.ELECTRON_CHARGE / GameConstants.dilution_factor; calculatedIsp = Math.Sqrt(joules_per_amu * 2.0 / GameConstants.ATOMIC_MASS_UNIT) / PluginHelper.GravityConstant; throtleExponent = Mathf.Abs(Mathf.Log10(_attached_reactor.MinimumChargdIspMult / _attached_reactor.MaximumChargedIspMult)); exchanger_thrust_divisor = radius > _attached_reactor.GetRadius() ? _attached_reactor.GetRadius() * _attached_reactor.GetRadius() / radius / radius : radius * radius / _attached_reactor.GetRadius() / _attached_reactor.GetRadius(); // Does this really need to be done each update? Or at all since it uses particles instead of thermal power? }
public override void OnStart(PartModule.StartState state) { var wasteheatPowerResource = part.Resources.list.FirstOrDefault(r => r.resourceName == FNResourceManager.FNRESOURCE_WASTEHEAT); // calculate WasteHeat Capacity if (wasteheatPowerResource != null) { var ratio = wasteheatPowerResource.amount / wasteheatPowerResource.maxAmount; wasteheatPowerResource.maxAmount = part.mass * 1.0e+5 * wasteHeatMultiplier; wasteheatPowerResource.amount = wasteheatPowerResource.maxAmount * ratio; } if (state == StartState.Editor) return; _attached_engine = this.part.FindModuleImplementing<ModuleEnginesFX>(); //this.part.Modules["ModuleEnginesFX"] as ModuleEnginesFX; _attached_warpable_engine = _attached_engine as ModuleEnginesWarp; if (_attached_engine != null) _attached_engine.Fields["finalThrust"].guiFormat = "F5"; else UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no ModuleEnginesFX found for MagneticNozzle!"); _attached_reactor = BreadthFirstSearchForChargedParticleSource(10, 1); if (_attached_reactor == null) UnityEngine.Debug.Log("[KSPI] - InterstellarMagneticNozzleControllerFX.OnStart no IChargedParticleSource found for MagneticNozzle!"); exchanger_thrust_divisor = radius > _attached_reactor.getRadius() ? _attached_reactor.getRadius() * _attached_reactor.getRadius() / radius / radius : radius * radius / _attached_reactor.getRadius() / _attached_reactor.getRadius(); // Does this really need to be done each update? Or at all since it uses particles instead of thermal power? }