Skip to content

Engine simulation #145

@WarezCrawler

Description

@WarezCrawler

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

https://forum.kerbalspaceprogram.com/index.php?/topic/152667-131-gtindustries-updated-04-02-2018/#comment-2866210 <<<

--- 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");
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions