SSTUTools.SSTUStockInterop.updateEngineThrust C# (CSharp) Method

updateEngineThrust() public static method

public static updateEngineThrust ( ModuleEngines engine, float minThrust, float maxThrust ) : void
engine ModuleEngines
minThrust float
maxThrust float
return void
        public static void updateEngineThrust(ModuleEngines engine, float minThrust, float maxThrust)
        {
            engine.minThrust = minThrust;
            engine.maxThrust = maxThrust;
            ConfigNode updateNode = new ConfigNode("MODULE");
            updateNode.AddValue("maxThrust", engine.maxThrust);
            updateNode.AddValue("minThrust", engine.minThrust);
            engine.Load(updateNode);
        }

Usage Example

Example #1
0
        private void updateEngineThrust()
        {
            ModuleEngines engine = part.GetComponent <ModuleEngines>();

            if (engine != null)
            {
                float scale           = getEngineScale();
                float thrustScalar    = Mathf.Pow(scale, thrustScalePower);
                float thrustPerEngine = engineThrust * thrustScalar;
                float totalThrust     = thrustPerEngine * engineModels.model.numberOfEngines;
                guiEngineThrust = totalThrust;
                SSTUStockInterop.updateEngineThrust(engine, engine.minThrust, totalThrust);
            }
            else
            {
                print("Cannot update engine thrust -- no engine module found!");
                guiEngineThrust = 0;
            }
        }