Decompiled source of StructureClipping v1.0.0

plugins/StructureClipping/StructureClipping.dll

Decompiled 2 years ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using StructureClipping.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("StructureClipping")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StructureClipping")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("77c31740-6639-46be-a1ae-fbcd9f441d29")]
[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")]
namespace StructureClipping
{
	[BepInPlugin("com.equinox.StructureClipping", "StructureClipping", "1.0.0")]
	public class StructureClippingPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.StructureClipping";

		private const string PluginName = "StructureClipping";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.equinox.StructureClipping");

		public static ManualLogSource Log = new ManualLogSource("StructureClipping");

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: StructureClipping, VersionString: 1.0.0 is loading...");
			Harmony.PatchAll();
			Harmony.CreateAndPatchAll(typeof(StructureBuilderPatch), (string)null);
			Harmony.CreateAndPatchAll(typeof(GridManagerPatch), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: StructureClipping, VersionString: 1.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}
	}
}
namespace StructureClipping.Patches
{
	internal class GridManagerPatch
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void CheckBuildableAtPostfix(ref bool __result, in Vector3Int minInt, in Vector3Int maxInt, int gridClearance, CheckOptions options)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			bool flag = true;
			Vector3Int val = minInt;
			int num = ((Vector3Int)(ref val)).x;
			int num7 = default(int);
			ushort key = default(ushort);
			while (true)
			{
				int num2 = num;
				val = maxInt;
				if (num2 > ((Vector3Int)(ref val)).x)
				{
					break;
				}
				val = minInt;
				int num3 = ((Vector3Int)(ref val)).y;
				while (true)
				{
					int num4 = num3;
					val = maxInt;
					if (num4 > ((Vector3Int)(ref val)).y)
					{
						break;
					}
					val = minInt;
					int num5 = ((Vector3Int)(ref val)).z;
					while (true)
					{
						int num6 = num5;
						val = maxInt;
						if (num6 > ((Vector3Int)(ref val)).z)
						{
							break;
						}
						if (GridManager.instance.GetChunkIndexAndCoordIndexFromCoord(ref num, ref num3, ref num5, ref num7, ref key) && GridManager.instance.chunkDatas[num7].coordToObj.TryGetValue(key, out var value) && (int)((GenericMachineInstanceRef)(ref value)).typeIndex != 31)
						{
							flag = false;
						}
						num5++;
					}
					num3++;
				}
				num++;
			}
			if (flag)
			{
				__result = true;
			}
		}
	}
	internal class StructureBuilderPatch
	{
		[HarmonyPatch(typeof(StructureBuilder), "CheckBuildIsValid")]
		[HarmonyPostfix]
		private static void alwaysTrue(ref bool __result)
		{
			Debug.Log((object)"Overwrote result of CheckBuildIsValid");
			__result = true;
		}

		[HarmonyPatch(typeof(StructureBuilder), "CheckBuildHasLEqualVoxelOverlapAndNoAABBGridOverlap")]
		[HarmonyPostfix]
		private static void alwaysTrue2(ref bool __result)
		{
			Debug.Log((object)"Overwrote result of CheckBuildIsValid");
			__result = true;
		}
	}
}