Decompiled source of Everything is Whippable v1.0.0

AnywheresWhippable2.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.IO;
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 PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.Events;

[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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AnywheresWhippable2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AnywheresWhippable2")]
[assembly: AssemblyTitle("AnywheresWhippable2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AnywheresWhippable2;

[BepInPlugin("AnywheresWhippable2", "AnywheresWhippable2", "1.0.0")]
[BepInProcess("ULTRAKILL.exe")]
public class AnywheresWhippable : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static IntValueChangeEventDelegate <>9__8_0;

		public static UnityAction <>9__12_0;

		public static UnityAction <>9__12_1;

		internal void <MakeButtons>b__8_0(IntValueChangeEvent data)
		{
			MonoSingleton<PrefsManager>.Instance.SetInt("slingshotvalue", data.value);
			SlingShotSpeed = data.value;
		}

		internal void <StopThrowStart>b__12_0()
		{
			Object.Destroy((Object)(object)hookpoint);
		}

		internal void <StopThrowStart>b__12_1()
		{
			Object.Destroy((Object)(object)hookpoint);
		}
	}

	public static string modlocat;

	public static ManualLogSource Cl;

	public static AssetBundle AB;

	private static PluginConfigurator config;

	public static GameObject hookpoint;

	public static int SlingShotSpeed = 0;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("org.crash.anywhereswhippable");
		val.PatchAll(typeof(AnywheresWhippable));
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin AnywheresWhippable2 is loaded!");
		modlocat = ModPath();
		AB = AssetBundle.LoadFromFile(Path.Combine(ModPath(), "slingshot"));
		Cl = ((BaseUnityPlugin)this).Logger;
		config = PluginConfigurator.Create("Everything is Whippable", "AnywheresWhippable2");
		config.SetIconWithURL("file://" + Path.Combine(ModPath(), "icon.png"));
		MakeButtons();
		LoadLastSelected();
	}

	public static void LoadLastSelected()
	{
		SlingShotSpeed = MonoSingleton<PrefsManager>.Instance.GetInt("slingshotvalue", 0);
	}

	public static void MakeButtons()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		new ConfigHeader(config.rootPanel, "Options", 24);
		IntField val = new IntField(config.rootPanel, "Slingshot Speed", "AnywheresWhippable2", 0);
		object obj = <>c.<>9__8_0;
		if (obj == null)
		{
			IntValueChangeEventDelegate val2 = delegate(IntValueChangeEvent data)
			{
				MonoSingleton<PrefsManager>.Instance.SetInt("slingshotvalue", data.value);
				SlingShotSpeed = data.value;
			};
			<>c.<>9__8_0 = val2;
			obj = (object)val2;
		}
		val.onValueChange += (IntValueChangeEventDelegate)obj;
	}

	public static string GameDirectory()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Invalid comparison between Unknown and I4
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Invalid comparison between Unknown and I4
		string text = Application.dataPath;
		if ((int)Application.platform == 1)
		{
			text = Utility.ParentDirectory(text, 2);
		}
		else if ((int)Application.platform == 2)
		{
			text = Utility.ParentDirectory(text, 1);
		}
		return text;
	}

	public static string ModDirectory()
	{
		return Path.Combine(GameDirectory(), "BepInEx", "plugins");
	}

	public static string ModPath()
	{
		return Assembly.GetCallingAssembly().Location.Substring(0, Assembly.GetCallingAssembly().Location.LastIndexOf(Path.DirectorySeparatorChar));
	}

	[HarmonyPatch(typeof(HookArm), "StopThrow")]
	[HarmonyPrefix]
	public static bool StopThrowStart(HookArm __instance, float animationTime = 0f, bool sparks = false)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Expected O, but got Unknown
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)__instance.caughtEid) && !Object.op_Implicit((Object)(object)__instance.caughtHook) && !Object.op_Implicit((Object)(object)__instance.caughtGrenade) && __instance.caughtObjects.Count == 0)
		{
			if ((Object)(object)hookpoint != (Object)null)
			{
				Object.Destroy((Object)(object)hookpoint);
			}
			hookpoint = Object.Instantiate<GameObject>(AB.LoadAsset<GameObject>("Sandbox GrapplePoint Slingshot Variant Variant"), __instance.hook.position, Quaternion.Euler(new Vector3(0f, 0f, 0f)));
			hookpoint.GetComponentInChildren<HookPoint>().slingShotForce = SlingShotSpeed;
			UnityEvent onActivate = hookpoint.GetComponentInChildren<HookPoint>().onUnhook.onActivate;
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					Object.Destroy((Object)(object)hookpoint);
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			onActivate.AddListener((UnityAction)obj);
			UnityEvent onActivate2 = hookpoint.GetComponentInChildren<HookPoint>().onReach.onActivate;
			object obj2 = <>c.<>9__12_1;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					Object.Destroy((Object)(object)hookpoint);
				};
				<>c.<>9__12_1 = val2;
				obj2 = (object)val2;
			}
			onActivate2.AddListener((UnityAction)obj2);
			__instance.caughtObjects.Clear();
			__instance.cooldown = 0.2f;
			return false;
		}
		return true;
	}
}
public static class MyPluginInfo
{
	public const string PLUGIN_GUID = "AnywheresWhippable2";

	public const string PLUGIN_NAME = "AnywheresWhippable2";

	public const string PLUGIN_VERSION = "1.0.0";
}