Decompiled source of CameraTools v0.6.5

CameraTools.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CameraTools")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.6.5.0")]
[module: UnverifiableCode]
namespace CameraTools;

public class CameraPath
{
	private readonly List<CameraPoint> cameras = new List<CameraPoint>();

	private readonly List<float> keyTimes = new List<float>();

	private float duration = 5f;

	private int interpolation = 1;

	private readonly LookTarget lookTarget = new LookTarget();

	private static bool hideGUI;

	private static bool preview;

	private static readonly string[] interpolationTexts = new string[3] { "Linear", "Spherical", "Curve" };

	private static bool autoSplit = true;

	private static int keyFormat = 0;

	private static readonly string[] keyFormatTexts = new string[2] { "Ratio", "Second" };

	private static Vector2 scrollPosition = new Vector2(100f, 100f);

	private CameraPose camPose;

	private VectorLF3 uPosition;

	private float progression;

	private float totalTime;

	private AnimationCurve animCurveX;

	private AnimationCurve animCurveY;

	private AnimationCurve animCurveZ;

	private AnimationCurve animCurveUX;

	private AnimationCurve animCurveUY;

	private AnimationCurve animCurveUZ;

	public int Index { get; set; }

	public string Name { get; set; } = "";


	public bool IsPlaying { get; set; }

	public static bool Loop { get; private set; }

	public bool HideGUI => hideGUI & IsPlaying;

	public bool Preview => preview & !HideGUI;

	public CameraPose CamPose => camPose;

	public VectorLF3 UPosition => uPosition;

	public float Progression => progression;

	private string SectionName => "path-" + Index;

	public CameraPath(int index)
	{
		Index = index;
		Name = SectionName;
	}

	public void Import(ConfigFile configFile = null)
	{
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		Name = configFile.Bind<string>(SectionName, "Name", "path-" + Index, (ConfigDescription)null).Value;
		int value = configFile.Bind<int>(SectionName, "cameraCount", 0, (ConfigDescription)null).Value;
		cameras.Clear();
		keyTimes.Clear();
		for (int i = 0; i < value; i++)
		{
			CameraPoint cameraPoint = new CameraPoint(i)
			{
				SectionPrefix = SectionName
			};
			cameraPoint.Import(configFile);
			cameras.Add(cameraPoint);
			float value2 = configFile.Bind<float>(SectionName, "keytime-" + i, 0f, (ConfigDescription)null).Value;
			keyTimes.Add(value2);
		}
		duration = configFile.Bind<float>(SectionName, "duration", 5f, (ConfigDescription)null).Value;
		interpolation = configFile.Bind<int>(SectionName, "interpolation", 0, (ConfigDescription)null).Value;
		lookTarget.Import(SectionName, configFile);
		OnKeyFrameChange();
	}

	public void Export(ConfigFile configFile = null)
	{
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		configFile.Bind<string>(SectionName, "Name", "Cam-" + Index, (ConfigDescription)null).Value = Name;
		configFile.Bind<int>(SectionName, "cameraCount", 0, (ConfigDescription)null).Value = cameras.Count;
		foreach (CameraPoint camera in cameras)
		{
			camera.SectionPrefix = SectionName;
			camera.Export(configFile);
		}
		for (int i = 0; i < keyTimes.Count; i++)
		{
			configFile.Bind<float>(SectionName, "keytime-" + i, 0f, (ConfigDescription)null).Value = keyTimes[i];
		}
		configFile.Bind<float>(SectionName, "duration", 5f, (ConfigDescription)null).Value = duration;
		configFile.Bind<int>(SectionName, "interpolation", 0, (ConfigDescription)null).Value = interpolation;
		lookTarget.Export(SectionName, configFile);
	}

	public void OnKeyFrameChange()
	{
		if (interpolation == 2)
		{
			RebuildAnimationCurves();
		}
	}

	public void OnLateUpdate(float deltaTime)
	{
		if (duration == 0f || !IsPlaying || GameMain.isPaused)
		{
			return;
		}
		progression = Mathf.Clamp01(progression + deltaTime / duration);
		totalTime += Time.deltaTime;
		if (duration > 0f && progression == 1f)
		{
			if (Loop)
			{
				progression = 0f;
			}
			else
			{
				IsPlaying = false;
			}
		}
	}

	public void TogglePlayButton(bool showView, bool forcePlay = false)
	{
		IsPlaying = !IsPlaying || forcePlay;
		if (IsPlaying)
		{
			if (!preview && showView)
			{
				Plugin.ViewingCam = null;
				Plugin.ViewingPath = this;
			}
			if (progression >= 1f && duration > 0f)
			{
				progression = 0f;
				totalTime = 0f;
			}
		}
	}

