﻿// Decompiled with JetBrains decompiler
// Type: AdjustCameraFromUI
// Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 19851F1B-4780-4223-BA01-2C20F2CD781E
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\Assembly-CSharp.dll

using UnityEngine;
using Wb.Lpw.Shared.Common;

public class AdjustCameraFromUI
{
  private float m_offsetWorldCamera;
  private float m_offsetScreen;

  public void UpdateOffsets(Camera uiCamera, Camera worldCamera, Vector3 startPosUI, Vector3 endPosUI, float time, float scale = 1f)
  {
    CommonLog.Gameplay.DebugFormat("UI Camera: startPos: {0}, endPos: {1}", (object) startPosUI, (object) endPosUI);
    Vector3 vector3_1 = uiCamera.WorldToScreenPoint(endPosUI);
    Vector3 vector3_2 = uiCamera.WorldToScreenPoint(startPosUI);
    CommonLog.Gameplay.DebugFormat("Screen: startPos: {0}, endPos: {1}", (object) vector3_2, (object) vector3_1);
    Vector3 vector3_3 = Vector3.op_Subtraction(vector3_2, vector3_1);
    // ISSUE: explicit reference operation
    this.m_offsetScreen = ((Vector3) @vector3_3).get_magnitude() * time;
    vector3_1.z = (__Null) 0.0;
    vector3_2.z = (__Null) 0.0;
    Ray ray1 = worldCamera.ScreenPointToRay(vector3_1);
    Ray ray2 = worldCamera.ScreenPointToRay(vector3_2);
    // ISSUE: explicit reference operation
    // ISSUE: explicit reference operation
    CommonLog.Gameplay.DebugFormat("World Camera: startPos: {0}, endPos: {1}", (object) ((Ray) @ray2).get_origin(), (object) ((Ray) @ray1).get_origin());
    double num1 = (double) time * (double) scale;
    // ISSUE: explicit reference operation
    // ISSUE: explicit reference operation
    Vector3 vector3_4 = Vector3.op_Subtraction(((Ray) @ray2).get_origin(), ((Ray) @ray1).get_origin());
    // ISSUE: explicit reference operation
    double num2 = (double) ((Vector3) @vector3_4).get_magnitude();
    this.m_offsetWorldCamera = (float) (num1 * num2);
    CommonLog.Gameplay.DebugFormat("Camera World Offset: {0}", (object) this.m_offsetWorldCamera);
  }

  public Vector3 CalculateOffset(Vector3 rightNorm, float fieldOfView, float zoomFactor, float axisDimension)
  {
    return Vector3.op_Multiply(rightNorm, (float) ((double) this.m_offsetWorldCamera * (double) fieldOfView * (double) zoomFactor * (1.0 - (double) this.m_offsetScreen / (double) axisDimension)));
  }
}
