strutConnected() public method

public strutConnected ( ) : bool
return bool
Exemplo n.º 1
0
        public void PlugHead(KASModulePort portModule, PlugState plugMode, bool fromSave = false, bool fireSound = true, bool alreadyDocked = false)
        {
            if (plugMode == PlugState.Locked || plugMode == PlugState.Deployed) return;

            if (!alreadyDocked)
            {
                if (portModule.strutConnected())
                {
                    ScreenMessages.PostScreenMessage(portModule.part.partInfo.title + " is already used !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return;
                }
                if (portModule.plugState == KASModulePort.KASPlugState.PlugDock || portModule.plugState == KASModulePort.KASPlugState.PlugUndock)
                {
                    ScreenMessages.PostScreenMessage(portModule.part.partInfo.title + " is already used !", 5, ScreenMessageStyle.UPPER_CENTER);
                    return;
                }
                if (this.part.vessel == portModule.part.vessel && fromSave == false)
                {
                    plugMode = PlugState.PlugUndocked;
                }
            }

            if (!cableJoint) Deploy();
            DropHead();

            if (plugMode == PlugState.PlugUndocked)
            {
                KAS_Shared.DebugLog("PlugHead(Winch) - Plug using undocked mode");
                headState = PlugState.PlugUndocked;
                if (fireSound) portModule.fxSndPlug.audio.Play();
            }
            if (plugMode == PlugState.PlugDocked)
            {
                KAS_Shared.DebugLog("PlugHead(Winch) - Plug using docked mode");  
                // This should be safe even if already connected
                AttachDocked(portModule);
                // Remove joints between connector and winch
                KAS_Shared.RemoveAttachJointBetween(this.part, portModule.part);
                headState = PlugState.PlugDocked;
                //nodeConnectedPort = portModule;
                if (fireSound) portModule.fxSndPlugDocked.audio.Play();
            }


            KAS_Shared.DebugLog("PlugHead(Winch) - Moving head...");
            headTransform.rotation = Quaternion.FromToRotation(headPortNode.forward, -portModule.portNode.forward) * headTransform.rotation;
            headTransform.position = headTransform.position - (headPortNode.position - portModule.portNode.position);

            SetHeadToPhysic(false);
            // Parent port to head for moving port with the head
            portModule.part.transform.parent = headTransform;
            // Set cable joint connected body to eva
            SetCableJointConnectedBody(portModule.part.rigidbody);
            // Unparent eva to head
            portModule.part.transform.parent = null;

            headTransform.parent = portModule.part.transform;
            cableJointLength = cableRealLenght + 0.01f;

            // Set variables
            connectedPortInfo.module = portModule;
            portModule.winchConnected = this;
        }
Exemplo n.º 2
0
        public void PlugHead(KASModulePort portModule, PlugState plugMode, bool fromSave = false,
                       bool fireSound = true, bool alreadyDocked = false)
        {
            if (plugMode == PlugState.Locked || plugMode == PlugState.Deployed) {
              return;
            }

            if (!alreadyDocked && !fromSave) {
              if (portModule.strutConnected()) {
            ScreenMessages.PostScreenMessage(
            string.Format("{0} is already used !", portModule.part.partInfo.title),
            5, ScreenMessageStyle.UPPER_CENTER);
            return;
              }
              if (portModule.plugged) {
            ScreenMessages.PostScreenMessage(
            string.Format("{0} is already used !", portModule.part.partInfo.title),
            5, ScreenMessageStyle.UPPER_CENTER);
            return;
              }
              if (this.part.vessel == portModule.part.vessel) {
            plugMode = PlugState.PlugUndocked;
              }
            }

            if (!cableJoint) {
              Deploy();
            }
            DropHead();

            if (plugMode == PlugState.PlugUndocked) {
              KAS_Shared.DebugLog("PlugHead(Winch) - Plug using undocked mode");
              headState = PlugState.PlugUndocked;
              if (fireSound) {
            AudioSource.PlayClipAtPoint(GameDatabase.Instance.GetAudioClip(portModule.plugSndPath),
                                    portModule.part.transform.position);
              }
            }
            if (plugMode == PlugState.PlugDocked) {
              KAS_Shared.DebugLog("PlugHead(Winch) - Plug using docked mode");
              // This should be safe even if already connected
              AttachDocked(portModule);
              // Set attached part
              portModule.part.FindAttachNode(portModule.attachNode).attachedPart = this.part;
              this.part.FindAttachNode(connectedPortNodeName).attachedPart = portModule.part;
              // Remove joints between connector and winch
              KAS_Shared.RemoveAttachJointBetween(this.part, portModule.part);
              headState = PlugState.PlugDocked;
              if (fireSound) {
            AudioSource.PlayClipAtPoint(
            GameDatabase.Instance.GetAudioClip(portModule.plugDockedSndPath),
            portModule.part.transform.position);
              }
              // Kerbal Joint Reinforcement compatibility
              GameEvents.onPartUndock.Fire(portModule.part);
            }

            KAS_Shared.DebugLog("PlugHead(Winch) - Moving head...");
            headTransform.rotation =
            Quaternion.FromToRotation(headPortNode.forward, -portModule.portNode.forward)
            * headTransform.rotation;
            headTransform.position =
            headTransform.position - (headPortNode.position - portModule.portNode.position);
            SetHeadToPhysic(false);
            SetCableJointConnectedBody(portModule.part.rb);
            headTransform.parent = portModule.part.transform;
            cableJointLength = cableRealLenght + 0.01f;

            // Set variables
            connectedPortInfo.module = portModule;
            connectedPortInfo.module.plugged = true;
            portModule.winchConnected = this;
        }