Decompiled source of RecordingCameraRedux v1.4.0

recordingcamerareduxv1.4.0.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[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("RecordingCameraRedux")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: AssemblyInformationalVersion("1.4.0+b6dd13c62528e0b834bdc7cbe1ee2acfc75cdfbb")]
[assembly: AssemblyProduct("RecordingCameraRedux")]
[assembly: AssemblyTitle("RecordingCameraRedux")]
[assembly: AssemblyVersion("1.4.0.0")]
namespace RecordingCameraRedux;

[BepInPlugin("com.andromedasidentitycrisis.lethalcompany.recordingcameraredux", "RecordingCameraRedux", "1.4.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<float> moveSpeedResetConfig;

	public static ConfigEntry<float> moveSpeedConfig;

	public static ConfigEntry<float> moveSpeedUpConfig;

	public static ConfigEntry<float> moveSpeedDownConfig;

	public static ConfigEntry<Key> moveForwardKey;

	public static ConfigEntry<Key> moveBackwardKey;

	public static ConfigEntry<Key> moveLeftKey;

	public static ConfigEntry<Key> moveRightKey;

	public static ConfigEntry<Key> moveDownKey;

	public static ConfigEntry<Key> moveUpKey;

	public static ConfigEntry<Key> toggleCameraKey;

	public static ConfigEntry<Key> toggleCameraTypeKey;

	public static ConfigEntry<Key> toggleCameraRotationKey;

	public static ConfigEntry<Key> moveSpeedUpKey;

	public static ConfigEntry<Key> moveSpeedDownKey;

	public static ConfigEntry<Key> resetspeedKey;

	public static ConfigEntry<Key> hidehudKey;

	public static ConfigEntry<Key> savePointLocationKey;

	public static ConfigEntry<Key> stopKeyframeKey;

	public static ConfigEntry<Key> playKeyframeKey;

	public static ConfigEntry<float> keyframeMoveSpeedConfig;

	public static Plugin Instance;

	private GameObject CamMan;

	public void Log(string message)
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)message);
	}

	private void Awake()
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		Instance = this;
		if ((Object)(object)CamMan == (Object)null)
		{
			CamMan = new GameObject("CameraMan");
			CamMan.AddComponent<CameraScript>();
			Object.DontDestroyOnLoad((Object)(object)CamMan);
			Debug.Log((object)"Camera Created.");
			Debug.LogWarning((object)"If the camera is destroyed almost instantly, this is because of Unity. Don't worry, it'll be recreated further within the code.");
			Debug.LogError((object)"If the log mentions a 'missing object' or some other text about missing references, IT IS FINE.");
			Debug.LogError((object)"The mod is trying to call something which does not yet exist, but will when you enter a lobby, nothing is broken:3");
			Debug.LogWarning((object)"With all that being said, I hope you enjoy the mod.");
		}
		string text = "\r\n                                             \r\n       _ _   _      _                        \r\n _ _ _|_| |_| |_   | |___ _ _ ___            \r\n| | | | |  _|   |  | | . | | | -_|_          \r\n|_____|_|_| |_|_|  |_|___|\\_/|___| |         \r\n                                 |_|   _     \r\n           _                     _    | |    \r\n ___ ___ _| |___ ___ _____ ___ _| |___|_|___ \r\n| .'|   | . |  _| . |     | -_| . | .'| |_ -|\r\n|__,|_|_|___|_| |___|_|_|_|___|___|__,| |___|\r\n _   _         _   _ _                       \r\n|_|_| |___ ___| |_|_| |_ _ _                 \r\n| | . | -_|   |  _| |  _| | |                \r\n|_|___|___|_|_|_| |_|_| |_  |                \r\n         _     _        |___|                \r\n ___ ___|_|___|_|___                         \r\n|  _|  _| |_ -| |_ -|                        \r\n|___|_| |_|___|_|___|                        \r\n _ ___                                       \r\n|_|_  |                                      \r\n _|_  |                                      \r\n|_|___|                                      \r\n                                             \r\n            ";
		((BaseUnityPlugin)this).Logger.LogInfo((object)text);
		moveSpeedResetConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Move Speed", "Reset Speed", 0.25f, new ConfigDescription("The Value your speed is reset to upon pressing the Reset Move Speed Key. This value can only be changed here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 5f), Array.Empty<object>()));
		moveSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Move Speed", "Base Move Speed Value", 0.25f, new ConfigDescription("The base movement speed of the camera. Should update between game sessions. (Cannot be below 0.001 or above 5f)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 5f), Array.Empty<object>()));
		moveSpeedUpConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Move Speed", "Move Speed Increase Value", 0.25f, new ConfigDescription("The amount of speed added to the Base Move Speed Value per press of the 'Increase Move Speed' Key. (Cannot be below 0.001 or above 5f)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 5f), Array.Empty<object>()));
		moveSpeedDownConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Move Speed", "Move Speed Decrease Value", 0.25f, new ConfigDescription("The amount oF speed subtracted when you press the 'Decrease Move Speed' Key.(Cannot be below 0.001 or above 5f)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 5f), Array.Empty<object>()));
		moveForwardKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Forward", (Key)35, "Key to move the camera forward.");
		moveBackwardKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Backward", (Key)24, "Key to move the camera backwards.");
		moveLeftKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Left", (Key)22, "Key to move the camera left.");
		moveRightKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Right", (Key)25, "Key to move the camera right.");
		moveUpKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Up", (Key)23, "Key to move the camera up.");
		moveDownKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Move Down", (Key)39, "Key to move the camera down.");
		toggleCameraKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Toggle Camera", (Key)69, "Key to toggle camera on or off.");
		toggleCameraTypeKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Toggle Camera Type", (Key)17, "Key to toggle between different camera types.");
		toggleCameraRotationKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Toggle Camera Rotation", (Key)30, "Key to toggle camera rotation.");
		moveSpeedUpKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Increase Move Speed", (Key)80, "Key to increase movement speed.");
		moveSpeedDownKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Decrease Move Speed", (Key)81, "Key to decrease movement speed.");
		resetspeedKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Reset Move Speed", (Key)89, "Key to reset your move spped back to the base move speed.");
		hidehudKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keybinds", "Hide HUD", (Key)68, "Key to Hide your HUD.");
		savePointLocationKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keyframing", "Keyframe Location", (Key)8, "Key used to save a location for the keyframing feature.");
		stopKeyframeKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keyframing", "Stop Keyframe Playback", (Key)7, "Key used to stop the playback of a keyframe.");
		playKeyframeKey = ((BaseUnityPlugin)this).Config.Bind<Key>("Keyframing", "Start Keyframe Playback", (Key)52, "Key to start the playback of a keyframe.");
		keyframeMoveSpeedConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Keyframing", "Keyframe Move Speed", 0.25f, new ConfigDescription("Speed of camera movement when returning to keyframe.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 5f), Array.Empty<object>()));
	}

	private void OnDestroy()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		if ((Object)(object)CamMan == (Object)null)
		{
			CamMan = new GameObject("CameraMan");
			CamMan.AddComponent<CameraScript>();
			Object.DontDestroyOnLoad((Object)(object)CamMan);
			Debug.LogWarning((object)"The Camera was destroyed. Recreating. EC - 138 - camdestroyedwarning");
		}
	}
}
internal class CameraScript : MonoBehaviour
{
	internal class PluginInfo
	{
		public const string GUID = "com.andromedasidentitycrisis.lethalcompany.recordingcameraredux";

