Decompiled source of PhotoModePlus v1.1.1

PhotoModePlus.dll

Decompiled 16 hours 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 System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
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+0cc52bbabc33d994fd3f0da9cef76bc6986c8f68")]
[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<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)
			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.");
			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_00b3: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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 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;
				}
			}
		}

		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;

		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private EmptyDelegate m_OnExit;

		private CursorOpener cursorOpener;

		private bool _cursorActive;

		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 EmptyDelegate OnExit
		{
			[CompilerGenerated]
			add
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				EmptyDelegate val = this.m_OnExit;
				EmptyDelegate val2;
				do
				{
					val2 = val;
					EmptyDelegate value2 = (EmptyDelegate)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnExit, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				EmptyDelegate val = this.m_OnExit;
				EmptyDelegate val2;
				do
				{
					val2 = val;
					EmptyDelegate value2 = (EmptyDelegate)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnExit, value2, val2);
				}
				while (val != val2);
			}
		}

		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 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()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			((Behaviour)cameraRigController.hud.mainContainer.GetComponent<Canvas>()).enabled = false;
			OnExit += (EmptyDelegate)delegate
			{
				((Behaviour)cameraRigController.hud.mainContainer.GetComponent<Canvas>()).enabled = true;
			};
			if (Options.disableIndicators.Value)
			{
				SetIndicatorsVisible(visible: false);
				OnExit += (EmptyDelegate)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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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 = 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()
		{
			EmptyDelegate obj = this.OnExit;
			if (obj != null)
			{
				obj.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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: 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_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			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;
			}
			if ((gamepad && inputPlayer.GetButton(10)) || Input.GetMouseButton(2))
			{
				cameraState.roll += (0f - mouseLookScaleX) * mouseLookSensitivity * axis * num * 0.01f * 10f;
			}
			else
			{
				float value = mouseLookScaleX * mouseLookSensitivity * axis * num * 0.01f;
				float value2 = mouseLookScaleY * mouseLookSensitivity * axis2 * num * 0.01f;
				ConditionalNegate(ref value, userProfile.mouseLookInvertX);
				ConditionalNegate(ref value2, userProfile.mouseLookInvertY);
				float num2 = cameraState.roll * (MathF.PI / 180f);
				cameraState.yaw += cameraState.fov * (value * Mathf.Cos(num2) - value2 * Mathf.Sin(num2));
				cameraState.pitch += cameraState.fov * ((0f - value2) * Mathf.Cos(num2) - value * 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);
			KeyboardShortcut value3;
			if (!gamepad || !inputPlayer.GetButton(7))
			{
				value3 = Options.cameraDownKey.Value;
				if (!Input.GetKey(((KeyboardShortcut)(ref value3)).MainKey))
				{
					goto IL_0210;
				}
			}
			val.y -= 1f;
			goto IL_0210;
			IL_0210:
			if (!gamepad || !inputPlayer.GetButton(8))
			{
				value3 = Options.cameraUpKey.Value;
				if (!Input.GetKey(((KeyboardShortcut)(ref value3)).MainKey))
				{
					goto IL_0259;
				}
			}
			val.y += 1f;
			goto IL_0259;
			IL_0259:
			((Vector3)(ref val)).Normalize();
			value3 = Options.cameraFastKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value3)).MainKey))
			{
				val *= Options.fastMult.Value;
			}
			value3 = Options.cameraSlowKey.Value;
			if (Input.GetKey(((KeyboardShortcut)(ref value3)).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;
		}

		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.1")]
	[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.1";

		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
			Log.Init(((BaseUnityPlugin)this).Logger);
			config = ((BaseUnityPlugin)this).Config;
			Assets.Init();
			Options.Init();
			PauseScreenController.Awake += new hook_Awake(SetupPhotoModeButton);
		}

		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);
		}
	}
}