	public void ApplyToCamera(Camera cam)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		if (cameras.Count == 0 || !UpdateCameraPose(progression))
		{
			return;
		}
		if (lookTarget.Type != 0)
		{
			lookTarget.SetFinalPose(ref camPose, ref uPosition, totalTime);
		}
		((CameraPose)(ref camPose)).ApplyToCamera(cam);
		if (GameMain.localPlanet == null && GameMain.mainPlayer != null)
		{
			if (ModConfig.MovePlayerWithSpaceCamera.Value)
			{
				GameMain.mainPlayer.uPosition = uPosition;
				return;
			}
			VectorLF3 val = GameMain.mainPlayer.uPosition - uPosition;
			Transform transform = ((Component)GameCamera.main).transform;
			transform.position -= VectorLF3.op_Implicit(val);
			Util.UniverseSimulatorGameTick(in uPosition);
		}
	}

	private bool UpdateCameraPose(float normalizedTime)
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		if (cameras.Count == 0)
		{
			return false;
		}
		int num = 0;
		for (int i = 0; i < keyTimes.Count && !(normalizedTime < keyTimes[i]); i++)
		{
			num++;
		}
		if (num == 0)
		{
			if (!cameras[0].CanView)
			{
				return false;
			}
			camPose = cameras[0].CamPose;
			uPosition = cameras[0].UPosition;
			return true;
		}
		if (num >= cameras.Count)
		{
			if (!cameras[cameras.Count - 1].CanView)
			{
				return false;
			}
			camPose = cameras[cameras.Count - 1].CamPose;
			uPosition = cameras[cameras.Count - 1].UPosition;
			return true;
		}
		if (!cameras[num].CanView || !cameras[num - 1].CanView)
		{
			return false;
		}
		float num2 = keyTimes[num] - keyTimes[num - 1];
		if (num2 == 0f)
		{
			camPose = cameras[num].CamPose;
			uPosition = cameras[num].UPosition;
			return true;
		}
		float t = (normalizedTime - keyTimes[num - 1]) / num2;
		camPose = PiecewiseLerp(cameras[num - 1], cameras[num], t);
		if (interpolation == 2 && animCurveX != null)
		{
			((CameraPose)(ref camPose)).position = new Vector3(animCurveX.Evaluate(normalizedTime), animCurveY.Evaluate(normalizedTime), animCurveZ.Evaluate(normalizedTime));
			if (GameMain.localPlanet == null)
			{
				uPosition = cameras[0].UPosition + new VectorLF3(animCurveUX.Evaluate(normalizedTime), animCurveUY.Evaluate(normalizedTime), animCurveUZ.Evaluate(normalizedTime));
			}
		}
		return true;
	}

	private CameraPose PiecewiseLerp(CameraPoint from, CameraPoint to, float t)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		uPosition = VectorLF3.zero;
		Vector3 val;
		if (interpolation == 1)
		{
			val = Vector3.Lerp(((CameraPose)(ref from.CamPose)).position, ((CameraPose)(ref to.CamPose)).position, t);
			uPosition = from.UPosition + (to.UPosition - from.UPosition) * (double)t;
			if (GameMain.localPlanet != null)
			{
				Vector3 val2 = val;
				Vector3 position = ((CameraPose)(ref from.CamPose)).position;
				float magnitude = ((Vector3)(ref position)).magnitude;
				position = ((CameraPose)(ref to.CamPose)).position;
				val = val2 * (Mathf.Lerp(magnitude, ((Vector3)(ref position)).magnitude, t) / ((Vector3)(ref val)).magnitude);
			}
			else if (GameMain.localStar != null)
			{
				VectorLF3 val3 = from.UPosition - GameMain.localStar.uPosition;
				float num = (float)((VectorLF3)(ref val3)).magnitude;
				val3 = to.UPosition - GameMain.localStar.uPosition;
				float num2 = (float)((VectorLF3)(ref val3)).magnitude;
				float num3 = Mathf.Lerp(num, num2, t);
				VectorLF3 val4 = GameMain.localStar.uPosition;
				val3 = uPosition - GameMain.localStar.uPosition;
				uPosition = val4 + ((VectorLF3)(ref val3)).normalized * (double)num3;
			}
		}
		else
		{
			val = Vector3.Lerp(((CameraPose)(ref from.CamPose)).position, ((CameraPose)(ref to.CamPose)).position, t);
			uPosition = from.UPosition + (to.UPosition - from.UPosition) * (double)t;
		}
		return new CameraPose(val, Quaternion.Slerp(((CameraPose)(ref from.CamPose)).rotation, ((CameraPose)(ref to.CamPose)).rotation, t), Mathf.Lerp(from.CamPose.fov, to.CamPose.fov, t), Mathf.Lerp(from.CamPose.near, to.CamPose.near, t), Mathf.Lerp(from.CamPose.far, to.CamPose.far, t));
	}

	private void RebuildAnimationCurves()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		animCurveX = new AnimationCurve();
		animCurveY = new AnimationCurve();
		animCurveZ = new AnimationCurve();
		animCurveUX = new AnimationCurve();
		animCurveUY = new AnimationCurve();
		animCurveUZ = new AnimationCurve();
		for (int i = 0; i < keyTimes.Count; i++)
		{
			animCurveX.AddKey(keyTimes[i], ((CameraPose)(ref cameras[i].CamPose)).position.x);
			animCurveY.AddKey(keyTimes[i], ((CameraPose)(ref cameras[i].CamPose)).position.y);
			animCurveZ.AddKey(keyTimes[i], ((CameraPose)(ref cameras[i].CamPose)).position.z);
			animCurveUX.AddKey(keyTimes[i], (float)(cameras[i].UPosition.x - cameras[0].UPosition.x));
			animCurveUY.AddKey(keyTimes[i], (float)(cameras[i].UPosition.y - cameras[0].UPosition.y));
			animCurveUZ.AddKey(keyTimes[i], (float)(cameras[i].UPosition.z - cameras[0].UPosition.z));
		}
	}

	public int GetCameraCount()
	{
		return cameras.Count;
	}

	public int SetCameraPoints(List<GameObject> cameraObjs, List<VectorLF3> uPointList)
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		uPointList.Clear();
		for (int i = 0; i < cameras.Count; i++)
		{
			float num = keyTimes[i];
			if (!UpdateCameraPose(num))
			{
				return 0;
			}
			if (lookTarget.Type != 0)
			{
				lookTarget.SetFinalPose(ref camPose, ref uPosition, num * duration);
			}
			cameraObjs[i].transform.position = ((CameraPose)(ref camPose)).position;
			cameraObjs[i].transform.rotation = ((CameraPose)(ref camPose)).rotation;
			uPointList.Add(uPosition + VectorLF3.op_Implicit(((CameraPose)(ref camPose)).position));
		}
		return cameras.Count;
	}

	public int SetPathPoints(Vector3[] lPoints, VectorLF3[] uPoints)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		int num = lPoints.Length;
		for (int i = 0; i < num; i++)
		{
			float num2 = (float)i / (float)num;
			if (!UpdateCameraPose(num2))
			{
				return 0;
			}
			if (lookTarget.Type != 0)
			{
				lookTarget.SetFinalPose(ref camPose, ref uPosition, num2 * duration);
			}
			lPoints[i] = ((CameraPose)(ref camPose)).position;
			uPoints[i] = uPosition + VectorLF3.op_Implicit(((CameraPose)(ref camPose)).position);
		}
		return num;
	}

	public bool SetLookAtLineRealtime(out Vector3 lPoint, out Vector3 lookDir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		lPoint = Vector3.zero;
		lookDir = Vector3.forward;
		if (!UpdateCameraPose(progression))
		{
			return false;
		}
		if (lookTarget.Type != 0)
		{
			lookTarget.SetFinalPose(ref camPose, ref uPosition, progression * duration);
		}
		if (GameMain.localPlanet == null && GameMain.mainPlayer != null)
		{
			lPoint = VectorLF3.op_Implicit(uPosition - GameMain.mainPlayer.uPosition) + ((CameraPose)(ref camPose)).position;
		}
		else
		{
			lPoint = ((CameraPose)(ref camPose)).position;
		}
		lookDir = ((CameraPose)(ref camPose)).rotation * Vector3.forward;
		return true;
	}

	public void UIConfigWindowFunc()
	{
		UIPlayControlPanel();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button((Plugin.ViewingPath == this) ? "[Viewing]".Translate() : "View".Translate(), Array.Empty<GUILayoutOption>()))
		{
			Plugin.ViewingPath = ((Plugin.ViewingPath == this) ? null : this);
		}
		Loop = GUILayout.Toggle(Loop, "Loop".Translate(), Array.Empty<GUILayoutOption>());
		bool flag = GUILayout.Toggle(preview, "Preview".Translate(), Array.Empty<GUILayoutOption>());
		if (flag != preview)
		{
			preview = flag;
			GizmoManager.OnPathChange();
		}
		hideGUI = GUILayout.Toggle(hideGUI, "Hide GUI".Translate(), Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		UIKeyframePanel();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Path List".Translate(), Array.Empty<GUILayoutOption>()))
		{
			UIWindow.TogglePathListWindow();
		}
		if (GUILayout.Button("Record This Path".Translate(), Array.Empty<GUILayoutOption>()))
		{
			CaptureManager.SetCameraPath(this);
			UIWindow.ToggleRecordWindow();
		}
		GUILayout.EndHorizontal();
	}

	private void UIPlayControlPanel()
	{
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		float num = GUILayout.HorizontalSlider(progression, 0f, 1f, Array.Empty<GUILayoutOption>());
		if (num != progression)
		{
			progression = num;
			totalTime = duration * progression;
		}
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Progress: ".Translate() + progression.ToString("F2"), Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("|<<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(40f) }))
		{
			progression = 0f;
			totalTime = 0f;
			if (!preview)
			{
				Plugin.ViewingPath = this;
			}
		}
		if (GUILayout.Button(IsPlaying ? "||" : "▶\ufe0e", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(40f) }))
		{
			TogglePlayButton(showView: true);
		}
		if (GUILayout.Button(">>|", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(40f) }))
		{
			progression = 1f;
			totalTime = duration;
			if (!preview)
			{
				Plugin.ViewingPath = this;
			}
		}
		GUILayout.EndHorizontal();
		Util.AddFloatFieldInput("Duration(s)".Translate(), ref duration, 1f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Interp".Translate(), Array.Empty<GUILayoutOption>());
		int num2 = GUILayout.Toolbar(interpolation, Extensions.TL(interpolationTexts), Array.Empty<GUILayoutOption>());
		if (num2 != interpolation)
		{
			interpolation = num2;
			OnKeyFrameChange();
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Target".Translate(), Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("<", Array.Empty<GUILayoutOption>()))
		{
			int type = (int)((lookTarget.Type == LookTarget.TargetType.None) ? LookTarget.TargetType.Space : (lookTarget.Type - 1));
			lookTarget.Type = (LookTarget.TargetType)type;
			GizmoManager.OnPathChange();
		}
		if (GUILayout.Button(lookTarget.Type.ToString().Translate(), Array.Empty<GUILayoutOption>()))
		{
			if (UIWindow.EditingTarget != lookTarget)
			{
				LookTarget.OpenAndSetWindow(lookTarget);
				GizmoManager.OnPathChange();
			}
			else
			{
				UIWindow.EditingTarget = null;
			}
		}
		if (GUILayout.Button(">", Array.Empty<GUILayoutOption>()))
		{
			lookTarget.Type = (LookTarget.TargetType)((int)(lookTarget.Type + 1) % 4);
			GizmoManager.OnPathChange();
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
	}

	private void UIKeyframePanel()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Keyframe".Translate(), Array.Empty<GUILayoutOption>());
		keyFormat = GUILayout.Toolbar(keyFormat, Extensions.TL(keyFormatTexts), Array.Empty<GUILayoutOption>());
		autoSplit = GUILayout.Toggle(autoSplit, "Auto Split".Translate(), Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>());
		int num = -1;
		int num2 = -1;
		int num3 = -1;
		foreach (CameraPoint camera in cameras)
		{
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			if (keyFormat == 0)
			{
				float value = keyTimes[camera.Index];
				Util.AddFloatFieldInput($"[{camera.Index}] {camera.Name}", ref value);
				keyTimes[camera.Index] = Mathf.Clamp01(value);
			}
			else
			{
				float value2 = keyTimes[camera.Index] * duration;
				Util.AddFloatFieldInput($"[{camera.Index}] {camera.Name}", ref value2);
				if (duration != 0f)
				{
					keyTimes[camera.Index] = Mathf.Clamp01(value2 / duration);
				}
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			bool flag = Plugin.ViewingCam == camera;
			if (GUILayout.Button(flag ? "[Viewing]".Translate() : (camera.CanView ? "View".Translate() : "Unavailable".Translate()), Array.Empty<GUILayoutOption>()))
			{
				if (flag)
				{
					Plugin.ViewingCam = null;
				}
				else if (!camera.CanView)
				{
					UIRealtimeTip.Popup("Camera type mismatch to current environment!".Translate(), true, 0);
				}
				else
				{
					Plugin.ViewingCam = camera;
				}
			}
			if (GUILayout.Button("↑", Array.Empty<GUILayoutOption>()))
			{
				num2 = camera.Index;
			}
			if (GUILayout.Button("↓", Array.Empty<GUILayoutOption>()))
			{
				num3 = camera.Index;
			}
			bool flag2 = UIWindow.EditingCam == camera;
			if (GUILayout.Button(flag2 ? "[Editing]".Translate() : "Edit".Translate(), Array.Empty<GUILayoutOption>()))
			{
				UIWindow.EditingCam = (flag2 ? null : camera);
				OnKeyFrameChange();
			}
			if (GUILayout.Button("Remove".Translate(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(60f) }))
			{
				num = camera.Index;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}
		if (num != -1)
		{
			Plugin.Log.LogDebug((object)("Remove Path Cam " + num));
			UIWindow.EditingCam = null;
			cameras.RemoveAt(num);
			keyTimes.RemoveAt(num);
			RearrangeTimes(autoSplit);
		}
		if (num2 >= 1)
		{
			SwapCamIndex(num2, num2 - 1);
		}
		if (num3 >= 0 && num3 + 1 < cameras.Count)
		{
			SwapCamIndex(num3, num3 + 1);
		}
		GUILayout.EndScrollView();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Insert Keyframe".Translate(), Array.Empty<GUILayoutOption>()))
		{
			int i;
			for (i = 0; i < cameras.Count && !(progression <= keyTimes[i]); i++)
			{
			}
			if (i >= cameras.Count)
			{
				i = cameras.Count;
			}
			Plugin.Log.LogDebug((object)("Insert Path Cam " + i));
			CameraPoint cameraPoint = new CameraPoint(i)
			{
				SectionPrefix = SectionName
			};
			if (GameMain.localPlanet != null)
			{
				cameraPoint.SetPlanetCamera();
			}
			else
			{
				cameraPoint.SetSpaceCamera();
			}
			cameraPoint.Name = cameraPoint.GetPolarName();
			cameras.Insert(i, cameraPoint);
			keyTimes.Insert(i, progression);
			RearrangeTimes(evenSplitTime: false);
		}
		if (GUILayout.Button("Append Keyframe".Translate(), Array.Empty<GUILayoutOption>()))
		{
			Plugin.Log.LogDebug((object)("Add Path Cam " + cameras.Count));
			CameraPoint cameraPoint2 = new CameraPoint(cameras.Count)
			{
				SectionPrefix = SectionName
			};
			if (GameMain.localPlanet != null)
			{
				cameraPoint2.SetPlanetCamera();
			}
			else
			{
				cameraPoint2.SetSpaceCamera();
			}
			cameraPoint2.Name = cameraPoint2.GetPolarName();
			cameras.Add(cameraPoint2);
			keyTimes.Add(1f);
			RearrangeTimes(autoSplit);
		}
		GUILayout.EndHorizontal();
		GUILayout.EndVertical();
	}

	private void RearrangeTimes(bool evenSplitTime)
	{
		int count = cameras.Count;
		if (count == 0)
		{
			return;
		}
		while (keyTimes.Count < count)
		{
			keyTimes.Add(1f);
		}
		for (int i = 0; i < count; i++)
		{
			cameras[i].Index = i;
			if (evenSplitTime)
			{
				keyTimes[i] = ((count > 1) ? ((float)i / (float)(count - 1)) : 0f);
			}
		}
		if (evenSplitTime)
		{
			keyTimes[count - 1] = 1f;
		}
		Export();
		OnKeyFrameChange();
	}

	private void SwapCamIndex(int a, int b)
	{
		List<CameraPoint> list = cameras;
		List<CameraPoint> list2 = cameras;
		CameraPoint cameraPoint = cameras[b];
		CameraPoint cameraPoint2 = cameras[a];
		CameraPoint cameraPoint4 = (list[a] = cameraPoint);
		cameraPoint4 = (list2[b] = cameraPoint2);
		cameras[a].Index = a;
		cameras[b].Index = b;
		Export();
		OnKeyFrameChange();
	}
}
public class CameraPoint
{
	private enum CameraType
	{
		Planet,
		Space
	}

	private static readonly string[] cameraTypeTexts = new string[2] { "Planet", "Space" };

	private CameraType cameraType;

	public CameraPose CamPose;

	public VectorLF3 UPosition;

	private static int positionType = 0;

	private static readonly string[] positionTypeTexts = new string[2] { "Cartesian", "Polar" };

	public int Index { get; set; }

	public string SectionPrefix { get; set; } = "";


	public string Name { get; set; } = "";


	public bool CanView
	{
		get
		{
			if (GameMain.data == null || DSPGame.Game.isMenuDemo || GameMain.mainPlayer == null)
			{
				return false;
			}
			if (cameraType == CameraType.Planet && GameMain.localPlanet == null)
			{
				return false;
			}
			if (cameraType == CameraType.Space && GameMain.localPlanet != null)
			{
				return false;
			}
			return true;
		}
	}

	private string SectionName => SectionPrefix + "cam-" + Index;

	public CameraPoint(int index)
	{
		Index = index;
	}

	public void Import(ConfigFile configFile = null)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		Name = configFile.Bind<string>(SectionName, "Name", "Cam-" + Index, (ConfigDescription)null).Value;
		cameraType = (CameraType)configFile.Bind<int>(SectionName, "cameraType", 0, (ConfigDescription)null).Value;
		((CameraPose)(ref CamPose)).position = configFile.Bind<Vector3>(SectionName, "pose Position", Vector3.zero, (ConfigDescription)null).Value;
		((CameraPose)(ref CamPose)).rotation = configFile.Bind<Quaternion>(SectionName, "pose Rotation", Quaternion.identity, (ConfigDescription)null).Value;
		CamPose.fov = configFile.Bind<float>(SectionName, "pose Fov", 0f, (ConfigDescription)null).Value;
		CamPose.near = configFile.Bind<float>(SectionName, "pose Near", 0f, (ConfigDescription)null).Value;
		CamPose.far = configFile.Bind<float>(SectionName, "pose Far", 0f, (ConfigDescription)null).Value;
		UPosition = configFile.Bind<VectorLF3>(SectionName, "uPosition", VectorLF3.zero, (ConfigDescription)null).Value;
	}

	public void Export(ConfigFile configFile = null)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		configFile.Bind<string>(SectionName, "Name", "Cam-" + Index, (ConfigDescription)null).Value = Name;
		configFile.Bind<int>(SectionName, "cameraType", 0, (ConfigDescription)null).Value = (int)cameraType;
		configFile.Bind<Vector3>(SectionName, "pose Position", Vector3.zero, (ConfigDescription)null).Value = ((CameraPose)(ref CamPose)).position;
		configFile.Bind<Quaternion>(SectionName, "pose Rotation", Quaternion.identity, (ConfigDescription)null).Value = ((CameraPose)(ref CamPose)).rotation;
		configFile.Bind<float>(SectionName, "pose Fov", 0f, (ConfigDescription)null).Value = CamPose.fov;
		configFile.Bind<float>(SectionName, "pose Near", 0f, (ConfigDescription)null).Value = CamPose.near;
		configFile.Bind<float>(SectionName, "pose Far", 0f, (ConfigDescription)null).Value = CamPose.far;
		configFile.Bind<VectorLF3>(SectionName, "uPosition", VectorLF3.zero, (ConfigDescription)null).Value = UPosition;
	}

	public void SetPlanetCamera()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		cameraType = CameraType.Planet;
		if (Plugin.ViewingCam != null)
		{
			UPosition = Plugin.ViewingCam.UPosition;
			CamPose = Plugin.ViewingCam.CamPose;
		}
		else if (Plugin.ViewingPath != null)
		{
			UPosition = Plugin.ViewingPath.UPosition;
			CamPose = Plugin.ViewingPath.CamPose;
		}
		else
		{
			UPosition = GameMain.mainPlayer?.uPosition ?? VectorLF3.op_Implicit(Vector3.zero);
			CamPose = GameCamera.instance.finalPoser.cameraPose;
		}
	}

	public void SetSpaceCamera()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		cameraType = CameraType.Space;
		if (Plugin.ViewingCam != null)
		{
			UPosition = Plugin.ViewingCam.UPosition;
			CamPose = Plugin.ViewingCam.CamPose;
		}
		else if (Plugin.ViewingPath != null)
		{
			UPosition = Plugin.ViewingPath.UPosition;
			CamPose = Plugin.ViewingPath.CamPose;
		}
		else
		{
			UPosition = GameMain.mainPlayer?.uPosition ?? VectorLF3.op_Implicit(Vector3.zero);
			CamPose = GameCamera.instance.finalPoser.cameraPose;
		}
	}

	public void ApplyToCamera(Camera cam)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		((CameraPose)(ref CamPose)).ApplyToCamera(cam);
		if (cameraType == CameraType.Space && GameMain.mainPlayer != null)
		{
			if (ModConfig.MovePlayerWithSpaceCamera.Value)
			{
				GameMain.mainPlayer.uPosition = UPosition;
				return;
			}
			VectorLF3 val = GameMain.mainPlayer.uPosition - UPosition;
			Transform transform = ((Component)GameCamera.main).transform;
			transform.position -= VectorLF3.op_Implicit(val);
			Util.UniverseSimulatorGameTick(in UPosition);
		}
	}

	public string GetInfo()
	{
		return cameraType switch
		{
			CameraType.Planet => "(P)", 
			CameraType.Space => "(S)", 
			_ => "", 
		};
	}

	public string GetPolarName()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		switch (cameraType)
		{
		case CameraType.Planet:
		{
			int num6 = default(int);
			int num7 = default(int);
			int num8 = default(int);
			int num9 = default(int);
			bool flag3 = default(bool);
			bool flag4 = default(bool);
			bool flag5 = default(bool);
			bool flag6 = default(bool);
			Maths.GetLatitudeLongitude(CamPose.pose.position, ref num6, ref num7, ref num8, ref num9, ref flag3, ref flag4, ref flag5, ref flag6);
			return $"{num6}°{num7}′" + (flag4 ? "S" : "N") + $" {num8}°{num9}′" + (flag5 ? "W" : "E");
		}
		case CameraType.Space:
		{
			if (GameMain.localStar == null)
			{
				return "";
			}
			int num = default(int);
			int num2 = default(int);
			int num3 = default(int);
			int num4 = default(int);
			double num5 = default(double);
			bool flag = default(bool);
			bool flag2 = default(bool);
			Maths.GetLatitudeLongitudeSpace(UPosition - GameMain.localStar.uPosition, ref num, ref num2, ref num3, ref num4, ref num5, ref flag, ref flag2);
			if (flag2)
			{
				num = -num;
			}
			return $"{num3}°{num4}′, {num}°{num2}′";
		}
		default:
			return "";
		}
	}

	public void ConfigWindowFunc()
	{
		//IL_0507: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_045c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Set to Current View".Translate(), Array.Empty<GUILayoutOption>()))
		{
			if (GameMain.localPlanet != null)
			{
				SetPlanetCamera();
			}
			else
			{
				SetSpaceCamera();
			}
		}
		if (GUILayout.Button(Plugin.FreePoser.Enabled ? "[Adjusting]".Translate() : "Adjust Mode".Translate(), Array.Empty<GUILayoutOption>()))
		{
			if (Plugin.FreePoser.Enabled)
			{
				Plugin.FreePoser.Enabled = false;
			}
			else if (CanView)
			{
				Plugin.FreePoser.Enabled = true;
				Plugin.ViewingCam = this;
			}
			else
			{
				UIRealtimeTip.Popup("Camera type mismatch to current environment!".Translate(), true, 0);
			}
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Name".Translate(), Array.Empty<GUILayoutOption>());
		string name = Name;
		name = GUILayout.TextField(name, 100, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(100f) });
		if (name != Name)
		{
			Name = name;
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Camera Type".Translate(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(35f) });
		cameraType = (CameraType)GUILayout.Toolbar((int)cameraType, Extensions.TL(cameraTypeTexts), Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		if (cameraType == CameraType.Planet)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Local Position".Translate(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(70f) });
			positionType = GUILayout.Toolbar(positionType, Extensions.TL(positionTypeTexts), Array.Empty<GUILayoutOption>());
			GUILayout.EndHorizontal();
			if (positionType == 0)
			{
				Util.AddFloatField("x", ref CamPose.pose.position.x, 1f);
				Util.AddFloatField("y", ref CamPose.pose.position.y, 1f);
				Util.AddFloatField("z", ref CamPose.pose.position.z, 1f);
			}
			else
			{
				Vector3 normalized = ((Vector3)(ref CamPose.pose.position)).normalized;
				float value = Mathf.Asin(normalized.y) * 57.29578f;
				float value2 = Mathf.Atan2(normalized.x, 0f - normalized.z) * 57.29578f;
				float value3 = ((Vector3)(ref CamPose.pose.position)).magnitude;
				Util.AddFloatField("Log", ref value2, 1f);
				Util.AddFloatField("Lat", ref value, 1f);
				Util.AddFloatField("Alt", ref value3, 1f);
				CamPose.pose.position = Maths.GetPosByLatitudeAndLongitude(value, value2, value3);
			}
		}
		else if (cameraType == CameraType.Space)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Space Position".Translate(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(70f) });
			if (GameMain.localStar != null)
			{
				positionType = GUILayout.Toolbar(positionType, Extensions.TL(positionTypeTexts), Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndHorizontal();
			if (positionType == 1 && GameMain.localStar != null)
			{
				VectorLF3 val = UPosition - GameMain.localStar.uPosition;
				Vector3 val2 = VectorLF3.op_Implicit(((VectorLF3)(ref val)).normalized);
				float value4 = Mathf.Asin(val2.y) * 57.29578f;
				float value5 = Mathf.Atan2(val2.x, 0f - val2.z) * 57.29578f;
				val = UPosition - GameMain.localStar.uPosition;
				float value6 = (float)((VectorLF3)(ref val)).magnitude;
				Util.AddFloatField("Log", ref value5, 1f);
				Util.AddFloatField("Lat", ref value4, 1f);
				Util.AddFloatField("Alt", ref value6, 100f);
				UPosition = GameMain.localStar.uPosition + VectorLF3.op_Implicit(Maths.GetPosByLatitudeAndLongitude(value4, value5, value6));
			}
			else
			{
				Util.AddDoubleField("ux", ref UPosition.x, 100.0);
				Util.AddDoubleField("uy", ref UPosition.y, 100.0);
				Util.AddDoubleField("uz", ref UPosition.z, 100.0);
			}
		}
		GUILayout.EndVertical();
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Rotation".Translate(), Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		Vector3 eulerAngles = ((CameraPose)(ref CamPose)).eulerAngles;
		Util.AddFloatField("pitch", ref eulerAngles.x, 10f);
		Util.AddFloatField("yaw", ref eulerAngles.y, 10f);
		Util.AddFloatField("roll", ref eulerAngles.z, 10f);
		((CameraPose)(ref CamPose)).eulerAngles = eulerAngles;
		GUILayout.EndVertical();
		Util.AddFloatField("Fov", ref CamPose.fov, 1f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Save All".Translate(), Array.Empty<GUILayoutOption>()))
		{
			Export();
			if (UIWindow.EditingPath != null)
			{
				UIWindow.EditingPath.OnKeyFrameChange();
			}
		}
		if (GUILayout.Button("Load All".Translate(), Array.Empty<GUILayoutOption>()))
		{
			Import();
			if (UIWindow.EditingPath != null)
			{
				UIWindow.EditingPath.OnKeyFrameChange();
			}
		}
		GUILayout.EndHorizontal();
	}
}
public static class CaptureManager
{
	public static ConfigEntry<float> TimeInterval;

	public static ConfigEntry<string> ScreenshotFolderPath;

	public static ConfigEntry<int> ScreenshotWidth;

	public static ConfigEntry<int> ScreenshotHeight;

	public static ConfigEntry<int> JpgQuality;

	public static ConfigEntry<bool> UseSubfolder;

	public static ConfigEntry<float> VideoOutputFps;

	public static ConfigEntry<string> VideoFolderPath;

	public static ConfigEntry<string> VideoFFmpegOptions;

	public static ConfigEntry<string> VideoExtension;

	private static bool recording;

	private static float timer;

	private static bool syncUPS;

	private static bool syncProgress = true;

	private static double lastTimeF;

	private static bool inSession;

	private static string folderPath = "";

	private static int fileIndex;

	private static readonly string subfolderFormatString = "MMdd_HHmmss";

	private static readonly string fileFormatString = "{0:D6}.jpg";

	private static bool videoRecordingEnabled = true;

	private static FFmpegSession ffmpegSession;

	private static readonly string videoFileFormat = "MM-dd_HH-mm-ss";

	private static string statusText = "";

	private static Vector2 scrollPosition;

	private static bool expandPathListMode = false;

	public static CameraPath CapturingPath { get; private set; }

	public static void Load(ConfigFile config)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		TimeInterval = config.Bind<float>("- TimeLapse -", "Time Interval(s)", 30f, "Screenshot time interval in seconds");
		ScreenshotFolderPath = config.Bind<string>("- TimeLapse -", "Folder Path", "", "The folder path to save screenshots");
		ScreenshotWidth = config.Bind<int>("- TimeLapse -", "Output Width", 1920, "Resolution width of timelapse screenshots");
		ScreenshotHeight = config.Bind<int>("- TimeLapse -", "Output Height", 1080, "Resolution height of timelapse screenshots");
		JpgQuality = config.Bind<int>("- TimeLapse -", "JPG Quality", 95, new ConfigDescription("Quality of screenshots", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		UseSubfolder = config.Bind<bool>("- TimeLapse -", "Use Subfolder", true, "Screenshot will be saved in the subfolder in Datetime foramt MMdd_HHmmss");
		VideoOutputFps = config.Bind<float>("- Video Recording -", "Output FPS", 24f, "Frame rate of output video");
		VideoFolderPath = config.Bind<string>("- Video Recording -", "Folder Path", "", "The folder path to save video recording");
		VideoExtension = config.Bind<string>("- Video Recording -", "Video Extension", ".mp4", "Video Format of the output file");
		VideoFFmpegOptions = config.Bind<string>("- Video Recording -", "FFmpeg Options", "-c:v libx264 -pix_fmt yuv420p -preset ultrafast -vf vflip -y", "Extra ffmpeg options to output video");
	}

	public static bool SetCameraPath(CameraPath cameraPath)
	{
		if (recording)
		{
			return false;
		}
		CapturingPath = cameraPath;
		return true;
	}

	public static void OnLateUpdate()
	{
		if ((syncProgress && !recording) || GameMain.isPaused)
		{
			return;
		}
		float num = Time.deltaTime;
		if (syncUPS)
		{
			num = (float)(GameMain.instance.timef - lastTimeF);
			lastTimeF = GameMain.instance.timef;
		}
		if (num < float.Epsilon)
		{
			return;
		}
		if (CapturingPath != null)
		{
			CapturingPath.OnLateUpdate(num);
		}
		if (!recording)
		{
			return;
		}
		timer += num;
		if (!(timer >= TimeInterval.Value))
		{
			return;
		}
		timer = 0f;
		if (string.IsNullOrWhiteSpace(folderPath))
		{
			statusText = "Folder path is empty!";
			recording = false;
			return;
		}
		Texture2D val = SetAndCapture(CapturingPath);
		if (ffmpegSession != null)
		{
			if (!ffmpegSession.SendToPipe(val, ref statusText))
			{
				recording = false;
				ffmpegSession.Stop();
				ffmpegSession = null;
			}
			Object.Destroy((Object)(object)val);
		}
		else
		{
			string fileName = Path.Combine(folderPath, string.Format(fileFormatString, fileIndex++));
			EncodeAndSave(val, fileName, JpgQuality.Value);
		}
		if (syncProgress)
		{
			CameraPath capturingPath = CapturingPath;
			if (capturingPath != null && !capturingPath.IsPlaying)
			{
				StopRecordSession();
			}
		}
	}

	private static Texture2D SetAndCapture(CameraPath cameraPath)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		Camera main = GameCamera.main;
		int cullingMask = main.cullingMask;
		Vector3 position = ((Component)main).transform.position;
		Quaternion rotation = ((Component)main).transform.rotation;
		float fieldOfView = main.fieldOfView;
		float nearClipPlane = main.nearClipPlane;
		float farClipPlane = main.farClipPlane;
		bool renderVegetable = true;
		if (GameMain.data.localPlanet != null && GameMain.data.localPlanet.factoryLoaded)
		{
			renderVegetable = GameMain.data.localPlanet.factoryModel.gpuiManager.renderVegetable;
			GameMain.data.localPlanet.factoryModel.gpuiManager.renderVegetable = false;
		}
		cameraPath?.ApplyToCamera(main);
		Texture2D result = CaptureTexture2D(ScreenshotWidth.Value, ScreenshotHeight.Value);
		main.cullingMask = cullingMask;
		((Component)main).transform.position = position;
		((Component)main).transform.rotation = rotation;
		main.fieldOfView = fieldOfView;
		main.nearClipPlane = nearClipPlane;
		main.farClipPlane = farClipPlane;
		if (GameMain.data.localPlanet != null && GameMain.data.localPlanet.factoryLoaded)
		{
			GameMain.universeSimulator.planetSimulators[GameMain.data.localPlanet.index].LateUpdate();
			GameMain.data.localPlanet.factoryModel.DrawInstancedBatches(main, true);
			GameMain.data.localPlanet.factoryModel.gpuiManager.renderVegetable = renderVegetable;
		}
		if (GameMain.data.spaceSector != null)
		{
			GameMain.data.spaceSector.model.DrawInstancedBatches(main, true);
		}
		return result;
	}

	private static Texture2D CaptureTexture2D(int width, int height)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected I4, but got Unknown
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Expected O, but got Unknown
		if (GameMain.data == null)
		{
			return null;
		}
		try
		{
			RenderTexture active = RenderTexture.active;
			Camera main = GameCamera.main;
			RenderTexture val2 = (main.targetTexture = new RenderTexture(width, height, 24));
			main.cullingMask = (int)GameCamera.instance.gameLayerMask;
			if (GameMain.data.localPlanet != null && GameMain.data.localPlanet.factoryLoaded)
			{
				GameMain.universeSimulator.planetSimulators[GameMain.data.localPlanet.index].LateUpdate();
				GameMain.data.localPlanet.factoryModel.DrawInstancedBatches(main, true);
			}
			if (GameMain.data.spaceSector != null)
			{
				GameMain.data.spaceSector.model.DrawInstancedBatches(main, true);
			}
			main.Render();
			Texture2D val3 = new Texture2D(((Texture)val2).width, ((Texture)val2).height, (TextureFormat)3, false);
			RenderTexture.active = val2;
			val3.ReadPixels(new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), 0, 0);
			val3.Apply();
			RenderTexture.active = active;
			main.targetTexture = null;
			val2.Release();
			Object.Destroy((Object)(object)val2);
			return val3;
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("CaptureTexture2D Failed!\n" + ex));
			return null;
		}
	}

	private static void EncodeAndSave(Texture2D texture2D, string fileName, int jpgQuality = 100)
	{
		ThreadingHelper.Instance.StartAsyncInvoke((Func<Action>)delegate
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			try
			{
				HighStopwatch val = new HighStopwatch();
				val.Begin();
				byte[] bytes = ImageConversion.EncodeToJPG(texture2D, jpgQuality);
				statusText = $"[{fileIndex:D6}.jpg] {val.duration * 1000.0}ms";
				File.WriteAllBytes(fileName, bytes);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("EncodeAndSave Failed!\n" + ex));
			}
			return delegate
			{
				Object.Destroy((Object)(object)texture2D);
			};
		});
	}

	private static void StartRecordSession()
	{
		folderPath = (videoRecordingEnabled ? VideoFolderPath.Value : ScreenshotFolderPath.Value);
		if (!Directory.Exists(folderPath))
		{
			statusText = "The folder doesn't exist!";
			return;
		}
		if (UseSubfolder.Value && !videoRecordingEnabled)
		{
			try
			{
				folderPath = Path.Combine(folderPath, DateTime.Now.ToString(subfolderFormatString));
				Directory.CreateDirectory(folderPath);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)ex);
				statusText = "Error when creating the subfolder!" + ex.Message;
				folderPath = "";
				return;
			}
		}
		if (videoRecordingEnabled)
		{
			string filePath = Path.Combine(folderPath, DateTime.Now.ToString(videoFileFormat) + VideoExtension.Value);
			int value = ScreenshotWidth.Value;
			int value2 = ScreenshotHeight.Value;
			float value3 = VideoOutputFps.Value;
			string value4 = VideoFFmpegOptions.Value;
			try
			{
				ffmpegSession = new FFmpegSession(filePath, value, value2, value3, value4);
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)ex2);
				statusText = "Error when starting ffmpeg!" + ex2.Message;
				ffmpegSession = null;
				return;
			}
		}
		recording = true;
		timer = TimeInterval.Value;
		lastTimeF = GameMain.instance.timef;
		inSession = true;
		if (syncProgress && CapturingPath != null)
		{
			CapturingPath.TogglePlayButton(showView: false, forcePlay: true);
		}
	}

	private static void StopRecordSession()
	{
		recording = false;
		timer = 0f;
		lastTimeF = 0.0;
		inSession = false;
		if (ffmpegSession != null)
		{
			ffmpegSession.Stop();
			ffmpegSession = null;
		}
		if (UseSubfolder.Value)
		{
			fileIndex = 0;
		}
	}

	public static void ConfigWindowFunc()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		scrollPosition = GUILayout.BeginScrollView(scrollPosition, Array.Empty<GUILayoutOption>());
		PlayControlPanel();
		Util.ConfigFloatField(TimeInterval);
		PathSelectionBox();
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Record Type".Translate(), Array.Empty<GUILayoutOption>());
		videoRecordingEnabled = !GUILayout.Toggle(!videoRecordingEnabled, "Image".Translate(), Array.Empty<GUILayoutOption>());
		videoRecordingEnabled = GUILayout.Toggle(videoRecordingEnabled, "Video".Translate(), Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		if (!videoRecordingEnabled)
		{
			ImageCaptureSettingPanel();
		}
		else
		{
			VideoCaptureSettingPanel();
		}
		GUILayout.EndVertical();
		GUILayout.EndScrollView();
	}

	private static void PlayControlPanel()
	{
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		if (!inSession)
		{
			if (GUILayout.Button("Start Record".Translate(), Array.Empty<GUILayoutOption>()))
			{
				StartRecordSession();
			}
			syncProgress = GUILayout.Toggle(syncProgress, "Sync Progress".Translate(), Array.Empty<GUILayoutOption>());
			syncUPS = GUILayout.Toggle(syncUPS, "Sync UPS".Translate(), Array.Empty<GUILayoutOption>());
		}
		else
		{
			if (GUILayout.Button(recording ? "Pause".Translate() : "Resume".Translate(), Array.Empty<GUILayoutOption>()))
			{
				recording = !recording;
			}
			if (GUILayout.Button("Stop".Translate(), Array.Empty<GUILayoutOption>()))
			{
				StopRecordSession();
			}
			string text = string.Format("Next: {0:F1}s".Translate(), TimeInterval.Value - timer);
			if (syncUPS)
			{
				text += " (UPS)";
			}
			GUILayout.Label(text, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndHorizontal();
		GUILayout.Label(statusText, Array.Empty<GUILayoutOption>());
	}

	private static void PathSelectionBox()
	{
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		GUILayout.Label("Path".Translate(), Array.Empty<GUILayoutOption>());
		if (CapturingPath != null)
		{
			GUILayout.Label($"[{CapturingPath.Index}]" + CapturingPath.Name, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(expandPathListMode ? "Clear".Translate() : "Select".Translate(), Array.Empty<GUILayoutOption>()))
			{
				expandPathListMode = !expandPathListMode;
				if (!expandPathListMode)
				{
					SetCameraPath(null);
				}
			}
		}
		else
		{
			GUILayout.Label("None".Translate(), Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(expandPathListMode ? "Clear".Translate() : "Select".Translate(), Array.Empty<GUILayoutOption>()))
			{
				expandPathListMode = !expandPathListMode;
			}
		}
		GUILayout.EndHorizontal();
		if (expandPathListMode)
		{
			foreach (CameraPath path in Plugin.PathList)
			{
				GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"[{path.Index}]", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(20f) });
				GUILayout.Label(path.Name, Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("Select".Translate(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(60f) }) && SetCameraPath(path))
				{
					expandPathListMode = false;
				}
				GUILayout.EndHorizontal();
			}
		}
		if (CapturingPath != null)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(CapturingPath.IsPlaying ? "||" : "▶\ufe0e", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth(40f) }))
			{
				CapturingPath.IsPlaying = !CapturingPath.IsPlaying;
			}
			if (GUILayout.Button((Plugin.ViewingPath == CapturingPath) ? "[Viewing]".Translate() : "View".Translate(), Array.Empty<GUILayoutOption>()))
			{
				Plugin.ViewingPath = ((Plugin.ViewingPath == CapturingPath) ? null : CapturingPath);
			}
			if (GUILayout.Button((UIWindow.EditingPath == CapturingPath) ? "[Editing]".Translate() : "Edit".Translate(), Array.Empty<GUILayoutOption>()))
			{
				UIWindow.EditingPath = ((UIWindow.EditingPath == CapturingPath) ? null : CapturingPath);
			}
			GUILayout.EndHorizontal();
		}
		GUILayout.EndVertical();
	}

	private static void ImageCaptureSettingPanel()
	{
		int value = JpgQuality.Value;
		Util.ConfigIntField(JpgQuality);
		Util.ConfigIntField(ScreenshotWidth);
		Util.ConfigIntField(ScreenshotHeight);
		if (value != JpgQuality.Value)
		{
			JpgQuality.Value = ((JpgQuality.Value > 100) ? 100 : JpgQuality.Value);
		}
		string text = Util.AddTextFieldInput("Folder".Translate(), ScreenshotFolderPath.Value);
		if (!string.IsNullOrWhiteSpace(text))
		{
			try
			{
				Directory.CreateDirectory(text);
				if (Directory.Exists(text))
				{
					ScreenshotFolderPath.Value = text;
				}
			}
			catch (Exception ex)
			{
				statusText = ex.ToString();
			}
		}
		UseSubfolder.Value = GUILayout.Toggle(UseSubfolder.Value, "Auto Create Subfolder".Translate(), Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Reset File Index".Translate() + $" [{fileIndex}]", Array.Empty<GUILayoutOption>()))
		{
			fileIndex = 0;
		}
	}

	private static void VideoCaptureSettingPanel()
	{
		Util.ConfigFloatField(VideoOutputFps);
		Util.ConfigIntField(ScreenshotWidth);
		Util.ConfigIntField(ScreenshotHeight);
		string text = Util.AddTextFieldInput("Folder".Translate(), VideoFolderPath.Value);
		if (!string.IsNullOrWhiteSpace(text))
		{
			try
			{
				Directory.CreateDirectory(text);
				if (Directory.Exists(text))
				{
					VideoFolderPath.Value = text;
				}
			}
			catch (Exception ex)
			{
				statusText = ex.ToString();
			}
		}
		Util.ConfigStringField(VideoExtension);
		Util.ConfigStringField(VideoFFmpegOptions);
	}
}
public static class Extensions
{
	private static readonly Dictionary<string[], string[]> translatedTexts = new Dictionary<string[], string[]>();

