Decompiled source of CinematographyPlugin v1.3.0

plugins/Cookie_K-CinematographyPlugin/CinematographyPlugin.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ChainedPuzzles;
using CinematographyPlugin.Cinematography;
using CinematographyPlugin.Cinematography.Networking;
using CinematographyPlugin.Cinematography.Settings;
using CinematographyPlugin.UI;
using CinematographyPlugin.UI.Enums;
using CinematographyPlugin.UI.UiInput;
using CinematographyPlugin.Util;
using Enemies;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CinematographyPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CinematographyPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3CC93051-593F-4E3A-B19D-404CBEDD1312")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace CinematographyPlugin
{
	[HarmonyPatch]
	public class CinemaPluginPatches
	{
		private static readonly List<int> PrevRequiredTeamScanIDs = new List<int>();

		public static event Action<bool> OnLocalPlayerDieOrRevive;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InputMapper), "DoGetButton")]
		[HarmonyPatch(typeof(InputMapper), "DoGetButtonUp")]
		[HarmonyPatch(typeof(InputMapper), "DoGetButtonDown")]
		private static bool Prefix_DoGetButton(ref bool __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Cursor.lockState > 0)
			{
				return true;
			}
			__result = false;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(InputMapper), "DoGetAxis")]
		private static bool Prefix_DoGetAxis(ref float __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Cursor.lockState > 0)
			{
				return true;
			}
			__result = 0f;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Prefix_SetLockState(ref CursorLockMode value)
		{
			if (Entry.Init && CinemaUIManager.Current.MenuOpen)
			{
				if (value)
				{
					CinemaUIManager.Current.CursorLockLastMode = value;
				}
				value = (CursorLockMode)0;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Prefix_setVisible(ref bool value)
		{
			if (Entry.Init && CinemaUIManager.Current.MenuOpen)
			{
				CinemaUIManager.Current.CursorLastVisible = value;
				value = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Prefix_PlayerAlive(bool value, PlayerAgent __instance)
		{
			if ((Object)(object)__instance != (Object)null && ((Agent)__instance).IsLocallyOwned)
			{
				CinemaPluginPatches.OnLocalPlayerDieOrRevive?.Invoke(value);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Prefix_SetTargetDivertAwayFromCameraMan(ref AgentTarget value)
		{
			if (value == null || PlayerManager.PlayerAgentsInLevel.Count == 1 || CinemaNetworkingManager.GetPlayersInFreeCam().Count() == PlayerManager.PlayerAgentsInLevel.Count)
			{
				return;
			}
			PlayerAgent playerAgent = default(PlayerAgent);
			ref PlayerAgent reference = ref playerAgent;
			Agent agent = value.m_agent;
			reference = (PlayerAgent)(object)((agent is PlayerAgent) ? agent : null);
			if (!((Object)(object)playerAgent == (Object)null) && CinemaNetworkingManager.GetPlayersInFreeCam().Any((PlayerAgent p) => p.Sync.PlayerNick == playerAgent.Sync.PlayerNick))
			{
				value.m_agent = (Agent)(object)CinemaNetworkingManager.GetPlayersNotInFreeCam().Aggregate((PlayerAgent currMin, PlayerAgent pa) => (((Agent)pa).GetAttackersScore() < ((Agent)currMin).GetAttackersScore()) ? pa : currMin);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyDetection), "IsTargetValid", new Type[] { typeof(AgentTarget) })]
		private static void Prefix_SetTargetDivertAwayFromCameraMan(AgentTarget agentTarget, ref EnemyDetection __instance, ref bool __result)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			AgentTarget agentTarget2 = agentTarget;
			if ((int)agentTarget2.m_agent.m_type == 0)
			{
				__result = CinemaNetworkingManager.GetPlayersInFreeCam().All((PlayerAgent p) => ((Object)p).GetInstanceID() != ((Object)agentTarget2.m_agent).GetInstanceID());
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyCourseNavigation), "SetTarget", new Type[] { typeof(AgentTarget) })]
		private static bool Prefix_SetTargetDivertAwayFromCameraMan(AgentTarget target)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			AgentTarget target2 = target;
			if ((int)target2.m_agent.m_type == 0)
			{
				return CinemaNetworkingManager.GetPlayersInFreeCam().All((PlayerAgent p) => ((Object)p).GetInstanceID() != ((Object)target2.m_agent).GetInstanceID());
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerSync), "WantsToWieldSlot", new Type[]
		{
			typeof(InventorySlot),
			typeof(bool)
		})]
		private static bool Prefix_DisableWeaponChange(InventorySlot slot, bool broadcastOnly, PlayerSync __instance)
		{
			return !Entry.Init || !CinemaCamManager.Current.FreeCamEnabled() || !((Agent)__instance.m_agent).IsLocallyOwned;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CP_Bioscan_Core), "Update")]
		private static void Prefix_ReduceTeamScanSizeIfPlayerInFreeCam(CP_Bioscan_Core __instance)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//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_0049: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)__instance).isActiveAndEnabled && __instance.m_currentPlayerCount != 0)
			{
				if ((int)__instance.m_playerScanner.ScanPlayersRequired == 1 && CinemaNetworkingManager.GetPlayersInFreeCam().Any() && (int)__instance.m_sync.GetCurrentState().status == 3 && __instance.m_sync.GetCurrentState().playersInScan >= CinemaNetworkingManager.GetPlayersNotInFreeCam().Count())
				{
					CinematographyCore.log.LogInfo((object)"Adjusting team scan to account for free cam players");
					((Component)__instance).GetComponent<CP_PlayerScanner>().m_playerRequirement = (PlayerRequirement)0;
					PrevRequiredTeamScanIDs.Add(((Object)__instance).GetInstanceID());
				}
				else if (PrevRequiredTeamScanIDs.Contains(((Object)__instance).GetInstanceID()) && __instance.m_currentPlayerCount < CinemaNetworkingManager.GetPlayersNotInFreeCam().Count())
				{
					CinematographyCore.log.LogInfo((object)"Reverting team scan to require all players");
					((Component)__instance).GetComponent<CP_PlayerScanner>().m_playerRequirement = (PlayerRequirement)1;
					PrevRequiredTeamScanIDs.Remove(((Object)__instance).GetInstanceID());
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PostProcessingAdapter), "SetDOF", new Type[]
		{
			typeof(float),
			typeof(float),
			typeof(float)
		})]
		private static bool Prefix_OverrideDoF(ref float focusDistance, ref float aperture, ref float focalLength)
		{
			return !PostProcessingController.IsDoFSet();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerDialogManager), "WantToStartDialog", new Type[]
		{
			typeof(uint),
			typeof(PlayerAgent)
		})]
		private static bool Postfix_IgnorePlayerDialog(uint dialogID, PlayerAgent source)
		{
			return !CinemaCamManager.Current.FreeCamEnabled() || !((Agent)source).IsLocallyOwned;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayerDialogManager), "WantToStartDialog", new Type[]
		{
			typeof(uint),
			typeof(int),
			typeof(bool),
			typeof(bool)
		})]
		private static bool Postfix_IgnorePlayerDialog(uint dialogID, int playerID, bool overrideFilters, bool forced)
		{
			return !CinemaCamManager.Current.FreeCamEnabled();
		}
	}
	[BepInPlugin("com.Cookie_K.Cinematography", "Cinematography", "1.3.0")]
	[BepInProcess("GTFO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CinematographyCore : BasePlugin
	{
		public const string NAME = "Cinematography Plugin";

		public const string MODNAME = "Cinematography";

		public const string AUTHOR = "Cookie_K";

		public const string GUID = "com.Cookie_K.Cinematography";

		public const string VERSION = "1.3.0";

		public static ManualLogSource log;

		private Harmony HarmonyPatches { get; set; }

		public override void Load()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			log = ((BasePlugin)this).Log;
			ClassInjector.RegisterTypeInIl2Cpp<UIWindow>();
			ClassInjector.RegisterTypeInIl2Cpp<CinemaUIManager>();
			ClassInjector.RegisterTypeInIl2Cpp<CinemaCamManager>();
			ClassInjector.RegisterTypeInIl2Cpp<CinemaCamController>();
			ClassInjector.RegisterTypeInIl2Cpp<TimeScaleController>();
			ClassInjector.RegisterTypeInIl2Cpp<ScreenClutterController>();
			ClassInjector.RegisterTypeInIl2Cpp<LookSmoothingController>();
			ClassInjector.RegisterTypeInIl2Cpp<CinemaNetworkingManager>();
			ClassInjector.RegisterTypeInIl2Cpp<PostProcessingController>();
			ClassInjector.RegisterTypeInIl2Cpp<IndependentDeltaTimeManager>();
			ClassInjector.RegisterTypeInIl2Cpp<LightManager>();
			ClassInjector.RegisterTypeInIl2Cpp<AspectRatioManager>();
			ClassInjector.RegisterTypeInIl2Cpp<DimensionManager>();
			HarmonyPatches = new Harmony("com.Cookie_K.Cinematography");
			HarmonyPatches.PatchAll();
		}
	}
	public static class ConfigManager
	{
		private static readonly ConfigFile ConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "CinematographyPlugin.cfg"), true);

		private static readonly ConfigEntry<KeyCode> MenuOpenClose = ConfigFile.Bind<KeyCode>("Key Binds", "Menu Open Close", (KeyCode)285, "The key to open / close the plugin menu");

		private static readonly ConfigEntry<KeyCode> FreeCamToggle = ConfigFile.Bind<KeyCode>("Key Binds", "Free Cam Toggle", (KeyCode)286, "The key to enable / disable free cam");

		private static readonly ConfigEntry<bool> UseAlpha = ConfigFile.Bind<bool>("Key Binds", "Use Alphanumeric keys for Time Controls", false, "The time scale percentages are bound to the numpad keys by default, change this to false to use the alpha numeric keys in stead (must be in free cam as to not conflict with weapon changes in first person)");

		private static readonly ConfigEntry<KeyCode> GoUp = ConfigFile.Bind<KeyCode>("Key Binds", "Go Up", (KeyCode)32, "Key to go straight up");

		private static readonly ConfigEntry<KeyCode> GoDown = ConfigFile.Bind<KeyCode>("Key Binds", "Go Down", (KeyCode)306, "Key to go straight down");

		private static readonly ConfigEntry<KeyCode> SpeedUp = ConfigFile.Bind<KeyCode>("Key Binds", "Speed Up", (KeyCode)304, "Key to speed up movement speed (x2)");

		private static readonly ConfigEntry<KeyCode> SlowDown = ConfigFile.Bind<KeyCode>("Key Binds", "Slow Down", (KeyCode)308, "Key to slow down movement speed (x1/2)");

		private static readonly ConfigEntry<KeyCode> TimeInc = ConfigFile.Bind<KeyCode>("Key Binds", "Time Increment", (KeyCode)101, "Speedup time");

		private static readonly ConfigEntry<KeyCode> TimeDec = ConfigFile.Bind<KeyCode>("Key Binds", "Time Decrement", (KeyCode)113, "Slowdown time");

		private static readonly ConfigEntry<KeyCode> TimePausePlay = ConfigFile.Bind<KeyCode>("Key Binds", "Time Pause/Play", (KeyCode)114, "Pause/play time");

		private static readonly ConfigEntry<KeyCode> OrbitEnterExit = ConfigFile.Bind<KeyCode>("Key Binds", "Orbit cam enter/exit", (KeyCode)99, "Enter/exit orbit cam");

		private static readonly ConfigEntry<KeyCode> WarpPlayer = ConfigFile.Bind<KeyCode>("Key Binds", "Warp Player", (KeyCode)116, "Warp the player to where the camera is");

		private static readonly ConfigEntry<KeyCode> DimensionWarp = ConfigFile.Bind<KeyCode>("Key Binds", "Warp to Dimension", (KeyCode)121, "Warp the everyone to a different dimension");

		public static KeyCode MenuKey => MenuOpenClose.Value;

		public static KeyCode FreeCamToggleKey => FreeCamToggle.Value;

		public static KeyCode UpKey => GoUp.Value;

		public static KeyCode DownKey => GoDown.Value;

		public static KeyCode SpeedUpKey => SpeedUp.Value;

		public static KeyCode SlowDownKey => SlowDown.Value;

		public static KeyCode TimeIncKey => TimeInc.Value;

		public static KeyCode TimeDecKey => TimeDec.Value;

		public static KeyCode TimePausePlayKey => TimePausePlay.Value;

		public static KeyCode OrbitEnterExitKey => OrbitEnterExit.Value;

		public static KeyCode WarpPlayerKey => WarpPlayer.Value;

		public static KeyCode DimensionWarpKey => DimensionWarp.Value;
	}
	[HarmonyPatch]
	public class Entry
	{
		private static GameObject _go;

		public static bool Init { get; private set; }

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameStateManager), "ChangeState", new Type[] { typeof(eGameStateName) })]
		private static void Postfix_InitOrDestroyCinematographyPlugin(eGameStateName nextState)
		{
			//IL_0023: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected I4, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			CinematographyCore.log.LogMessage((object)("Next state " + ((object)(eGameStateName)(ref nextState)).ToString()));
			eGameStateName val = nextState;
			eGameStateName val2 = val;
			switch (val2 - 10)
			{
			case 0:
			{
				CinematographyCore.log.LogMessage((object)"Initializing Cinematography Plugin");
				GameObject val3 = new GameObject("Cookie_K - Cinematography Plugin");
				val3.AddComponent<CinemaUIManager>();
				val3.AddComponent<TimeScaleController>();
				val3.AddComponent<CinemaCamManager>();
				val3.AddComponent<ScreenClutterController>();
				val3.AddComponent<LookSmoothingController>();
				val3.AddComponent<PostProcessingController>();
				val3.AddComponent<IndependentDeltaTimeManager>();
				val3.AddComponent<LightManager>();
				val3.AddComponent<AspectRatioManager>();
				val3.AddComponent<DimensionManager>();
				val3.AddComponent<CinemaNetworkingManager>().RegisterEvents();
				Object.DontDestroyOnLoad((Object)(object)val3);
				_go = val3;
				Init = true;
				break;
			}
			case 1:
			case 4:
			case 5:
			case 6:
				if ((Object)(object)_go != (Object)null)
				{
					CinematographyCore.log.LogMessage((object)"Closing Cinematography Plugin");
					if (CinemaUIManager.Current.MenuOpen)
					{
						CinemaUIManager.Current.CloseUI();
					}
					TimeScaleController.ResetTimeScale();
					ScreenClutterController.GetInstance().HideUI();
					Object.Destroy((Object)(object)_go);
					Init = false;
				}
				break;
			case 2:
			case 3:
				break;
			}
		}
	}
}
namespace CinematographyPlugin.Util
{
	public class IndependentDeltaTimeManager : MonoBehaviour
	{
		private static float _independentDeltaTime;

