Esempio n. 1
0
 public void UpdateParts()
 {
     EngineWrapper.ThrustPI.setMaster(CFG.Engines);
     Engines.Clear(); 
     Torque.Clear();
     Physics.Clear();
     OnPlanetParams.Clear();
     var drag_parts = 0;
     var parts_count = vessel.Parts.Count;
     var max_active_stage = -1;
     for(int i = 0; i < parts_count; i++)
     {
         Part p = vessel.Parts[i];
         if(p.State == PartStates.ACTIVE && p.inverseStage > max_active_stage)
             max_active_stage = p.inverseStage;
         Physics.UpdateMaxTemp(p);
         if(p.angularDragByFI) { Physics.AngularDrag += p.angularDrag; drag_parts += 1; }
         for(int j = 0, pModulesCount = p.Modules.Count; j < pModulesCount; j++)
         {
             var module = p.Modules[j];
             if(Engines.AddEngine(module)) continue;
             if(Engines.AddRCS(module)) continue;
             if(OnPlanetParams.AddLaunchClamp(module)) continue;
             if(OnPlanetParams.AddParachute(module)) continue;
             if(OnPlanetParams.AddGear(module)) continue;
             if(Torque.AddTorqueProvider(module)) continue;
         }
     }
     Physics.AngularDrag /= drag_parts;
     Engines.Clusters.Update();
     if(max_active_stage >= 0 && 
        (vessel.currentStage < 0 || vessel.currentStage > max_active_stage))
         vessel.currentStage = StageManager.RecalculateVesselStaging(vessel);
     if(CFG.EnginesProfiles.Empty) CFG.EnginesProfiles.AddProfile(Engines.All);
     else if(CFG.Enabled && TCA.ProfileSyncAllowed) CFG.ActiveProfile.Update(Engines.All);
 }
        public void UpdateParts()
        {
            EngineWrapper.ThrustPI.setMaster(CFG.Engines);
            Engines.Clear();
            Torque.Wheels.Clear();
            Physics.Clear();
            OnPlanetParams.Clear();
            var drag_parts       = 0;
            var parts_count      = vessel.Parts.Count;
            var max_active_stage = -1;

            for (int i = 0; i < parts_count; i++)
            {
                Part p = vessel.Parts[i];
                if (p.State == PartStates.ACTIVE && p.inverseStage > max_active_stage)
                {
                    max_active_stage = p.inverseStage;
                }
                Physics.UpdateMaxTemp(p);
                if (p.angularDragByFI)
                {
                    Physics.AngularDrag += p.angularDrag; drag_parts += 1;
                }
                for (int j = 0, pModulesCount = p.Modules.Count; j < pModulesCount; j++)
                {
                    var module = p.Modules[j];
                    if (Engines.AddEngine(module))
                    {
                        continue;
                    }
                    if (Engines.AddRCS(module))
                    {
                        continue;
                    }
                    if (OnPlanetParams.AddLaunchClamp(module))
                    {
                        continue;
                    }
                    if (OnPlanetParams.AddParachute(module))
                    {
                        continue;
                    }
                    if (OnPlanetParams.AddGear(module))
                    {
                        continue;
                    }
                    if (AddModule(module, Torque.Wheels))
                    {
                        continue;
                    }
                }
            }
            Physics.AngularDrag /= drag_parts;
            Engines.Clusters.Update();
            //test: adjusting vessel stage seems to be not that strightforward
            Log("max active stage {}, vessel stage {}", max_active_stage, vessel.currentStage);            //debug
            if (max_active_stage >= 0 &&
                (vessel.currentStage < 0 || vessel.currentStage > max_active_stage))
            {
                vessel.currentStage = StageManager.RecalculateVesselStaging(vessel);
            }
            if (CFG.EnginesProfiles.Empty)
            {
                CFG.EnginesProfiles.AddProfile(Engines.All);
            }
            else if (CFG.Enabled && TCA.ProfileSyncAllowed)
            {
                CFG.ActiveProfile.Update(Engines.All);
            }
        }