Decompiled source of CameraFPSChanger v1.0.0

CameraFPSChanger.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Zorro.Recorder;

[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("CameraFPSChanger")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CameraFPSChanger")]
[assembly: AssemblyTitle("CameraFPSChanger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CameraFPSChanger
{
	[BepInPlugin("CameraFPSChanger", "CameraFPSChanger", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<byte> configFPS;

		internal static ManualLogSource log;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			log = ((BaseUnityPlugin)this).Logger;
			configFPS = ((BaseUnityPlugin)this).Config.Bind<byte>("Camera", "fps", (byte)24, "Camera's fps. May cause failure to extract if all clips aren't at the same FPS. Requires full restart to apply");
			Harmony val = new Harmony("com.wackery.CameraFPSChanger");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CameraFPSChanger is loaded!");
		}
	}
	[HarmonyPatch(typeof(VideoCamera), "StartRecording")]
	public static class RecordFPS_Patch
	{
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			bool flag = false;
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(list[i], (object)24))
				{
					list[i].operand = (int)Plugin.configFPS.Value;
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				Plugin.log.LogWarning((object)"We were unable to patch StartRecording.");
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch(typeof(FfmpegEncoder), "Encode")]
	public static class EncodeFPS_Patch
	{
		public static void Prefix(ref byte framerate, ref FfmpegDeadline deadline)
		{
			framerate = Plugin.configFPS.Value;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CameraFPSChanger";

		public const string PLUGIN_NAME = "CameraFPSChanger";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}