-
Notifications
You must be signed in to change notification settings - Fork 101
Description
Suggestion for code change...
The current engine simulation is dependent on the stock multimode module. This makes KER calculate incorrect for my custom multimode modules. Therefore I've done some testing and think it can be made more general.
I rewrote "public void CreateEngineSims(..)", now relying on engine.isEndabled which it the same setting the stock multimode is manipulating to enable/disable engines.
This way the logic does the same thing for all engines, and does not rely on other modules for the logic.
I hope this helps.
my mod for reference
--- CODE CHANGES ---
public void CreateEngineSims(List allEngines, double atmosphere, double mach, bool vectoredThrust, bool fullThrust, LogMsg log)
{
if (log != null) log.AppendLine("CreateEngineSims for ", this.name);
List cacheModuleEngines = part.FindModulesImplementing();
try
{
if (cacheModuleEngines.Count > 0)
{
//Debug.Log("[KER-GTI Extension] Engine Exists " + cacheModuleEngines.Count + " " + this.part.ToString());
//find first active engine, assuming that two are never active at the same time
foreach (ModuleEngines engine in cacheModuleEngines)
{
//Debug.Log("[KER-GTI Extension] Engine Evaluated " + engine.isEnabled);
if (engine.isEnabled)
{
//Debug.Log("[KER-GTI Extension] Engine Enabled");
if (log != null) log.AppendLine("Module: ", engine.moduleName);
EngineSim engineSim = EngineSim.New(
this,
engine,
atmosphere,
(float)mach,
vectoredThrust,
fullThrust,
log);
allEngines.Add(engineSim);
}
}
}
}
catch
{
Debug.Log("[KER-GTI Extension] Error Catch in CreateEngineSims");
}