Decompiled source of RemoveZoomOut v1.0.0

plugins/RemoveZoomOut/RemoveZoomOut.dll

Decompiled a week 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.Configuration;
using BepInEx.Logging;
using HG.BlendableTypes;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.ContentManagement;
using RoR2BepInExPack.GameAssetPaths;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RemoveZoomOut")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f8092d517f41f2d3edf9eccccc4148e4af9b9ba6")]
[assembly: AssemblyProduct("RemoveZoomOut")]
[assembly: AssemblyTitle("RemoveZoomOut")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 RemoveZoomOut
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("RemoveZoomOut");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "RemoveZoomOut".Length + 1);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("Nuxlar.RemoveZoomOut", "RemoveZoomOut", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "Nuxlar.RemoveZoomOut";

		public const string PluginAuthor = "Nuxlar";

		public const string PluginName = "RemoveZoomOut";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<bool> changeSeekerUtil;

		public static ConfigEntry<bool> changeSeekerSec;

		public static ConfigEntry<bool> changeFSUtil;

		public static ConfigEntry<bool> changeEgg;

		internal static Main Instance { get; private set; }

		public static string PluginDirectory { get; private set; }

		private static ConfigFile RZOConfig { get; set; }

		public void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			RZOConfig = new ConfigFile(Paths.ConfigPath + "\\com.Nuxlar.RemoveZoomOut.cfg", true);
			changeEgg = RZOConfig.Bind<bool>("General", "Change Egg Zoom", true, "Reduces camera zoom out on the Volcanic Egg equipment.");
			changeFSUtil = RZOConfig.Bind<bool>("General", "Change False Son Zoom", true, "Removes camera zoom out when aiming False Son's alt utility.");
			changeSeekerSec = RZOConfig.Bind<bool>("General", "Change Seeker Sec Zoom", true, "Removes camera zoom out when aiming Seeker's secondary Unseen Hand.");
			changeSeekerUtil = RZOConfig.Bind<bool>("General", "Change Seeker Util Zoom", true, "Removes camera zoom out when using Seeker's utility (both).");
			LoadAssets();
			if (changeSeekerSec.Value)
			{
				TweakEntityState(RoR2_DLC2_Seeker_EntityStates_Seeker.UnseenHand_asset, "abilityAimType", "3");
			}
			if (changeFSUtil.Value)
			{
				TweakEntityState(RoR2_DLC2_FalseSon_EntityStates_FalseSon.AimMeridiansWill_asset, "cameraTeleportPositionOffset", "0 0 -3");
			}
		}

		private void TweakEntityState(string path, string fieldName, string value)
		{
			//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)
			AsyncOperationHandle<EntityStateConfiguration> val = AssetAsyncReferenceManager<EntityStateConfiguration>.LoadAsset(new AssetReferenceT<EntityStateConfiguration>(path), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<EntityStateConfiguration> x)
			{
				EntityStateConfiguration result = x.Result;
				for (int i = 0; i < result.serializedFieldsCollection.serializedFields.Length; i++)
				{
					if (result.serializedFieldsCollection.serializedFields[i].fieldName == fieldName)
					{
						result.serializedFieldsCollection.serializedFields[i].fieldValue.stringValue = value;
					}
				}
			};
		}

		private static void LoadAssets()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			if (changeEgg.Value)
			{
				AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Base_FireBallDash.FireballVehicle_prefab), (AsyncReferenceHandleUnloadType)2);
				val.Completed += delegate(AsyncOperationHandle<GameObject> x)
				{
					//IL_0025: 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)
					x.Result.GetComponent<CameraTargetParams>().cameraParams.data.idealLocalCameraPos = BlendableVector3.op_Implicit(new Vector3(0f, 2f, -15f));
				};
			}
			if (changeSeekerUtil.Value)
			{
				AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_DLC2_Seeker_SojournVehicle.SojournVehicle_prefab), (AsyncReferenceHandleUnloadType)2);
				val.Completed += delegate(AsyncOperationHandle<GameObject> x)
				{
					//IL_0025: 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)
					x.Result.GetComponent<CameraTargetParams>().cameraParams.data.idealLocalCameraPos = BlendableVector3.op_Implicit(new Vector3(0f, 0f, -15f));
				};
			}
		}
	}
}