	private static readonly Dictionary<string, string> strings = new Dictionary<string, string>
	{
		{ "View", "查看" },
		{ "[Viewing]", "[查看中]" },
		{ "Edit", "编辑" },
		{ "[Editing]", "[编辑中]" },
		{ "Load", "加载" },
		{ "Add", "添加" },
		{ "Remove", "移除" },
		{ "edit", "修改" },
		{ "set", "设置" },
		{ "Camera List", "摄像机列表" },
		{ "Add Camera", "添加摄像机" },
		{ "Camera", "摄像机" },
		{ "Path", "路径" },
		{ "Config", "配置" },
		{ "Camera Config", "摄像机配置" },
		{ "Unavailable", "无法查看" },
		{ "Camera type mismatch to current environment!", "摄影机类型与当前环境不一致!" },
		{ "Set to Current View", "设置为当前视角" },
		{ "Adjust Mode", "调整模式" },
		{ "[Adjusting]", "[调整中]" },
		{ "Name", "名称" },
		{ "Camera Type", "摄像机类型" },
		{ "Planet", "星球" },
		{ "Space", "太空" },
		{ "Position", "位置" },
		{ "Local Position", "本地位置" },
		{ "Space Position", "宇宙位置" },
		{ "Cartesian", "直角坐标" },
		{ "Polar", "极坐标" },
		{ "Log", "经度" },
		{ "Lat", "纬度" },
		{ "Alt", "高度" },
		{ "Rotation", "旋转" },
		{ "pitch", "俯仰" },
		{ "yaw", "偏摆" },
		{ "roll", "翻滚" },
		{ "Fov", "视野" },
		{ "Save All", "保存全部" },
		{ "Load All", "加载全部" },
		{ "Path Config", "路径配置" },
		{ "Progress: ", "进度: " },
		{ "Duration(s)", "持续时间(秒)" },
		{ "Interp", "插值" },
		{ "Linear", "线性" },
		{ "Spherical", "球面" },
		{ "Curve", "曲线" },
		{ "Target", "朝向" },
		{ "Loop", "循环" },
		{ "Preview", "预览" },
		{ "Hide GUI", "隐藏UI" },
		{ "Keyframe", "关键帧" },
		{ "Ratio", "比例" },
		{ "Second", "秒" },
		{ "Auto Split", "自动分配时间" },
		{ "Insert Keyframe", "插入关键帧" },
		{ "Append Keyframe", "后加关键帧" },
		{ "Target Config", "目标配置" },
		{ "Type", "类型" },
		{ "None", "无" },
		{ "Local", "本地" },
		{ "Copy Planet Rotation Speed", "复制星球自转速度" },
		{ "Copy Planet Revolution Speed", "复制星球公转速度" },
		{ "Mecha", "机甲" },
		{ "Offset to Mecha", "偏移" },
		{ "Cam Rotation", "镜头旋转" },
		{ "Speed", "速度" },
		{ "Period", "周期" },
		{ "Speed(°/s)", "速度(°/s)" },
		{ "Period(s)", "周期(s)" },
		{ "Marker Size", "标记大小" },
		{ "Set to mecha Position", "设为当前机甲位置" },
		{ "Undo", "撤消" },
		{ "Local Mecha Coordinates Info", "机甲本地座标信息" },
		{ "xyz:\t", "直角坐标:\t" },
		{ "polar:\t", "极坐标:\t" },
		{ "Universal Coordinates Info", "宇宙坐标信息" },
		{ "Mecha:\t", "机甲:\t" },
		{ "Local Planet:", "本地星球:\t" },
		{ "Local Star:  ", "本地恒星:\t" },
		{ "Path List", "路径列表" },
		{ "Add Path", "添加路径" },
		{ "Record This Path", "录制此路径" },
		{ "Timelapse Record", "缩时摄影" },
		{ "Start Record", "开始录制" },
		{ "Pause", "暂停" },
		{ "Resume", "继续" },
		{ "Stop", "停止" },
		{ "Sync Progress", "同步进度" },
		{ "Sync UPS", "同步逻辑帧率" },
		{ "Select", "选取" },
		{ "Clear", "清除" },
		{ "Time Interval(s)", "时间间隔(秒)" },
		{ "Record Type", "录制类型" },
		{ "Image", "图片" },
		{ "Video", "视频" },
		{ "Output Width", "输出宽度" },
		{ "Output Height", "输出高度" },
		{ "Folder", "保存路径" },
		{ "JPG Quality", "JPG质量" },
		{ "Auto Create Subfolder", "自动产生子文件夹" },
		{ "Reset File Index", "重置文件编号" },
		{ "Output FPS", "输出影格率" },
		{ "Video Extension", "输出格式" },
		{ "FFmpeg Options", "FFmpeg选项" },
		{ "Mod Config", "模组配置" },
		{ "Waiting for key..", "等待输入.." },
		{ "Camera List Window", "摄像机列表窗口" },
		{ "Camera Path Window", "摄像机路径窗口" },
		{ "Record Window", "录制窗口" },
		{ "Toggle Last Cam", "切换到上次机位" },
		{ "Cycle To Next Cam", "循环到下一个机位" },
		{ "Play Current Path", "播放当前路径" },
		{ "Move Player With Space Camera", "随太空摄像机移动玩家" },
		{ "Lock Player Position (tmp)", "锁定玩家位置(此项不保存)" },
		{ "Path Preview Size", "镜头路径预览大小" },
		{ "Reset Windows Position", "重置窗口位置" },
		{ "I/O", "输入/输出" },
		{ "Export File", "导出文件" },
		{ "Overwrite ", "覆盖文件 " },
		{ "Current Cam", "当前摄像机" },
		{ "Current Path", "当前路径" },
		{ "All", "全部" },
		{ "Import", "导入" },
		{ "Imported Content", "导入内容" }
	};

