protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            if (!VRSF_Components.SetupVRIsReady)
            {
                return(inputDeps);
            }

            NativeArray <float3> rotationAxisOutput = new NativeArray <float3>(1, Allocator.TempJob);
            NativeArray <float>  currentSpeedOutput = new NativeArray <float>(1, Allocator.TempJob);

            var job = new DecelerationJob
            {
                DeltaTime    = Time.deltaTime,
                RotationAxis = rotationAxisOutput,
                CurrentSpeed = currentSpeedOutput
            }.Schedule(this, inputDeps);

            job.Complete();

            VRSF_Components.RotateVRCameraAround(rotationAxisOutput[0], currentSpeedOutput[0]);

            rotationAxisOutput.Dispose();
            currentSpeedOutput.Dispose();

            return(inputDeps);
        }
Esempio n. 2
0
        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()
        {
            if (!VRSF_Components.SetupVRIsReady)
            {
                return;
            }

            Entities.ForEach((ref NonLinearUserRotation nlur, ref ControllersInteractionType cit, ref BaseInputCapture bic, ref TouchpadInputCapture tic) =>
            {
                if (!nlur.HasAlreadyRotated && InteractionChecker.IsInteracting(bic, cit) && math.abs(tic.ThumbPosition.x) > 0.5f)
                {
                    VRSF_Components.RotateVRCameraAround(new float3(0.0f, tic.ThumbPosition.x, 0.0f), nlur.DegreesToRotate);
                    nlur.HasAlreadyRotated = true;
                }
                else if (nlur.HasAlreadyRotated && math.abs(tic.ThumbPosition.x) < 0.5f)
                {
                    nlur.HasAlreadyRotated = false;
                }
            });
        }
Esempio n. 4
0
 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);
                 }
             }
         }
     });
 }
Esempio n. 5
0
 private void TeleportUser(OnFadingOutEndedEvent info)
 {
     OnFadingOutEndedEvent.Listeners -= TeleportUser;
     VRSF_Components.SetCameraRigPosition(_tempPointToGoTo);
 }