		private static float _lastInterval;

		private void Update()
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			_independentDeltaTime = realtimeSinceStartup - _lastInterval;
			_lastInterval = realtimeSinceStartup;
		}

		public static float GetDeltaTime()
		{
			return _independentDeltaTime;
		}
	}
}
namespace CinematographyPlugin.UI
{
	public class CinemaUIManager : MonoBehaviour
	{
		public static CinemaUIManager Current;

		private readonly KeyCode UIOpenKey = ConfigManager.MenuKey;

		private const string PrefabPath = "Assets/UI/CinemaUI.prefab";

		internal Dictionary<UIOption, ToggleOption> Toggles;

		internal Dictionary<UIOption, SliderOption> Sliders;

		private bool _init;

		private bool _hideTargetingText;

		private TMP_Text _centerText;

		private GameObject _centerTextWindow;

		private GameObject _window;

		private GameObject _cinematicBars;

		private GameObject _cinemaUIgo;

		private CanvasGroup _canvasGroup;

		private LocalPlayerAgent _playerAgent;

		internal Dictionary<UIOption, Option> Options { get; set; }

		internal CursorLockMode CursorLockLastMode { get; set; }

		internal bool CursorLastVisible { get; set; }

		internal bool MenuOpen { get; set; }

		public static event Action OnUIStart;

		public void Awake()
		{
			Current = this;
			Object loadedAsset = AssetAPI.GetLoadedAsset("Assets/UI/CinemaUI.prefab");
			Object val = Object.Instantiate(loadedAsset);
			_cinemaUIgo = ((Il2CppObjectBase)val).TryCast<GameObject>();
			if (_cinemaUIgo == null)
			{
				CinematographyCore.log.LogWarning((object)"Cinematography plugin could not load UI prefab. Asset either not loaded or not in Bepinex/Config/Assets/AssetBundles folder");
				return;
			}
			Transform child = _cinemaUIgo.transform.GetChild(0);
			_canvasGroup = ((Component)child).GetComponent<CanvasGroup>();
			_cinematicBars = ((Component)child.GetChild(0)).gameObject;
			_window = ((Component)child.GetChild(1)).gameObject;
			_centerTextWindow = ((Component)child.GetChild(2)).gameObject;
			_centerText = _centerTextWindow.GetComponentInChildren<TMP_Text>();
			_window.gameObject.AddComponent<UIWindow>();
			Button componentInChildren = _cinemaUIgo.GetComponentInChildren<Button>();
			((UnityEvent)componentInChildren.onClick).AddListener(UnityAction.op_Implicit((Action)OnCloseButton));
			Options = UIFactory.BuildOptions(_cinemaUIgo);
			Toggles = UIFactory.GetToggles(Options);
			Sliders = UIFactory.GetSliders(Options);
			_window.active = true;
			_centerTextWindow.active = false;
			_cinematicBars.active = false;
			_cinemaUIgo.active = true;
			CloseUI();
			_init = true;
		}

		public void Start()
		{
			CinemaNetworkingManager.OnTimeScaleEnableOrDisable += OnTimeScaleEnableOrDisable;
			CinemaPluginPatches.OnLocalPlayerDieOrRevive += OnFreeCamEnableOrDisable;
			Toggles[UIOption.ToggleFreeCamera].OnValueChanged += OnFreeCamSetActive;
			Toggles[UIOption.ToggleTargetingVisibility].OnValueChanged += SetHideTextOnScreen;
			_playerAgent = Object.FindObjectOfType<LocalPlayerAgent>();
			CinemaUIManager.OnUIStart?.Invoke();
		}

		public void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			UpdateInputEnableDisable();
			if (_init && Input.GetKeyDown(UIOpenKey))
			{
				if (MenuOpen)
				{
					CloseUI();
				}
				else
				{
					OpenUI();
				}
			}
		}

