protected override void OnUpdate() { Entities.ForEach((Entity teleportEntity, ref CurveTeleporterCalculations ctc, ref ParabolPointsParameters ppp, ref ParabolCalculations parabolCalc, ref GeneralTeleportParameters gtp, ref TeleportNavMesh tnm, ref VRRaycastParameters raycastParam) => { if (gtp.CurrentTeleportState == ETeleportState.Selecting) { NativeArray <Translation> pointsTranslation = new NativeArray <Translation>(ppp.PointCount, Allocator.Temp); Transform controller = parabolCalc.Origin == Core.Controllers.EHand.LEFT ? VRSF_Components.LeftController.transform : VRSF_Components.RightController.transform; // Calculate Parabola Points parabolCalc.Velocity = ParaboleCalculationsHelper.ForceUpdateCurrentAngle(ctc, controller.TransformDirection(ctc.InitialVelocity)); parabolCalc.Normal = ParaboleCalculationsHelper.ParabolaPointsCalculations(ref pointsTranslation, ref ctc, ppp, tnm, controller.position, raycastParam.ExcludedLayer, parabolCalc.Velocity); var index = 0; Entities.WithAll <ParabolPointTag>().ForEach((Entity point, ref Translation translation) => { if (_entityManager.GetSharedComponentData <ParabolPointParent>(point).TeleporterEntityIndex == teleportEntity.Index) { translation.Value = pointsTranslation[index].Value; index++; } }); pointsTranslation.Dispose(); } else if (gtp.CurrentTeleportState == ETeleportState.Teleporting && !gtp.HasTeleported) { if (ctc.PointOnNavMesh) { if (gtp.IsUsingFadingEffect) { OnFadingOutEndedEvent.Listeners += TeleportUser; _tempPointToGoTo = ctc.PointToGoTo; new StartFadingOutEvent(true); } else { VRSF_Components.SetCameraRigPosition(ctc.PointToGoTo); } } gtp.HasTeleported = true; } }); }
protected override void OnUpdate() { Entities.ForEach((ref StepByStepComponent sbs, ref VRRaycastParameters raycastParam, ref GeneralTeleportParameters gtp, ref TeleportNavMesh tnm, ref VRRaycastOutputs raycastOutputs) => { if (gtp.CurrentTeleportState == ETeleportState.Teleporting) { // We teleport the user as soon as we go out of the job gtp.HasTeleported = true; if (UserIsOnNavMesh(sbs, tnm, raycastOutputs, raycastParam.ExcludedLayer, out float3 newUsersPos)) { if (gtp.IsUsingFadingEffect) { OnFadingOutEndedEvent.Listeners += TeleportUser; _tempPointToGoTo = newUsersPos; new StartFadingOutEvent(true); } else { VRSF_Components.SetCameraRigPosition(newUsersPos); } } } }); }
private void TeleportUser(OnFadingOutEndedEvent info) { OnFadingOutEndedEvent.Listeners -= TeleportUser; VRSF_Components.SetCameraRigPosition(_tempPointToGoTo); }