	internal static string Translate(this string s)
	{
		if (Localization.isZHCN && strings.TryGetValue(s, out var value))
		{
			return value;
		}
		return s;
	}

	public static string[] TL(string[] optionTexts)
	{
		if (!Localization.isZHCN)
		{
			return optionTexts;
		}
		if (translatedTexts.TryGetValue(optionTexts, out var value))
		{
			return value;
		}
		value = new string[optionTexts.Length];
		for (int i = 0; i < optionTexts.Length; i++)
		{
			value[i] = optionTexts[i].Translate();
		}
		translatedTexts[optionTexts] = value;
		return value;
	}
}
public class FFmpegSession
{
	private readonly Process process;

	private readonly string fileName;

	private int frameIndex;

	private const int ChunkSize = 4096;

	private readonly byte[] buffer = new byte[4096];

	public FFmpegSession(string filePath, int videoWidth, int videoHeight, float fps, string extraOutputArgs = "")
	{
		string fullPath = Path.GetFullPath(filePath);
		fileName = Path.GetFileName(filePath);
		string text = $"-f rawvideo -framerate {fps} -pix_fmt rgb24 -video_size {videoWidth}x{videoHeight} -i -";
		string text2 = $"-r {fps} \"{fullPath}\"";
		Plugin.Log.LogInfo((object)("Start ffmpeg piping\n" + text + "\n" + extraOutputArgs + " " + text2));
		process = new Process
		{
			StartInfo = 
			{
				FileName = "ffmpeg.exe",
				Arguments = text + " " + extraOutputArgs + " " + text2,
				UseShellExecute = false,
				CreateNoWindow = true,
				RedirectStandardInput = true,
				RedirectStandardError = true
			}
		};
		process.EnableRaisingEvents = true;
		process.Start();
		process.ErrorDataReceived += delegate(object o, DataReceivedEventArgs e)
		{
			if (!string.IsNullOrEmpty(e.Data))
			{
				Plugin.Log.LogDebug((object)("[ffmpeg] " + e.Data));
			}
		};
		process.BeginErrorReadLine();
	}