		private void UpdateInputEnableDisable()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			KeyBindInputManager.SetInputsEnabled((int)Cursor.lockState == 0);
		}

		public void OnCloseButton()
		{
			CloseUI();
		}

		public GameObject GetCinematicBars()
		{
			return _cinematicBars;
		}

		public void ShowTextOnScreen(string text)
		{
			if (!_hideTargetingText)
			{
				_centerText.SetText("[" + text + "]", true);
				_centerTextWindow.gameObject.active = true;
			}
		}

		public void ShowNoTargetTextOnScreen()
		{
			if (!_hideTargetingText)
			{
				_centerText.SetText("[NO TARGET]", true);
				_centerTextWindow.gameObject.active = true;
			}
		}

		public void HideTextOnScreen()
		{
			_centerTextWindow.gameObject.active = false;
		}

		private void SetHideTextOnScreen(bool value)
		{
			_hideTargetingText = value;
		}

		private void OnFreeCamEnableOrDisable(bool enable)
		{
			ToggleOption toggleOption = Toggles[UIOption.ToggleFreeCamera];
			if (enable)
			{
				toggleOption.Enable(toggleOption.Toggle.isOn);
			}
			else
			{
				toggleOption.Disable(state: false);
			}
		}

		private void OnFreeCamSetActive(bool active)
		{
			if (active)
			{
				((PlayerAgent)_playerAgent).Sync.WantsToWieldSlot((InventorySlot)10, false);
			}
		}

		private void OnTimeScaleEnableOrDisable(bool enable)
		{
			ToggleOption toggleOption = Toggles[UIOption.ToggleTimeScale];
			if (enable)
			{
				toggleOption.Enable(toggleOption.Toggle.isOn);
			}
			else
			{
				toggleOption.Disable(state: false);
			}
		}

		public void OpenUI()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (CinemaNetworkingManager.AssertAllPlayersHasPlugin())
			{
				CursorLockLastMode = Cursor.lockState;
				CursorLastVisible = Cursor.visible;
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ExpandUI()));
				_canvasGroup.interactable = true;
				MenuOpen = true;
			}
		}

		public void CloseUI()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Cursor.lockState = CursorLockLastMode;
			Cursor.visible = CursorLastVisible;
			((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ShrinkUI()));
			_canvasGroup.interactable = false;
			MenuOpen = false;
		}

		private IEnumerator ShrinkUI()
		{
			Vector3 finalScale = new Vector3(0f, 1f, 1f);
			while (_window.transform.localScale != finalScale)
			{
				float newX = Mathf.MoveTowards(_window.transform.localScale.x, 0f, IndependentDeltaTimeManager.GetDeltaTime() * 10f);
				_window.transform.localScale = new Vector3(newX, 1f, 1f);
				yield return null;
			}
		}

		private IEnumerator ExpandUI()
		{
			Vector3 finalScale = new Vector3(1f, 1f, 1f);
			while (_window.transform.localScale != finalScale)
			{
				float newX = Mathf.MoveTowards(_window.transform.localScale.x, 1f, IndependentDeltaTimeManager.GetDeltaTime() * 10f);
				_window.transform.localScale = new Vector3(newX, 1f, 1f);
				yield return null;
			}
		}

		public void OnDestroy()
		{
			CinemaNetworkingManager.OnTimeScaleEnableOrDisable -= OnTimeScaleEnableOrDisable;
			CinemaPluginPatches.OnLocalPlayerDieOrRevive -= OnFreeCamEnableOrDisable;
			Toggles[UIOption.ToggleTargetingVisibility].OnValueChanged -= SetHideTextOnScreen;
			if ((Object)(object)_cinemaUIgo != (Object)null)
			{
				Object.Destroy((Object)(object)_cinemaUIgo);
			}
		}
	}
	public abstract class Option
	{
		protected readonly bool ActiveWhenParentOff;

		protected GameObject Go { get; }

		internal List<Option> SubOptions { get; } = new List<Option>();


		internal Dictionary<Option, bool> StateByDisableOnSelectOptions { get; } = new Dictionary<Option, bool>();


		protected Option(GameObject go, bool startActive, bool activeWhenParentOff = false)
		{
			Go = go;
			ActiveWhenParentOff = activeWhenParentOff;
			go.active = startActive;
		}

		public void SetActive(bool state)
		{
			OnSetActive(state != ActiveWhenParentOff);
			Go.active = state != ActiveWhenParentOff;
		}

		public abstract void Disable(bool state);

		public abstract void Enable(bool state);

		public abstract void OnReset();

		public abstract void SetPreviousValue();

		public abstract void OnSetActive(bool state);
	}
	public sealed class SliderOption : Option
	{
		private readonly float _initialValue;

		private readonly TMP_Text _valueText;

		private bool _prevValueSet;

		private float _prevValue;

		private Slider Slider { get; }

		internal event Action<float> OnValueChanged;

		public SliderOption(GameObject go, bool startActive, float initialValue, float minValue, float maxValue)
			: base(go, startActive)
		{
			Slider = go.GetComponentInChildren<Slider>();
			_valueText = ((Component)go.transform.GetChild(1)).GetComponentInChildren<TMP_Text>();
			Button componentInChildren = ((Component)go.transform.GetChild(3)).GetComponentInChildren<Button>();
			((UnityEvent<float>)(object)Slider.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)OnSliderChange));
			((UnityEvent)componentInChildren.onClick).AddListener(UnityAction.op_Implicit((Action)OnReset));
			Slider.maxValue = maxValue;
			Slider.minValue = minValue;
			Slider.Set(initialValue, true);
			_initialValue = initialValue;
			OnSliderChange(initialValue);
		}

		public void OnSliderChange(float value)
		{
			_valueText.text = value.ToString((Mathf.Abs(value) < 100f) ? "0.00" : "0.0");
			this.OnValueChanged?.Invoke(value);
			Slider.value = value;
		}

		public override void Disable(bool state)
		{
			OnReset();
			((Behaviour)Slider).enabled = false;
			((Selectable)Slider).interactable = false;
		}

		public override void Enable(bool state)
		{
			((Behaviour)Slider).enabled = true;
			((Selectable)Slider).interactable = true;
			if (_prevValueSet)
			{
				SetPreviousValue();
			}
			else
			{
				OnReset();
			}
		}

		public override void OnReset()
		{
			SetSliderValue(_initialValue);
		}

		public override void SetPreviousValue()
		{
			SetSliderValue(_prevValueSet ? _prevValue : _initialValue);
		}

		public override void OnSetActive(bool state)
		{
			if (!state && base.Go.active)
			{
				_prevValue = Slider.value;
				_prevValueSet = true;
			}
		}

		private void SetSliderValue(float value)
		{
			Slider.Set(value, true);
			OnSliderChange(value);
		}
	}
	public sealed class ToggleOption : Option
	{
		private readonly bool _initialValue;

		private readonly TMP_Text _tmp;

		private bool _prevValueSet;

		private bool _prevValue;

		internal Toggle Toggle { get; }

		internal event Action<bool> OnValueChanged;

		public ToggleOption(GameObject go, bool initialValue, bool startActive, bool activeWhenParentOff = false)
			: base(go, startActive, activeWhenParentOff)
		{
			Toggle = go.GetComponentInChildren<Toggle>();
			((UnityEvent<bool>)(object)Toggle.onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)OnToggleChange));
			_tmp = ((Component)((Component)Toggle).transform).GetComponentInChildren<TMP_Text>();
			Toggle.Set(initialValue, true);
			OnToggleChange(initialValue);
			_initialValue = initialValue;
		}

		private void OnToggleChange(bool value)
		{
			_tmp.text = (value ? "<color=\"orange\">ON</color>" : "OFF");
			foreach (var (option2, state) in base.StateByDisableOnSelectOptions)
			{
				if (value)
				{
					option2.Disable(state);
				}
				else
				{
					option2.Enable(state);
				}
			}
			foreach (Option subOption in base.SubOptions)
			{
				subOption.SetActive(value);
				if (value)
				{
					subOption.SetPreviousValue();
				}
				else
				{
					subOption.OnReset();
				}
			}
			this.OnValueChanged?.Invoke(value);
		}

		public override void Disable(bool state)
		{
			Toggle.Set(state, true);
			((Behaviour)Toggle).enabled = false;
			_tmp.text = "<s>" + _tmp.text + "</s>";
			foreach (Option subOption in base.SubOptions)
			{
				subOption.OnReset();
				subOption.SetActive(state: false);
			}
		}

		public override void Enable(bool state)
		{
			((Behaviour)Toggle).enabled = true;
			if (_prevValueSet)
			{
				SetPreviousValue();
				{
					foreach (Option subOption in base.SubOptions)
					{
						subOption.SetPreviousValue();
					}
					return;
				}
			}
			OnReset();
			foreach (Option subOption2 in base.SubOptions)
			{
				subOption2.OnReset();
			}
		}

		public override void OnReset()
		{
			SetToggleValue(_initialValue);
		}

		public override void SetPreviousValue()
		{
			SetToggleValue(_prevValueSet ? _prevValue : _initialValue);
		}

		public override void OnSetActive(bool state)
		{
			if (state)
			{
				if (_prevValueSet)
				{
					SetPreviousValue();
				}
			}
			else
			{
				_prevValue = Toggle.isOn;
				_prevValueSet = true;
				OnReset();
			}
			foreach (Option subOption in base.SubOptions)
			{
				subOption.OnSetActive(state);
			}
		}

		private void SetToggleValue(bool value)
		{
			Toggle.Set(value, true);
			OnToggleChange(value);
		}
	}
	public static class UIFactory
	{
		public static Dictionary<UIOption, Option> BuildOptions(GameObject cinemaUI)
		{
			Dictionary<UIOption, Option> dictionary = new Dictionary<UIOption, Option>
			{
				{
					UIOption.ToggleUI,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleUI), initialValue: true, startActive: true)
				},
				{
					UIOption.ToggleBio,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleBio), initialValue: false, startActive: false, activeWhenParentOff: true)
				},
				{
					UIOption.ToggleAspectRatio,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleAspectRatio), initialValue: false, startActive: true)
				},
				{
					UIOption.AspectRatioSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.AspectRatioSlider), startActive: false, 1.777f, 0f, 5f)
				},
				{
					UIOption.ToggleBody,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleBody), initialValue: true, startActive: true)
				},
				{
					UIOption.ToggleFreeCamera,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleFreeCamera), initialValue: false, startActive: true)
				},
				{
					UIOption.MovementSpeedSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.MovementSpeedSlider), startActive: false, 1f, 0f, 2f)
				},
				{
					UIOption.MovementSmoothingSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.MovementSmoothingSlider), startActive: false, 0.2f, 0f, 1f)
				},
				{
					UIOption.RotationSpeedSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.RotationSpeedSlider), startActive: false, 0.9f, 0f, 2f)
				},
				{
					UIOption.RotationSmoothingSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.RotationSmoothingSlider), startActive: false, 0.1f, 0f, 1f)
				},
				{
					UIOption.ZoomSpeedSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.ZoomSpeedSlider), startActive: false, 0.9f, 0f, 1f)
				},
				{
					UIOption.ZoomSmoothingSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.ZoomSmoothingSlider), startActive: false, 0.02f, 0f, 1f)
				},
				{
					UIOption.ToggleDynamicRoll,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleDynamicRoll), initialValue: false, startActive: false)
				},
				{
					UIOption.DynamicRollIntensitySlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.DynamicRollIntensitySlider), startActive: false, 0.6f, 0f, 2f)
				},
				{
					UIOption.ToggleAlignPitchAxisWCam,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleAlignPitchAxisWCam), initialValue: true, startActive: false)
				},
				{
					UIOption.ToggleAlignRollAxisWCam,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleAlignRollAxisWCam), initialValue: false, startActive: false)
				},
				{
					UIOption.ToggleTargetingVisibility,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleTargetingVisibility), initialValue: false, startActive: false)
				},
				{
					UIOption.ToggleFpsLookSmoothing,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleFpsLookSmoothing), initialValue: false, startActive: true)
				},
				{
					UIOption.FpsLookSmoothingSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.FpsLookSmoothingSlider), startActive: false, 0.2f, 0f, 5f)
				},
				{
					UIOption.ToggleDoF,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleDoF), initialValue: false, startActive: true)
				},
				{
					UIOption.FocusDistanceSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.FocusDistanceSlider), startActive: false, 90f, 0f, 100f)
				},
				{
					UIOption.ApertureSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.ApertureSlider), startActive: false, 0.15f, 0f, 10f)
				},
				{
					UIOption.FocalLenghtSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.FocalLenghtSlider), startActive: false, 0.98f, 0f, 50f)
				},
				{
					UIOption.ToggleVignette,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleVignette), initialValue: true, startActive: true)
				},
				{
					UIOption.ToggleAmbientParticles,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleAmbientParticles), initialValue: true, startActive: true)
				},
				{
					UIOption.ToggleTimeScale,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleTimeScale), initialValue: false, startActive: true)
				},
				{
					UIOption.TimeScaleSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.TimeScaleSlider), startActive: false, 1f, 0.01f, 1f)
				},
				{
					UIOption.TogglePointLight,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.TogglePointLight), initialValue: false, startActive: true)
				},
				{
					UIOption.PointLightIntensitySlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.PointLightIntensitySlider), startActive: false, 0.005f, 0.005f, 1f)
				},
				{
					UIOption.PointLightRangeSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.PointLightRangeSlider), startActive: false, 5f, 0f, 100f)
				},
				{
					UIOption.ToggleSpotLight,
					new ToggleOption(GetOptionObj(cinemaUI, UIOption.ToggleSpotLight), initialValue: false, startActive: false)
				},
				{
					UIOption.SpotLightIntensitySlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.SpotLightIntensitySlider), startActive: false, 0.35f, 0f, 1f)
				},
				{
					UIOption.SpotLightRangeSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.SpotLightRangeSlider), startActive: false, 11f, 0f, 100f)
				},
				{
					UIOption.SpotLightAngleSlider,
					new SliderOption(GetOptionObj(cinemaUI, UIOption.SpotLightAngleSlider), startActive: false, 40f, 0f, 179f)
				}
			};
			dictionary[UIOption.ToggleFreeCamera].SubOptions.AddRange(new Option[11]
			{
				dictionary[UIOption.MovementSpeedSlider],
				dictionary[UIOption.MovementSmoothingSlider],
				dictionary[UIOption.RotationSpeedSlider],
				dictionary[UIOption.RotationSmoothingSlider],
				dictionary[UIOption.ZoomSpeedSlider],
				dictionary[UIOption.ZoomSmoothingSlider],
				dictionary[UIOption.ToggleDynamicRoll],
				dictionary[UIOption.ToggleAlignPitchAxisWCam],
				dictionary[UIOption.ToggleAlignRollAxisWCam],
				dictionary[UIOption.ToggleTargetingVisibility],
				dictionary[UIOption.ToggleSpotLight]
			});
			dictionary[UIOption.ToggleDynamicRoll].SubOptions.Add(dictionary[UIOption.DynamicRollIntensitySlider]);
			dictionary[UIOption.ToggleAspectRatio].SubOptions.Add(dictionary[UIOption.AspectRatioSlider]);
			dictionary[UIOption.ToggleFpsLookSmoothing].SubOptions.Add(dictionary[UIOption.FpsLookSmoothingSlider]);
			dictionary[UIOption.ToggleTimeScale].SubOptions.Add(dictionary[UIOption.TimeScaleSlider]);
			dictionary[UIOption.ToggleUI].SubOptions.Add(dictionary[UIOption.ToggleBio]);
			dictionary[UIOption.TogglePointLight].SubOptions.AddRange(new Option[2]
			{
				dictionary[UIOption.PointLightRangeSlider],
				dictionary[UIOption.PointLightIntensitySlider]
			});
			dictionary[UIOption.ToggleSpotLight].SubOptions.AddRange(new Option[3]
			{
				dictionary[UIOption.SpotLightRangeSlider],
				dictionary[UIOption.SpotLightIntensitySlider],
				dictionary[UIOption.SpotLightAngleSlider]
			});
			dictionary[UIOption.ToggleDoF].SubOptions.AddRange(new Option[3]
			{
				dictionary[UIOption.FocusDistanceSlider],
				dictionary[UIOption.ApertureSlider],
				dictionary[UIOption.FocalLenghtSlider]
			});
			dictionary[UIOption.ToggleFreeCamera].StateByDisableOnSelectOptions.Add(dictionary[UIOption.ToggleUI], value: false);
			dictionary[UIOption.ToggleFreeCamera].StateByDisableOnSelectOptions.Add(dictionary[UIOption.ToggleBody], value: false);
			dictionary[UIOption.ToggleFreeCamera].StateByDisableOnSelectOptions.Add(dictionary[UIOption.ToggleFpsLookSmoothing], value: false);
			dictionary[UIOption.ToggleTimeScale].StateByDisableOnSelectOptions.Add(dictionary[UIOption.ToggleFpsLookSmoothing], value: false);
			return dictionary;
		}

		public static Dictionary<UIOption, ToggleOption> GetToggles(Dictionary<UIOption, Option> options)
		{
			return options.Where<KeyValuePair<UIOption, Option>>((KeyValuePair<UIOption, Option> o) => o.Value is ToggleOption).ToDictionary((KeyValuePair<UIOption, Option> o) => o.Key, (KeyValuePair<UIOption, Option> o) => o.Value as ToggleOption);
		}

		public static Dictionary<UIOption, SliderOption> GetSliders(Dictionary<UIOption, Option> options)
		{
			return options.Where<KeyValuePair<UIOption, Option>>((KeyValuePair<UIOption, Option> o) => o.Value is SliderOption).ToDictionary((KeyValuePair<UIOption, Option> o) => o.Key, (KeyValuePair<UIOption, Option> o) => o.Value as SliderOption);
		}

		private static GameObject GetOptionObj(GameObject cinemaUI, UIOption option)
		{
			Transform child = cinemaUI.transform.GetChild(0).GetChild(1).GetChild(0);
			Transform child2 = child.GetChild(1).GetChild(0);
			return ((Component)((Component)child2).transform.Find(option.ToString())).gameObject;
		}
	}
	public class UIWindow : MonoBehaviour
	{
		private bool _aspectRatioOn;

		private float _lastCanvasAlpha;

		private RectTransform _dragRectTransform;

		private CanvasGroup _canvasGroup;

		private Canvas _canvas;

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			_dragRectTransform = ((Component)((Component)this).transform).GetComponent<RectTransform>();
			_canvas = ((Component)((Component)this).transform).GetComponentInParent<Canvas>();
			_canvasGroup = ((Component)_canvas).GetComponentInParent<CanvasGroup>();
			_lastCanvasAlpha = _canvasGroup.alpha;
			EventTrigger component = ((Component)this).GetComponent<EventTrigger>();
			Entry val = new Entry();
			val.eventID = (EventTriggerType)5;
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener(UnityAction<BaseEventData>.op_Implicit((Action<BaseEventData>)OnDrag));
			component.triggers.Add(val);
			Entry val2 = new Entry();
			val2.eventID = (EventTriggerType)0;
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener(UnityAction<BaseEventData>.op_Implicit((Action<BaseEventData>)OnEnter));
			component.triggers.Add(val2);
			Entry val3 = new Entry();
			val3.eventID = (EventTriggerType)1;
			((UnityEvent<BaseEventData>)(object)val3.callback).AddListener(UnityAction<BaseEventData>.op_Implicit((Action<BaseEventData>)OnExit));
			component.triggers.Add(val3);
		}

		private void Start()
		{
			CinemaUIManager.Current.Toggles[UIOption.ToggleAspectRatio].OnValueChanged += OnToggleAspectRatio;
		}

		public void OnDrag(BaseEventData data)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0055: 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)
			RectTransform dragRectTransform = _dragRectTransform;
			dragRectTransform.anchoredPosition += ((Il2CppObjectBase)data).TryCast<PointerEventData>().delta / _canvas.scaleFactor;
			RectTransform dragRectTransform2 = _dragRectTransform;
			Vector2 anchoredPosition = dragRectTransform2.anchoredPosition;
			float x = anchoredPosition.x;
			x = Mathf.Clamp(x, 0f, (float)Screen.width - dragRectTransform2.sizeDelta.x);
			anchoredPosition.x = x;
			dragRectTransform2.anchoredPosition = anchoredPosition;
		}

		public void OnEnter(BaseEventData data)
		{
			_canvasGroup.alpha = 1f;
		}

		public void OnExit(BaseEventData data)
		{
			_canvasGroup.alpha = (_aspectRatioOn ? 1f : _lastCanvasAlpha);
		}

		public void OnPointerDown(PointerEventData data)
		{
			((Transform)_dragRectTransform).SetAsLastSibling();
		}

		private void OnToggleAspectRatio(bool value)
		{
			_canvasGroup.alpha = (value ? 1f : _lastCanvasAlpha);
			_aspectRatioOn = value;
		}

		private void OnDestroy()
		{
			CinemaUIManager.Current.Toggles[UIOption.ToggleAspectRatio].OnValueChanged -= OnToggleAspectRatio;
		}
	}
}
namespace CinematographyPlugin.UI.UiInput
{
	public enum AxisName
	{
		PosX,
		PosY,
		PosZ,
		RotX,
		RotY,
		RotZ,
		Zoom,
		Speed
	}
	public static class KeyBindInputManager
	{
		private const float TimeCheckIntervalStart = 0.1f;

