コード例 #1
0
        private void ConnectPlug(Plug plug)
        {
            if (plug == null)
            {
                return;
            }

            plug.ConnectedCord = this;

            if (plug.IsPluggedIn())
            {
                if (plug.DestinationEndpoint.GetComponent <PhysicalDataInput>() != null)
                {
                    if (plug.CordAttachPoint.Equals(A))
                    {
                        Flow = -1;
                    }
                    else
                    {
                        Flow = 1;
                    }
                }
                else if (plug.DestinationEndpoint.GetComponent <PhysicalDataOutput>() != null)
                {
                    if (plug.CordAttachPoint.Equals(A))
                    {
                        Flow = 1;
                    }
                    else
                    {
                        Flow = -1;
                    }
                }
            }
        }
コード例 #2
0
 private PhysicalDataEndpoint GetConnectedEndpoint(Plug plug)
 {
     if (plug != null)
     {
         if (plug.IsPluggedIn())
         {
             return(plug.DestinationEndpoint);
         }
     }
     return(null);
 }
コード例 #3
0
        private void OnPlugUnlockTriggerExit(object sender, SimpleTriggerEventArgs args)
        {
            Plug p = args.other.gameObject.GetComponentInActor <Plug>();

            if (p != null)
            {
                //If the plug attachLock was held by the PlugAttach, release it
                if (p.Equals(LockedPlug) && !p.IsPluggedIn())
                {
                    UnlockPlug();
                }
            }
        }
コード例 #4
0
ファイル: Plug.cs プロジェクト: lane-s/ComposeVR
        public void DisconnectFromDataEndpoint()
        {
            DestinationEndpoint.Disconnect(connectedCord, CordAttachPoint);
            DestinationEndpoint = null;

            transform.GetComponent <VRTK_TransformFollow>().gameObjectToFollow = null;
            PlugTransform.GetComponent <CapsuleCollider>().center = plugColliderCenter;
            PlugTransform.GetComponent <CapsuleCollider>().height = plugColliderHeight;

            Transform oppositeNode = GetOppositeCordNode();
            Plug      p            = oppositeNode.GetComponentInActor <Plug>();

            if (p != null && !p.IsPluggedIn())
            {
                connectedCord.Flow = 0;
            }
        }
コード例 #5
0
ファイル: Plug.cs プロジェクト: lane-s/ComposeVR
        /// <summary>
        /// Collapse the cord if one of the following conditions are met:
        ///     1. Both ends of the cord are plugs and neither plug is plugged in
        ///     2. One end of the cord is an unplugged plug and the other is a BranchHandle.
        /// </summary>
        private IEnumerator TryCollapseRoutine()
        {
            yield return(null);

            if (!IsPluggedIn() && connectedCord != null)
            {
                Transform oppositeNode = GetOppositeCordNode();
                Plug      p            = oppositeNode.GetComponentInActor <Plug>();

                if (p != null && !p.IsPluggedIn())
                {
                    connectedCord.Collapse();
                }
                else if (oppositeNode.GetComponent <BranchHandle>())
                {
                    connectedCord.Collapse();
                }
            }
        }