Exemplo n.º 1
0
        public void Update()
        {
            if (LongEventHandler.ShouldWaitForEvent)
            {
                return;
            }
            if (Find.World == null)
            {
                MyCamera.gameObject.SetActive(value: false);
                return;
            }
            if (!Find.WorldInterface.everReset)
            {
                Find.WorldInterface.Reset();
            }
            Vector2 lhs = CalculateCurInputDollyVect();

            if (lhs != Vector2.zero)
            {
                float d = (altitude - 125f) / 975f * 0.85f + 0.15f;
                rotationVelocity = new Vector2(lhs.x, lhs.y) * d;
            }
            if (!Input.GetMouseButton(2) && dragTimeStamps.Any())
            {
                rotationVelocity += CameraDriver.GetExtraVelocityFromReleasingDragButton(dragTimeStamps, 5f);
                dragTimeStamps.Clear();
            }
            if (!AnythingPreventsCameraMotion)
            {
                float num = Time.deltaTime * CameraDriver.HitchReduceFactor;
                sphereRotation *= Quaternion.AngleAxis(rotationVelocity.x * num * config.rotationSpeedScale, MyCamera.transform.up);
                sphereRotation *= Quaternion.AngleAxis((0f - rotationVelocity.y) * num * config.rotationSpeedScale, MyCamera.transform.right);
                if (desiredRotationRaw != Vector2.zero)
                {
                    sphereRotation *= Quaternion.AngleAxis(desiredRotationRaw.x, MyCamera.transform.up);
                    sphereRotation *= Quaternion.AngleAxis(0f - desiredRotationRaw.y, MyCamera.transform.right);
                }
                dragTimeStamps.Add(new CameraDriver.DragTimeStamp
                {
                    posDelta = desiredRotationRaw,
                    time     = Time.time
                });
            }
            desiredRotationRaw = Vector2.zero;
            int num2 = Gen.FixedTimeStepUpdate(ref fixedTimeStepBuffer, 60f);

            for (int i = 0; i < num2; i++)
            {
                if (rotationVelocity != Vector2.zero)
                {
                    rotationVelocity *= config.camRotationDecayFactor;
                    if (rotationVelocity.magnitude < 0.05f)
                    {
                        rotationVelocity = Vector2.zero;
                    }
                }
                if (config.smoothZoom)
                {
                    float num3 = Mathf.Lerp(altitude, desiredAltitude, 0.05f);
                    desiredAltitude += (num3 - altitude) * config.zoomPreserveFactor;
                    altitude         = num3;
                }
                else
                {
                    float num4 = (desiredAltitude - altitude) * 0.4f;
                    desiredAltitude += config.zoomPreserveFactor * num4;
                    altitude        += num4;
                }
            }
            rotationAnimation_lerpFactor += Time.deltaTime * 8f;
            if (Find.PlaySettings.lockNorthUp)
            {
                RotateSoNorthIsUp(interpolate: false);
                ClampXRotation(ref sphereRotation);
            }
            for (int j = 0; j < num2; j++)
            {
                config.ConfigFixedUpdate_60(ref rotationVelocity);
            }
            ApplyPositionToGameObject();
        }