	public void Stop()
	{
		try
		{
			Plugin.Log.LogInfo((object)"Stop ffmpeg piping");
			process.StandardInput.BaseStream.Flush();
			process.StandardInput.Close();
			process.WaitForExit(0);
			process.Close();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
		}
	}

	public bool SendToPipe(Texture2D texture2D, ref string status)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		try
		{
			HighStopwatch val = new HighStopwatch();
			val.Begin();
			if (process == null)
			{
				return false;
			}
			byte[] rawTextureData = texture2D.GetRawTextureData();
			process.StandardInput.BaseStream.Write(rawTextureData, 0, rawTextureData.Length);
			status = $"{fileName} [{++frameIndex}] {val.duration * 1000.0}ms";
			return true;
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)ex);
			status = "ffmpeg pipe fail! " + ex.Message;
			return false;
		}
	}

	public unsafe void WriteNativeArray(NativeArray<byte> nativeArray, Stream stream)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		byte* unsafePtr = (byte*)NativeArrayUnsafeUtility.GetUnsafePtr<byte>(nativeArray);
		int length = nativeArray.Length;
		int num;
		for (int i = 0; i < length; i += num)
		{
			num = Math.Min(4096, length - i);
			fixed (byte* ptr = buffer)
			{
				UnsafeUtility.MemCpy((void*)ptr, (void*)(unsafePtr + i), (long)num);
			}
			stream.Write(buffer, 0, num);
		}
	}
}
public class FreePointPoser
{
	private readonly float rotateSens = 1f;

