Decompiled source of RecordingCamera v1.3.2

BepInEx/plugins/RecordingCamera.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
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("RecordingCamera")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b6dd13c62528e0b834bdc7cbe1ee2acfc75cdfbb")]
[assembly: AssemblyProduct("RecordingCamera")]
[assembly: AssemblyTitle("RecordingCamera")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RecordingCamera;

[BepInPlugin("com.graze.gorillatag.placeablecamera", "RecordingCamera", "1.3.1")]
public class Plugin : BaseUnityPlugin
{
	private GameObject CamMan;

	private void Update()
	{
		//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);
			Object.Destroy((Object)(object)this);
		}
	}

	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);
		}
	}
}
internal class CameraScript : MonoBehaviour
{
	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 CopyRottation;

	private bool hide;

	public float MoveSpeed = 0.22f;

	public float lerpingSpeed = 3f;

	private Vector3 targetPosition;

	private Vector3 Perspective()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_003b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_003b: 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_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: 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_030f: 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_0337: 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_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: 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>();
				return;
			}
			((Behaviour)cam).enabled = ThirdP;
			HemlRend.forceRenderingOff = ThirdP;
			if ((Object)(object)Arms != (Object)null)
			{
				Arms.SetActive(!ThirdP);
			}
			if ((Object)(object)me == (Object)null)
			{
				PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
				foreach (PlayerControllerB val in array)
				{
					if (((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
					{
						me = val;
						MainCam = me.gameplayCamera;
						cam.cullingMask = MainCam.cullingMask;
						targetPosition = ((Component)MainCam).transform.position;
						Arms = ((Component)me.cameraContainerTransform.parent.GetChild(1)).gameObject;
						lodg = ((Component)((Component)me).transform.GetChild(0)).GetComponent<LODGroup>();
					}
				}
			}
			else
			{
				if (me.inTerminalMenu && me.isTypingChat)
				{
					return;
				}
				if (me.isPlayerDead)
				{
					ThirdP = false;
					hide = false;
				}
				if (((ButtonControl)Keyboard.current.endKey).wasPressedThisFrame)
				{
					ThirdP = !ThirdP;
					if (ThirdP)
					{
						lodg.ForceLOD(1);
					}
					else
					{
						lodg.enabled = false;
						lodg.enabled = true;
					}
				}
				if (((ButtonControl)Keyboard.current.cKey).wasPressedThisFrame)
				{
					Dropped = !Dropped;
					SwitchCamState();
				}
				if (Dropped)
				{
					if (((ButtonControl)Keyboard.current.uKey).isPressed)
					{
						targetPosition += ((Component)cam).transform.forward * MoveSpeed;
					}
					if (((ButtonControl)Keyboard.current.jKey).isPressed)
					{
						targetPosition -= ((Component)cam).transform.forward * MoveSpeed;
					}
					if (((ButtonControl)Keyboard.current.kKey).isPressed)
					{
						targetPosition += ((Component)cam).transform.right * MoveSpeed;
					}
					if (((ButtonControl)Keyboard.current.hKey).isPressed)
					{
						targetPosition -= ((Component)cam).transform.right * MoveSpeed;
					}
					if (((ButtonControl)Keyboard.current.iKey).isPressed)
					{
						targetPosition += ((Component)cam).transform.up * MoveSpeed;
					}
					if (((ButtonControl)Keyboard.current.yKey).isPressed)
					{
						targetPosition -= ((Component)cam).transform.up * MoveSpeed;
					}
					((Component)cam).transform.position = Vector3.Lerp(((Component)cam).transform.position, targetPosition, lerpingSpeed * Time.deltaTime);
					if (CopyRottation)
					{
						((Component)cam).transform.rotation = ((Component)MainCam).transform.rotation;
					}
				}
				if (((ButtonControl)Keyboard.current.pKey).wasPressedThisFrame)
				{
					if (Dropped)
					{
						CopyRottation = !CopyRottation;
						SwitchCamState();
					}
					else
					{
						Behind = !Behind;
						SwitchCamState();
					}
				}
				if (((ButtonControl)Keyboard.current.homeKey).isPressed)
				{
					hide = !hide;
					((Transform)((Component)me.playerHudUIContainer).GetComponent<RectTransform>()).localPosition = Hide();
				}
			}
		}
		catch
		{
		}
	}

	private Vector3 Hide()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_002c: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		if (Dropped)
		{
			((Component)cam).transform.parent = null;
			targetPosition = ((Component)cam).transform.position;
		}
		else
		{
			((Component)cam).transform.SetParent(((Component)MainCam).transform, false);
			((Component)cam).transform.localRotation = rotPerspective();
			((Component)cam).transform.localPosition = Perspective();
		}
	}
}
internal class PluginInfo
{
	public const string GUID = "com.graze.gorillatag.placeablecamera";

	public const string Name = "RecordingCamera";

	public const string Version = "1.3.1";
}