You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.7 KiB

using System;
using UnityEngine;
namespace FX
{
// Token: 0x02000777 RID: 1911
[RequireComponent(typeof(Camera))]
public class FX_CameraCtrl : MonoBehaviour
{
// Token: 0x06003084 RID: 12420 RVA: 0x00105110 File Offset: 0x00105110
private void Start()
{
this.cameraComponent = base.GetComponent<Camera>();
this.fov = this.cameraComponent.fieldOfView;
}
// Token: 0x06003085 RID: 12421 RVA: 0x00105130 File Offset: 0x00105130
private void Update()
{
this.lookatPos = base.transform.position + base.transform.forward * this.lookatDistance;
this.MouseUpdate();
}
// Token: 0x06003086 RID: 12422 RVA: 0x00105164 File Offset: 0x00105164
private void MouseUpdate()
{
float num = Input.GetAxis("Mouse ScrollWheel") * -this.wheelSpeed;
if (num != 0f)
{
this.CameraFov(num);
}
if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
{
this.preMousePos = Input.mousePosition;
}
this.MouseDrag(Input.mousePosition);
}
// Token: 0x06003087 RID: 12423 RVA: 0x001051D0 File Offset: 0x001051D0
private void MouseDrag(Vector3 mousePos)
{
Vector3 a = mousePos - this.preMousePos;
if (a.magnitude < 1E-05f)
{
return;
}
if (Input.GetMouseButton(2))
{
base.transform.Translate(-a * Time.deltaTime * this.mouseMiddleSpeed);
}
else if (Input.GetMouseButton(1))
{
this.CameraTargetRotate(new Vector2(-a.y, a.x) * this.mouseRightSpeed);
}
else if (Input.GetMouseButton(0))
{
this.CameraMoveForward(a.y * this.mouseLeftSpeed);
}
this.preMousePos = mousePos;
}
// Token: 0x06003088 RID: 12424 RVA: 0x00105290 File Offset: 0x00105290
public void CameraTargetRotate(Vector2 angle)
{
base.transform.RotateAround(this.lookatPos, base.transform.right, angle.x);
base.transform.RotateAround(this.lookatPos, Vector3.up, angle.y);
}
// Token: 0x06003089 RID: 12425 RVA: 0x001052E0 File Offset: 0x001052E0
public void CameraRotate(Vector2 angle)
{
base.transform.RotateAround(base.transform.position, base.transform.right, angle.x);
base.transform.RotateAround(base.transform.position, Vector3.up, angle.y);
}
// Token: 0x0600308A RID: 12426 RVA: 0x00105338 File Offset: 0x00105338
public void CameraFov(float angle)
{
this.fov += angle;
this.fov = Mathf.Clamp(this.fov, 5f, 170f);
this.cameraComponent.fieldOfView = this.fov;
}
// Token: 0x0600308B RID: 12427 RVA: 0x00105374 File Offset: 0x00105374
private void CameraMoveForward(float delta)
{
base.transform.position += base.transform.forward * delta * 0.1f;
}
// Token: 0x0600308C RID: 12428 RVA: 0x001053A8 File Offset: 0x001053A8
private void OnDrawGizmos()
{
Gizmos.color = new Color(0f, 0f, 0f, 0.5f);
Gizmos.DrawWireSphere(this.lookatPos, 0.01f);
Gizmos.DrawWireSphere(this.lookatPos, 0.02f);
Gizmos.DrawWireSphere(this.lookatPos, 0.03f);
Gizmos.DrawLine(this.lookatPos, base.transform.position);
}
// Token: 0x040056FF RID: 22271
[Range(0.1f, 50f)]
[SerializeField]
private float wheelSpeed = 20f;
// Token: 0x04005700 RID: 22272
[Range(0.01f, 10f)]
[SerializeField]
private float mouseMiddleSpeed = 1f;
// Token: 0x04005701 RID: 22273
[Range(0.01f, 10f)]
[SerializeField]
private float mouseRightSpeed = 0.2f;
// Token: 0x04005702 RID: 22274
[Range(0.01f, 10f)]
[SerializeField]
private float mouseLeftSpeed = 0.1f;
// Token: 0x04005703 RID: 22275
private Vector3 preMousePos;
// Token: 0x04005704 RID: 22276
private Camera cameraComponent;
// Token: 0x04005705 RID: 22277
private float fov;
// Token: 0x04005706 RID: 22278
private Vector3 lookatPos;
// Token: 0x04005707 RID: 22279
private float lookatDistance = 3f;
}
}