Exemplo n.º 1
0
        public void Update()
        {
            if (LongEventHandler.ShouldWaitForEvent)
            {
                if (Current.SubcameraDriver != null)
                {
                    Current.SubcameraDriver.UpdatePositions(this.MyCamera);
                }
                return;
            }
            if (Find.CurrentMap == null)
            {
                return;
            }
            Vector2 lhs = this.CalculateCurInputDollyVect();

            if (lhs != Vector2.zero)
            {
                float d = (this.rootSize - 11f) / 49f * 0.7f + 0.3f;
                this.velocity = new Vector3(lhs.x, 0f, lhs.y) * d;
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraDolly, KnowledgeAmount.FrameInteraction);
            }
            if (!this.AnythingPreventsCameraMotion)
            {
                float d2 = Time.deltaTime * CameraDriver.HitchReduceFactor;
                this.rootPos  += this.velocity * d2 * this.config.moveSpeedScale;
                this.rootPos.x = Mathf.Clamp(this.rootPos.x, 2f, (float)Find.CurrentMap.Size.x + -2f);
                this.rootPos.z = Mathf.Clamp(this.rootPos.z, 2f, (float)Find.CurrentMap.Size.z + -2f);
            }
            int num = Gen.FixedTimeStepUpdate(ref this.fixedTimeStepBuffer, 60f);

            for (int i = 0; i < num; i++)
            {
                if (this.velocity != Vector3.zero)
                {
                    this.velocity *= this.config.camSpeedDecayFactor;
                    if (this.velocity.magnitude < 0.1f)
                    {
                        this.velocity = Vector3.zero;
                    }
                }
                if (this.config.smoothZoom)
                {
                    float num2 = Mathf.Lerp(this.rootSize, this.desiredSize, 0.05f);
                    this.desiredSize += (num2 - this.rootSize) * this.config.zoomPreserveFactor;
                    this.rootSize     = num2;
                }
                else
                {
                    float num3 = this.desiredSize - this.rootSize;
                    float num4 = num3 * 0.4f;
                    this.desiredSize += this.config.zoomPreserveFactor * num4;
                    this.rootSize    += num4;
                }
                this.config.ConfigFixedUpdate_60(ref this.velocity);
            }
            this.shaker.Update();
            this.ApplyPositionToGameObject();
            Current.SubcameraDriver.UpdatePositions(this.MyCamera);
            if (Find.CurrentMap != null)
            {
                RememberedCameraPos rememberedCameraPos = Find.CurrentMap.rememberedCameraPos;
                rememberedCameraPos.rootPos  = this.rootPos;
                rememberedCameraPos.rootSize = this.rootSize;
            }
        }
Exemplo n.º 2
0
 public void Update()
 {
     if (LongEventHandler.ShouldWaitForEvent)
     {
         if (Current.SubcameraDriver != null)
         {
             Current.SubcameraDriver.UpdatePositions(MyCamera);
         }
     }
     else
     {
         if (Find.CurrentMap == null)
         {
             return;
         }
         Vector2 lhs = CalculateCurInputDollyVect();
         if (lhs != Vector2.zero)
         {
             float d = (rootSize - config.minSize) / (60f - config.minSize) * 0.7f + 0.3f;
             velocity = new Vector3(lhs.x, 0f, lhs.y) * d;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraDolly, KnowledgeAmount.FrameInteraction);
         }
         if (!Input.GetMouseButton(2) && dragTimeStamps.Any())
         {
             Vector2 extraVelocityFromReleasingDragButton = GetExtraVelocityFromReleasingDragButton(dragTimeStamps, 0.75f);
             velocity += new Vector3(extraVelocityFromReleasingDragButton.x, 0f, extraVelocityFromReleasingDragButton.y);
             dragTimeStamps.Clear();
         }
         if (!AnythingPreventsCameraMotion)
         {
             float d2 = Time.deltaTime * HitchReduceFactor;
             rootPos += velocity * d2 * config.moveSpeedScale;
             rootPos += new Vector3(desiredDollyRaw.x, 0f, desiredDollyRaw.y);
             dragTimeStamps.Add(new DragTimeStamp
             {
                 posDelta = desiredDollyRaw,
                 time     = Time.time
             });
             rootPos.x = Mathf.Clamp(rootPos.x, 2f, (float)Find.CurrentMap.Size.x + -2f);
             rootPos.z = Mathf.Clamp(rootPos.z, 2f, (float)Find.CurrentMap.Size.z + -2f);
         }
         desiredDollyRaw = Vector2.zero;
         int num = Gen.FixedTimeStepUpdate(ref fixedTimeStepBuffer, 60f);
         for (int i = 0; i < num; i++)
         {
             if (velocity != Vector3.zero)
             {
                 velocity *= config.camSpeedDecayFactor;
                 if (velocity.magnitude < 0.1f)
                 {
                     velocity = Vector3.zero;
                 }
             }
             if (config.smoothZoom)
             {
                 float num2 = Mathf.Lerp(rootSize, desiredSize, 0.05f);
                 desiredSize += (num2 - rootSize) * config.zoomPreserveFactor;
                 rootSize     = num2;
             }
             else
             {
                 float num3 = (desiredSize - rootSize) * 0.4f;
                 desiredSize += config.zoomPreserveFactor * num3;
                 rootSize    += num3;
             }
             config.ConfigFixedUpdate_60(ref velocity);
         }
         shaker.Update();
         ApplyPositionToGameObject();
         Current.SubcameraDriver.UpdatePositions(MyCamera);
         if (Find.CurrentMap != null)
         {
             RememberedCameraPos rememberedCameraPos = Find.CurrentMap.rememberedCameraPos;
             rememberedCameraPos.rootPos  = rootPos;
             rememberedCameraPos.rootSize = rootSize;
         }
     }
 }