Decompiled source of CameraToolsPlugin v3.4.0

CameraToolsPlugin.dll

Decompiled a week ago
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CameraToolsPlugin.Patches;
using HarmonyLib;
using PluginUtilities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CameraToolsPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HolloFox modding")]
[assembly: AssemblyProduct("CameraToolsPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("3.4.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("3.4.0.0")]
namespace CameraToolsPlugin
{
	[BepInPlugin("org.hollofox.plugins.CameraToolsPlugin", "Camera Tools Plug-In", "3.4.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CameraToolsPlugin : DependencyUnityPlugin
	{
		public const string Guid = "org.hollofox.plugins.CameraToolsPlugin";

		internal const string Version = "3.4.0.0";

		internal static ManualLogSource logSource;

		private Harmony harmony;

		internal static ConfigEntry<float> MinTilt { get; set; }

		internal static ConfigEntry<float> MaxTilt { get; set; }

		protected override void OnAwake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			logSource = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"In Awake for Camera Tools");
			ConfigDescription val = new ConfigDescription("", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationAttributes
			{
				CallbackAction = UpdateTiltFromConfig
			} });
			ConfigDescription val2 = new ConfigDescription("", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationAttributes
			{
				CallbackAction = UpdateTiltFromConfig
			} });
			MinTilt = ((BaseUnityPlugin)this).Config.Bind<float>("Tilt Limit", "minimum", -124f, val);
			MaxTilt = ((BaseUnityPlugin)this).Config.Bind<float>("Tilt Limit", "maximum", 53f, val2);
			((BaseUnityPlugin)this).Logger.LogDebug((object)"CameraTools Plug-in loaded");
			harmony = new Harmony("org.hollofox.plugins.CameraToolsPlugin");
			harmony.PatchAll();
			RootTargetCameraModeAwakePatch.instance = Object.FindAnyObjectByType<RootTargetCameraMode>();
			if ((Object)(object)RootTargetCameraModeAwakePatch.instance != (Object)null)
			{
				RootTargetCameraModeAwakePatch.UpdateTilt(MinTilt.Value, MaxTilt.Value);
			}
		}

		private void UpdateTiltFromConfig(object o)
		{
			RootTargetCameraModeAwakePatch.UpdateTilt(MinTilt.Value, MaxTilt.Value);
		}

		protected override void OnDestroyed()
		{
			if ((Object)(object)RootTargetCameraModeAwakePatch.instance != (Object)null)
			{
				RootTargetCameraModeAwakePatch.UpdateTilt(-18f, 42f);
			}
			RootTargetCameraModeAwakePatch.instance = null;
			harmony.UnpatchSelf();
		}
	}
}
namespace CameraToolsPlugin.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("CameraToolsPlugin.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace CameraToolsPlugin.Patches
{
	[HarmonyPatch(typeof(RootTargetCameraMode), "Awake")]
	internal class RootTargetCameraModeAwakePatch
	{
		internal static RootTargetCameraMode instance;

		internal static void Postfix(RootTargetCameraMode __instance, ref float ___maxTilt, ref float ___minTilt)
		{
			instance = __instance;
			___minTilt = CameraToolsPlugin.MinTilt.Value;
			___maxTilt = CameraToolsPlugin.MaxTilt.Value;
		}

		internal static void UpdateTilt(float min, float max)
		{
			if (!((Object)(object)instance == (Object)null))
			{
				typeof(RootTargetCameraMode).GetField("minTilt", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, min);
				typeof(RootTargetCameraMode).GetField("maxTilt", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(instance, max);
			}
		}
	}
}