/// <summary> /// Removes a teleportable from the portal area /// </summary> /// <param name="teleportScript">teleportable to remove</param> private void RemoveTeleportable(Teleportable teleportScript) { if (!teleportScript || !NearTeleportables.Contains(teleportScript)) { return; } if (teleportScript.RemovedLastFrame) { return; } teleportScript.RemovedLastFrame = true; if (!NonObliqueOverride) { teleportScript.SetClipPlane(Vector3.zero, Vector3.zero, teleportScript.Renderers.Keys); teleportScript.SetClipPlane(Vector3.zero, Vector3.zero, teleportScript.Renderers.Values); } UpdateDopplegangers(); NearTeleportables.Remove(teleportScript); if (NearTeleportables.Count < 1) { SetBufferWallActive(false); } teleportScript.LeavePortal(); //teleportScript.ResetDoppleganger(); teleportScript.ResumeAllCollision(this); }
/// <summary> /// Removes a teleportable from the portal area /// </summary> /// <param name="teleportable">teleportable to remove</param> private void RemoveTeleportable(Teleportable teleportable) { if (!teleportable || teleportable.RemovedLastFrame) { return; } if (!NearTeleportables.Contains(teleportable)) { return; } teleportable.RemovedLastFrame = true; if (!NonObliqueOverride) { teleportable.SetClipPlane(Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero); } NearTeleportables.Remove(teleportable); UpdateDopplegangers(); if (NearTeleportables.Count < 1) { SetBufferWallActive(false); } teleportable.LeavePortal(this); teleportable.CollisionManager.ResumeCollisionsForKey(this); if (teleportable == GlobalPortalSettings.PlayerTeleportable) { _headInPortalTrigger = false; } }
/// <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) { if (!TargetPortal) { return; } Rigidbody teleportableBody = col.attachedRigidbody; if (!teleportableBody) { return; } //todo: cache these Teleportable teleportScript = teleportableBody.GetComponent <Teleportable>(); AddTeleportable(teleportScript); if (!Enterable || !teleportScript || !teleportScript.initialized) { return; } if (teleportScript == GlobalPortalSettings.PlayerTeleportable) { _headInPortalTrigger = true; //teleportScript = PlayerTeleportable; } //Updates clip planes for disappearing effect if (!NonObliqueOverride) { teleportScript.SetClipPlane(Origin.position, Origin.forward /* (1 + transform.localScale.z)*/ + (Origin.forward * 0.01f), teleportScript.Renderers.Keys); teleportScript.SetClipPlane(ArrivalTarget.position, -ArrivalTarget.forward, teleportScript.Renderers.Values); } WakeBufferWall(); //Makes objects collide with invisible buffer bounds foreach (Collider c in BufferWall) { teleportScript.AddCollision(this, c); } //Makes objects collide with invisible buffer bounds foreach (Collider c in TargetPortal.BufferWall) { teleportScript.IgnoreCollision(this, c, true); } if (SKSGlobalRenderSettings.PhysicsPassthrough) { //Makes objects collide with objects on the other side of the Portal foreach (Collider c in PassthroughColliders.Values) { teleportScript.AddCollision(this, c); } } //Passes Portal info to teleport script teleportScript.SetPortalInfo(this); //Enables Doppleganger teleportScript.EnableDoppleganger(); //Checks if object should be teleported TryTeleportTeleporable(teleportScript, col); }