Decompiled source of PeakCam v0.1.0

plugins/com.github.TomuraTheActual.PeakCam.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.TomuraTheActual.PeakCam")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.TomuraTheActual.PeakCam")]
[assembly: AssemblyTitle("PeakCam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
[BepInPlugin("com", "tomuratheactual", "1.0.0")]
public class PeakCamTheBetter : BaseUnityPlugin
{
	private ManualLogSource log;

	private Camera? cam;

	private bool isRecording;

	private bool muted;

	private int camMode;

	private Transform? player;

	private GameObject? peakCamObject;

	private void Awake()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[PeakCamPlugin] Plugin initializing...");
		peakCamObject = new GameObject("PeakCamObject");
		peakCamObject.AddComponent<PeakCamTheBetter>();
		Object.DontDestroyOnLoad((Object)(object)peakCamObject);
		log = Logger.CreateLogSource("PeakCam");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[PeakCamPlugin] PeakCam initialized.");
	}

	public void InitializeLogger(ManualLogSource logger)
	{
		log = logger;
	}

	private void Start()
	{
		cam = Camera.main;
		if ((Object)(object)cam == (Object)null)
		{
			log.LogWarning((object)"[PeakCam] Could not find main Camera!");
		}
		GameObject obj = GameObject.FindWithTag("Player");
		player = ((obj != null) ? obj.transform : null);
		if ((Object)(object)player == (Object)null)
		{
			log.LogWarning((object)"[PeakCam] Could not find Player with tag 'Player'.");
		}
		else
		{
			log.LogInfo((object)("[PeakCam] Found player object: " + ((Object)player).name));
		}
	}

	private void Update()
	{
		//IL_00d9: 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_010d: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: 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_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)282))
		{
			camMode = (camMode + 1) % 4;
		}
		if (Input.GetKeyDown((KeyCode)114))
		{
			isRecording = !isRecording;
		}
		if (Input.GetKeyDown((KeyCode)109))
		{
			muted = !muted;
		}
		if (isRecording)
		{
			ManualLogSource obj = log;
			if (obj != null)
			{
				obj.LogDebug((object)"[PeakCam] Recording...");
			}
		}
		if (muted)
		{
			ManualLogSource obj2 = log;
			if (obj2 != null)
			{
				obj2.LogDebug((object)"[PeakCam] Microphone muted.");
			}
		}
		if ((Object)(object)cam != (Object)null && (Object)(object)player != (Object)null)
		{
			switch (camMode)
			{
			case 0:
				((Component)cam).transform.position = player.position + new Vector3(0f, 1.6f, 0f);
				((Component)cam).transform.rotation = player.rotation;
				break;
			case 1:
				((Component)cam).transform.position = player.position + player.forward * 2f + Vector3.up * 1.6f;
				((Component)cam).transform.LookAt(player);
				break;
			case 2:
				((Component)cam).transform.position = player.position - player.forward * 2f + Vector3.up * 1.6f;
				((Component)cam).transform.LookAt(player);
				break;
			case 3:
				((Component)cam).transform.position = Vector3.Lerp(((Component)cam).transform.position, player.position + new Vector3(0f, 2f, -3f), Time.deltaTime * 5f);
				((Component)cam).transform.LookAt(player);
				break;
			}
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakCam
{
	[BepInPlugin("com.github.TomuraTheActual.PeakCam", "PeakCam", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.github.TomuraTheActual.PeakCam");

		public const string Id = "com.github.TomuraTheActual.PeakCam";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PeakCam";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			harmony.PatchAll();
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}