예제 #1
0
파일: Utils.cs 프로젝트: zxzxn3/KSPWheel
 public static void wheelGroupUpdate <T>(this T t, int wheelGroup, Action <T> act) where T : KSPWheelSubmodule
 {
     if (wheelGroup <= 0)
     {
         act(t);
         return;
     }
     try
     {//need to call the passed in delegate on each module of the given type where the controller module for that part shares the wheel group that is passed in
         List <T> subModules = new List <T>();
         if (HighLogic.LoadedSceneIsFlight)
         {
             int len = t.part.vessel.Parts.Count;
             for (int i = 0; i < len; i++)
             {
                 //TODO -- accomodate multiple base modules on a part, query the submodules belonging to that base module
                 KSPWheelBase baseModule = t.part.vessel.Parts[i].GetComponent <KSPWheelBase>();
                 if (baseModule == null)
                 {
                     continue;
                 }
                 if (int.Parse(baseModule.wheelGroup) == wheelGroup)
                 {
                     subModules.AddRange(baseModule.part.GetComponents <T>());
                 }
             }
         }
         else
         {
             int len = EditorLogic.fetch.ship.Parts.Count;
             for (int i = 0; i < len; i++)
             {
                 KSPWheelBase baseModule = EditorLogic.fetch.ship.Parts[i].GetComponent <KSPWheelBase>();
                 if (baseModule == null)
                 {
                     continue;
                 }
                 if (int.Parse(baseModule.wheelGroup) == wheelGroup)
                 {
                     subModules.AddRange(baseModule.part.GetComponents <T>());
                 }
             }
         }
         int len2 = subModules.Count;
         for (int i = 0; i < len2; i++)
         {
             act(subModules[i]);
         }
     }
     catch (Exception e)
     {
         MonoBehaviour.print(e);
     }
 }
예제 #2
0
 private void initializeController()
 {
     KSPWheelBase[] bases = part.GetComponents <KSPWheelBase>();
     controller = bases[baseModuleIndex];
     if (controller == null)
     {
         throw new NullReferenceException("ERROR: Could not locate KSPWheelBase controller module for wheel system.");
     }
     controller.addSubmodule(this);
     wheelData = controller.wheelData[wheelIndex];
     postControllerSetup();
     onUIControlsUpdated(controller.showControls);
 }
예제 #3
0
파일: Utils.cs 프로젝트: zxzxn3/KSPWheel
 public static void wheelGroupUpdateBase <T>(this T t, int wheelGroup, Action <T> act) where T : KSPWheelBase
 {
     if (wheelGroup <= 0)
     {
         act.Invoke(t);
         return;
     }
     try
     {
         //need to call the passed in delegate on each module of the given type where the controller module for that part shares the wheel group that is passed in
         List <T> subModules = new List <T>();
         if (HighLogic.LoadedSceneIsFlight)
         {
             int len = t.part.vessel.Parts.Count;
             for (int i = 0; i < len; i++)
             {
                 KSPWheelBase baseModule = t.part.vessel.Parts[i].GetComponent <KSPWheelBase>();
                 if (baseModule == null)
                 {
                     continue;
                 }
                 if (int.Parse(baseModule.wheelGroup) == wheelGroup)
                 {
                     subModules.AddRange(baseModule.part.GetComponents <T>());
                 }
             }
         }
         else if (HighLogic.LoadedSceneIsEditor)
         {
             //TODO loop through ship construct parts list...
         }
         int len2 = subModules.Count;
         for (int i = 0; i < len2; i++)
         {
             act.Invoke(subModules[i]);
         }
     }
     catch (Exception e)
     {
         MonoBehaviour.print(e);
     }
 }
예제 #4
0
 public WheelDebugData(KSPWheelBase baseModule, KSPWheelBase.KSPWheelData wheelData)
 {
     this.baseModule = baseModule;
     this.wheelData  = wheelData;
 }