Inheritance: PartModule, IPartMassModifier, IPartCostModifier
        private void doWeld(Part otherPort, SSTUWeldingDockingPort otherPortModule, Part otherWeld)
        {
            Part weld = getBasePart();

            if (otherPort == null || otherPortModule == null || otherWeld == null || weld == null)
            {
                return;
            }

            AttachNode thisNode  = weld.FindAttachNodeByPart(part);
            AttachNode otherNode = otherWeld.FindAttachNodeByPart(otherPort);

            decoupleFromBase();
            otherPortModule.decoupleFromBase();
            weld.Couple(otherWeld);
            setupPartAttachNodes(weld, otherWeld, thisNode, otherNode);

            //cleanup global data from all the changing of parts/etc
            FlightGlobals.ForceSetActiveVessel(weld.vessel);
            //if you don't de-activate the GUI it will null-ref because the active window belongs to one of the exploding parts below.
            UIPartActionController.Instance.Deactivate();
            //but then we need to re-activate it to make sure that part-right clicking/etc doesn't break
            UIPartActionController.Instance.Activate();

            //remove the welding docking ports
            //TODO find non-explosive way to do this?
            selfDestruct();
            otherPortModule.selfDestruct();
        }
        public void weldEvent()
        {
            Part targetPart = getDockPart();

            if (targetPart == null)
            {
                MonoBehaviour.print("no other docking port attached!");
                return;
            }//nothing attached to docking port
            SSTUWeldingDockingPort targetModule = targetPart.GetComponent <SSTUWeldingDockingPort>();

            if (targetModule == null)
            {
                MonoBehaviour.print("no other construction port module found on attached port part");
                return;
            }//no construction port found
            Part baseWeld = getBasePart();

            if (baseWeld == null)
            {
                MonoBehaviour.print("nothing found for base part to do welding!");
                return;
            }//nothing to weld on this part
            Part targetBaseWeld = targetModule.getBasePart();

            if (targetBaseWeld == null)
            {
                MonoBehaviour.print("nothing found for other port base part to do welding!");
                return;
            }//nothing to weld on other part
            doWeld(targetPart, targetModule, targetBaseWeld);
            GameEvents.onVesselWasModified.Fire(part.vessel);
        }
Exemplo n.º 3
0
        private void doWeld(Part otherPort, SSTUWeldingDockingPort otherPortModule, Part otherWeld)
        {
            Part weld = getBasePart();

            if (otherPort == null || otherPortModule == null || otherWeld == null || weld == null)
            {
                return;
            }
            decoupleFromBase();
            otherPortModule.decoupleFromBase();
            weld.Couple(otherWeld);
            //if you don't de-activate the GUI it will null-ref because the active window belongs to one of the exploding parts below.
            UIPartActionController.Instance.Deactivate();
            //but then we need to re-activate it to make sure that part-right clicking/etc doesn't break
            UIPartActionController.Instance.Activate();
            selfDestruct();
            otherPortModule.selfDestruct();
        }
        private void doWeld(Part otherPort, SSTUWeldingDockingPort otherPortModule, Part otherWeld)
        {
            Part weld = getBasePart();
            if (otherPort == null || otherPortModule == null || otherWeld == null || weld == null) { return; }

            AttachNode thisNode = weld.FindAttachNodeByPart(part);
            AttachNode otherNode = otherWeld.FindAttachNodeByPart(otherPort);
            decoupleFromBase();
            otherPortModule.decoupleFromBase();
            weld.Couple(otherWeld);
            setupPartAttachNodes(weld, otherWeld, thisNode, otherNode);

            //cleanup global data from all the changing of parts/etc
            FlightGlobals.ForceSetActiveVessel(weld.vessel);
            //if you don't de-activate the GUI it will null-ref because the active window belongs to one of the exploding parts below.
            UIPartActionController.Instance.Deactivate();
            //but then we need to re-activate it to make sure that part-right clicking/etc doesn't break
            UIPartActionController.Instance.Activate();

            //remove the welding docking ports
            //TODO find non-explosive way to do this?
            selfDestruct();
            otherPortModule.selfDestruct();
        }