		private const float TimeScaleSmallDelta = 0.01f;

		private static bool _disableInputs;

		private static readonly KeyCode PosX = (KeyCode)100;

		private static readonly KeyCode NegX = (KeyCode)97;

		private static readonly KeyCode PosY = ConfigManager.UpKey;

		private static readonly KeyCode NegY = ConfigManager.DownKey;

		private static readonly KeyCode PosZ = (KeyCode)119;

		private static readonly KeyCode NegZ = (KeyCode)115;

		private static readonly KeyCode PosS = ConfigManager.SpeedUpKey;

		private static readonly KeyCode NegS = ConfigManager.SlowDownKey;

		private static readonly KeyCode TimeInc = ConfigManager.TimeIncKey;

		private static readonly KeyCode TimeDec = ConfigManager.TimeDecKey;

		private static readonly KeyCode TimePausePlay = ConfigManager.TimePausePlayKey;

		private static readonly KeyCode FreeCamToggleKey = ConfigManager.FreeCamToggleKey;

		private static readonly KeyCode OrbitTargetSelect = ConfigManager.OrbitEnterExitKey;

		private static readonly KeyCode WarpPlayerKey = ConfigManager.WarpPlayerKey;

		private static readonly KeyCode DimensionWarpKey = ConfigManager.DimensionWarpKey;