	private readonly float moveSens = 1f;

	private readonly float damp = 0.2f;

	private float pitchWanted;

	private float yawWanted;

	private float rollWanted;

	private float xWanted;

	private float yWanted;

	private float zWanted;

	private bool enabled;

	public bool Enabled
	{
		get
		{
			return enabled;
		}
		set
		{
			enabled = value;
			yawWanted = (pitchWanted = (rollWanted = 0f));
			xWanted = (yWanted = (zWanted = 0f));
		}
	}

	public void Calculate(ref CameraPose cameraPose)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0398: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		if (!VFInput.inFullscreenGUI)
		{
			if (VFInput._cameraRTSRotateButton.pressing)
			{
				yawWanted += VFInput.mouseMoveAxis.x * 5f * rotateSens * GameCamera.camRotSensX;
				pitchWanted += VFInput.mouseMoveAxis.y * 5f * rotateSens * GameCamera.camRotSensY;
			}
			if (VFInput._cameraRTSRollButton.pressing)
			{
				rollWanted += VFInput.mouseMoveAxis.x * 5f * rotateSens * GameCamera.camRotSensX;
				rollWanted -= VFInput.mouseMoveAxis.y * 5f * rotateSens * GameCamera.camRotSensY;
			}
			yawWanted += VFInput.camJoystickAxis.x * 2f * rotateSens;
			pitchWanted += VFInput.camJoystickAxis.y * 0.5f * rotateSens;
			yawWanted = Mathf.Clamp(yawWanted, -89.9f, 89.9f);
			pitchWanted = Mathf.Clamp(pitchWanted, -89.9f, 89.9f);
			float num = Mathf.LerpAngle(0f, yawWanted, damp);
			float num2 = Mathf.LerpAngle(0f, pitchWanted, damp);
			float num3 = Mathf.LerpAngle(0f, rollWanted, damp);
			yawWanted -= num;
			pitchWanted -= num2;
			rollWanted -= num3;
			float num4 = (VFInput.shift ? 10f : 1f);
			xWanted += VFInput._moveRight.value * 0.3f * moveSens * GameCamera.camRotSensX * num4;
			xWanted += VFInput._moveLeft.value * -0.3f * moveSens * GameCamera.camRotSensX * num4;
			yWanted += VFInput._moveForward.value * 0.3f * moveSens * GameCamera.camRotSensY * num4;
			yWanted += VFInput._moveBackward.value * -0.3f * moveSens * GameCamera.camRotSensY * num4;
			zWanted += (VFInput._cameraZoomIn + VFInput._cameraZoomOut) * GameCamera.camZoomSens * 100f * moveSens * num4;
			float num5 = Lerp.Tween(0f, xWanted, damp * 100f);
			float num6 = Lerp.Tween(0f, yWanted, damp * 100f);
			float num7 = Lerp.Tween(0f, zWanted, damp * 100f);
			xWanted -= num5;
			yWanted -= num6;
			zWanted -= num7;
			((CameraPose)(ref cameraPose)).rotation = ((CameraPose)(ref cameraPose)).rotation * Quaternion.Euler(num2, num, num3);
			((CameraPose)(ref cameraPose)).position = ((CameraPose)(ref cameraPose)).position + ((CameraPose)(ref cameraPose)).rotation * Vector3.right * num5;
			((CameraPose)(ref cameraPose)).position = ((CameraPose)(ref cameraPose)).position + ((CameraPose)(ref cameraPose)).rotation * Vector3.up * num6;
			((CameraPose)(ref cameraPose)).position = ((CameraPose)(ref cameraPose)).position + ((CameraPose)(ref cameraPose)).rotation * Vector3.forward * num7;
		}
	}
}
public static class GizmoManager
{
	public static float TargetMarkerSize = 3f;

