Decompiled source of HumanGrenadeBigBoom v1.0.1

HumanGrenadeBigBoom.dll

Decompiled 3 months ago
using System;
using System.Collections;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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("Human Grenade Big Boom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("Human Grenade Big Boom")]
[assembly: AssemblyCopyright("Copyright © HP 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ebd68942-d8bc-4e7e-9700-5a5510b4ac17")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("com.yourname.repo.humangrenadebigboom", "HumanGrenadeBigBoom", "1.0.0")]
public class HumanGrenadeBigBoom : BaseUnityPlugin
{
	[HarmonyPatch]
	private static class ItemGrenadeHuman_Explosion_Patch
	{
		private static MethodBase TargetMethod()
		{
			if (!UseExplosionPatch.Value)
			{
				return null;
			}
			Type type = AccessTools.TypeByName("ItemGrenadeHuman");
			if (type == null)
			{
				return null;
			}
			return AccessTools.Method(type, "Explosion", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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)
			try
			{
				MonoBehaviour val = (MonoBehaviour)((__instance is MonoBehaviour) ? __instance : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Vector3 position = ((Component)val).transform.position;
				float value = ExplosionRadius.Value;
				float num = ExplosionBaseForce.Value * ForceMultiplier.Value;
				float value2 = ExplosionUplift.Value;
				int num2 = 0;
				try
				{
					if (OverlapSphereMethodCached != null)
					{
						if (OverlapSphereMethodCached.Invoke(null, new object[2] { position, value }) is Array array)
						{
							for (int i = 0; i < array.Length; i++)
							{
								object value3 = array.GetValue(i);
								if (value3 == null)
								{
									continue;
								}
								PropertyInfo attachedRigidbodyPropCached = AttachedRigidbodyPropCached;
								object obj;
								if ((obj = ((attachedRigidbodyPropCached != null) ? attachedRigidbodyPropCached.GetValue(value3, null) : null)) == null)
								{
									PropertyInfo property = value3.GetType().GetProperty("attachedRigidbody");
									obj = ((property != null) ? property.GetValue(value3, null) : null);
								}
								object obj2 = obj;
								if (obj2 == null)
								{
									continue;
								}
								try
								{
									MethodInfo addExplosionForceMethodCached = AddExplosionForceMethodCached;
									if (addExplosionForceMethodCached != null)
									{
										addExplosionForceMethodCached.Invoke(obj2, new object[5]
										{
											num,
											position,
											value,
											value2,
											Enum.Parse(ForceModeTypeCached, "Impulse")
										});
									}
									num2++;
								}
								catch
								{
								}
							}
						}
					}
					else
					{
						ManualLogSource log = Log;
						if (log != null)
						{
							log.LogWarning((object)"No OverlapSphere method cached; cannot apply explosion forces.");
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log2 = Log;
					if (log2 != null)
					{
						string text = "Explosion apply error: ";
						log2.LogError((object)(text + ex));
					}
				}
				if (DebugLogs.Value)
				{
					ManualLogSource log3 = Log;
					if (log3 != null)
					{
						log3.LogInfo((object)$"Applied explosion force to {num2} rigidbodies (force={num}, radius={value}, uplift={value2})");
					}
				}
				else
				{
					ManualLogSource log4 = Log;
					if (log4 != null)
					{
						log4.LogInfo((object)$"Applied explosion force to {num2} rigidbodies (x{ForceMultiplier.Value})");
					}
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource obj4 = Logger.CreateLogSource("HumanGrenadeBigBoom");
				string text2 = "Explosion postfix error: ";
				obj4.LogError((object)(text2 + ex2));
			}
		}
	}

	[HarmonyPatch]
	private static class ItemGrenadeHuman_Spawn_Patch
	{
		private static MethodBase TargetMethod()
		{
			if (!UseSpawnPatch.Value)
			{
				return null;
			}
			Type type = AccessTools.TypeByName("ItemGrenadeHuman");
			if (type == null)
			{
				return null;
			}
			return AccessTools.Method(type, "Spawn", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			try
			{
				MonoBehaviour val = (MonoBehaviour)((__instance is MonoBehaviour) ? __instance : null);
				if (!((Object)(object)val == (Object)null))
				{
					val.StartCoroutine(ScaleGrenadeAfterSpawn(val));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Log;
				if (log != null)
				{
					string text = "Postfix error: ";
					log.LogError((object)(text + ex));
				}
			}
		}

		private static IEnumerator ScaleGrenadeAfterSpawn(MonoBehaviour instance)
		{
			int frames = SpawnDelayFrames.Value;
			for (int i = 0; i < frames; i++)
			{
				yield return null;
			}
			Rigidbody component = ((Component)instance).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.velocity *= SpawnVelocityMultiplier.Value;
			}
		}
	}

	public static ConfigEntry<float> ForceMultiplier;

	public static ConfigEntry<float> SpawnVelocityMultiplier;

	public static ConfigEntry<int> SpawnDelayFrames;

	public static ConfigEntry<float> ExplosionBaseForce;

	public static ConfigEntry<float> ExplosionRadius;

	public static ConfigEntry<float> ExplosionUplift;

	public static ConfigEntry<bool> UseSpawnPatch;

	public static ConfigEntry<bool> UseExplosionPatch;

	public static ConfigEntry<bool> DebugLogs;

	private ManualLogSource logSource;

	public static Type PhysicsTypeCached;

	public static MethodInfo OverlapSphereMethodCached;

	public static Type RigidbodyTypeCached;

	public static MethodInfo AddExplosionForceMethodCached;

	public static Type ForceModeTypeCached;

	public static PropertyInfo AttachedRigidbodyPropCached;

	public static ManualLogSource Log;

	private void Awake()
	{
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		logSource = ((BaseUnityPlugin)this).Logger;
		ForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ForceMultiplier", 2f, "Global multiplier applied to grenade forces.");
		SpawnVelocityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn", "SpawnVelocityMultiplier", 2f, "Multiplier applied to grenade initial velocity (spawn).");
		SpawnDelayFrames = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn", "SpawnDelayFrames", 0, "Frames to wait after spawn before scaling velocity.");
		ExplosionBaseForce = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "ExplosionBaseForce", 60f, "Base explosion force applied to nearby rigidbodies.");
		ExplosionRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "ExplosionRadius", 45f, "Explosion radius for applied forces.");
		ExplosionUplift = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "ExplosionUplift", 0f, "Uplift applied when adding explosion force.");
		UseSpawnPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "UseSpawnPatch", true, "Enable spawn velocity scaling patch.");
		UseExplosionPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "UseExplosionPatch", true, "Enable explosion force patch.");
		DebugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "DebugLogs", false, "Enable verbose debug logs for grenade processing.");
		try
		{
			new Harmony("com.yourname.repo.humangrenadebigboom").PatchAll();
			logSource.LogInfo((object)"HumanGrenadeBigBoom: Harmony patches applied.");
			string text = "\r\n ________  ___  ________                         \r\n|\\   __  \\|\\  \\|\\   ____\\                        \r\n\\ \\  \\|\\ /\\ \\  \\ \\  \\___|                        \r\n \\ \\   __  \\ \\  \\ \\  \\  ___                      \r\n  \\ \\  \\|\\  \\ \\  \\ \\  \\|\\  \\                     \r\n   \\ \\_______\\ \\__\\ \\_______\\                    \r\n    \\|_______|\\|__|\\|_______|                    \r\n                                                 \r\n                                                      Hello from TechedCrayon413                  \r\n\r\n________  ________  ________  _____ _______     \r\n|\\   __  \\|\\   __  \\|\\   __  \\|\\   _ \\  _   \\    \r\n\\ \\  \\|\\ /\\ \\  \\|\\  \\ \\  \\|\\  \\ \\  \\\\\\__\\ \\  \\   \r\n \\ \\   __  \\ \\  \\\\\\  \\ \\  \\\\\\  \\ \\  \\\\|__| \\  \\  \r\n  \\ \\  \\|\\  \\ \\  \\\\\\  \\ \\  \\\\\\  \\ \\  \\    \\ \\  \\ \r\n   \\ \\_______\\ \\_______\\ \\_______\\ \\__\\    \\ \\__\\\r\n    \\|_______|\\|_______|\\|_______|\\|__|     \\|__| \r\n";
			logSource.LogMessage((object)text);
			logSource.LogMessage((object)"Hello I hope you like my mod, Credits to me, myself, and I, and the miscrosft visual studio for dealing with a lot of bugs");
			Log = ((BaseUnityPlugin)this).Logger;
			PhysicsTypeCached = AccessTools.TypeByName("UnityEngine.Physics") ?? Type.GetType("UnityEngine.Physics, UnityEngine.PhysicsModule");
			Type physicsTypeCached = PhysicsTypeCached;
			OverlapSphereMethodCached = ((physicsTypeCached != null) ? physicsTypeCached.GetMethod("OverlapSphere", new Type[2]
			{
				typeof(Vector3),
				typeof(float)
			}) : null);
			RigidbodyTypeCached = AccessTools.TypeByName("UnityEngine.Rigidbody") ?? Type.GetType("UnityEngine.Rigidbody, UnityEngine.PhysicsModule");
			ForceModeTypeCached = AccessTools.TypeByName("UnityEngine.ForceMode") ?? Type.GetType("UnityEngine.ForceMode, UnityEngine.PhysicsModule");
			Type rigidbodyTypeCached = RigidbodyTypeCached;
			AddExplosionForceMethodCached = ((rigidbodyTypeCached != null) ? rigidbodyTypeCached.GetMethod("AddExplosionForce", new Type[5]
			{
				typeof(float),
				typeof(Vector3),
				typeof(float),
				typeof(float),
				ForceModeTypeCached ?? typeof(object)
			}) : null);
			Type type = AccessTools.TypeByName("UnityEngine.Collider") ?? Type.GetType("UnityEngine.Collider, UnityEngine.CoreModule");
			AttachedRigidbodyPropCached = ((type != null) ? type.GetProperty("attachedRigidbody") : null);
		}
		catch (Exception ex)
		{
			ManualLogSource obj = logSource;
			string text2 = "HumanGrenadeBigBoom: Harmony failed to initialize: ";
			obj.LogError((object)(text2 + ex));
		}
	}
}
namespace idk_testing;

public class Class1
{
}