		public const string Name = "RecordingCameraRedux";

		public const string Version = "1.4.0";
	}

	private Camera cam;

	private Camera MainCam;

	private PlayerControllerB me;

	private Renderer HemlRend;

	private GameObject Arms;

	private LODGroup lodg;

	private bool ThirdP;

	private bool Dropped = true;

	private bool Behind;

	private bool CopyRotation;

	private bool hide;

	private bool playerControllerWarningLogged = false;

	public float lerpingSpeed = 2f;

	public float MoveSpeed = Plugin.moveSpeedConfig.Value;

	private Vector3 targetPosition;

	private Vector3 saveKeyframePosition;

	private Quaternion saveKeyframeRotation;

	private bool isKeyframeSaved = false;

	private bool isKeyframePlaying = false;

	private Vector3 Perspective()
	{
		//IL_0032: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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)
		if (Behind)
		{
			return new Vector3(0f, 0f, -2.5f);
		}
		return new Vector3(0f, 0f, 2.5f);
	}

	private Quaternion rotPerspective()
	{
		//IL_0032: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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)
		if (Behind)
		{
			return Quaternion.Euler(0f, 0f, 0f);
		}
		return Quaternion.Euler(0f, 180f, 0f);
	}

	private void Update()
	{
		//IL_0019: 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_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_048b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_041d: Unknown result type (might be due to invalid IL or missing references)
		//IL_042e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		//IL_0556: Unknown result type (might be due to invalid IL or missing references)
		//IL_056b: Unknown result type (might be due to invalid IL or missing references)
		//IL_058c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0592: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0671: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0774: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_078c: Unknown result type (might be due to invalid IL or missing references)
		//IL_079c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_080e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_085b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0826: Unknown result type (might be due to invalid IL or missing references)
		//IL_0836: Unknown result type (might be due to invalid IL or missing references)
		//IL_0841: Unknown result type (might be due to invalid IL or missing references)
		//IL_0846: Unknown result type (might be due to invalid IL or missing references)
		//IL_084b: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0873: Unknown result type (might be due to invalid IL or missing references)
		//IL_0883: Unknown result type (might be due to invalid IL or missing references)
		//IL_088e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0893: Unknown result type (might be due to invalid IL or missing references)
		//IL_0898: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08db: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_094e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0954: Unknown result type (might be due to invalid IL or missing references)
		//IL_0965: Unknown result type (might be due to invalid IL or missing references)
		//IL_090d: Unknown result type (might be due to invalid IL or missing references)
		//IL_091d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0928: Unknown result type (might be due to invalid IL or missing references)
		//IL_092d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0932: Unknown result type (might be due to invalid IL or missing references)
		//IL_0993: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)cam == (Object)null)
			{
				cam = new GameObject("ThridPersonCam").AddComponent<Camera>();
				HemlRend = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel/ScavengerHelmet").GetComponent<Renderer>();
				if ((Object)(object)HemlRend == (Object)null)
				{
					Debug.LogWarning((object)"Helmet not found. You may not be in a lobby. EC - 212 - helmetfendererfail");
				}
				return;
			}
			((Behaviour)cam).enabled = ThirdP;
			if ((Object)(object)HemlRend != (Object)null)
			{
				HemlRend.forceRenderingOff = ThirdP;
			}
			if ((Object)(object)Arms != (Object)null)
			{
				Arms.SetActive(!ThirdP);
			}
			if ((Object)(object)me == (Object)null)
			{
				PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
				if ((array == null || array.Length == 0) && !playerControllerWarningLogged)
				{
					Debug.LogWarning((object)"PlayerControllerB Not Found, Cannot Proceed. Try entering a lobby. EC - 231 playercontrollerblobbyfail");
					playerControllerWarningLogged = true;
				}
				PlayerControllerB[] array2 = array;
				foreach (PlayerControllerB val in array2)
				{
					if (((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
					{
						me = val;
						MainCam = me.gameplayCamera;
						Debug.Log((object)"PlayerControllerB found! Proceeding.");
						playerControllerWarningLogged = false;
						if ((Object)(object)MainCam == (Object)null)
						{
							Debug.LogWarning((object)"Camera doesn't exist at this moment. Try entering a lobby. EC - 244 - maincamlobbyfail");
							break;
						}
						cam.cullingMask = MainCam.cullingMask;
						targetPosition = ((Component)MainCam).transform.position;
						Transform cameraContainerTransform = me.cameraContainerTransform;
						if ((Object)(object)((cameraContainerTransform != null) ? cameraContainerTransform.parent : null) == (Object)null || me.cameraContainerTransform.parent.childCount < 2)
						{
							Debug.LogError((object)"Could not find the camera container. EC - 251 - cameracontainerfail");
							break;
						}
						Arms = ((Component)me.cameraContainerTransform.parent.GetChild(1)).gameObject;
						if ((Object)(object)Arms == (Object)null)
						{
							Debug.LogError((object)"CRITICAL ERROR: Could not find Arms. Cannot proceed. EC - 257 - theydonetookyourfrickinarmsfail");
							break;
						}
						if (((Component)me).transform.childCount == 0)
						{
							Debug.LogError((object)"Transform has no children. ya done gone and lost the baby. EC - 262 - abortionjokefail");
							break;
						}
						lodg = ((Component)((Component)me).transform.GetChild(0)).GetComponent<LODGroup>();
						if ((Object)(object)lodg == (Object)null)
						{
							Debug.LogError((object)"LODGroup not found. EC - 268 - lodgroupfail");
						}
					}
				}
				return;
			}
			if ((Object)(object)me != (Object)null)
			{
				if ((Object)(object)MainCam == (Object)null)
				{
					Debug.LogWarning((object)"The MainCam is not loaded yet, meaning RecordingCameraRedux cannot proceed. Please enter a lobby to continue. EC - 279 - maincamfail");
					return;
				}
				if (me.inTerminalMenu && me.isTypingChat)
				{
					return;
				}
				if (me.isPlayerDead)
				{
					ThirdP = false;
					hide = false;
				}
			}
			if (((ButtonControl)Keyboard.current[Plugin.toggleCameraKey.Value]).wasPressedThisFrame)
			{
				ThirdP = !ThirdP;
				if (ThirdP)
				{
					lodg.ForceLOD(1);
				}
				else
				{
					lodg.enabled = false;
					lodg.enabled = true;
				}
			}
			if (((ButtonControl)Keyboard.current[Plugin.toggleCameraTypeKey.Value]).wasPressedThisFrame)
			{
				Dropped = !Dropped;
				SwitchCamState();
			}
			if (((ButtonControl)Keyboard.current[Plugin.savePointLocationKey.Value]).wasPressedThisFrame)
			{
				saveKeyframePosition = ((Component)cam).transform.position;
				saveKeyframeRotation = ((Component)cam).transform.rotation;
				isKeyframeSaved = true;
				Debug.Log((object)"Location & Rotation saved. Ready for playback.");
				Debug.Log((object)$"The Saved Position is now: {saveKeyframePosition}");
				Debug.Log((object)$"The Saved Rotation is now: {saveKeyframeRotation}");
			}
			if (((ButtonControl)Keyboard.current[Plugin.playKeyframeKey.Value]).wasPressedThisFrame && isKeyframeSaved)
			{
				if ((Object)(object)cam == (Object)null)
				{
					Debug.LogWarning((object)"Camera isn't alive. Cannot playback. Camera is not be alive, my dude. EC - 324 - keyframenocamfail");
					return;
				}
				if (!isKeyframeSaved)
				{
					Debug.LogWarning((object)"No keyframe has been saved yet. EC - 329 - nokeyframesavedfail");
					return;
				}
				if ((Object)(object)((Component)cam).transform == (Object)null)
				{
					Debug.LogError((object)"The camera's position & rotation were not logged correctly. EC - 334 - camsavefail");
					return;
				}
				isKeyframePlaying = true;
				Debug.Log((object)"Initiating playback.");
			}
			if (isKeyframePlaying)
			{
				((Component)cam).transform.position = Vector3.Lerp(((Component)cam).transform.position, saveKeyframePosition, Time.deltaTime * Plugin.keyframeMoveSpeedConfig.Value);
				((Component)cam).transform.rotation = Quaternion.Lerp(((Component)cam).transform.rotation, saveKeyframeRotation, Time.deltaTime * Plugin.keyframeMoveSpeedConfig.Value);
				if (((ButtonControl)Keyboard.current[Plugin.stopKeyframeKey.Value]).wasPressedThisFrame)
				{
					isKeyframePlaying = false;
					Debug.Log((object)"Playback stopped.");
				}
				return;
			}
			if (((ButtonControl)Keyboard.current[Plugin.moveSpeedUpKey.Value]).wasPressedThisFrame)
			{
				ConfigEntry<float> moveSpeedConfig = Plugin.moveSpeedConfig;
				moveSpeedConfig.Value += Plugin.moveSpeedUpConfig.Value;
				MoveSpeed = Plugin.moveSpeedConfig.Value;
				((BaseUnityPlugin)Plugin.Instance).Config.Save();
				Plugin.Instance.Log($"Move Speed increased to: {MoveSpeed}");
			}
			if (((ButtonControl)Keyboard.current[Plugin.moveSpeedDownKey.Value]).wasPressedThisFrame)
			{
				ConfigEntry<float> moveSpeedConfig2 = Plugin.moveSpeedConfig;
				moveSpeedConfig2.Value -= Plugin.moveSpeedDownConfig.Value;
				MoveSpeed = Plugin.moveSpeedConfig.Value;
				((BaseUnityPlugin)Plugin.Instance).Config.Save();
				Plugin.Instance.Log($"Move Speed decreased to: {MoveSpeed}");
			}
			if (((ButtonControl)Keyboard.current[Plugin.resetspeedKey.Value]).wasPressedThisFrame)
			{
				Plugin.moveSpeedConfig.Value = Plugin.moveSpeedResetConfig.Value;
				MoveSpeed = Plugin.moveSpeedConfig.Value;
				((BaseUnityPlugin)Plugin.Instance).Config.Save();
				Plugin.Instance.Log($"Move Speed Reset to: {MoveSpeed}");
			}
			if (Dropped)
			{
				if (((ButtonControl)Keyboard.current[Plugin.moveForwardKey.Value]).isPressed)
				{
					targetPosition += ((Component)cam).transform.forward * MoveSpeed;
				}
				if (((ButtonControl)Keyboard.current[Plugin.moveBackwardKey.Value]).isPressed)
				{
					targetPosition -= ((Component)cam).transform.forward * MoveSpeed;
				}
				if (((ButtonControl)Keyboard.current[Plugin.moveRightKey.Value]).isPressed)
				{
					targetPosition += ((Component)cam).transform.right * MoveSpeed;
				}
				if (((ButtonControl)Keyboard.current[Plugin.moveLeftKey.Value]).isPressed)
				{
					targetPosition -= ((Component)cam).transform.right * MoveSpeed;
				}
				if (((ButtonControl)Keyboard.current[Plugin.moveUpKey.Value]).isPressed)
				{
					targetPosition += ((Component)cam).transform.up * MoveSpeed;
				}
				if (((ButtonControl)Keyboard.current[Plugin.moveDownKey.Value]).isPressed)
				{
					targetPosition -= ((Component)cam).transform.up * MoveSpeed;
				}
				((Component)cam).transform.position = Vector3.Lerp(((Component)cam).transform.position, targetPosition, lerpingSpeed * Time.deltaTime);
				if (CopyRotation)
				{
					((Component)cam).transform.rotation = ((Component)MainCam).transform.rotation;
				}
			}
			if (((ButtonControl)Keyboard.current[Plugin.toggleCameraRotationKey.Value]).wasPressedThisFrame)
			{
				if (Dropped)
				{
					CopyRotation = !CopyRotation;
					SwitchCamState();
				}
				else
				{
					Behind = !Behind;
					SwitchCamState();
				}
			}
			if (((ButtonControl)Keyboard.current[Plugin.hidehudKey.Value]).wasPressedThisFrame)
			{
				if (Object.op_Implicit((Object)(object)me) && (Object)(object)me.playerHudUIContainer != (Object)null)
				{
					hide = !hide;
					((Transform)((Component)me.playerHudUIContainer).GetComponent<RectTransform>()).localPosition = Hide();
				}
				else
				{
					Debug.LogWarning((object)"Cannot hide Hud, Hud UI does not exist right now. You could be out of the lobby. EC - 434 - huduifail");
				}
			}
		}
		catch (Exception ex)
		{
			string text = "An error occurred: " + ex.Message + "\n EC - 440 - catch" + $"Target Site: {ex.TargetSite}\n" + "Stack Trace: " + ex.StackTrace;
			if (ex.InnerException != null)
			{
				text = text + "\nInner Exception: " + ex.InnerException.Message;
			}
			Debug.LogError((object)text);
		}
	}

	private Vector3 Hide()
	{
		//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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (hide)
		{
			return new Vector3(0f, 5555f, 0f);
		}
		return Vector3.zero;
	}

	private void SwitchCamState()
	{
		//IL_003f: 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_0087: 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)
		if (!((Object)(object)cam == (Object)null))
		{
			if (Dropped)
			{
				((Component)cam).transform.parent = null;
				targetPosition = ((Component)cam).transform.position;
			}
			else if ((Object)(object)MainCam != (Object)null)
			{
				((Component)cam).transform.SetParent(((Component)MainCam).transform, false);
				((Component)cam).transform.localRotation = rotPerspective();
				((Component)cam).transform.localPosition = Perspective();
				Debug.Log((object)"Switching Cam State.");
			}
			else
			{
				Debug.LogWarning((object)"The Camera doesn't exist at the moment. You could be out of the lobby. EC - 483 - failcamswitch");
			}
		}
	}
}