StartPump() private method

private StartPump ( bool from_ui ) : void
from_ui bool
return void
Example #1
0
        private bool LinkTo(KASModuleStrut tgtModule, bool checkCondition = true,
                            bool setJointOrDock = true)
        {
            //Check condition if needed
            if (checkCondition)
            {
                if (!CheckLink(this.strutTransform, tgtModule.strutTransform, true))
                {
                    ScreenMessages.PostScreenMessage("Max angle or length reached, cannot link !",
                                                     5, ScreenMessageStyle.UPPER_CENTER);
                    return(false);
                }

                if (tgtModule == this)
                {
                    ScreenMessages.PostScreenMessage(this.part.partInfo.title + " cannot be linked to itself !",
                                                     5, ScreenMessageStyle.UPPER_CENTER);
                    return(false);
                }

                if (tgtModule.type != this.type)
                {
                    ScreenMessages.PostScreenMessage(
                        this.part.partInfo.title + " cannot be linked to " + tgtModule.part.partInfo.title
                        + " because they are not compatible !",
                        5, ScreenMessageStyle.UPPER_CENTER);
                    return(false);
                }

                if (tgtModule.vessel != this.vessel && !allowDock)
                {
                    ScreenMessages.PostScreenMessage(
                        this.part.partInfo.title + " cannot be linked to another vessel !",
                        5, ScreenMessageStyle.UPPER_CENTER);
                    return(false);
                }
            }

            // Load tube renderer in this module
            this.StopEvaLink();
            this.strutRenderer.tgtNode    = tgtModule.strutTransform;
            this.strutRenderer.shaderName = "Diffuse";
            this.strutRenderer.color      = Color.white;
            this.strutRenderer.color.a    = 1f;
            this.strutRenderer.Load();

            // Set references for the current module
            this.Events["ContextMenuUnlink"].guiActiveUnfocused = true;
            this.Events["ContextMenuLink"].guiActiveUnfocused   = false;
            this.linkedStrutModule = tgtModule;
            this.linked            = true;

            // Set references for the target module
            tgtModule.linkedStrutModule = this;
            tgtModule.Events["ContextMenuUnlink"].guiActiveUnfocused = true;
            tgtModule.Events["ContextMenuLink"].guiActiveUnfocused   = false;
            tgtModule.linked = true;
            tgtStrutPartID   = tgtModule.part.flightID.ToString();
            tgtStrutVesselID = tgtModule.part.vessel.id.ToString();

            KAS_Shared.InvalidateContextMenu(this.part);
            KAS_Shared.InvalidateContextMenu(tgtModule.part);

            if (setJointOrDock)
            {
                // Create joint or dock part
                if (tgtModule.vessel == this.vessel)
                {
                    if (tgtModule.part.parent != this.part && this.part.parent != tgtModule.part)
                    {
                        KAS_Shared.DebugLog("LinkTo(Strut) Parts are from the same vessel but are not connected,"
                                            + " setting joint...");
                        if (this.part.parent && tgtModule.part.parent)
                        {
                            KAS_Shared.DebugLog("LinkTo(Strut) Set joint on struts parents");
                            AttachFixed(this.part.parent, tgtModule.part.parent, breakForce);
                        }
                        else
                        {
                            KAS_Shared.DebugLog("LinkTo(Strut) Set joint on struts");
                            AttachFixed(this.part, tgtModule.part, breakForce);
                        }
                    }
                }
                else
                {
                    KAS_Shared.DebugLog("LinkTo(Strut) Parts are from a different vessel, docking...");
                    AttachDocked(tgtModule);
                }
            }
            else
            {
                KAS_Shared.DebugLog("LinkTo(Strut) setJointOrDock = false, ignoring dock and creating joint");
            }

            // Connect fuel flow when appropriate
            bool both_attached =
                this.part.srfAttachNode.attachedPart && tgtModule.part.srfAttachNode.attachedPart;

            this.Events["ContextMenuTogglePump"].active = this.allowPumpFuel && both_attached;
            if (this.pumpFuel)
            {
                this.StartPump(checkCondition);
            }

            tgtModule.Events["ContextMenuTogglePump"].active = tgtModule.allowPumpFuel && both_attached;
            if (tgtModule.pumpFuel)
            {
                tgtModule.StartPump(checkCondition);
            }

            return(true);
        }
