void ToggleGear()
        {
            List <Part> partsList = EditorLogic.SortedShipList;

            for (int i = 0; i < partsList.Count; i++)
            {
                Part p = partsList[i];
                if (p.Modules.Contains("ModuleLandingGear"))
                {
                    ModuleLandingGear l = (ModuleLandingGear)p.Modules["ModuleLandingGear"];
                    l.StartDeployed = gearToggle;
                }
                if (p.Modules.Contains("ModuleAdvancedLandingGear"))
                {
                    ModuleAdvancedLandingGear l = (ModuleAdvancedLandingGear)p.Modules["ModuleAdvancedLandingGear"];
                    l.startDeployed = gearToggle;
                }
                if (p.Modules.Contains("FSwheel"))
                {
                    PartModule m      = p.Modules["FSwheel"];
                    MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic);
                    method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" });
                }
                if (p.Modules.Contains("FSBDwheel"))
                {
                    PartModule m      = p.Modules["FSBDwheel"];
                    MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic);
                    method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" });
                }
            }
            gearToggle = !gearToggle;
        }
Beispiel #2
0
 internal LandingGear(Part part)
 {
     this.part = part;
     gear      = part.InternalPart.Module <ModuleLandingGear> ();
     if (gear == null)
     {
         throw new ArgumentException("Part does not have a ModuleLandingGear PartModule");
     }
 }
Beispiel #3
0
 internal LandingGear(Part part)
 {
     this.part = part;
     gear      = part.InternalPart.Module <ModuleLandingGear> ();
     advGear   = part.InternalPart.Module <ModuleAdvancedLandingGear> ();
     fixedGear = part.InternalPart.Module <ModuleLandingGearFixed> ();
     if (gear == null && advGear == null && fixedGear == null)
     {
         throw new ArgumentException("Part is not landing gear");
     }
 }
 public override void OnStart(PartModule.StartState state)
 {
     base.OnStart(state);
     gear = part.GetComponent<ModuleLandingGear>();
     if (gear != null)
     {
         gear.Events["LowerLandingGear"].guiActiveUnfocused = true;
         gear.Events["LowerLandingGear"].unfocusedRange = 5f;
         gear.Events["RaiseLandingGear"].guiActiveUnfocused = true;
         gear.Events["RaiseLandingGear"].unfocusedRange = 5f;
     }
 }
Beispiel #5
0
 public override void OnStart(PartModule.StartState state)
 {
     base.OnStart(state);
     gear = part.GetComponent <ModuleLandingGear>();
     if (gear != null)
     {
         gear.Events["LowerLandingGear"].guiActiveUnfocused = true;
         gear.Events["LowerLandingGear"].unfocusedRange     = 5f;
         gear.Events["RaiseLandingGear"].guiActiveUnfocused = true;
         gear.Events["RaiseLandingGear"].unfocusedRange     = 5f;
     }
 }
Beispiel #6
0
        //============================================================================================================================================
        public void EngageGear()
        {
            //Look through each part that is enabled
            foreach (Part EnabledPart in EnabledPartList) {
                //Check to see if it is a certain module type
                //---------------------------------------------------------------------------------------------------------------------
                //Landing Gear Module
                if (EnabledPart.Modules.Contains ("ModuleLandingGear")) {
                    //Create new Instance of ModuleLandingGear to reference
                    ModuleLandingGear MLG = new ModuleLandingGear ();
                    MLG = EnabledPart.FindModuleImplementing<ModuleLandingGear> ();
                    //Increase count by 1 of enabled parts for GUI display
                    RoboBrakes_GearEnabledCount++;
                    //Create a list of actions that are available to this particular part & it's modules
                    BaseActionList BAL = new BaseActionList (EnabledPart, MLG);
                    //Cycle throught each action
                    foreach (BaseAction BA in BAL) {
                        //Find the 'Brakes' action
                        if (BA.guiName == "Brakes") {
                            //Engage brakes (or other action) when triggered
                            if ((RoboBrakes_AUTOMATICBRAKE_ACTIVE == true && RoboBrakes_GEARAUTO == true) | (RoboBrakes_OVERRIDEBRAKE_ACTIVE == true && RoboBrakes_GEAROVERRIDE == true)) {
                                //Create Action Parameter for enabling brakes (or other action) - I don't full understand this, but it is needed to activate the action
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Activate);
                                //Perform said action
                                BA.Invoke (AP);
                            } else {
                                //Create Action Parameter for disabling brakes (or other action)
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Deactivate);
                                //Perform said action
                                BA.Invoke (AP);
                            }
                        }
                    }
                }

                //---------------------------------------------------------------------------------------------------------------------
                //Advanced Landing Gear Module
                if (EnabledPart.Modules.Contains ("ModuleAdvancedLandingGear")) {
                    ModuleAdvancedLandingGear MALG = new ModuleAdvancedLandingGear ();
                    MALG = EnabledPart.FindModuleImplementing<ModuleAdvancedLandingGear> ();
                    RoboBrakes_GearEnabledCount++;
                    BaseActionList BAL = new BaseActionList (EnabledPart, MALG);
                    foreach (BaseAction BA in BAL) {
                        if (BA.guiName == "Brakes") {
                            if ((RoboBrakes_AUTOMATICBRAKE_ACTIVE == true && RoboBrakes_GEARAUTO == true) | (RoboBrakes_OVERRIDEBRAKE_ACTIVE == true && RoboBrakes_GEAROVERRIDE == true)) {
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Activate);
                                BA.Invoke (AP);
                            } else {
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Deactivate);
                                BA.Invoke (AP);
                            }
                        }
                    }
                }

                //---------------------------------------------------------------------------------------------------------------------
                //Fixed Landing Gear Module
                if (EnabledPart.Modules.Contains ("ModuleLandingGearFixed")) {
                    ModuleLandingGearFixed MLGF = new ModuleLandingGearFixed ();
                    MLGF = EnabledPart.FindModuleImplementing<ModuleLandingGearFixed> ();
                    //These Gear are always down
                    RoboBrakes_GearEnabledCount++;
                    BaseActionList BAL = new BaseActionList (EnabledPart, MLGF);
                    foreach (BaseAction BA in BAL) {
                        if (BA.guiName == "Brakes") {
                            if ((RoboBrakes_AUTOMATICBRAKE_ACTIVE == true && RoboBrakes_GEARAUTO == true) | (RoboBrakes_OVERRIDEBRAKE_ACTIVE == true && RoboBrakes_GEAROVERRIDE == true)) {
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Activate);
                                BA.Invoke (AP);
                            } else {
                                KSPActionParam AP = new KSPActionParam (KSPActionGroup.None, KSPActionType.Deactivate);
                                BA.Invoke (AP);
                            }
                        }
                    }
                }
            }
        }