Decompiled source of PhotoModePlus v1.1.4

PhotoModePlus.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2.UI;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using RoR2.UI.SkinControllers;
using UnityEngine;
using UnityEngine.Events;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PhotoModePlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e0e521da4451759bacb60dcf523b721310d00a5e")]
[assembly: AssemblyProduct("PhotoModePlus")]
[assembly: AssemblyTitle("PhotoModePlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public static class QuaternionExtension
{
	public static Quaternion WithEulerAngles(this Quaternion quaternion, float? x = null, float? y = null, float? z = null)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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_0030: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		Vector3 eulerAngles = ((Quaternion)(ref quaternion)).eulerAngles;
		((Vector3)(ref eulerAngles)).Set(x ?? eulerAngles.x, y ?? eulerAngles.y, z ?? eulerAngles.z);
		return Quaternion.Euler(eulerAngles);
	}
}
namespace PhotoModePlus
{
	public class Assets
	{
		public static AssetBundle assetBundle;

		public static void Init()
		{
			GetAssetBundle();
		}

		private static void GetAssetBundle()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("PhotoModePlus.mwmwphotomodeplusbundle");
			if (stream != null)
			{
				assetBundle = AssetBundle.LoadFromStream(stream);
			}
			else
			{
				Log.Error("Failed to load assetbundle!");
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class Options
	{
		private static bool? _rooEnabled;

		public static ConfigEntry<KeyboardShortcut> cameraUpKey;

		public static ConfigEntry<KeyboardShortcut> cameraDownKey;

		public static ConfigEntry<KeyboardShortcut> cameraFastKey;

		public static ConfigEntry<KeyboardShortcut> cameraSlowKey;

		public static ConfigEntry<KeyboardShortcut> stepTime;

		public static ConfigEntry<KeyboardShortcut> increaseSpeedKey;

		public static ConfigEntry<KeyboardShortcut> decreaseSpeedKey;

		public static ConfigEntry<KeyboardShortcut> cursorToggleKey;

		public static ConfigEntry<KeyboardShortcut> adjustFOVKey;

		public static ConfigEntry<KeyboardShortcut> defaultFOVKey;

		public static ConfigEntry<float> defaultSpeed;

		public static ConfigEntry<float> fastMult;

		public static ConfigEntry<float> slowMult;

		public static ConfigEntry<bool> disableIndicators;

		public static ConfigEntry<int> buttonPlacement;

		public static ConfigEntry<bool> disableCameraWithConsole;

		public static bool rooEnabled
		{
			get
			{
				if (!_rooEnabled.HasValue)
				{
					_rooEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _rooEnabled.Value;
			}
		}

		public static void Init()
		{
			//IL_0017: 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_006e: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			cameraUpKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Move Up Key", new KeyboardShortcut((KeyCode)101, Array.Empty<KeyCode>()), "Key to hold to make the camera move up.");
			cameraDownKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Move Down Key", new KeyboardShortcut((KeyCode)113, Array.Empty<KeyCode>()), "Key to hold to make the camera move down.");
			cameraFastKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Camera Fast Key", new KeyboardShortcut((KeyCode)306, Array.Empty<KeyCode>()), "Key to hold to make the camera move faster.");
			cameraSlowKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Camera Slow Key", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Key to hold to make the camera move slower.");
			stepTime = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Step Forward Key", new KeyboardShortcut((KeyCode)275, Array.Empty<KeyCode>()), "Key to press to step forward one physics update.");
			increaseSpeedKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Increase Default Speed Key", new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()), "Key to press to increase the default speed of the current camera instance.");
			decreaseSpeedKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Decrease Default Speed Key", new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()), "Key to press to decrease the default speed of the current camera instance.");
			cursorToggleKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Cursor Opener Toggle Key", new KeyboardShortcut((KeyCode)9, Array.Empty<KeyCode>()), "Key to press to free and unfree the cursor while in Photo Mode. Freeing the cursor freezes movement controls.");
			adjustFOVKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Adjust FOV Key", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "Key to hold to adjust the FOV while in Photo Mode.");
			defaultFOVKey = PhotoModePlus.config.Bind<KeyboardShortcut>("Keybinds", "Reset FOV Key", new KeyboardShortcut((KeyCode)114, Array.Empty<KeyCode>()), "Key to press to snap the FOV back to the default while in Photo Mode.");
			defaultSpeed = PhotoModePlus.config.Bind<float>("Movement", "Default Camera Speed", 10f, "The speed at which the camera will move upon entering Photo Mode, without holding any keybinds.");
			fastMult = PhotoModePlus.config.Bind<float>("Movement", "Fast Mult", 5f, "The value which the default camera speed is multiplied by when holding down the Fast Camera keybind.");
			slowMult = PhotoModePlus.config.Bind<float>("Movement", "Slow Mult", 0.3f, "The value which the default camera speed is multiplied by when holding down the Slow Camera keybind.");
			disableIndicators = PhotoModePlus.config.Bind<bool>("Visuals", "Disable Ping Indicators", true, "Hide pings while Photo Mode is active.");
			buttonPlacement = PhotoModePlus.config.Bind<int>("Misc", "Photo Mode Button Index", 1, "The index position of the Photo Mode button in the pause menu.");
			disableCameraWithConsole = PhotoModePlus.config.Bind<bool>("Misc", "Disable Camera Movements with Console", true, "Prevent the camera from moving in Photo Mode while the dev console is active.");
			if (rooEnabled)
			{
				RoOInit();
			}
		}

		private static void RoOInit()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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_0139: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(cameraUpKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(cameraDownKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(cameraFastKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(cameraSlowKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(stepTime, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(increaseSpeedKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(decreaseSpeedKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(cursorToggleKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(adjustFOVKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(defaultFOVKey, new KeyBindConfig()));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(defaultSpeed, new StepSliderConfig
			{
				min = 0.1f,
				max = 100f,
				increment = 0.1f
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(fastMult, new StepSliderConfig
			{
				min = 1f,
				max = 100f,
				increment = 0.1f
			}));
			ModSettingsManager.AddOption((BaseOption)new StepSliderOption(slowMult, new StepSliderConfig
			{
				min = 0f,
				max = 1f,
				increment = 0.01f
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(disableIndicators, new CheckBoxConfig()));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(buttonPlacement, new IntSliderConfig
			{
				min = 0,
				max = 6
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(disableCameraWithConsole, new CheckBoxConfig()));
			ModSettingsManager.SetModDescription("Config options for PhotoModePlus.");
			ModSettingsManager.SetModIcon(Assets.assetBundle.LoadAsset<Sprite>("icon"));
		}
	}
	internal class PhotoModeController : MonoBehaviour, ICameraStateProvider
	{
		internal struct PhotoModeCameraState
		{
			internal float pitch;

			internal float yaw;

			internal float roll;

			internal Vector3 position;

			internal float fov;

			internal Quaternion Rotation
			{
				get
				{
					//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_001b: Unknown result type (might be due to invalid IL or missing references)
					return Quaternion.Euler(pitch, yaw, roll);
				}
				set
				{
					//IL_0003: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: 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)
					Vector3 eulerAngles = ((Quaternion)(ref value)).eulerAngles;
					pitch = eulerAngles.x;
					yaw = eulerAngles.y;
					roll = eulerAngles.z;
				}
			}
		}

		public static PhotoModeController instance;

		private float cameraSpeed;

		public CameraRigController cameraRigController;

		private InteractionDriver interactionDriver;

		private PhotoModeCameraState cameraState;

		private Player inputPlayer;

		private UserProfile userProfile;

		private float? prevTimescale;

		private bool isSteppingTime;

		private float stepTimeHoldDuration;

		private List<PingIndicator> pingIndicators;

		private CursorOpener cursorOpener;

		private bool _cursorActive;

		private float defaultFov;

		private const float speedChangeSpeed = 140f;

		private bool cursorActive
		{
			get
			{
				return _cursorActive;
			}
			set
			{
				if (!Object.op_Implicit((Object)(object)cursorOpener))
				{
					((Component)this).gameObject.AddComponent<MPEventSystemProvider>().fallBackToMainEventSystem = true;
					((Component)this).gameObject.AddComponent<MPEventSystemLocator>();
					cursorOpener = ((Component)this).gameObject.AddComponent<CursorOpener>();
				}
				((Behaviour)cursorOpener).enabled = value;
				_cursorActive = value;
			}
		}

		private Camera camera => cameraRigController.sceneCam;

		public InputSource currentInputSource { get; private set; }

		private bool gamepad => (int)currentInputSource == 1;

		private event Action OnExit;

		internal void EnterPhotoMode(CameraRigController cameraRigController)
		{
			cameraSpeed = Options.defaultSpeed.Value;
			if (!Object.op_Implicit((Object)(object)cameraRigController))
			{
				Log.Error("Camera rig controller is null! Cancelling photo mode...");
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			userProfile = cameraRigController.localUserViewer.userProfile;
			SetupCameraState(cameraRigController);
			SetInteractionDriverActive(active: false);
			HoldVisuals();
		}

		private void Awake()
		{
			instance = this;
		}

		private void SetInteractionDriverActive(bool active)
		{
			if (Object.op_Implicit((Object)(object)interactionDriver) || (Object.op_Implicit((Object)(object)cameraRigController.targetBody) && ((Component)cameraRigController.targetBody).TryGetComponent<InteractionDriver>(ref interactionDriver)))
			{
				((Behaviour)interactionDriver).enabled = active;
				if (!active)
				{
					interactionDriver.SetCurrentInteractable((GameObject)null);
				}
			}
		}

		private void HoldVisuals()
		{
			((Behaviour)cameraRigController.hud.mainContainer.GetComponent<Canvas>()).enabled = false;
			OnExit += delegate
			{
				((Behaviour)cameraRigController.hud.mainContainer.GetComponent<Canvas>()).enabled = true;
			};
			if (Options.disableIndicators.Value)
			{
				SetIndicatorsVisible(visible: false);
				OnExit += delegate
				{
					SetIndicatorsVisible(visible: true);
				};
			}
		}

		private void SetupCameraState(CameraRigController cameraRigController)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			this.cameraRigController = cameraRigController;
			this.cameraRigController.SetOverrideCam((ICameraStateProvider)(object)this, 0f);
			this.cameraRigController.enableFading = false;
			cameraState = default(PhotoModeCameraState);
			cameraState.position = ((Component)camera).transform.position;
			cameraState.Rotation = Quaternion.LookRotation(((Component)camera).transform.rotation * Vector3.forward, Vector3.up);
			cameraState.fov = (defaultFov = camera.fieldOfView);
			if (cameraState.pitch > 90f)
			{
				cameraState.pitch -= 360f;
			}
			inputPlayer = cameraRigController.localUserViewer.inputPlayer;
			inputPlayer.controllers.AddLastActiveControllerChangedDelegate(new PlayerActiveControllerChangedDelegate(OnLastActiveControllerChanged));
			OnLastActiveControllerChanged(inputPlayer, inputPlayer.controllers.GetLastActiveController());
			if (Object.op_Implicit((Object)(object)PauseStopController.instance))
			{
				prevTimescale = PauseStopController.instance._oldTimeScale;
			}
			else
			{
				prevTimescale = 1f;
			}
		}

		private void ExitPhotoMode()
		{
			this.OnExit?.Invoke();
			SetInteractionDriverActive(active: true);
			DestroyCameraState();
		}

		private void DestroyCameraState()
		{
			//IL_003a: 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)
			if (Object.op_Implicit((Object)(object)cameraRigController))
			{
				cameraRigController.enableFading = true;
				cameraRigController.SetOverrideCam((ICameraStateProvider)null, 1f);
				((Component)camera).transform.localPosition = Vector3.zero;
				((Component)camera).transform.localRotation = Quaternion.identity;
			}
			for (int i = 0; i < PauseScreenController.instancesList.Count; i++)
			{
				PauseScreenController.instancesList[i].DestroyPauseScreen(true);
			}
			if (Object.op_Implicit((Object)(object)PauseStopController.instance))
			{
				PauseStopController.instance.Pause(false);
			}
			if (prevTimescale.HasValue)
			{
				Time.timeScale = prevTimescale.Value;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void SetIndicatorsVisible(bool visible)
		{
			if (!visible)
			{
				DamageNumberManager.instance.ps.Clear(true);
				cameraRigController.sprintingParticleSystem.Clear(true);
				pingIndicators = new List<PingIndicator>(PingIndicator.instancesList);
			}
			for (int i = 0; i < pingIndicators.Count; i++)
			{
				PingIndicator obj = pingIndicators[i];
				if ((Object)(object)((obj != null) ? ((Component)obj).gameObject : null) != (Object)null)
				{
					((Component)pingIndicators[i]).gameObject.SetActive(visible);
				}
			}
			((Behaviour)cameraRigController.hud.combatHealthBarViewer).enabled = visible;
		}

		private void OnLastActiveControllerChanged(Player player, Controller controller)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0012: 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_0025: Expected I4, but got Unknown
			if (controller != null)
			{
				ControllerType type = controller.type;
				ControllerType val = type;
				switch ((int)val)
				{
				case 0:
					currentInputSource = (InputSource)0;
					break;
				case 1:
					currentInputSource = (InputSource)0;
					break;
				case 2:
					currentInputSource = (InputSource)1;
					break;
				}
			}
		}

		private void Update()
		{
			if (isSteppingTime)
			{
				Time.timeScale = 1f;
			}
			else
			{
				Time.timeScale = 0f;
			}
			if (inputPlayer.GetButton(25))
			{
				ExitPhotoMode();
				return;
			}
			HandleUtilityInputs();
			if (!cursorActive && (!Options.disableCameraWithConsole.Value || !Object.op_Implicit((Object)(object)ConsoleWindow.instance)))
			{
				HandleMovementInputs();
			}
		}

		private void FixedUpdate()
		{
			if (isSteppingTime)
			{
				isSteppingTime = false;
			}
		}

		private void HandleUtilityInputs()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = Options.increaseSpeedKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				cameraSpeed = Mathf.Clamp(cameraSpeed + 0.5f * Time.unscaledDeltaTime * 140f, 0f, 200f);
			}
			value = Options.decreaseSpeedKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				cameraSpeed = Mathf.Clamp(cameraSpeed - 0.5f * Time.unscaledDeltaTime * 140f, 0f, 200f);
			}
			value = Options.stepTime.Value;
			if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
			{
				isSteppingTime = true;
			}
			value = Options.cursorToggleKey.Value;
			if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
			{
				cursorActive = !cursorActive;
			}
			value = Options.stepTime.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				stepTimeHoldDuration += Time.unscaledDeltaTime;
				if (stepTimeHoldDuration > 0.6f)
				{
					isSteppingTime = true;
				}
			}
			else
			{
				stepTimeHoldDuration = 0f;
			}
		}

		private void HandleMovementInputs()
		{
			//IL_0063: 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_006c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			float mouseLookSensitivity = userProfile.mouseLookSensitivity;
			float mouseLookScaleX = userProfile.mouseLookScaleX;
			float mouseLookScaleY = userProfile.mouseLookScaleY;
			float axis = inputPlayer.GetAxis(23);
			float axis2 = inputPlayer.GetAxis(24);
			float num = 1f;
			if (gamepad)
			{
				num = 10f;
			}
			KeyboardShortcut value = Options.defaultFOVKey.Value;
			if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
			{
				cameraState.fov = defaultFov;
			}
			else
			{
				value = Options.adjustFOVKey.Value;
				if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
				{
					cameraState.fov = Mathf.Clamp(camera.fieldOfView + mouseLookSensitivity * axis2 * num, 4f, 120f);
				}
				else if ((gamepad && inputPlayer.GetButton(10)) || Input.GetMouseButton(2))
				{
					cameraState.roll += (0f - mouseLookScaleX) * mouseLookSensitivity * axis * num * 0.01f * 10f;
				}
				else
				{
					float value2 = mouseLookScaleX * mouseLookSensitivity * axis * num * 0.01f;
					float value3 = mouseLookScaleY * mouseLookSensitivity * axis2 * num * 0.01f;
					ConditionalNegate(ref value2, userProfile.mouseLookInvertX);
					ConditionalNegate(ref value3, userProfile.mouseLookInvertY);
					float num2 = cameraState.roll * (MathF.PI / 180f);
					cameraState.yaw += cameraState.fov * (value2 * Mathf.Cos(num2) - value3 * Mathf.Sin(num2));
					cameraState.pitch += cameraState.fov * ((0f - value3) * Mathf.Cos(num2) - value2 * Mathf.Sin(num2));
					cameraState.pitch = Mathf.Clamp(cameraState.pitch, -90f, 90f);
				}
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(inputPlayer.GetAxis(0) * num, 0f, inputPlayer.GetAxis(1) * num);
			if (!gamepad || !inputPlayer.GetButton(7))
			{
				value = Options.cameraDownKey.Value;
				if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
				{
					goto IL_0298;
				}
			}
			val.y -= 1f;
			goto IL_0298;
			IL_02e1:
			((Vector3)(ref val)).Normalize();
			value = Options.cameraFastKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				val *= Options.fastMult.Value;
			}
			value = Options.cameraSlowKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
			{
				val *= Options.slowMult.Value;
			}
			ref Vector3 position = ref cameraState.position;
			position += cameraState.Rotation * val * Time.unscaledDeltaTime * cameraSpeed;
			((Component)camera).transform.position = cameraState.position;
			Quaternion val2 = cameraState.Rotation;
			if ((double)Mathf.Abs(((Quaternion)(ref val2)).eulerAngles.z) < 2.0)
			{
				val2 = val2.WithEulerAngles(null, null, 0f);
			}
			((Component)camera).transform.rotation = val2;
			camera.fieldOfView = cameraState.fov;
			return;
			IL_0298:
			if (!gamepad || !inputPlayer.GetButton(8))
			{
				value = Options.cameraUpKey.Value;
				if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey))
				{
					goto IL_02e1;
				}
			}
			val.y += 1f;
			goto IL_02e1;
		}

		private void OnDisable()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)cameraRigController))
			{
				Player val = cameraRigController.localUserViewer.inputPlayer;
				val.controllers.RemoveLastActiveControllerChangedDelegate(new PlayerActiveControllerChangedDelegate(OnLastActiveControllerChanged));
			}
		}

		private void OnDestroy()
		{
			ExitPhotoMode();
		}

		public void GetCameraState(CameraRigController cameraRigController, ref CameraState cameraState)
		{
		}

		private void ConditionalNegate(ref float value, bool condition)
		{
			value = (condition ? (0f - value) : value);
		}

		public bool IsHudAllowed(CameraRigController cameraRigController)
		{
			return false;
		}

		public bool IsUserControlAllowed(CameraRigController cameraRigController)
		{
			return false;
		}

		public bool IsUserLookAllowed(CameraRigController cameraRigController)
		{
			return false;
		}
	}
	[BepInPlugin("mwmw.PhotoModePlus", "PhotoModePlus", "1.1.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PhotoModePlus : BaseUnityPlugin
	{
		public const string PluginGUID = "mwmw.PhotoModePlus";

		public const string PluginAuthor = "mwmw";

		public const string PluginName = "PhotoModePlus";

		public const string PluginVersion = "1.1.4";

		public static ConfigFile config;

		public void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			config = ((BaseUnityPlugin)this).Config;
			Assets.Init();
			Options.Init();
			PauseScreenController.Awake += new hook_Awake(SetupPhotoModeButton);
			HUD.Update += new Manipulator(SkipScoreboardIfPhotoMode);
		}

		private void SkipScoreboardIfPhotoMode(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel branchAddress = val.DefineLabel();
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(PauseManager), "PauseScreenIsOpen"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref branchAddress)
			}))
			{
				val.EmitDelegate<Func<bool>>((Func<bool>)(() => Object.op_Implicit((Object)(object)PhotoModeController.instance) ? true : false));
				val.Emit(OpCodes.Brtrue, (object)branchAddress);
			}
			else
			{
				Log.Error("SkipScoreboardIfPhotoMode IL hook failed! Pressing the inspect button in Photo Mode will still blur the screen!");
			}
		}

		private void SetupPhotoModeButton(orig_Awake orig, PauseScreenController self)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			orig.Invoke(self);
			GameObject gameObject = ((Component)((Component)self).GetComponentInChildren<ButtonSkinController>()).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
			((Object)val).name = "GenericMenuButton (Photo Mode)";
			val.SetActive(true);
			ButtonSkinController component = val.GetComponent<ButtonSkinController>();
			((Component)component).GetComponent<LanguageTextMeshController>().token = "Photo Mode";
			HGButton component2 = val.GetComponent<HGButton>();
			((MPButton)component2).defaultFallbackButton = false;
			object obj;
			if (CameraRigController.instancesList.Count <= 0)
			{
				obj = null;
			}
			else
			{
				List<CameraRigController> instancesList = CameraRigController.instancesList;
				obj = instancesList[instancesList.Count - 1];
			}
			CameraRigController cameraRigInstance = (CameraRigController)obj;
			((Selectable)component2).interactable = Object.op_Implicit((Object)(object)cameraRigInstance) && cameraRigInstance.localUserViewer != null;
			((UnityEvent)((Button)component2).onClick).AddListener((UnityAction)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				GameObject val2 = new GameObject("PhotoModeController");
				PhotoModeController photoModeController = val2.AddComponent<PhotoModeController>();
				photoModeController.EnterPhotoMode(cameraRigInstance);
			});
			val.transform.SetSiblingIndex(Options.buttonPlacement.Value + 1);
		}
	}
}