示例#1
0
        public static void updateResourceVolume(Part part)
        {
            SSTULog.debug("Part volume changed...");
            SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>();

            if (vc != null)
            {
                vc.recalcVolume();
                SSTUResourceBoiloff rb = part.GetComponent <SSTUResourceBoiloff>();
                if (rb != null)
                {
                    rb.onPartResourcesChanged();
                }
            }
            else
            {
                IContainerVolumeContributor[] contributors = part.FindModulesImplementing <IContainerVolumeContributor>().ToArray();
                ContainerContribution[]       cts;
                int   len         = contributors.Length;
                float totalVolume = 0;
                for (int i = 0; i < len; i++)
                {
                    cts = contributors[i].getContainerContributions();
                    int len2 = cts.Length;
                    for (int k = 0; k < len2; k++)
                    {
                        totalVolume += cts[k].containerVolume;
                    }
                }
                realFuelsVolumeUpdate(part, totalVolume);
            }
        }
 public void thrustCurveGuiClosed(string preset, FloatCurve curve)
 {
     //update the persistent curve data from
     currentCurve    = curve;
     presetCurveName = preset;
     usePresetCurve  = !string.IsNullOrEmpty(presetCurveName);
     if (!usePresetCurve)
     {
         customCurveData = currentCurve.ToStringSingleLine();
     }
     SSTULog.debug("Updating engine thrust cuve data.  Use preset: " + usePresetCurve);
     updateEngineCurve();
 }
示例#3
0
 public static void openGUI(SSTUEngineThrustCurveGUI srbModule, string preset, FloatCurve inputCurve)
 {
     module = srbModule;
     id     = module.GetInstanceID();
     MonoBehaviour.print("ThrustCurveEditor-input curve: " + curve + "\n" + SSTUUtils.printFloatCurve(curve));
     presetName = preset;
     setupCurveData(inputCurve);
     texture = new Texture2D(graphWidth, graphHeight);
     updateGraphTexture();
     loadPresets();
     if (activeGUI == null)
     {
         activeGUI = srbModule.gameObject.AddComponent <ThrustCurveEditorGUI>();
         SSTULog.debug("Created new gui object: " + activeGUI);
     }
 }
 /// <summary>
 /// Applies the 'currentCurve' to the engine module as its active thrust curve.
 /// </summary>
 private void updateEngineCurve()
 {
     ModuleEngines[] engines = part.GetComponents <ModuleEngines>();
     if (engineModuleIndex < 0)
     {
         return;
     }                                     //config error
     if (engineModuleIndex >= engines.Length)
     {
         return;
     }                                                   //config error
     if (currentCurve == null)
     {
         return;
     }                                    //code error
     SSTULog.debug("Updating ModuleEngine's thrust-curve");
     engines[engineModuleIndex].thrustCurve = currentCurve;
 }
示例#5
0
 /// <summary>
 /// Called by SSTUModInterop whenever resources are changed for a part and VolumeContainer is present.
 /// </summary>
 public void onPartResourcesChanged()
 {
     SSTULog.debug("Part resources changed...");
     initialize();
     updateStatsFromContainer();
 }