Decompiled source of Attaching To Water Update v1.0.0

plugins/AttachingToWater.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AttachingToWaterUpdate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AttachingToWaterUpdate")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b032edb0-8d66-4fdc-a508-60c41d180f61")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("cro.attachingtowater", "Attaching To Water", "1.0.0")]
public class AttachingToWater : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony("cro.attachingtowater");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(RopeHook), "UpdateSim")]
public static class b
{
	private static readonly HashSet<int> attachedHooks = new HashSet<int>();

	private static bool Prefix(RopeHook __instance, Fix SimDeltaTime)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null)
		{
			return true;
		}
		if (SimDeltaTime <= Fix.Zero)
		{
			return true;
		}
		try
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (attachedHooks.Contains(instanceID))
			{
				return false;
			}
			FixTransform component = ((Component)__instance).GetComponent<FixTransform>();
			if ((Object)(object)component == (Object)null)
			{
				return true;
			}
			Vec2 position = component.position;
			Vec2 value = Traverse.Create((object)__instance).Field("velocity").GetValue<Vec2>();
			Vec2 val = value * SimDeltaTime;
			Fix val2 = Fix.Sqrt(val.x * val.x + val.y * val.y);
			if (val2 <= Fix.Zero)
			{
				return true;
			}
			Vec2 val3 = val / val2;
			int num = LayerMask.NameToLayer("Water");
			if (num < 0)
			{
				return true;
			}
			LayerMask val4 = LayerMask.op_Implicit(1 << num);
			RaycastInformation val5 = DetPhysics.Get().RaycastToClosest(position, val3, val2, val4);
			if (val5.layer != num)
			{
				return true;
			}
			RopeAttachment value2 = Traverse.Create((object)__instance).Field("ropeAttachment").GetValue<RopeAttachment>();
			RopeBody value3 = Traverse.Create((object)__instance).Field("ropeBody").GetValue<RopeBody>();
			bool value4 = Traverse.Create((object)__instance).Field("topAttachment").GetValue<bool>();
			Rope value5 = Traverse.Create((object)__instance).Field("rope").GetValue<Rope>();
			if ((Object)(object)value2 == (Object)null)
			{
				return true;
			}
			if (value3 == null)
			{
				return true;
			}
			component.position = val5.nearPos;
			((Component)__instance).transform.position = (Vector3)val5.nearPos;
			Traverse.Create((object)__instance).Field("velocity").SetValue((object)Vec2.zero);
			if ((Object)(object)value5 != (Object)null)
			{
				value5.hookArrived = true;
			}
			value3.timeSinceHookArrived = (Fix)0.001;
			value2.AttachToNonPlatform(component, Vec2.zero, value3, value4);
			int num2 = ((!value4) ? (value3.segmentCount - 1) : 0);
			value3.segment[num2] = val5.nearPos;
			value3.segmentPrev[num2] = val5.nearPos;
			DPhysicsCircle value6 = Traverse.Create((object)__instance).Field("hitbox").GetValue<DPhysicsCircle>();
			if ((Object)(object)value6 != (Object)null && !((MonoUpdatable)value6).IsDestroyed)
			{
				Updater.DestroyFix((MonoBehaviour)(object)value6);
			}
			attachedHooks.Add(instanceID);
			return false;
		}
		catch (Exception)
		{
			return true;
		}
	}
}