GetEvaCollider() публичный статический Метод

public static GetEvaCollider ( Vessel evaVessel, string colliderName ) : Collider
evaVessel Vessel
colliderName string
Результат UnityEngine.Collider
Пример #1
0
 private void SetEvaNode(Vessel kerbalEvaVessel)
 {
     //Get eva transform
     evaCollider = KAS_Shared.GetEvaCollider(kerbalEvaVessel, evaTransformName);
     if (evaNodeTransform)
     {
         Destroy(evaNodeTransform.gameObject);
     }
     evaNodeTransform               = new GameObject("KASEvaNode").transform;
     evaNodeTransform.parent        = evaCollider.transform;
     evaNodeTransform.localPosition = evaPartPos;
     evaNodeTransform.rotation      = KAS_Shared.DirectionToQuaternion(evaCollider.transform, evaPartDir);
 }
Пример #2
0
        public void Grab(Vessel kerbalEvaVessel)
        {
            KAS_Shared.DebugLog("Grab - Grabbing part :" + this.part.partInfo.name);

            //Get eva transform
            evaCollider = KAS_Shared.GetEvaCollider(kerbalEvaVessel, evaTransformName);
            if (!evaCollider)
            {
                KAS_Shared.DebugLog("Grab - " + evaTransformName + "transform not found on eva !");
                return;
            }

            //Get attach node
            if (attachNodeName == null || attachNodeName == "")
            {
                if (this.part.srfAttachNode == null)
                {
                    KAS_Shared.DebugLog("Grab - surface attach node cannot be found on the part !");
                    return;
                }
                KAS_Shared.AddNodeTransform(this.part, this.part.srfAttachNode);
                partNode = this.part.srfAttachNode;
            }
            else
            {
                AttachNode an = this.part.findAttachNode(attachNodeName);
                if (an == null)
                {
                    KAS_Shared.DebugLog("Grab - " + attachNodeName + " node cannot be found on the part !");
                    return;
                }
                KAS_Shared.AddNodeTransform(this.part, an);
                partNode = an;
            }

            //Send message to other modules
            base.SendMessage("OnPartGrab", kerbalEvaVessel, SendMessageOptions.DontRequireReceiver);

            //Drop grabbed part on eva if needed
            KASModuleGrab tmpGrabbbedPartModule = KAS_Shared.GetGrabbedPartModule(kerbalEvaVessel);

            if (tmpGrabbbedPartModule)
            {
                KAS_Shared.DebugWarning("Grab - Drop current grabbed part");
                tmpGrabbbedPartModule.Drop();
            }

            evaNodeTransform               = new GameObject("KASEvaNode").transform;
            evaNodeTransform.parent        = evaCollider.transform;
            evaNodeTransform.localPosition = evaPartPos;
            evaNodeTransform.rotation      = KAS_Shared.DirectionToQuaternion(evaCollider.transform, evaPartDir);

            KAS_Shared.MoveAlign(this.part.transform, partNode.nodeTransform, evaNodeTransform);

            //Grab winch connected head if any
            KASModuleWinch moduleWinch = KAS_Shared.GetConnectedWinch(this.part);

            if (moduleWinch)
            {
                KASModulePort modulePort = this.part.GetComponent <KASModulePort>();
                moduleWinch.UnplugHead(false);
                moduleWinch.GrabHead(kerbalEvaVessel, modulePort);
            }

            List <Collider> allColliders = new List <Collider>(this.part.GetComponentsInChildren <Collider>() as Collider[]);

            foreach (Collider col in allColliders)
            {
                col.isTrigger = true;
            }

            Detach();
            KAS_Shared.DecoupleFromAll(this.part);
            this.part.Couple(kerbalEvaVessel.rootPart);
            //Destroy joint to avoid buggy eva move
            Destroy(this.part.attachJoint);

            this.part.rigidbody.velocity = kerbalEvaVessel.rootPart.rigidbody.velocity;

            if (physicJoint)
            {
                if (evaJoint)
                {
                    Destroy(evaJoint);
                }
                evaJoint = this.part.gameObject.AddComponent <FixedJoint>();
                evaJoint.connectedBody = evaCollider.attachedRigidbody;
                evaJoint.breakForce    = 5;
                evaJoint.breakTorque   = 5;
            }
            else
            {
                this.part.physicalSignificance  = Part.PhysicalSignificance.NONE;
                this.part.transform.parent      = evaNodeTransform;
                this.part.rigidbody.isKinematic = true;
            }

            //Add grabbed part mass to eva
            if (addPartMass && !physicJoint)
            {
                orgKerbalMass = kerbalEvaVessel.rootPart.mass;
                kerbalEvaVessel.rootPart.mass += this.part.mass;
            }

            evaHolderVesselName = kerbalEvaVessel.vesselName;
            evaHolderPart       = kerbalEvaVessel.rootPart;
            grabbed             = true;

            RefreshContextMenu();

            //Play grab sound
            fxSndGrab.audio.Play();
            base.SendMessage("OnPartGrabbed", kerbalEvaVessel, SendMessageOptions.DontRequireReceiver);
        }
Пример #3
0
        private bool AlignEvaPosition(Vessel kerbalEvaVessel)
        {
            //Get eva transform
            evaCollider = KAS_Shared.GetEvaCollider(kerbalEvaVessel, evaTransformName);
            if (!evaCollider)
            {
                KAS_Shared.DebugLog("Grab - " + evaTransformName + "transform not found on eva !");
                return(false);
            }

            //Get attach node
            if (attachNodeName == null || attachNodeName == "")
            {
                if (this.part.srfAttachNode == null)
                {
                    KAS_Shared.DebugLog("Grab - surface attach node cannot be found on the part !");
                    return(false);
                }
                KAS_Shared.AddNodeTransform(this.part, this.part.srfAttachNode);
                partNode = this.part.srfAttachNode;
            }
            else
            {
                AttachNode an = this.part.findAttachNode(attachNodeName);
                if (an == null)
                {
                    KAS_Shared.DebugLog("Grab - " + attachNodeName + " node cannot be found on the part !");
                    return(false);
                }
                KAS_Shared.AddNodeTransform(this.part, an);
                partNode = an;
            }

            //Send message to other modules
            base.SendMessage("OnPartGrab", kerbalEvaVessel, SendMessageOptions.DontRequireReceiver);

            //Drop grabbed part on eva if needed
            KASModuleGrab tmpGrabbbedPartModule = KAS_Shared.GetGrabbedPartModule(kerbalEvaVessel);

            if (tmpGrabbbedPartModule)
            {
                if (tmpGrabbbedPartModule.part.packed)
                {
                    KAS_Shared.DebugWarning("Grab - cannot drop an incompletely grabbed part!");
                    return(false);
                }

                KAS_Shared.DebugWarning("Grab - Drop current grabbed part");
                tmpGrabbbedPartModule.Drop();
            }

            if (evaNodeTransform)
            {
                Destroy(evaNodeTransform.gameObject);
            }

            evaNodeTransform               = new GameObject("KASEvaNode").transform;
            evaNodeTransform.parent        = evaCollider.transform;
            evaNodeTransform.localPosition = evaPartPos;
            evaNodeTransform.rotation      = KAS_Shared.DirectionToQuaternion(evaCollider.transform, evaPartDir);

            KAS_Shared.MoveAlign(this.part.transform, partNode.nodeTransform, evaNodeTransform);

            if (this.part.vessel == kerbalEvaVessel)
            {
                this.part.UpdateOrgPosAndRot(kerbalEvaVessel.rootPart);
            }

            return(true);
        }