	public static float PathMarkerSize = 5f;

	public static float PathCameraCubeSize = 2f;

	public const int LinePointCount = 180;

	private static GameObject targetMarkerGo;

	private static LineGizmo cameraPathLine;

	private static LineGizmo lookAtLine;

	private static readonly VectorLF3[] lineUPoints = (VectorLF3[])(object)new VectorLF3[180];

	private static readonly List<VectorLF3> cameraUPointList = new List<VectorLF3>();

	private static GameObject cameraObjGroup;

	private static readonly List<GameObject> cameraObjs = new List<GameObject>();

	private static readonly List<GameObject> cameraDirObjs = new List<GameObject>();

	private static float lastUpdateTime;

	private static bool hasErrored;

	public static void OnAwake()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		targetMarkerGo = GameObject.CreatePrimitive((PrimitiveType)0);
		Object.Destroy((Object)(object)targetMarkerGo.GetComponent<SphereCollider>());
		((Renderer)targetMarkerGo.GetComponent<MeshRenderer>()).material = null;
		targetMarkerGo.SetActive(false);
		cameraObjGroup = new GameObject();
	}

	public static void OnDestroy()
	{
		Object.Destroy((Object)(object)targetMarkerGo);
		Object.Destroy((Object)(object)cameraObjGroup);
		LineGizmo obj = cameraPathLine;
		if (obj != null)
		{
			((GizmoBase)obj).Close();
		}
		LineGizmo obj2 = lookAtLine;
		if (obj2 != null)
		{
			((GizmoBase)obj2).Close();
		}
	}

	public static void OnPathChange()
	{
		lastUpdateTime = 0f;
	}

	public static void OnUpdate()
	{
		if (GameMain.mainPlayer == null)
		{
			return;
		}
		try
		{
			if (Time.time - lastUpdateTime > 0.5f)
			{
				lastUpdateTime = Time.time;
				RefreshPathPreview();
			}
			UpdateTargetMarker();
			UpdatePathMarker();
		}
		catch (Exception ex)
		{
			if (!hasErrored)
			{
				Plugin.Log.LogError((object)ex);
			}
			hasErrored = true;
		}
	}

	private static void RefreshPathPreview()
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		CameraPath editingPath = UIWindow.EditingPath;
		if (editingPath != null && editingPath.Preview && PathMarkerSize > 0f)
		{
			if ((Object)(object)cameraPathLine == (Object)null || cameraPathLine.points == null)
			{
				cameraPathLine = LineGizmo.Create(1, (Vector3[])(object)new Vector3[180], 0);
				cameraPathLine.spherical = false;
				cameraPathLine.autoRefresh = false;
				cameraPathLine.width = PathMarkerSize;
				cameraPathLine.color = Color.green;
				((GizmoBase)cameraPathLine).Open();
			}
			if ((Object)(object)cameraPathLine != (Object)null)
			{
				cameraPathLine.validPointCount = UIWindow.EditingPath.SetPathPoints(cameraPathLine.points, lineUPoints);
				cameraPathLine.width = PathMarkerSize;
				cameraPathLine.RefreshGeometry();
			}
			int cameraCount = UIWindow.EditingPath.GetCameraCount();
			for (int i = cameraObjs.Count; i < cameraCount; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
				((Renderer)val.GetComponent<MeshRenderer>()).material = null;
				val.transform.parent = cameraObjGroup.transform;
				val.transform.localScale = Vector3.one * PathCameraCubeSize;
				cameraObjs.Add(val);
				GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Renderer)val2.GetComponent<MeshRenderer>()).material = null;
				val2.transform.parent = cameraObjGroup.transform;
				val2.transform.localScale = new Vector3(0.5f, 0.5f, PathCameraCubeSize * 3f);
				cameraDirObjs.Add(val2);
			}
			cameraCount = UIWindow.EditingPath.SetCameraPoints(cameraObjs, cameraUPointList);
			for (int j = 0; j < cameraCount; j++)
			{
				cameraObjs[j].SetActive(true);
				cameraDirObjs[j].transform.localPosition = cameraObjs[j].transform.localPosition + cameraObjs[j].transform.rotation * Vector3.forward * PathCameraCubeSize;
				cameraDirObjs[j].transform.rotation = cameraObjs[j].transform.rotation;
				cameraDirObjs[j].SetActive(true);
			}
			for (int k = cameraCount; k < cameraObjs.Count; k++)
			{
				cameraObjs[k].SetActive(false);
				cameraDirObjs[k].SetActive(false);
			}
		}
	}

	private static void UpdateTargetMarker()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		if (UIWindow.EditingTarget == null || TargetMarkerSize <= 0f)
		{
			targetMarkerGo.SetActive(false);
			return;
		}
		LookTarget editingTarget = UIWindow.EditingTarget;
		switch (editingTarget.Type)
		{
		case LookTarget.TargetType.Mecha:
			targetMarkerGo.transform.position = GameMain.mainPlayer.position + VectorLF3.op_Implicit(editingTarget.Position);
			break;
		case LookTarget.TargetType.Local:
			targetMarkerGo.transform.position = VectorLF3.op_Implicit(editingTarget.Position);
			break;
		case LookTarget.TargetType.Space:
			targetMarkerGo.transform.position = VectorLF3.op_Implicit(editingTarget.Position - GameMain.mainPlayer.uPosition);
			break;
		default:
			targetMarkerGo.SetActive(false);
			return;
		}
		targetMarkerGo.transform.localScale = Vector3.one * TargetMarkerSize;
		targetMarkerGo.SetActive(true);
	}

	private static void UpdatePathMarker()
	{
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		if (UIWindow.EditingPath == null || PathMarkerSize <= 0f || !UIWindow.EditingPath.Preview)
		{
			cameraObjGroup.SetActive(false);
			LineGizmo obj = cameraPathLine;
			if (obj != null)
			{
				((GizmoBase)obj).Close();
			}
			cameraPathLine = null;
			LineGizmo obj2 = lookAtLine;
			if (obj2 != null)
			{
				((GizmoBase)obj2).Close();
			}
			lookAtLine = null;
			return;
		}
		cameraObjGroup.SetActive(true);
		if (GameMain.localPlanet == null && GameMain.mainPlayer != null)
		{
			if ((Object)(object)cameraPathLine != (Object)null)
			{
				for (int i = 0; i < 180; i++)
				{
					cameraPathLine.points[i] = VectorLF3.op_Implicit(lineUPoints[i] - GameMain.mainPlayer.uPosition);
				}
				cameraPathLine.RefreshGeometry();
			}
			for (int j = 0; j < cameraUPointList.Count; j++)
			{
				cameraObjs[j].transform.position = VectorLF3.op_Implicit(cameraUPointList[j] - GameMain.mainPlayer.uPosition);
				cameraDirObjs[j].transform.position = VectorLF3.op_Implicit(cameraUPointList[j] - GameMain.mainPlayer.uPosition);
			}
		}
		if ((Object)(object)lookAtLine == (Object)null)
		{
			lookAtLine = LineGizmo.Create(2, Vector3.zero, Vector3.zero);
			lookAtLine.spherical = false;
			lookAtLine.autoRefresh = false;
			lookAtLine.width = 0f;
			lookAtLine.color = Color.white;
			lookAtLine.tiling = false;
			((GizmoBase)lookAtLine).Open();
		}
		if ((Object)(object)lookAtLine != (Object)null && UIWindow.EditingPath.SetLookAtLineRealtime(out var lPoint, out var lookDir))
		{
			lookAtLine.width = PathMarkerSize;
			lookAtLine.startPoint = lPoint;
			lookAtLine.endPoint = lPoint + lookDir * 15f;
			lookAtLine.RefreshGeometry();
		}
	}
}
public class LookTarget
{
	public enum TargetType
	{
		None,
		Mecha,
		Local,
		Space
	}

