MoveRelatedTo() 공개 정적인 메소드

public static MoveRelatedTo ( Transform fromTransform, Transform toTransform, Vector3 position, Vector3 direction ) : void
fromTransform Transform
toTransform Transform
position Vector3
direction Vector3
리턴 void
예제 #1
0
        public void Drop()
        {
            if (grabbed)
            {
                KAS_Shared.DebugLog("Drop - Dropping part :" + this.part.partInfo.name);
                base.SendMessage("OnPartDrop", SendMessageOptions.DontRequireReceiver);

                if (this.part.vessel.isEVA)
                {
                    this.part.decouple();
                }

                //Remove created joints between eva and part if exist
                KAS_Shared.RemoveFixedJointBetween(this.part, evaHolderPart);
                KAS_Shared.RemoveHingeJointBetween(this.part, evaHolderPart);

                List <Collider> allColliders = new List <Collider>(this.part.GetComponentsInChildren <Collider>() as Collider[]);
                foreach (Collider col in allColliders)
                {
                    col.isTrigger = false;
                }

                if (customGroundPos && evaHolderPart.checkLanded())
                {
                    KAS_Shared.MoveRelatedTo(this.part.transform, evaCollider.transform, dropPartPos, dropPartRot);
                }
                else
                {
                    KAS_Shared.MoveAlign(this.part.transform, partNode.nodeTransform, evaNodeTransform);
                }

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

                this.part.transform.parent          = null;
                this.part.rigidbody.isKinematic     = false;
                this.part.physicalSignificance      = Part.PhysicalSignificance.FULL;
                this.part.rigidbody.velocity        = evaHolderPart.rigidbody.velocity;
                this.part.rigidbody.angularVelocity = evaHolderPart.rigidbody.angularVelocity;

                if (addPartMass & !physicJoint)
                {
                    evaHolderPart.mass = orgKerbalMass;
                }

                KASModuleWinch grabbedWinchHead = KAS_Shared.GetWinchModuleGrabbed(evaHolderPart.vessel);
                if (grabbedWinchHead)
                {
                    if (grabbedWinchHead.grabbedPortModule)
                    {
                        KAS_Shared.DebugLog("Drop - Grabbed part have a port connected");
                        grabbedWinchHead.PlugHead(grabbedWinchHead.grabbedPortModule, KASModuleWinch.PlugState.PlugDocked, fireSound: false);
                    }
                }

                evaJoint            = null;
                evaNodeTransform    = null;
                evaHolderVesselName = null;
                evaHolderPart       = null;
                grabbed             = false;

                RefreshContextMenu();

                //Send drop message to all child objects
                base.SendMessage("OnPartDropped", SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                KAS_Shared.DebugWarning("Drop - Part not grabbed, ignoring drop...");
            }
        }
예제 #2
0
        public void Drop(bool forAttach = false)
        {
            if (grabbed)
            {
                KAS_Shared.DebugLog("Drop - Dropping part :" + this.part.partInfo.name);

                base.SendMessage("OnPartDrop", SendMessageOptions.DontRequireReceiver);

                if (this.part.vessel.isEVA || grab_pending)
                {
                    this.part.decouple();
                }

                if (grab_pending)
                {
                    Destroy(evaNodeTransform.gameObject);
                    evaNodeTransform    = null;
                    evaHolderVesselName = null;
                    evaHolderPart       = null;
                    grabbed             = grab_pending = false;
                    RefreshContextMenu();
                    return;
                }

                //Remove created joints between eva and part if exist
                KAS_Shared.RemoveFixedJointBetween(this.part, evaHolderPart);
                KAS_Shared.RemoveHingeJointBetween(this.part, evaHolderPart);

                List <Collider> allColliders = new List <Collider>(this.part.GetComponentsInChildren <Collider>() as Collider[]);
                foreach (Collider col in allColliders)
                {
                    col.isTrigger = (keepTriggers != null && keepTriggers.Contains(col));
                }

                if (customGroundPos && evaHolderPart.checkLanded())
                {
                    KAS_Shared.MoveRelatedTo(this.part.transform, evaCollider.transform, dropPartPos, dropPartRot);
                }
                else
                {
                    KAS_Shared.MoveAlign(this.part.transform, partNode.nodeTransform, evaNodeTransform);
                }

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

                this.part.rigidbody.velocity        = evaHolderPart.rigidbody.velocity;
                this.part.rigidbody.angularVelocity = evaHolderPart.rigidbody.angularVelocity;

                KAS_Shared.ResetCollisionEnhancer(this.part);

                if (addPartMass & !physicJoint)
                {
                    evaHolderPart.mass = orgKerbalMass;
                }

                KASModuleWinch grabbedWinchHead = KAS_Shared.GetWinchModuleGrabbed(evaHolderPart.vessel);
                if (grabbedWinchHead)
                {
                    if (grabbedWinchHead.grabbedPortModule && grabbedWinchHead.grabbedPortModule.part == part)
                    {
                        KAS_Shared.DebugLog("Drop - Grabbed part have a port connected");

                        if (forAttach)
                        {
                            // Docked causes big problems when the part is later coupled
                            grabbedWinchHead.PlugHead(grabbedWinchHead.grabbedPortModule, KASModuleWinch.PlugState.PlugUndocked, fireSound: false);
                        }
                        else
                        {
                            grabbedWinchHead.PlugHead(grabbedWinchHead.grabbedPortModule, KASModuleWinch.PlugState.PlugDocked, fireSound: false);
                        }
                    }
                }

                GameEvents.onCrewBoardVessel.Remove(new EventData <GameEvents.FromToAction <Part, Part> > .OnEvent(this.OnCrewBoardVessel));

                syncGrab            = false;
                keepTriggers        = null;
                evaJoint            = null;
                evaNodeTransform    = null;
                evaHolderVesselName = null;
                evaHolderPart       = null;
                grabbed             = grab_pending = false;

                RefreshContextMenu();

                //Send drop message to all child objects
                base.SendMessage("OnPartDropped", SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                KAS_Shared.DebugWarning("Drop - Part not grabbed, ignoring drop...");
            }
        }