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 BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("HoleHook")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoleHook")]
[assembly: AssemblyTitle("HoleHook")]
[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 HoleHook
{
[BepInPlugin("com.maxgamertyper1.pullableblackholes", "Pullable Black Holes", "1.0.0")]
public class HoleHook : BaseUnityPlugin
{
internal static ConfigFile config;
internal static ConfigEntry<bool> WhiteHoleAttach;
internal static ConfigEntry<bool> InvertWhiteHolePull;
internal static ConfigEntry<bool> WhiteHolePull;
internal static ConfigEntry<bool> BlackHolePull;
private void Log(string message)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)message);
}
private void Awake()
{
Log("Plugin HoleHook is loaded!");
DoPatching();
}
private void DoPatching()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony harmony = new Harmony("com.maxgamertyper1.pullableblackholes");
config = ((BaseUnityPlugin)this).Config;
BlackHolePull = config.Bind<bool>("Black Hole Patches", "Black Hole Pull Patch", true, "pulls black holes when connected with a grappling hook");
WhiteHoleAttach = config.Bind<bool>("White Hole Patches", "White Hole Attach Patch", true, "allows grappling hooks to attach to white holes");
WhiteHolePull = config.Bind<bool>("White Hole Patches", "White Hole Pull Patch", true, "pulls white holes when connected with a grappling hook");
InvertWhiteHolePull = config.Bind<bool>("White Hole Patches", "Invert White Hole Force Patch", false, "pulls white holes toward the player (unlike the beam)");
Patch(harmony, typeof(RopeAttachment), "UpdateSim", "FullPatch", prefix: true);
}
private void OnDestroy()
{
Log("Bye Bye From HoleHook");
}
private void Patch(Harmony harmony, Type OriginalClass, string OriginalMethod, string PatchMethod, bool prefix)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(OriginalClass, OriginalMethod, (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), PatchMethod, (Type[])null, (Type[])null);
if (prefix)
{
harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
Log("Patched " + OriginalMethod + " in " + OriginalClass.ToString());
}
}
public class Patches
{
public static bool FullPatch(ref RopeAttachment __instance)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
if (__instance.ropeBody != null && __instance.ropeBody.enabled && __instance.ropeBody.hookHasArrived && !__instance.ropeBody.hasBeenDettached && !GameTime.IsTimeStopped() && (Object)(object)__instance.blackHole != (Object)null && !((MonoUpdatable)__instance.blackHole).IsDestroyed)
{
if (__instance.blackHole.GetMass() < Fix.Zero && !HoleHook.WhiteHoleAttach.Value)
{
__instance.blackHole = null;
__instance.Deattach();
}
if (__instance.blackHole.GetMass() < Fix.Zero && !HoleHook.WhiteHolePull.Value)
{
return false;
}
if (__instance.blackHole.GetMass() > Fix.Zero && !HoleHook.BlackHolePull.Value)
{
return false;
}
int num = ((!__instance.topAttachment) ? (__instance.ropeBody.segmentCount - 1) : 0);
int num2 = (__instance.topAttachment ? 1 : (__instance.ropeBody.segmentCount - 2));
Vec2 val = (__instance.ropeBody.segment[num] - __instance.ropeBody.segment[num2]) * (__instance.isPlatformAttachment ? __instance.platformPullStr : __instance.pullStr);
if (__instance.blackHole.GetMass() < Fix.Zero && HoleHook.InvertWhiteHolePull.Value)
{
__instance.blackHole.AddForce(-val);
return false;
}
__instance.blackHole.AddForce(val);
return false;
}
return true;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "HoleHook";
public const string PLUGIN_NAME = "HoleHook";
public const string PLUGIN_VERSION = "1.0.0";
}
}