Decompiled source of MyPitsDontLeak v1.0.0

MyPitsDontLeak.dll

Decompiled 20 hours 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 System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MyPitsDontLeak")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Azumatt")]
[assembly: AssemblyProduct("MyPitsDontLeak")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 MyPitsDontLeak
{
	[BepInPlugin("Azumatt.MyPitsDontLeak", "MyPitsDontLeak", "1.0.0")]
	public class MyPitsDontLeakPlugin : BaseUnityPlugin
	{
		internal const string ModName = "MyPitsDontLeak";

		internal const string ModVersion = "1.0.0";

		internal const string Author = "Azumatt";

		private const string ModGUID = "Azumatt.MyPitsDontLeak";

		private readonly Harmony _harmony = new Harmony("Azumatt.MyPitsDontLeak");

		public static readonly ManualLogSource MyPitsDontLeakLogger = Logger.CreateLogSource("MyPitsDontLeak");

		public void Awake()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}
	}
	[HarmonyPatch(typeof(LiquidVolume), "Awake")]
	internal static class LiquidVolumeAwakePatch
	{
		private static bool Prefix(LiquidVolume __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			__instance.m_nview = ((Component)__instance).GetComponent<ZNetView>();
			__instance.m_meshFilter = ((Component)__instance).GetComponent<MeshFilter>();
			((Component)__instance).transform.rotation = Quaternion.identity;
			int num = __instance.m_width + 1;
			int num2 = num * num;
			__instance.m_depths = new List<float>(num2);
			__instance.m_heights = new List<float>(num2);
			for (int i = 0; i < num2; i++)
			{
				__instance.m_depths.Add(0f);
				__instance.m_heights.Add(0f);
			}
			__instance.m_mesh = new Mesh();
			((Object)__instance.m_mesh).name = "___LiquidVolume m_mesh";
			if (__instance.HaveSavedData())
			{
				__instance.CheckLoad();
			}
			else
			{
				__instance.InitializeLevels();
			}
			__instance.m_maxVertex = new Vector3((float)((double)__instance.m_width * (double)__instance.m_scale * -0.5), __instance.m_maxDepth, (float)((double)__instance.m_width * (double)__instance.m_scale * -0.5)) + ((Component)__instance).transform.position;
			__instance.m_raycastResults = new NativeArray<RaycastHit>(num * num, (Allocator)4, (NativeArrayOptions)1);
			__instance.m_raycastCommands = new NativeArray<RaycastCommand>(num * num, (Allocator)4, (NativeArrayOptions)1);
			__instance.m_raycastHitsArray = (RaycastHit[])(object)new RaycastHit[num * num];
			__instance.m_builder = new Thread((ThreadStart)__instance.UpdateThread);
			__instance.m_builder.Start();
			return false;
		}
	}
	[HarmonyPatch(typeof(LiquidVolume), "OnDestroy")]
	internal static class LiquidVolumeOnDestroyPatch
	{
		private static bool Prefix(LiquidVolume __instance)
		{
			__instance.m_stopThread = true;
			__instance.m_builder.Join();
			__instance.m_timerLock.Close();
			__instance.m_meshDataLock.Close();
			Object.Destroy((Object)(object)__instance.m_mesh);
			if (__instance.m_raycastResults.IsCreated)
			{
				__instance.m_raycastResults.Dispose();
			}
			if (__instance.m_raycastCommands.IsCreated)
			{
				__instance.m_raycastCommands.Dispose();
			}
			return false;
		}
	}
}