Ejemplo n.º 1
0
        public void ConnectToDataEndpoint(PhysicalDataEndpoint receptacle)
        {
            ResetPlugTransform();

            DestinationEndpoint = receptacle;

            float flow = 1;

            if (CordAttachPoint.Equals(connectedCord.StartNode))
            {
                flow = -flow;
            }

            if (DestinationEndpoint.GetComponent <PhysicalDataInput>())
            {
                connectedCord.Flow = flow;
            }
            else
            {
                connectedCord.Flow = -flow;
            }

            connectedCord.Flowing = true;

            DestinationEndpoint.Connect(connectedCord, CordAttachPoint);
            ShrinkCollider();
        }
Ejemplo n.º 2
0
        protected virtual void Awake()
        {
            plugReceptacle = GetComponent <PhysicalDataEndpoint>();
            nearbyPlugs    = new List <Plug>();

            if (PlugLockTrigger != null && PlugUnlockTrigger != null)
            {
                PlugLockTrigger.TriggerEnter  += OnPlugLockTriggerEnter;
                PlugLockTrigger.TriggerExit   += OnPlugLockTriggerExit;
                PlugUnlockTrigger.TriggerExit += OnPlugUnlockTriggerExit;
            }
            else
            {
                Debug.LogError("PlugAttach requires a reference to a SimpleTrigger in the PlugTrigger fields in the inspector");
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This method searches the network of cords connected to this cord in the direction determined by reverseFlow.
        ///
        /// For a given cord, flow is positive if the cord flows from A -> B (i.e. A is the output and B is the input)
        /// Flow is negative if the cords flows from B -> A
        ///
        /// When searching, we look for nodes that are 'downstream' from the start point. This means we only take paths with positive flow during our search.
        /// This is reversed when searching for output jacks
        ///
        /// </summary>
        /// <param name="reverseFlow"></param>
        /// <param name="cordPos"></param>
        /// <returns></returns>
        public HashSet <PhysicalDataEndpoint> GetConnectedEndpoints(bool reverseFlow, Transform searchStartNode)
        {
            HashSet <PhysicalDataEndpoint> results = new HashSet <PhysicalDataEndpoint>();

            float workingFlow = Flow;

            if (reverseFlow)
            {
                workingFlow = -workingFlow;
            }

            if (workingFlow > 0 && !B.Equals(searchStartNode))
            {
                BranchHandle handleB = B.GetComponent <BranchHandle>();
                results.UnionWith(GetEndpointsConnectedToHandle(reverseFlow, handleB));

                Plug plugB = B.GetComponentInActor <Plug>();
                PhysicalDataEndpoint connectedReceptacle = GetConnectedEndpoint(plugB);

                if (connectedReceptacle != null)
                {
                    results.Add(connectedReceptacle);
                }
            }
            else if (workingFlow < 0 && !A.Equals(searchStartNode))
            {
                BranchHandle handleA = A.GetComponent <BranchHandle>();
                results.UnionWith(GetEndpointsConnectedToHandle(reverseFlow, handleA));

                Plug plugA = A.GetComponentInActor <Plug>();
                PhysicalDataEndpoint connectedReceptacle = GetConnectedEndpoint(plugA);

                if (connectedReceptacle != null)
                {
                    results.Add(connectedReceptacle);
                }
            }

            return(results);
        }