		private static float _lastTimeHeld;

		private static float _timeCheckInterval = 0.1f;

		public static void SetInputsEnabled(bool enable)
		{
			_disableInputs = enable;
		}

		public static float GetAxis(AxisName axis)
		{
			if (_disableInputs)
			{
				return 0f;
			}
			switch (axis)
			{
			case AxisName.PosX:
			case AxisName.PosY:
			case AxisName.PosZ:
			case AxisName.Speed:
				return GetAxisKeyInput(axis);
			case AxisName.RotX:
			case AxisName.RotY:
			case AxisName.RotZ:
			case AxisName.Zoom:
				return GetMouseInput(axis);
			default:
				throw new ArgumentOutOfRangeException("axis", axis, $"Invalid axis sent to GetAxis: {axis}");
			}
		}

		public static bool GetFreeCamToggle()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetKeyDown(FreeCamToggleKey);
		}

		public static bool GetMiddleMouse()
		{
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetMouseButtonDown(2);
		}

		public static float GetTimeScaleInput()
		{
			//IL_004f: 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)
			if (_disableInputs)
			{
				return 0f;
			}
			float num = 0f;
			if (Time.realtimeSinceStartup - _lastTimeHeld < _timeCheckInterval)
			{
				_timeCheckInterval = Mathf.MoveTowards(_timeCheckInterval, 0f, IndependentDeltaTimeManager.GetDeltaTime());
				return num;
			}
			if (Input.GetKey(TimeInc))
			{
				num = 0.01f;
			}
			if (Input.GetKey(TimeDec))
			{
				num = -0.01f;
			}
			if (num != 0f)
			{
				_lastTimeHeld = Time.realtimeSinceStartup;
			}
			else
			{
				_timeCheckInterval = 0.1f;
			}
			return num;
		}

		public static bool GetTimeScalePausePlay()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetKeyDown(TimePausePlay);
		}

		public static bool GetOrbitTargetSelect()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetKey(OrbitTargetSelect);
		}

		public static bool ChangeOrbitLockState()
		{
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetMouseButtonDown(0);
		}

		public static bool GetPlayerWarp()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetKeyDown(WarpPlayerKey);
		}

		public static bool GetDimensionWarp()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return false;
			}
			return Input.GetKeyDown(DimensionWarpKey);
		}

		private static float GetMouseInput(AxisName axis)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return 0f;
			}
			return axis switch
			{
				AxisName.RotX => 0f - Input.GetAxis("MouseY"), 
				AxisName.RotY => Input.GetAxis("MouseX"), 
				AxisName.RotZ => GetMouseButtonAxisFloat(), 
				AxisName.Zoom => 0f - Input.mouseScrollDelta.y, 
				_ => throw new ArgumentOutOfRangeException("axis", axis, $"Invalid axis sent to GetMouseAxis: {axis}"), 
			};
		}

		private static float GetMouseButtonAxisFloat()
		{
			if (_disableInputs)
			{
				return 0f;
			}
			return Input.GetMouseButton(0) ? 1 : (Input.GetMouseButton(1) ? (-1) : 0);
		}

		private static float GetAxisKeyInput(AxisName axis)
		{
			//IL_0036: 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_007f: 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_0068: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (_disableInputs)
			{
				return 0f;
			}
			return axis switch
			{
				AxisName.PosX => Input.GetKey(PosX) ? 1 : (Input.GetKey(NegX) ? (-1) : 0), 
				AxisName.PosY => Input.GetKey(PosY) ? 1 : (Input.GetKey(NegY) ? (-1) : 0), 
				AxisName.PosZ => Input.GetKey(PosZ) ? 1 : (Input.GetKey(NegZ) ? (-1) : 0), 
				AxisName.Speed => Input.GetKey(PosS) ? 1 : (Input.GetKey(NegS) ? (-1) : 0), 
				_ => throw new ArgumentOutOfRangeException("axis", axis, $"Invalid axis sent to GetKeyAxis: {axis}"), 
			};
		}
	}
}
namespace CinematographyPlugin.UI.Enums
{
	public enum UIOption
	{
		ToggleUI,
		ToggleBio,
		ToggleAspectRatio,
		AspectRatioSlider,
		ToggleBody,
		ToggleFreeCamera,
		MovementSpeedSlider,
		MovementSmoothingSlider,
		RotationSpeedSlider,
		RotationSmoothingSlider,
		ZoomSpeedSlider,
		ZoomSmoothingSlider,
		ToggleDynamicRoll,
		DynamicRollIntensitySlider,
		ToggleAlignPitchAxisWCam,
		ToggleAlignRollAxisWCam,
		ToggleTargetingVisibility,
		ToggleFpsLookSmoothing,
		FpsLookSmoothingSlider,
		ToggleDoF,
		FocusDistanceSlider,
		ApertureSlider,
		FocalLenghtSlider,
		ToggleVignette,
		ToggleAmbientParticles,
		ToggleTimeScale,
		TimeScaleSlider,
		TogglePointLight,
		PointLightIntensitySlider,
		PointLightRangeSlider,
		ToggleSpotLight,
		SpotLightIntensitySlider,
		SpotLightRangeSlider,
		SpotLightAngleSlider
	}
}
namespace CinematographyPlugin.Cinematography
{
	public class AspectRatioManager : MonoBehaviour
	{
		private GameObject _cinematicBars;

		private RectTransform _topBar;

		private RectTransform _bottomBar;

		private void Awake()
		{
			CinemaUIManager.Current.Toggles[UIOption.ToggleAspectRatio].OnValueChanged += OnAspectRatioToggle;
			CinemaUIManager.Current.Sliders[UIOption.AspectRatioSlider].OnValueChanged += OnAspectRatioChange;
		}

		private void Start()
		{
			_cinematicBars = CinemaUIManager.Current.GetCinematicBars();
			_topBar = ((Component)_cinematicBars.transform.GetChild(0)).GetComponent<RectTransform>();
			_bottomBar = ((Component)_cinematicBars.transform.GetChild(1)).GetComponent<RectTransform>();
		}

		private void OnAspectRatioToggle(bool value)
		{
			_cinematicBars.active = value;
		}

