Example #1
0
 void sumForces(List <PartModule> moduleList, Transform refTransform,
                ref Vector3 translation, ref Vector3 torque)
 {
     List <PartModule> .Enumerator em = moduleList.GetEnumerator();
     while (em.MoveNext())
     {
         PartModule mod = em.Current;
         if (mod == null)
         {
             continue;
         }
         ModuleForces mf = mod.GetComponent <ModuleForces> ();
         if (mf == null || !mf.enabled)
         {
             continue;
         }
         for (int t = 0; t < mf.vectors.Length; t++)
         {
             Vector3 force = -1 * mf.vectors [t].value; /* vectors represent exhaust force,
                                                         * so -1 for actual thrust */
             translation += force;
             torque      += calcTorque(mf.vectors [t].transform, refTransform, force);
         }
     }
 }
Example #2
0
 void calcRCSIsp(ref float num, ref float den)
 {
     foreach (PartModule pm in RCSBuildAid.RCS)
     {
         if (pm == null)
         {
             continue;
         }
         ModuleForces forces = pm.GetComponent <ModuleForces> ();
         if (forces && forces.enabled)
         {
             ModuleRCS mod = (ModuleRCS)pm;
             float     v1  = mod.atmosphereCurve.Evaluate(0f);
             foreach (VectorGraphic vector in forces.vectors)
             {
                 Vector3 thrust = vector.value;
                 float   v2     = Vector3.Dot(v1 * thrust.normalized,
                                              RCSBuildAid.VesselForces.Thrust().normalized * -1);
                 /* calculating weighted mean, RCS thrust magnitude is already "weighted" */
                 num += thrust.magnitude * v2;
                 den += thrust.magnitude;
             }
         }
     }
 }
Example #3
0
        void addForcesSelection()
        {
            /* add force MonoBehaviours to parts grabbed by the cursor */
            Profiler.BeginSample("[RCSBA] RCSBuildAid addForcesSelection");
            if (EditorLogic.SelectedPart == null)
            {
                Profiler.EndSample();
                return;
            }
            const bool onlyConnected = false;
            var        list          = EditorUtils.GetSelectedModulesOf <ModuleRCS>(onlyConnected);

            foreach (var pm in list)
            {
                ModuleForces.Add <RCSForce>(pm);
            }
            var moduleEngineList    = EditorUtils.GetSelectedModulesOf <ModuleEngines>(onlyConnected);
            var multiModeEngineList = EditorUtils.GetSelectedModulesOf <MultiModeEngine>(onlyConnected);

            list = sortEngineList(moduleEngineList, multiModeEngineList);
            foreach (var pm in list)
            {
                if (pm is MultiModeEngine)
                {
                    ModuleForces.Add <MultiModeEngineForce>(pm);
                }
                else if (pm is ModuleEngines)
                {
                    ModuleForces.Add <EngineForce>(pm);
                }
            }
            Profiler.EndSample();
        }
Example #4
0
        void sumForces(IList <ModuleForces> forceList, Transform refTransform, ref Vector3 translation, ref Vector3 torque)
        {
            for (int i = forceList.Count - 1; i >= 0; i--)
            {
                ModuleForces mforces = forceList [i];

                Debug.Assert(mforces != null, "[RCSBA, MarkerForces]: ModuleForces != null");

                if (!mforces.enabled)
                {
                    continue;
                }
                for (int t = mforces.vectors.Length - 1; t >= 0; t--)
                {
                    /* vectors represent exhaust force, so negative for actual thrust */
                    Vector3 force = -1 * mforces.vectors [t].value;
                    translation += force;
                    torque      += calcTorque(mforces.vectors [t].transform, refTransform, force);
                }
            }
        }
Example #5
0
 void addForces()
 {
     /* add force MonoBehaviours to parts in vessel */
     Profiler.BeginSample("[RCSBA] RCSBuildAid addForces");
     foreach (var mod in rcsList)
     {
         ModuleForces.Add <RCSForce> (mod);
     }
     foreach (var mod in engineList)
     {
         if (mod is ModuleEngines)
         {
             ModuleForces.Add <EngineForce>(mod);
         }
         else if (mod is MultiModeEngine)
         {
             ModuleForces.Add <MultiModeEngineForce> (mod);
         }
     }
     Profiler.EndSample();
 }
Example #6
0
 void sumForces(List <PartModule> moduleList, Transform refTransform,
                ref Vector3 translation, ref Vector3 torque)
 {
     for (int i = 0; i < moduleList.Count; i++)
     {
         PartModule mod = moduleList [i];
         if (mod == null)
         {
             continue;
         }
         ModuleForces mf = mod.GetComponent <ModuleForces> ();
         if (mf == null || !mf.enabled)
         {
             continue;
         }
         for (int t = 0; t < mf.vectors.Length; t++)
         {
             /* vectors represent exhaust force, so -1 for actual thrust */
             Vector3 force = -1 * mf.vectors [t].value;
             translation += force;
             torque      += calcTorque(mf.vectors [t].transform, refTransform, force);
         }
     }
 }
Example #7
0
 void onLeavingEditor()
 {
     ModuleForces.ClearLists();
 }