	public TargetType Type;

	public VectorLF3 Position;

	public float RotationSpeed;

	private static readonly string[] targetTypeTexts = new string[4] { "None", "Mecha", "Local", "Space" };

	private static readonly VectorLF3[] uiPositions = (VectorLF3[])(object)new VectorLF3[4];

	private static int positionType;

	private static readonly string[] positionTypeTexts = new string[2] { "Cartesian", "Polar" };

	private static int rotationType;

	private static readonly string[] rotationTypeTexts = new string[2] { "Speed", "Period" };

	private static Vector2 scrollpos;

	private static VectorLF3 lastPosition;

	public void Import(string sectionName, ConfigFile configFile = null)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		Type = (TargetType)configFile.Bind<int>(sectionName, "TargetType", 0, (ConfigDescription)null).Value;
		Position = configFile.Bind<VectorLF3>(sectionName, "TargetPosition", VectorLF3.zero, (ConfigDescription)null).Value;
		RotationSpeed = configFile.Bind<float>(sectionName, "TargetRotationSpeed", 0f, (ConfigDescription)null).Value;
	}

	public void Export(string sectionName, ConfigFile configFile = null)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (configFile == null)
		{
			configFile = Plugin.ConfigFile;
		}
		configFile.Bind<int>(sectionName, "TargetType", 0, (ConfigDescription)null).Value = (int)Type;
		configFile.Bind<VectorLF3>(sectionName, "TargetPosition", VectorLF3.zero, (ConfigDescription)null).Value = Position;
		configFile.Bind<float>(sectionName, "TargetRotationSpeed", 0f, (ConfigDescription)null).Value = RotationSpeed;
	}

	public static void OpenAndSetWindow(LookTarget target)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		UIWindow.EditingTarget = target;
		uiPositions[(int)target.Type] = target.Position;
	}

	public void SetFinalPose(ref CameraPose cameraPose, ref VectorLF3 camUpos, float totalTime)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		float num = totalTime * RotationSpeed;
		Vector3 val = ((CameraPose)(ref cameraPose)).position;
		Vector3 val3;
		switch (Type)
		{
		case TargetType.Mecha:
		{
			val3 = GameMain.mainPlayer.position + VectorLF3.op_Implicit(Position);
			Vector3 val4 = val - val3;
			if (RotationSpeed != 0f)
			{
				Vector3 up = ((Vector3)(ref val3)).normalized;
				val4 = Quaternion.AngleAxis(num, up) * val4;
				val = (((CameraPose)(ref cameraPose)).position = val3 + val4);
			}
			((CameraPose)(ref cameraPose)).rotation = Quaternion.LookRotation(-val4, val);
			break;
		}
		case TargetType.Local:
		{
			val3 = (Vector3)((Position == VectorLF3.zero) ? new Vector3(0f, 1f, 0f) : VectorLF3.op_Implicit(Position));
			Vector3 val4 = val - val3;
			if (RotationSpeed != 0f)
			{
				Vector3 up = ((Vector3)(ref val3)).normalized;
				val4 = Quaternion.AngleAxis(num, up) * val4;
				val = (((CameraPose)(ref cameraPose)).position = val3 + val4);
			}
			((CameraPose)(ref cameraPose)).rotation = Quaternion.LookRotation(-val4, val);
			break;
		}
		case TargetType.Space:
			if (camUpos == VectorLF3.zero && GameMain.localPlanet != null)
			{
				camUpos = VectorLF3.op_Implicit(Maths.QInvRotate(GameMain.localPlanet.runtimeRotation, VectorLF3.op_Implicit(GameMain.localPlanet.uPosition + VectorLF3.op_Implicit(val))));
			}
			if (RotationSpeed != 0f)
			{
				VectorLF3 val2 = camUpos - Position;
				Vector3 up = Vector3.up;
				val2 = VectorLF3.op_Implicit(Quaternion.AngleAxis(num, up) * VectorLF3.op_Implicit(val2));
				camUpos = Position + val2;
			}
			((CameraPose)(ref cameraPose)).rotation = Quaternion.LookRotation(VectorLF3.op_Implicit(Position - camUpos), Vector3.up);
			break;
		}
	}

	public void ConfigWindowFunc()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result t