Example #2
0
        private bool LinkTo(KASModuleStrut tgtModule, bool checkCondition = true, bool setJointOrDock = true)
        {
            //Check condition if needed
            if (checkCondition)
            {
                if (!CheckLink(this.strutTransform, tgtModule.strutTransform, true))
                {
                    ScreenMessages.PostScreenMessage("Max angle or length reached, cannot link !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return false;
                }

                if (tgtModule == this)
                {
                    ScreenMessages.PostScreenMessage(this.part.partInfo.title + " cannot be linked to itself !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return false;
                }

                if (tgtModule.type != this.type)
                {
                    ScreenMessages.PostScreenMessage(this.part.partInfo.title + " cannot be linked to " + tgtModule.part.partInfo.title + " because they are not compatible !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return false;
                }

                if (tgtModule.vessel != this.vessel && !allowDock)
                {
                    ScreenMessages.PostScreenMessage(this.part.partInfo.title + " cannot be linked to another vessel !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return false;
                }
            }

            // Load tube renderer in this module
            this.StopEvaLink();
            this.strutRenderer.tgtNode = tgtModule.strutTransform;
            this.strutRenderer.shaderName = "Diffuse";
            this.strutRenderer.color = Color.white;
            this.strutRenderer.color.a = 1f;
            this.strutRenderer.Load();

            // Set references for the current module
            this.Events["ContextMenuUnlink"].guiActiveUnfocused = true;
            this.Events["ContextMenuLink"].guiActiveUnfocused = false;
            this.linkedStrutModule = tgtModule;
            this.linked = true;

            // Set references for the target module
            tgtModule.linkedStrutModule = this;
            tgtModule.Events["ContextMenuUnlink"].guiActiveUnfocused = true;
            tgtModule.Events["ContextMenuLink"].guiActiveUnfocused = false;
            tgtModule.linked = true;
            tgtStrutPartID = tgtModule.part.flightID.ToString();
            tgtStrutVesselID = tgtModule.part.vessel.id.ToString();

            KAS_Shared.InvalidateContextMenu(this.part);
            KAS_Shared.InvalidateContextMenu(tgtModule.part);

            if (setJointOrDock)
            {
                // Create joint or dock part
                if (tgtModule.vessel == this.vessel)
                {
                    if (tgtModule.part.parent != this.part && this.part.parent != tgtModule.part)
                    {
                        KAS_Shared.DebugLog("LinkTo(Strut) Parts are from the same vessel but are not connected, setting joint...");
                        if (this.part.parent && tgtModule.part.parent)
                        {
                            KAS_Shared.DebugLog("LinkTo(Strut) Set joint on struts parents");
                            AttachFixed(this.part.parent, tgtModule.part.parent, breakForce);
                        }
                        else
                        {
                            KAS_Shared.DebugLog("LinkTo(Strut) Set joint on struts");
                            AttachFixed(this.part, tgtModule.part, breakForce);
                        }

                    }
                }
                else
                {
                    KAS_Shared.DebugLog("LinkTo(Strut) Parts are from a different vessel, docking...");
                    AttachDocked(tgtModule);
                }
            }
            else
            {
                KAS_Shared.DebugLog("LinkTo(Strut) setJointOrDock = false, ignoring dock and creating joint");
            }

            // Connect fuel flow when appropriate
            bool both_attached = this.part.srfAttachNode.attachedPart && tgtModule.part.srfAttachNode.attachedPart;

            this.Events["ContextMenuTogglePump"].active = this.allowPumpFuel && both_attached;
            if (this.pumpFuel)
            {
                this.StartPump(checkCondition);
            }

            tgtModule.Events["ContextMenuTogglePump"].active = tgtModule.allowPumpFuel && both_attached;
            if (tgtModule.pumpFuel)
            {
                tgtModule.StartPump(checkCondition);
            }

            return true;
        }