Ejemplo n.º 1
0
        // Token: 0x0600131F RID: 4895 RVA: 0x00051DE4 File Offset: 0x0004FFE4
        public static void ApplySpacialRumble(LocalUser localUser, Transform cameraTransform)
        {
            Vector3 right    = cameraTransform.right;
            Vector3 position = cameraTransform.position;
            float   num      = 0f;
            float   num2     = 0f;
            int     i        = 0;
            int     count    = ShakeEmitter.instances.Count;

            while (i < count)
            {
                ShakeEmitter shakeEmitter = ShakeEmitter.instances[i];
                Vector3      position2    = shakeEmitter.transform.position;
                float        value        = Vector3.Dot(position2 - position, right);
                float        sqrMagnitude = (position - position2).sqrMagnitude;
                float        num3         = shakeEmitter.radius;
                float        num4         = 0f;
                if (sqrMagnitude < num3 * num3)
                {
                    float num5 = 1f - Mathf.Sqrt(sqrMagnitude) / num3;
                    num4 = shakeEmitter.CurrentShakeFade() * shakeEmitter.wave.amplitude * num5;
                }
                float num6 = Mathf.Clamp01(Util.Remap(value, -1f, 1f, 0f, 1f));
                float num7 = num4;
                num  += num7 * (1f - num6);
                num2 += num7 * num6;
                i++;
            }
        }
        // Token: 0x060006F1 RID: 1777 RVA: 0x0001CFF8 File Offset: 0x0001B1F8
        private void SetCameraState(CameraState cameraState)
        {
            this.currentCameraState = cameraState;
            float   d        = (this.localUserViewer == null) ? 1f : this.localUserViewer.userProfile.screenShakeScale;
            Vector3 position = cameraState.position;

            this.rawScreenShakeDisplacement = ShakeEmitter.ComputeTotalShakeAtPoint(cameraState.position);
            Vector3 vector    = this.rawScreenShakeDisplacement * d;
            Vector3 position2 = position + vector;

            if (vector != Vector3.zero)
            {
                Vector3    origin    = position;
                Vector3    direction = vector;
                RaycastHit raycastHit;
                if (Physics.SphereCast(origin, this.sceneCam.nearClipPlane, direction, out raycastHit, vector.magnitude, LayerIndex.world.mask, QueryTriggerInteraction.Ignore))
                {
                    position2 = position + vector.normalized * raycastHit.distance;
                }
            }
            base.transform.SetPositionAndRotation(position2, cameraState.rotation);
            this.currentFov = cameraState.fov;
            if (this.sceneCam)
            {
                this.sceneCam.fieldOfView = this.currentFov;
            }
        }
Ejemplo n.º 3
0
        // Token: 0x06001320 RID: 4896 RVA: 0x00051EEC File Offset: 0x000500EC
        public static Vector3 ComputeTotalShakeAtPoint(Vector3 position)
        {
            Vector3 vector = Vector3.zero;
            int     i      = 0;
            int     count  = ShakeEmitter.instances.Count;

            while (i < count)
            {
                ShakeEmitter shakeEmitter = ShakeEmitter.instances[i];
                float        sqrMagnitude = (position - shakeEmitter.transform.position).sqrMagnitude;
                float        num          = shakeEmitter.radius;
                if (sqrMagnitude < num * num)
                {
                    float d = 1f - Mathf.Sqrt(sqrMagnitude) / num;
                    vector += shakeEmitter.currentOffset * d;
                }
                i++;
            }
            return(vector);
        }
        // Token: 0x06000BF8 RID: 3064 RVA: 0x0003B0D8 File Offset: 0x000392D8
        private void SetCameraState(CameraState cameraState)
        {
            this.currentCameraState = cameraState;
            float   d        = (this.localUserViewer == null) ? 1f : this.localUserViewer.userProfile.screenShakeScale;
            Vector3 position = cameraState.position;
            Vector3 vector   = ShakeEmitter.ComputeTotalShakeAtPoint(cameraState.position) * d;
            Vector3 vector2  = position + vector;

            if (this.localUserViewer != null)
            {
                Player inputPlayer = this.localUserViewer.inputPlayer;
                if (this.localUserViewer.eventSystem.currentInputSource == MPEventSystem.InputSource.Gamepad)
                {
                    ShakeEmitter.ApplyDeepQuickRumble(this.localUserViewer, vector);
                }
                else
                {
                    inputPlayer.SetVibration(0, 0f);
                    inputPlayer.SetVibration(1, 0f);
                }
            }
            Vector3 position2 = vector2;

            if (vector != Vector3.zero)
            {
                Vector3    origin    = position;
                Vector3    direction = vector;
                RaycastHit raycastHit;
                if (Physics.SphereCast(origin, this.sceneCam.nearClipPlane, direction, out raycastHit, vector.magnitude, LayerIndex.world.mask, QueryTriggerInteraction.Ignore))
                {
                    position2 = position + vector.normalized * raycastHit.distance;
                }
            }
            base.transform.SetPositionAndRotation(position2, cameraState.rotation);
            this.currentFov = cameraState.fov;
            if (this.sceneCam)
            {
                this.sceneCam.fieldOfView = this.currentFov;
            }
        }
Ejemplo n.º 5
0
        // Token: 0x06001321 RID: 4897 RVA: 0x00051F78 File Offset: 0x00050178
        public static ShakeEmitter CreateSimpleShakeEmitter(Vector3 position, Wave wave, float duration, float radius, bool amplitudeTimeDecay)
        {
            if (wave.frequency == 0f)
            {
                Debug.Log("ShakeEmitter with wave frequency 0.0 is not allowed!");
                wave.frequency = 1f;
            }
            GameObject gameObject = new GameObject("ShakeEmitter", new Type[]
            {
                typeof(ShakeEmitter),
                typeof(DestroyOnTimer)
            });
            ShakeEmitter   component  = gameObject.GetComponent <ShakeEmitter>();
            DestroyOnTimer component2 = gameObject.GetComponent <DestroyOnTimer>();

            gameObject.transform.position = position;
            component.wave               = wave;
            component.duration           = duration;
            component.radius             = radius;
            component.amplitudeTimeDecay = amplitudeTimeDecay;
            component2.duration          = duration;
            return(component);
        }