void SwitchHitArea(TeleportingArea ta) { if (ta != hitArea) { if (ta != null) { ta.OnEnterArea(this); } if (hitArea != null) { hitArea.OnExitArea(); } hitArea = ta; } }
// Update is called once per frame void Update() { if (WorkingTeleporter != null && WorkingTeleporter != this) { return; } if (!transportingEnabled || inTransporting) { if (LineDrawer) { LineDrawer.drawLine = false; } return; } if (LineDrawer) { if (GetTeleportingCommand()) { WorkingTeleporter = this; if (!LineDrawer.drawLine)//Enable teleporting predicting { GlobalEventManager.SendEvent("VRPlayer.BeginTeleportingPredict"); LineDrawer.drawLine = true; } //Teleporting Area Update TeleportingArea ta = null; if (LineDrawer.HitCollider != null) { ta = LineDrawer.HitCollider.GetComponent <TeleportingArea>(); } AnticipateHitPoint = LineDrawer.AnticipateHitPoint;//Acquire anticipated hit point of predicting line,not the final hit point SwitchHitArea(ta); //Telepoint Update if (AnticipateHitPoint != null) { TeleportingPoint tp = TeleportingPoint.FindClosestTelepoints(AnticipateHitPoint.Value);//Check if a telepoint is near the anicipate hit point SwitchHitPoint(tp); } else { SwitchHitPoint(null); } } else { if (LineDrawer.drawLine) { AnticipateHitPoint = null; LineDrawer.drawLine = false; if (hitArea != null) { hitArea.OnTeleport(); } if (hitTelepoint != null) { hitTelepoint.OnTeleport(); } SwitchHitArea(null); SwitchHitPoint(null); GlobalEventManager.SendEvent("VRPlayer.StopTeleportingPredict"); WorkingTeleporter = null; if (LineDrawer.Status == HittingStatus.HitTeleportingArea || LineDrawer.Status == HittingStatus.HitModifiedTarget) { StartBodyTransporting(); GlobalEventManager.SendEvent("TransportBody"); } } } } }