Decompiled source of LetMeSpawnCamp v1.1.0

BepInEx/plugins/LetMeSpawnCamp.dll

Decompiled 21 hours ago
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LetMeSpawnCamp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("LetMeSpawnCamp mod for Ultimate Chicken Horse")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8c7bfe26e6f4e27142ddb11088d2519bd8cb56fd")]
[assembly: AssemblyProduct("LetMeSpawnCamp")]
[assembly: AssemblyTitle("LetMeSpawnCamp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LetMeSpawnCamp
{
	[BepInPlugin("krw.mods.letmespawncamp", "LetMeSpawnCamp", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<bool> ModEnabled;

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the LetMeSpawnCamp mod.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin krw.mods.letmespawncamp is loaded!");
			new Harmony("krw.mods.letmespawncamp").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patches applied.");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "krw.mods.letmespawncamp";

		public const string PLUGIN_NAME = "LetMeSpawnCamp";

		public const string PLUGIN_VERSION = "1.1.0";
	}
	[HarmonyPatch(typeof(CheckColliding))]
	public class SpawnProtectionPatch
	{
		[HarmonyPatch("handleCollision")]
		[HarmonyPrefix]
		public static bool HandleCollisionPrefix(CheckColliding __instance, GameObject go)
		{
			if (!Plugin.ModEnabled.Value)
			{
				return true;
			}
			if ((Object)(object)go == (Object)null)
			{
				return true;
			}
			CollisionTag val = go.GetComponent<CollisionTag>();
			if ((Object)(object)val == (Object)null)
			{
				val = go.GetComponentInParent<CollisionTag>();
			}
			if ((Object)(object)val == (Object)null)
			{
				val = go.GetComponentInChildren<CollisionTag>();
			}
			if ((Object)(object)val != (Object)null && (val.ContainsAnyTag((Tag)16777216) || val.ContainsAnyTag((Tag)4194304) || val.ContainsAnyTag((Tag)2)))
			{
				CollisionTag component = ((Component)__instance).GetComponent<CollisionTag>();
				if (!((Object)(object)component != (Object)null) || (!component.ContainsAnyTag((Tag)128) && !component.ContainsAnyTag((Tag)8192)))
				{
					Placeable componentInParent = ((Component)__instance).GetComponentInParent<Placeable>();
					bool flag = false;
					if ((Object)(object)componentInParent != (Object)null)
					{
						CheckColliding[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren<CheckColliding>(true);
						foreach (CheckColliding val2 in componentsInChildren)
						{
							if ((Object)(object)val2 != (Object)null)
							{
								CollisionTag component2 = ((Component)val2).GetComponent<CollisionTag>();
								if ((Object)(object)component2 != (Object)null && (component2.ContainsAnyTag((Tag)128) || component2.ContainsAnyTag((Tag)8192)))
								{
									flag = true;
									break;
								}
							}
						}
					}
					if (flag)
					{
						return false;
					}
				}
			}
			return true;
		}

		[HarmonyPatch("CheckCollidingObject")]
		[HarmonyPrefix]
		public static bool CheckCollidingObjectPrefix(CheckColliding __instance, GameObject go, ref bool __result)
		{
			if (!Plugin.ModEnabled.Value)
			{
				return true;
			}
			if ((Object)(object)go == (Object)null)
			{
				return true;
			}
			CollisionTag val = go.GetComponent<CollisionTag>();
			if ((Object)(object)val == (Object)null)
			{
				val = go.GetComponentInParent<CollisionTag>();
			}
			if ((Object)(object)val == (Object)null)
			{
				val = go.GetComponentInChildren<CollisionTag>();
			}
			if ((Object)(object)val != (Object)null && (val.ContainsAnyTag((Tag)16777216) || val.ContainsAnyTag((Tag)4194304) || val.ContainsAnyTag((Tag)2)))
			{
				CollisionTag component = ((Component)__instance).GetComponent<CollisionTag>();
				if (!((Object)(object)component != (Object)null) || (!component.ContainsAnyTag((Tag)128) && !component.ContainsAnyTag((Tag)8192)))
				{
					Placeable componentInParent = ((Component)__instance).GetComponentInParent<Placeable>();
					bool flag = false;
					if ((Object)(object)componentInParent != (Object)null)
					{
						CheckColliding[] componentsInChildren = ((Component)componentInParent).GetComponentsInChildren<CheckColliding>(true);
						foreach (CheckColliding val2 in componentsInChildren)
						{
							if ((Object)(object)val2 != (Object)null)
							{
								CollisionTag component2 = ((Component)val2).GetComponent<CollisionTag>();
								if ((Object)(object)component2 != (Object)null && (component2.ContainsAnyTag((Tag)128) || component2.ContainsAnyTag((Tag)8192)))
								{
									flag = true;
									break;
								}
							}
						}
					}
					if (flag)
					{
						__result = false;
						return false;
					}
				}
			}
			return true;
		}
	}
}