Exemplo n.º 1
0
 public void DoUndock()
 {
     // if the module is not currently docked, fail silently.
     if (module.otherNode != null)
     {
         // check to see if either the undock or decouple events are available
         // and execute accordingly.
         var evnt1 = module.Events["Undock"];
         var evnt2 = module.Events["Decouple"];
         if (evnt1 != null && evnt1.guiActive && evnt1.active)
         {
             module.Undock();
         }
         else if (evnt2 != null && evnt2.guiActive && evnt2.active)
         {
             module.Decouple();
         }
         else
         {
             // If you can't do either event on this port, check to see if
             // you can on the port it's docked too!
             evnt1 = module.otherNode.Events["Undock"];
             evnt2 = module.otherNode.Events["Decouple"];
             if (evnt1 != null && evnt1.guiActive && evnt1.active)
             {
                 module.otherNode.Undock();
             }
             else if (evnt2 != null && evnt2.guiActive && evnt2.active)
             {
                 module.otherNode.Decouple();
             }
         }
     }
 }
 private void departureStage1()
 {
     if (RmmUtil.IsDocked(_vessel, _part))
     {
         ModuleDockingNode DockNode = _part.Modules.OfType <ModuleDockingNode>().FirstOrDefault();
         DockNode.Undock();
     }
     _departureStage = 2;
     _nextLogicTime  = Planetarium.GetUniversalTime() + 2;
 }
Exemplo n.º 3
0
 private void DockingInitializeSuffixes()
 {
     AddSuffix("AQUIRERANGE", new Suffix <float>(() => module.acquireRange));
     AddSuffix("AQUIREFORCE", new Suffix <float>(() => module.acquireForce));
     AddSuffix("AQUIRETORQUE", new Suffix <float>(() => module.acquireTorque));
     AddSuffix("REENGAGEDISTANCE", new Suffix <float>(() => module.minDistanceToReEngage));
     AddSuffix("DOCKEDSHIPNAME", new Suffix <string>(() => module.vesselInfo != null ? module.vesselInfo.name : string.Empty));
     AddSuffix("STATE", new Suffix <string>(() => module.state));
     AddSuffix("TARGETABLE", new Suffix <bool>(() => true));
     AddSuffix("UNDOCK", new NoArgsSuffix(() => module.Undock()));
     AddSuffix("TARGET", new NoArgsSuffix(() => module.SetAsTarget()));
     AddSuffix("PORTFACING", new NoArgsSuffix <Direction>(GetPortFacing,
                                                          "The direction facing outward from the docking port.  This " +
                                                          "can differ from :FACING in the case of sideways-facing " +
                                                          "docking ports like the inline docking port."));
 }
        /// <summary>
        /// Undock the current reference part, or the inferred first dock on
        /// the current vessel.
        ///
        /// The state of the dock appears to be queriable only by reading a
        /// string.  The possible values of that string (that I've discovered)
        /// are:
        ///
        /// "Disabled", for shielded docking ports that are closed.
        /// "Docked (dockee)", for docks that were docked to (recipient dock).
        /// "Docked (docker)", for docks that initiated the docking.
        /// "PreAttached", for docks that were attached to something in the VAB
        /// "Ready", for docks that are ready.
        /// </summary>
        /// <param name="state">New state - must be 'false' to trigger the undock event</param>
        public void DockUndock(bool state)
        {
            if (vessel == null || state == true)
            {
                return;
            }

            ModuleDockingNode node = InferDockingNode(vessel);

            if (node != null)
            {
                if ((node.state == "Docked (docker)") || (node.state == "Docked (dockee)"))
                {
                    node.Undock();
                }
            }
        }
Exemplo n.º 5
0
 private void DockingInitializeSuffixes()
 {
     AddSuffix("AQUIRERANGE", new Suffix <float>(() => { throw new Safe.Exceptions.KOSDeprecationException("0.18.0", "AQUIRERANGE", "ACQUIRERANGE", string.Empty); }));
     AddSuffix("AQUIREFORCE", new Suffix <float>(() => { throw new Safe.Exceptions.KOSDeprecationException("0.18.0", "AQUIREFORCE", "ACQUIREFORCE", string.Empty); }));
     AddSuffix("AQUIRETORQUE", new Suffix <float>(() => { throw new Safe.Exceptions.KOSDeprecationException("0.18.0", "AQUIRETORQUE", "ACQUIRETORQUE", string.Empty); }));
     AddSuffix("ACQUIRERANGE", new Suffix <float>(() => module.acquireRange));
     AddSuffix("ACQUIREFORCE", new Suffix <float>(() => module.acquireForce));
     AddSuffix("ACQUIRETORQUE", new Suffix <float>(() => module.acquireTorque));
     AddSuffix("REENGAGEDISTANCE", new Suffix <float>(() => module.minDistanceToReEngage));
     AddSuffix("DOCKEDSHIPNAME", new Suffix <string>(() => module.vesselInfo != null ? module.vesselInfo.name : string.Empty));
     AddSuffix("STATE", new Suffix <string>(() => module.state));
     AddSuffix("TARGETABLE", new Suffix <bool>(() => true));
     AddSuffix("UNDOCK", new NoArgsSuffix(() => module.Undock()));
     AddSuffix("TARGET", new NoArgsSuffix(() => module.SetAsTarget()));
     AddSuffix("PORTFACING", new NoArgsSuffix <Direction>(GetPortFacing,
                                                          "The direction facing outward from the docking port.  This " +
                                                          "can differ from :FACING in the case of sideways-facing " +
                                                          "docking ports like the inline docking port."));
     AddSuffix("NODEPOSITION", new Suffix <Vector>(GetNodePosition, "The position of the docking node itself rather than the part's center of mass"));
     AddSuffix("NODETYPE", new Suffix <string>(() => module.nodeType, "The type of the docking node"));
 }