Decompiled source of MiniV1 v1.1.0

MiniV1.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MiniV1;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;

[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("MiniV1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("MiniV1")]
[assembly: AssemblyTitle("MiniV1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class util
{
	public static T CallPrivate<T>(object instance, Type classType, string method, object[] args)
	{
		MethodInfo method2 = classType.GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		return (T)method2.Invoke(instance, args);
	}

	public static Texture2D LoadEmbeddedTexture(string resourceName)
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
		if (stream == null)
		{
			Plugin.Logger.LogError((object)("Embedded resource '" + resourceName + "' not found"));
			return null;
		}
		byte[] array = new byte[stream.Length];
		stream.Read(array, 0, array.Length);
		Texture2D val = new Texture2D(2, 2);
		if (ImageConversion.LoadImage(val, array))
		{
			return val;
		}
		Plugin.Logger.LogError((object)"Failed to load embedded texture");
		return null;
	}
}
namespace MiniV1Patches
{
	[HarmonyPatch(typeof(CameraController))]
	public class CameraControllerPatch
	{
		public static float GetCameraPos(float mult)
		{
			return 2.5f * (1f / mult) - 1.1f;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CameraController), "Update")]
		public static void UpdatePrefix(ref CameraController __instance, ref Vector3 ___targetPos)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			if (!__instance.pm.sliding)
			{
				__instance.originalPos = new Vector3(0f, GetCameraPos(Plugin.multiplier.value), 0f);
			}
			if (Plugin.multiplier.value >= 3f)
			{
				___targetPos = __instance.originalPos;
				__instance.defaultPos = __instance.originalPos;
				__instance.defaultTarget = __instance.originalPos;
			}
		}
	}
	[HarmonyPatch(typeof(NewMovement))]
	public class NewMovementPatch
	{
		[CompilerGenerated]
		private sealed class <FixedUpdateTranspiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			private IEnumerator<CodeInstruction> <>s__1;

			private CodeInstruction <code>5__2;

			CodeInstruction IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FixedUpdateTranspiler>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>s__1 = null;
				<code>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>s__1 = instructions.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<code>5__2 = null;
						break;
					}
					if (<>s__1.MoveNext())
					{
						<code>5__2 = <>s__1.Current;
						if (<code>5__2.opcode == OpCodes.Ldc_R4 && (float)<code>5__2.operand == 10f)
						{
							<code>5__2.operand = 10f / Mathf.Pow(2f, Mathf.Log10(Plugin.multiplier.value));
						}
						<>2__current = <code>5__2;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>s__1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>s__1 != null)
				{
					<>s__1.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<FixedUpdateTranspiler>d__1 <FixedUpdateTranspiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<FixedUpdateTranspiler>d__ = this;
				}
				else
				{
					<FixedUpdateTranspiler>d__ = new <FixedUpdateTranspiler>d__1(0);
				}
				<FixedUpdateTranspiler>d__.instructions = <>3__instructions;
				return <FixedUpdateTranspiler>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		[CompilerGenerated]
		private sealed class <UpdateTranspiler>d__2 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			private IEnumerator<CodeInstruction> <>s__1;

			private CodeInstruction <code>5__2;

			CodeInstruction IEnumerator<CodeInstruction>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <UpdateTranspiler>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>s__1 = null;
				<code>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>s__1 = instructions.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<code>5__2 = null;
						break;
					}
					if (<>s__1.MoveNext())
					{
						<code>5__2 = <>s__1.Current;
						if (<code>5__2.opcode == OpCodes.Ldc_R4 && (float)<code>5__2.operand == 0.625f)
						{
							<code>5__2.operand = ((Plugin.multiplier.value < 3f) ? (0.625f / Plugin.multiplier.value) : 0f);
						}
						<>2__current = <code>5__2;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>s__1 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>s__1 != null)
				{
					<>s__1.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<UpdateTranspiler>d__2 <UpdateTranspiler>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<UpdateTranspiler>d__ = this;
				}
				else
				{
					<UpdateTranspiler>d__ = new <UpdateTranspiler>d__2(0);
				}
				<UpdateTranspiler>d__.instructions = <>3__instructions;
				return <UpdateTranspiler>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(NewMovement), "Update")]
		public static void UpdatePostfix(ref NewMovement __instance)
		{
			float num = Mathf.Pow(2f, Mathf.Log10(Plugin.multiplier.value));
			__instance.walkSpeed = 750f / num;
			__instance.jumpPower = 90f / num;
			__instance.wallJumpPower = 150f / num;
			__instance.airAcceleration = 6000f / num;
		}

		[IteratorStateMachine(typeof(<FixedUpdateTranspiler>d__1))]
		[HarmonyTranspiler]
		[HarmonyPatch(typeof(NewMovement), "FixedUpdate")]
		public static IEnumerable<CodeInstruction> FixedUpdateTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FixedUpdateTranspiler>d__1(-2)
			{
				<>3__instructions = instructions
			};
		}

		[IteratorStateMachine(typeof(<UpdateTranspiler>d__2))]
		[HarmonyTranspiler]
		[HarmonyPatch(typeof(NewMovement), "Update")]
		public static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <UpdateTranspiler>d__2(-2)
			{
				<>3__instructions = instructions
			};
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(NewMovement), "StartSlide")]
		public static void StartSlidePrefix(ref NewMovement __instance)
		{
			//IL_0052: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			__instance.cc.originalPos = ((Plugin.multiplier.value < 3f) ? __instance.cc.originalPos : (__instance.cc.originalPos + new Vector3(0f, 9f / Plugin.multiplier.value, 0f)));
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(NewMovement), "StopSlide")]
		public static void StopSlidePrefix(ref NewMovement __instance)
		{
			//IL_0052: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			__instance.cc.originalPos = ((Plugin.multiplier.value < 3f) ? __instance.cc.originalPos : (__instance.cc.originalPos - new Vector3(0f, 9f / Plugin.multiplier.value, 0f)));
		}
	}
	[HarmonyPatch(typeof(PlatformerMovement), "Update")]
	public class PlatformerMovementPatch
	{
		public static void Postfix(ref PlatformerMovement __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			((Component)__instance).transform.localScale = new Vector3(0.8f, 0.8f, 0.8f) / Plugin.multiplier.value;
			GameObject val = GameObject.Find("PlatformerController(Clone)");
			if ((Object)(object)val != (Object)null)
			{
				val.transform.localScale = new Vector3(1f, 1f, 1f) / Plugin.multiplier.value;
				val.transform.Find("CameraParent").localScale = new Vector3(1f, 1f, 1f) * Plugin.multiplier.value;
			}
		}
	}
}
namespace MiniV1
{
	[BepInPlugin("billy.miniv1", "MiniV1", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static FloatValueChangeEventDelegate <>9__6_0;

			internal void <Awake>b__6_0(FloatValueChangeEvent e)
			{
				if (e.value <= 0f)
				{
					multiplier.value = 0.1f;
					e.value = 0.1f;
				}
				Harmony.UnpatchAll();
				multiplier.value = e.value;
				Harmony.PatchAll();
			}
		}

		private static readonly Harmony Harmony = new Harmony("billy.miniv1");

		internal static ManualLogSource Logger;

		private static PluginConfigurator config;

		public static Texture2D configIconTexture = util.LoadEmbeddedTexture("MiniV1.assets.icon.png");

		public static Sprite configIcon = Sprite.Create(configIconTexture, new Rect(0f, 0f, (float)((Texture)configIconTexture).width, (float)((Texture)configIconTexture).height), new Vector2(0.5f, 0.5f));

		public static FloatField multiplier;

		private void Awake()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin MiniV1 is loaded!");
			config = PluginConfigurator.Create("MiniV1", "billy.miniv1");
			config.image = configIcon;
			multiplier = new FloatField(config.rootPanel, "Size multiplier", "multiplier", 10f);
			new ConfigHeader(config.rootPanel, "Higher value = smaller V1\r\n1 - default", 16);
			Harmony.PatchAll();
			FloatField obj = multiplier;
			object obj2 = <>c.<>9__6_0;
			if (obj2 == null)
			{
				FloatValueChangeEventDelegate val = delegate(FloatValueChangeEvent e)
				{
					if (e.value <= 0f)
					{
						multiplier.value = 0.1f;
						e.value = 0.1f;
					}
					Harmony.UnpatchAll();
					multiplier.value = e.value;
					Harmony.PatchAll();
				};
				<>c.<>9__6_0 = val;
				obj2 = (object)val;
			}
			obj.onValueChange += (FloatValueChangeEventDelegate)obj2;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MiniV1";

		public const string PLUGIN_NAME = "MiniV1";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}