Decompiled source of LethalWhoopieLandmine v1.1.5

BepInEx/plugins/WhoopieExplosion.dll

Decompiled 2 months 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 BepInEx.Logging;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WhoopieExplosion")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WhoopieLandMine")]
[assembly: AssemblyTitle("WhoopieExplosion")]
[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 WhoopieLandMine
{
	[BepInPlugin("WhoopieExplosion", "WhoopieLandMine", "1.0.0")]
	public class WhoopieLandMine : BaseUnityPlugin
	{
		public ConfigEntry<bool> explosionEffectConfig;

		public ConfigEntry<bool> goThroughCarConfig;

		public ConfigEntry<float> killRangeConfig;

		public ConfigEntry<float> physicsForceConfig;

		public ConfigEntry<float> damageRangeConfig;

		public ConfigEntry<int> nonLethalDamageConfig;

		public static WhoopieLandMine Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			explosionEffectConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "explosionEffectConfig", true, "Sets the explosion effect to active or disabled");
			goThroughCarConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "goThroughCarConfig", false, "?");
			killRangeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "killRangeConfig", 1f, "Sets kill range");
			physicsForceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "physicsForceConfig", 5f, "Sets knockback force");
			damageRangeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "damageRangeConfig", 10f, "Sets damage range");
			nonLethalDamageConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "nonLethalDamageConfig", 50, "Sets Non-Lethal damage");
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"WhoopieExplosion v1.0.0 has loaded!");
			Logger.LogInfo((object)$"explosionEffectConfig: {explosionEffectConfig.Value}");
			Logger.LogInfo((object)$"goThroughCarConfig: {goThroughCarConfig.Value}");
			Logger.LogInfo((object)$"killRangeConfig: {killRangeConfig.Value}");
			Logger.LogInfo((object)$"physicsForceConfig: {physicsForceConfig.Value}");
			Logger.LogInfo((object)$"damageRangeConfig: {damageRangeConfig.Value}");
			Logger.LogInfo((object)$"nonLethalDamageConfig: {nonLethalDamageConfig.Value}");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("WhoopieExplosion");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class ConfigManager
	{
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public class WhoopieLandMinePatches
	{
		[HarmonyPatch(typeof(WhoopieCushionTrigger))]
		public static class WhoopieCushionTriggerPatch
		{
			public static event EventHandler<WhoopieEventArgs> OnWhoopieTrigger;

			[HarmonyPatch("OnTriggerEnter")]
			[HarmonyPostfix]
			private static void Postfix(WhoopieCushionTrigger __instance, Collider other)
			{
				if (!((GrabbableObject)__instance.itemScript).isHeld && (((Component)other).gameObject.CompareTag("Player") || ((Component)other).gameObject.CompareTag("Enemy")))
				{
					WhoopieCushionTriggerPatch.OnWhoopieTrigger?.Invoke(__instance, new WhoopieEventArgs
					{
						collider = other
					});
				}
			}
		}

		public class WhoopieEventArgs : EventArgs
		{
			public Collider collider { get; set; }
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Postfix(GrabbableObject __instance)
		{
			Debug.Log((object)"GrabbableObject Patch Loading...");
			if (!(__instance is WhoopieCushionItem))
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("Trigger");
			if ((Object)(object)val != (Object)null)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if ((Object)(object)gameObject.GetComponent<WhoopieScript>() == (Object)null)
				{
					gameObject.gameObject.AddComponent<WhoopieScript>();
					Debug.Log((object)"WhoopieScript Attached to child");
				}
			}
			else
			{
				Debug.LogError((object)"Child object named 'Trigger' not found");
			}
		}
	}
	internal class WhoopieScript : MonoBehaviour
	{
		private Vector3 whoopiePos;

		private GameObject parentWhoopieCushion;

		private bool explosionEffect;

		private float killRange;

		private float damageRange;

		private int nonLethalDamage;

		private float physicsForce;

		private bool goThroughCar;

		private void Awake()
		{
			explosionEffect = WhoopieLandMine.Instance.explosionEffectConfig.Value;
			goThroughCar = WhoopieLandMine.Instance.goThroughCarConfig.Value;
			killRange = WhoopieLandMine.Instance.killRangeConfig.Value;
			damageRange = WhoopieLandMine.Instance.damageRangeConfig.Value;
			physicsForce = WhoopieLandMine.Instance.physicsForceConfig.Value;
			nonLethalDamage = WhoopieLandMine.Instance.nonLethalDamageConfig.Value;
		}

		private void Start()
		{
			parentWhoopieCushion = ((Component)((Component)this).transform.parent).gameObject;
		}

		private void Update()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			whoopiePos = ((Component)this).transform.position;
		}

		private void OnEnable()
		{
			WhoopieLandMinePatches.WhoopieCushionTriggerPatch.OnWhoopieTrigger += WhoopieCushionTriggerPatch_OnWhoopieTrigger;
		}

		private void WhoopieCushionTriggerPatch_OnWhoopieTrigger(object sender, WhoopieLandMinePatches.WhoopieEventArgs e)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Explode");
			Landmine.SpawnExplosion(whoopiePos, explosionEffect, killRange, damageRange, nonLethalDamage, physicsForce, (GameObject)null, goThroughCar);
			Object.Destroy((Object)(object)parentWhoopieCushion.gameObject);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WhoopieExplosion";

		public const string PLUGIN_NAME = "WhoopieLandMine";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}