		private void OnAspectRatioChange(float value)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.width / value;
			float num2 = ((float)Screen.height - num) / 2f;
			_topBar.sizeDelta = new Vector2(_topBar.sizeDelta.x, num2);
			_bottomBar.sizeDelta = new Vector2(_bottomBar.sizeDelta.x, num2);
		}

		private void OnDestroy()
		{
			CinemaUIManager.Current.Toggles[UIOption.ToggleAspectRatio].OnValueChanged -= OnAspectRatioToggle;
			CinemaUIManager.Current.Sliders[UIOption.AspectRatioSlider].OnValueChanged -= OnAspectRatioChange;
		}
	}
	public class CinemaCamController : MonoBehaviour
	{
		private readonly Vector3 _warpOffset = new Vector3(0f, 0.8f, 0f);

		private bool _alignPitchAxisWCam = true;

		private bool _alignRollAxisWCam;

		private bool _dynamicRotation = true;

		private bool _inOrbit;

		private float _movementSpeed = 1f;

		private float _rotationSpeed = 0.9f;

		private float _movementSmoothFactor = 0.2f;

		private float _rotationSmoothFactor = 0.1f;

		private float _orbitSmoothFactor = 0f;

		private float _targetZoom = CinemaCamSettings.ZoomDefault;

		private float _currZoom = CinemaCamSettings.ZoomDefault;

		private float _zoomSpeed = 0.9f;

		private float _orbitDistance = 2f;

		private float _zoomSmoothFactor = 0.02f;

		private float _dynamicRotationSpeed = 0.6f;

		private FPSCamera _fpsCamera;

		private PlayerAgent _playerAgent;

		private Transform _childTrans;

		private Transform _orbitOffsetTrans;

		private Vector3 _targetPos = Vector3.zero;

		private Vector3 _prevPos = Vector3.zero;

		private Vector3 _movementVelocity = Vector3.zero;

		private Quaternion _targetWorldRot = Quaternion.identity;

		private Quaternion _targetLocalRot = Quaternion.identity;

		private Vector3 _orbitOffset;

		private Transform _orbitTarget;

		private void Awake()
		{
			CinemaUIManager.Current.Sliders[UIOption.MovementSpeedSlider].OnValueChanged += SetMovementSpeed;
			CinemaUIManager.Current.Sliders[UIOption.MovementSmoothingSlider].OnValueChanged += SetMovementSmoothTime;
			CinemaUIManager.Current.Sliders[UIOption.RotationSpeedSlider].OnValueChanged += SetRotationSpeed;
			CinemaUIManager.Current.Sliders[UIOption.RotationSmoothingSlider].OnValueChanged += SetRotationSmoothTime;
			CinemaUIManager.Current.Sliders[UIOption.ZoomSpeedSlider].OnValueChanged += SetZoomSpeed;
			CinemaUIManager.Current.Sliders[UIOption.ZoomSmoothingSlider].OnValueChanged += SetZoomSmoothTime;
			CinemaUIManager.Current.Toggles[UIOption.ToggleDynamicRoll].OnValueChanged += SetDynamicRotation;
			CinemaUIManager.Current.Sliders[UIOption.DynamicRollIntensitySlider].OnValueChanged += SetDynamicRotationSpeed;
			CinemaUIManager.Current.Toggles[UIOption.ToggleAlignPitchAxisWCam].OnValueChanged += SetAlignPitchAxisWCam;
			CinemaUIManager.Current.Toggles[UIOption.ToggleAlignRollAxisWCam].OnValueChanged += SetAlignRollAxisWCam;
			DimensionManager.OnDimensionWarp = (Action<Vector3>)Delegate.Combine(DimensionManager.OnDimensionWarp, new Action<Vector3>(OnDimensionWarp));
			_playerAgent = PlayerManager.GetLocalPlayerAgent();
			_fpsCamera = Object.FindObjectOfType<FPSCamera>();
			_childTrans = ((Component)this).transform.GetChild(0);
			_orbitOffsetTrans = _childTrans;
		}

		public void SyncWithCameraTransform()
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0046: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			Vector3 eulerAngles = _fpsCamera.m_orgParent.eulerAngles;
			Quaternion targetWorldRot = Quaternion.Euler(0f, eulerAngles.y, 0f);
			Quaternion targetLocalRot = Quaternion.Euler(eulerAngles.x, 0f, 0f);
			((Component)this).transform.localRotation = (_targetWorldRot = targetWorldRot);
			_childTrans.localRotation = (_targetLocalRot = targetLocalRot);
			Vector3 targetPos = (((Component)this).transform.position = _fpsCamera.Position);
			_targetPos = targetPos;
		}

		private void Update()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Cursor.lockState != 1)
			{
				return;
			}
			UpdateRotation();
			CheckAndResetFpsCamRotation();
			if (_inOrbit)
			{
				UpdateOrbitPosition();
				UpdateOrbitLocalPosition();
			}
			else
			{
				UpdatePosition();
				UpdateZoom();
				if (_dynamicRotation)
				{
					CalculateDynamicRotationDelta();
				}
			}
			UpdateCuller();
			CheckReset();
		}

		public void OnDimensionWarp(Vector3 targetPos)
		{
			//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_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0048: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = _playerAgent.GetHeadCamTransform().rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
			targetPos += _warpOffset;
			((Component)this).transform.position = targetPos;
			_targetPos = targetPos;
			_targetWorldRot = Quaternion.Euler(0f, eulerAngles.y, eulerAngles.z);
			_targetLocalRot = Quaternion.Euler(eulerAngles.x, 0f, 0f);
		}

		public void SetOrbit(Agent targetAgent)
		{
			//IL_0014: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_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_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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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)
			_orbitTarget = ((Component)targetAgent).transform;
			_orbitOffset = targetAgent.AimTarget.position - _orbitTarget.position;
			_orbitOffsetTrans.localPosition = _orbitOffset;
			Quaternion localRotation = ((Component)this).transform.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			_targetWorldRot = Quaternion.Euler(0f, eulerAngles.y, 0f);
			_targetLocalRot = Quaternion.Euler(eulerAngles.x, 0f, 0f);
			_targetPos = ((Component)this).transform.position;
			_inOrbit = true;
		}

		public void DisableOrbit()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			transform.position += _orbitOffsetTrans.localPosition;
			_orbitOffsetTrans.localPosition = Vector3.zero;
			Quaternion localRotation = ((Component)this).transform.localRotation;
			Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
			_targetWorldRot = Quaternion.Euler(0f, eulerAngles.y, 0f);
			_targetLocalRot = Quaternion.Euler(eulerAngles.x, 0f, 0f);
			_targetPos = ((Component)this).transform.position;
			_inOrbit = false;
		}

		private void UpdatePosition()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0096: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00b7: 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_00c1: 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_00c8: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_00fd: 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)
			//IL_0104: 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_0114: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_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_015a: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			float axis = KeyBindInputManager.GetAxis(AxisName.PosX);
			float axis2 = KeyBindInputManager.GetAxis(AxisName.PosY);
			float axis3 = KeyBindInputManager.GetAxis(AxisName.PosZ);
			Vector3 zero = Vector3.zero;
			float axis4 = KeyBindInputManager.GetAxis(AxisName.Speed);
			float num = 10f * ((axis4 > 0f) ? 2f : ((axis4 < 0f) ? 0.5f : 1f));
			float num2 = _movementSpeed * num;
			Vector3 val = (_alignRollAxisWCam ? _childTrans.right : FlatRight());
			Vector3 val2 = (_alignPitchAxisWCam ? _childTrans.forward : FlatForward());
			Vector3 val3 = (_alignPitchAxisWCam ? _childTrans.up : Vector3.up);
			zero += deltaTime * num2 * axis * val;
			zero += deltaTime * num2 * axis2 * val3;
			zero += deltaTime * num2 * axis3 * val2;
			_targetPos += zero;
			Vector3 position = ((Component)this).transform.position;
			float num3 = 1f - Mathf.Pow(_movementSmoothFactor, deltaTime);
			Vector3 val4 = Vector3.Lerp(position, _targetPos, num3);
			_movementVelocity = (val4 - _prevPos) / deltaTime;
			_prevPos = val4;
			((Component)this).transform.position = val4;
		}

		private void UpdateOrbitPosition()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0055: 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_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_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_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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)
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			float axis = KeyBindInputManager.GetAxis(AxisName.Zoom);
			_orbitDistance += axis * 0.2f;
			Vector3 position = ((Component)_orbitTarget).transform.position;
			_targetPos = position - ((Component)_fpsCamera).transform.forward * _orbitDistance;
			Vector3 position2 = ((Component)this).transform.position;
			float num = 1f - Mathf.Pow(_orbitSmoothFactor, deltaTime);
			Vector3 val = Vector3.Lerp(position2, _targetPos, num);
			_movementVelocity = (val - _prevPos) / deltaTime;
			_prevPos = val;
			((Component)this).transform.position = val;
		}

		private void UpdateOrbitLocalPosition()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_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_0075: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			float axis = KeyBindInputManager.GetAxis(AxisName.PosX);
			float axis2 = KeyBindInputManager.GetAxis(AxisName.PosY);
			float axis3 = KeyBindInputManager.GetAxis(AxisName.PosZ);
			Vector3 zero = Vector3.zero;
			zero += deltaTime * 1f * axis * Vector3.right;
			zero += deltaTime * 1f * axis2 * Vector3.up;
			zero += deltaTime * 1f * axis3 * Vector3.forward;
			Transform orbitOffsetTrans = _orbitOffsetTrans;
			orbitOffsetTrans.localPosition += zero;
		}

		private void UpdateRotation()
		{
			//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_0074: 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_007f: 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_008d: 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_0099: 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_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)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_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_0114: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_00f4: 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)
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			Transform transform = ((Component)this).transform;
			Transform childTrans = _childTrans;
			float axis = KeyBindInputManager.GetAxis(AxisName.RotX);
			float axis2 = KeyBindInputManager.GetAxis(AxisName.RotY);
			float num = (_inOrbit ? 0f : KeyBindInputManager.GetAxis(AxisName.RotZ));
			int num2 = Math.Sign(Vector3.Dot(childTrans.up, Vector3.up));
			axis2 *= (float)num2;
			float num3 = _rotationSpeed * 100f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(axis, axis2, num);
			val *= deltaTime * num3;
			Quaternion val2 = Quaternion.Euler(0f, val.y, val.z);
			Quaternion val3 = Quaternion.Euler(val.x, 0f, 0f);
			if (!IsYawRotationFlippedByNewRotation(val2))
			{
				_targetWorldRot *= val2;
			}
			if (!IsPitchRotationFlippedByNewRotation(val3))
			{
				_targetLocalRot *= val3;
			}
			float num4 = 1f - Mathf.Pow(_rotationSmoothFactor, deltaTime);
			Quaternion localRotation = Quaternion.Slerp(transform.localRotation, _targetWorldRot, num4);
			Quaternion localRotation2 = Quaternion.Slerp(childTrans.localRotation, _targetLocalRot, num4);
			transform.localRotation = localRotation;
			childTrans.localRotation = localRotation2;
		}

		private bool IsYawRotationFlippedByNewRotation(Quaternion delta)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0045: 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_0051: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _targetWorldRot * Vector3.fwd;
			Vector3 val2 = _targetWorldRot * delta * Vector3.fwd;
			Vector3 val3 = ((Component)this).transform.localRotation * Vector3.fwd;
			Vector3 val4 = Vector3.Cross(_fpsCamera.Forward, val);
			float value = Vector3.SignedAngle(val3, val, val4);
			float value2 = Vector3.SignedAngle(val3, val2, val4);
			return Math.Abs(value) >= 90f && Math.Sign(value) != Math.Sign(value2);
		}

		private bool IsPitchRotationFlippedByNewRotation(Quaternion delta)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0045: 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_0051: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = _targetLocalRot * Vector3.fwd;
			Vector3 val2 = _targetLocalRot * delta * Vector3.fwd;
			Vector3 val3 = _childTrans.localRotation * Vector3.fwd;
			Vector3 val4 = Vector3.Cross(_fpsCamera.Forward, val);
			float value = Vector3.SignedAngle(val3, val, val4);
			float value2 = Vector3.SignedAngle(val3, val2, val4);
			return Math.Abs(value) >= 90f && Math.Sign(value) != Math.Sign(value2);
		}

		private void CalculateDynamicRotationDelta()
		{
			//IL_0025: 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_002a: 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_0034: 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_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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_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_0066: 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_0076: 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_007a: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			Transform transform = ((Component)this).transform;
			Transform childTrans = _childTrans;
			Vector3 val = (_alignPitchAxisWCam ? childTrans.up : Vector3.up);
			Vector3 val2 = (_alignPitchAxisWCam ? childTrans.right : FlatRight());
			Vector3 val3 = Vector3.ProjectOnPlane(_movementVelocity, val);
			Vector3 val4 = val3 * (_dynamicRotationSpeed * 10f);
			float num = Mathf.Sign(Vector3.Dot(val4, val2));
			Vector3 val5 = Vector3.Project(val4, val2);
			float num2 = Mathf.Clamp(((Vector3)(ref val5)).magnitude, 0f, 180f) * num;
			Quaternion val6 = transform.rotation * Quaternion.Euler(0f, 0f, num2);
			float num3 = 1f - Mathf.Pow(0.4f, deltaTime);
			Quaternion localRotation = Quaternion.Slerp(transform.localRotation, val6, num3);
			transform.localRotation = localRotation;
		}

		private void CheckAndResetFpsCamRotation()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)_fpsCamera).transform.parent.localRotation != Quaternion.identity)
			{
				((Component)_fpsCamera).transform.parent.localRotation = Quaternion.identity;
			}
		}

		private void UpdateZoom()
		{
			float deltaTime = IndependentDeltaTimeManager.GetDeltaTime();
			float axis = KeyBindInputManager.GetAxis(AxisName.Zoom);
			float num = _zoomSpeed * 200f;
			_targetZoom = Mathf.Clamp(_targetZoom + deltaTime * num * axis, 1f, 160f);
			float num2 = 1f - Mathf.Pow(_zoomSmoothFactor, deltaTime);
			float num3 = Mathf.Lerp(_currZoom, _targetZoom, num2);
			((CameraController)_fpsCamera).m_camera.fieldOfView = num3;
			_currZoom = num3;
		}

		private void UpdateCuller()
		{
			//IL_0007: 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_000d: 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_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_001a: 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_002e: 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_0033: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = position + FlatForward();
			RaycastHit val2 = default(RaycastHit);
			Vector3 val3 = (Physics.Raycast(val, Vector3.down, ref val2) ? ((RaycastHit)(ref val2)).point : position);
			((PlayerAgent)_fpsCamera.m_owner).m_movingCuller.UpdatePosition(((Agent)_playerAgent).m_dimensionIndex, val3);
		}

		private void CheckReset()
		{
			if (KeyBindInputManager.GetMiddleMouse())
			{
				OnReset();
			}
		}

		private void OnReset()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			_targetZoom = CinemaCamSettings.ZoomDefault;
			_targetWorldRot = Quaternion.Euler(0f, ((Quaternion)(ref _targetWorldRot)).eulerAngles.y, 0f);
			_orbitDistance = 2f;
			if (_inOrbit)
			{
				_orbitOffsetTrans.localPosition = _orbitOffset;
			}
		}

		private Vector3 FlatForward()
		{
			//IL_0007: 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_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(_childTrans.forward, Vector3.up);
			return ((Vector3)(ref val)).normalized;
		}

		private Vector3 FlatRight()
		{
			//IL_0007: 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_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.ProjectOnPlane(_childTrans.right, Vector3.up);
			return ((Vector3)(ref val)).normalized;
		}

		private void SetMovementSpeed(float value)
		{
			_movementSpeed = value;
		}

		private void SetMovementSmoothTime(float value)
		{
			_movementSmoothFactor = value;
		}

		private void SetRotationSpeed(float value)
		{
			_rotationSpeed = value;
		}

		private void SetRotationSmoothTime(float value)
		{
			_rotationSmoothFactor = value;
		}

		private void SetZoomSpeed(float value)
		{
			_zoomSpeed = value;
		}

		private void SetZoomSmoothTime(float value)
		{
			_zoomSmoothFactor = value;
		}

		private void SetAlignPitchAxisWCam(bool value)
		{
			_alignPitchAxisWCam = value;
		}

		private void SetAlignRollAxisWCam(bool value)
		{
			_alignRollAxisWCam = value;
		}

		private void SetDynamicRotation(bool value)
		{
			_dynamicRotation = value;
		}

		private void SetDynamicRotationSpeed(float value)
		{
			_dynamicRotationSpeed = value;
		}

		private void OnDestroy()
		{
			CinemaUIManager.Current.Sliders[UIOption.MovementSpeedSlider].OnValueChanged -= SetMovementSpeed;
			CinemaUIManager.Current.Sliders[UIOption.MovementSmoothingSlider].OnValueChanged -= SetMovementSmoothTime;
			CinemaUIManager.Current.Sliders[UIOption.RotationSpeedSlider].OnValueChanged -= SetRotationSpeed;
			CinemaUIManager.Current.Sliders[UIOption.RotationSmoothingSlider].OnValueChanged -= SetRotationSmoothTime;
			CinemaUIManager.Current.Sliders[UIOption.ZoomSpeedSlider].OnValueChanged -= SetZoomSpeed;
			CinemaUIManager.Current.Sliders[UIOption.ZoomSmoothingSlider].OnValueChanged -= SetZoomSmoothTime;
			CinemaUIManager.Current.Toggles[UIOption.ToggleAlignPitchAxisWCam].OnValueChanged -= SetAlignPitchAxisWCam;
			CinemaUIManager.Current.Toggles[UIOption.ToggleAlignRollAxisWCam].OnValueChanged -= SetAlignRollAxisWCam;
			CinemaUIManager.Current.Toggles[UIOption.ToggleDynamicRoll].OnValueChanged -= SetDynamicRotation;
			CinemaUIManager.Current.Sliders[UIOption.DynamicRollIntensitySlider].OnValueChanged -= SetDynamicRotationSpeed;
			DimensionManager.OnDimensionWarp = (Action<Vector3>)Delegate.Remove(DimensionManager.OnDimensionWarp, new Action<Vector3>(OnDimensionWarp));
		}
	}
	public class CinemaCamManager : MonoBehaviour
	{
		public static CinemaCamManager Current;

		private const float CameraManMaxHealth = 1E+12f;

		private const float RayCastMax = 50f;

		private const float RayCastRadius = 0.5f;

		private const float OrbitReselectDelay = 0.5f;

		private const float PlayerBodyOffset = 2f;

		private const float RaycastTimeScaleThreshold = 0.05f;

		private readonly int _playerLayerMask = LayerMask.GetMask(new string[1] { "PlayerSynced" });

		private readonly int _enemyLayerMask = LayerMask.GetMask(new string[1] { "EnemyDamagable" });

		private readonly int _enemyLayer = LayerMask.NameToLayer("EnemyDamagable");

		private readonly Dictionary<string, SphereCollider> _shieldSphereByAgentName = new Dictionary<string, SphereCollider>();

		private bool _freeCamEnabled;

		private bool _inOrbit;

		private bool _inOrbitLock;

		private bool _orbitTargetSet;

		private string _orbitTargetName;

		private float _lastOrbitDeselect;

		private float _playerOrigMax;

		private Vector3 _originalPlayerPos;

		private RaycastHit _cameraHit;

		private GameObject _prevHit = new GameObject();

		private FPSCamera _fpsCamera;

		private Agent _orbitTarget;

		private Transform _prevParent;

		private Transform _orbitLockObj;

		private Transform _cinemaCamCtrlHolder;

		private Transform _cinemaCam;

		private Transform _fpsCamHolderSubstitute;

		private PlayerAgent _playerAgent;

		private PlayerLocomotion _playerLocomotion;

		private CinemaCamController _cinemaCamController;

		private void Awake()
		{
			//IL_003a: 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_005f: 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)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Current = this;
			_playerAgent = PlayerManager.GetLocalPlayerAgent();
			_fpsCamera = _playerAgent.FPSCamera;
			_playerLocomotion = ((Component)_playerAgent).GetComponent<PlayerLocomotion>();
			_cinemaCam = new GameObject("CinemaCam").transform;
			Transform transform = new GameObject("CinemaCamRotation").transform;
			_fpsCamHolderSubstitute = new GameObject("FPSCamHolderSubstitute").transform;
			_cinemaCamCtrlHolder = new GameObject("CinemaCamControl").transform;
			_orbitLockObj = new GameObject("CinemaCamOrbitLock").transform;
			_fpsCamHolderSubstitute.parent = transform;
			transform.parent = _cinemaCamCtrlHolder;
			_cinemaCamCtrlHolder.parent = _orbitLockObj;
			_orbitLockObj.parent = _cinemaCam;
			_cinemaCamController = ((Component)_cinemaCamCtrlHolder).gameObject.AddComponent<CinemaCamController>();
			((Behaviour)_cinemaCamController).enabled = false;
			_playerOrigMax = ((Dam_SyncedDamageBase)_playerAgent.Damage).HealthMax;
		}

		private void Start()
		{
			CinemaUIManager.Current.Toggles[UIOption.ToggleFreeCamera].OnValueChanged += OnFreeCameraToggle;
			CinemaNetworkingManager.OnOtherPlayerEnterExitFreeCam += OnOtherPlayerEnterOrExitFreeCam;
		}

		private void Update()
		{
			if (_freeCamEnabled)
			{
				if (_inOrbit && !_inOrbitLock)
				{
					CounterParentRotation();
				}
				CheckAndForceUiHidden();
				DivertEnemiesAwayFromCameraMan();
				UpdateOrbitCamState();
				CheckPlayerWarp();
			}
			CheckFreeCamHotKey();
		}

		public bool FreeCamEnabled()
		{
			return _freeCamEnabled;
		}

		public Vector3 GetOriginalPlayerPosition()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			return _originalPlayerPos;
		}

		public void EnableOrDisableCinemaCam(bool enable)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			ScreenClutterController.GetInstance().ToggleAllScreenClutter(!enable);
			UpdateCameramanHealth(_playerAgent, enable);
			if (enable)
			{
				((Behaviour)_playerLocomotion).enabled = false;
				_prevParent = _fpsCamera.m_orgParent.parent;
				_cinemaCamController.SyncWithCameraTransform();
				_fpsCamera.m_orgParent.parent = _fpsCamHolderSubstitute;
				_fpsCamera.MouseLookEnabled = false;
				((Component)_prevParent).gameObject.active = false;
				((Behaviour)_cinemaCamController).enabled = true;
				UpdatePlayerShield(_playerAgent, setUp: true);
			}
			else
			{
				((Behaviour)_cinemaCamController).enabled = false;
				_fpsCamera.MouseLookEnabled = true;
				((Component)_prevParent).gameObject.active = true;
				_fpsCamera.m_orgParent.parent = _prevParent;
				_fpsCamera.m_orgParent.localPosition = Vector3.zero;
				((Behaviour)_playerLocomotion).enabled = true;
				if (_inOrbit)
				{
					DisconnectOrbit();
				}
				UpdatePlayerShield(_playerAgent, setUp: false);
				_playerLocomotion.DisableFallDamageTemporarily = true;
			}
			CinematographyCore.log.LogMessage((object)(enable ? "Cinema cam enabled" : "Cinema cam disabled"));
		}

		private void UpdateCameramanHealth(PlayerAgent agent, bool setUp)
		{
			if (setUp)
			{
				((Dam_SyncedDamageBase)agent.Damage).HealthMax = 1E+12f;
				((Dam_SyncedDamageBase)agent.Damage).Health = 1E+12f;
			}
			else
			{
				((Dam_SyncedDamageBase)agent.Damage).HealthMax = _playerOrigMax;
				((Dam_SyncedDamageBase)agent.Damage).Health = _playerOrigMax;
			}
		}

		private void UpdatePlayerShield(PlayerAgent agent, bool setUp)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			UpdatePlayerShield(agent, ((Component)agent).transform.position, setUp);
		}

		public void UpdatePlayerShield(PlayerAgent agent, Vector3 playerPosition, bool setUp)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			if (setUp)
			{
				_originalPlayerPos = playerPosition;
			}
			string name = ((Object)agent.Sync).name;
			if (!_shieldSphereByAgentName.ContainsKey(name))
			{
				_shieldSphereByAgentName[name] = GameObject.CreatePrimitive((PrimitiveType)0).GetComponent<SphereCollider>();
				((Renderer)((Component)_shieldSphereByAgentName[name]).GetComponent<MeshRenderer>()).enabled = false;
				((Component)_shieldSphereByAgentName[name]).transform.localScale = new Vector3(3f, 3f, 3f);
			}
			((Component)_shieldSphereByAgentName[name]).transform.position = playerPosition;
			((Collider)_shieldSphereByAgentName[name]).enabled = setUp;
		}

		private void CheckFreeCamHotKey()
		{
			if (KeyBindInputManager.GetFreeCamToggle())
			{
				CinemaUIManager.Current.Toggles[UIOption.ToggleFreeCamera].Toggle.isOn = !_freeCamEnabled;
			}
		}

		private void CheckAndForceUiHidden()
		{
			if (ScreenClutterController.GetInstance().IsBodyOrUiVisible())
			{
				ScreenClutterController.GetInstance().ToggleAllScreenClutter(value: false);
			}
		}

		private void OnFreeCameraToggle(bool value)
		{
			EnableOrDisableCinemaCam(value);
			_freeCamEnabled = value;
		}

		private void UpdateOrbitCamState()
		{
			if (KeyBindInputManager.ChangeOrbitLockState())
			{
				_inOrbitLock = !_inOrbitLock;
			}
			if (KeyBindInputManager.GetOrbitTargetSelect() && Time.realtimeSinceStartup - _lastOrbitDeselect > 0.5f)
			{
				if (_inOrbit)
				{
					DisconnectOrbit();
					return;
				}
				FindAndSetOrbitTarget();
			}
			else
			{
				CinemaUIManager.Current.HideTextOnScreen();
				if (!_inOrbit && _orbitTargetSet)
				{
					SetOrbit();
				}
			}
			if (_orbitTargetSet && !_orbitTarget.Alive)
			{
				DisconnectOrbit();
			}
		}

		private void FindAndSetOrbitTarget()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.SphereCast(_fpsCamera.m_camRay, 0.5f, ref _cameraHit, 50f, _playerLayerMask | _enemyLayerMask))
			{
				if (((Object)_prevHit).GetInstanceID() != ((Object)((Component)((RaycastHit)(ref _cameraHit)).collider).gameObject).GetInstanceID())
				{
					Agent val = (_orbitTarget = ((Component)((RaycastHit)(ref _cameraHit)).collider).GetComponentInParent<Agent>());
					if (((Component)((RaycastHit)(ref _cameraHit)).collider).gameObject.layer == _enemyLayer)
					{
						_orbitTargetName = ((GameDataBlockBase<EnemyDataBlock>)(object)((Il2CppObjectBase)val).TryCast<EnemyAgent>().EnemyData).name;
					}
					else
					{
						_orbitTargetName = ((Il2CppObjectBase)val).TryCast<PlayerAgent>().PlayerName;
					}
				}
				_prevHit = ((Component)((RaycastHit)(ref _cameraHit)).collider).gameObject;
				_orbitTargetSet = true;
				CinemaUIManager.Current.ShowTextOnScreen(_orbitTargetName);
			}
			else
			{
				CinemaUIManager.Current.ShowNoTargetTextOnScreen();
				_orbitTargetSet = false;
			}
		}

		private void SetOrbit()
		{
			((Component)_orbitLockObj).transform.parent = ((Component)_orbitTarget).transform;
			_cinemaCamController.SetOrbit(_orbitTarget);
			_inOrbit = true;
		}

		private void DisconnectOrbit()
		{
			((Component)_orbitLockObj).transform.parent = _cinemaCam;
			_cinemaCamController.DisableOrbit();
			_inOrbit = false;
			_orbitTargetSet = false;
			_lastOrbitDeselect = Time.realtimeSinceStartup;
		}

		private void CounterParentRotation()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			((Component)_orbitLockObj).transform.rotation = Quaternion.identity;
		}

		private void OnOtherPlayerEnterOrExit