예제 #1
0
        /// <summary>
        /// Checks if objects are in portal, and teleports them if they are. Also handles player entry.
        /// </summary>
        /// <param name="col"></param>
        public void E_OnTriggerStay(Collider col)
        {
            Teleportable teleportScript = col.GetComponent <Teleportable>();

            AddTeleportable(teleportScript);
            //Detects when head enters portal area
            if (col == headCollider)
            {
                _headInPortalTrigger = true;
            }

            if (enterable && teleportScript)
            {
                //Updates clip planes for disappearing effect
                if (!nonObliqueOverride)
                {
                    teleportScript.SetClipPlane(origin.position, origin.forward, teleportScript.oTeleportRends);
                    teleportScript.SetClipPlane(destination.position, -destination.forward, teleportScript.dTeleportRends);
                }
                if (GlobalPortalSettings.physicsPassthrough)
                {
                    //Makes objects collide with objects on the other side of the portal
                    foreach (Tuple <Collider, Collider> c in passthroughColliders)
                    {
                        teleportScript.AddCollision(c.Item2);
                    }

                    foreach (Collider c in bufferWall)
                    {
                        teleportScript.AddCollision(c);
                    }
                }


                //Passes portal info to teleport script
                teleportScript.SetPortalInfo(this);

                //Teleports objects
                if (PortalUtils.IsBehind(col.transform.position, origin.position, origin.forward) && !teleportScript.VisOnly)
                {
                    //_nearTeleportables.Remove(teleportScript);
                    //teleportScript.ResumeAllCollision();
                    RemoveTeleportable(teleportScript);
                    PortalUtils.TeleportObject(teleportScript.root.gameObject, origin, destination, teleportScript.root);
                    targetPortal.FixedUpdate();
                    targetPortal.SendMessage("E_OnTriggerStay", col);
                    teleportScript.Teleport();
                    targetPortal.UpdateDopplegangers();
                    targetPortal.physicsPassthrough.SendMessage("UpdatePhysics");
                    //physicsPassthrough.SendMessage("UpdatePhysics");

                    if (teleportScript == playerTeleportable)
                    {
                        targetPortal.UpdateDopplegangers();
                        targetPortal.IncomingCamera();
                        _CheeseActivated     = false;
                        _headInPortalTrigger = false;
                        //Resets the vis depth of the portal volume
                        if (!is3d)
                        {
                            transform.localScale = new Vector3(1f, 1f, 0f);
                        }

                        //Flips the nearby light tables

                        ArrayList tempList = new ArrayList(passthroughLights);
                        passthroughLights = targetPortal.passthroughLights;
                        targetPortal.passthroughLights = tempList;
                        foreach (Tuple <Light, GameObject> tup in passthroughLights)
                        {
                            tup.Item2.transform.parent = destination;
                        }
                        foreach (Tuple <Light, GameObject> tup in targetPortal.passthroughLights)
                        {
                            tup.Item2.transform.parent = targetPortal.destination;
                        }
                    }
                }
            }
        }