Decompiled source of HiveBomb v1.2.0

BepInEx/plugins/HiveBomb.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
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 GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RuntimeNetcodeRPCValidator;
using Unity.Netcode;
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("HiveBomb")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4eb109e4ecff8526675cdd4b34edddb9dc604d94")]
[assembly: AssemblyProduct("hivebombnetcode")]
[assembly: AssemblyTitle("HiveBomb")]
[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 hivebombnetcode
{
	public sealed class Config
	{
		private static Config instance;

		public ConfigEntry<bool> Enabled { get; set; }

		public ConfigEntry<bool> KnockbackEnabled { get; set; }

		public ConfigEntry<bool> VisibleExplosions { get; set; }

		public ConfigEntry<float> Radius { get; set; }

		public ConfigEntry<float> RandomnessMult { get; set; }

		public ConfigEntry<int> MaxPlayerDamage { get; set; }

		public ConfigEntry<int> GlobalExplosionCooldown { get; set; }

		public static Config Instance
		{
			get
			{
				if (instance == null)
				{
					instance = new Config();
				}
				return instance;
			}
		}

		public void Setup()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			Enabled = Plugin.BepInExConfig().Bind<bool>("General", "Enabled", true, "Enables access to track your social security, banking info, home address and DNA samples, Default: On");
			KnockbackEnabled = Plugin.BepInExConfig().Bind<bool>("General", "Masochist Mode", true, "Enables Knockback, Default: On");
			VisibleExplosions = Plugin.BepInExConfig().Bind<bool>("General", "Explosion Visibility", true, "Turns the explosion particles On or Off, Default: On");
			MaxPlayerDamage = Plugin.BepInExConfig().Bind<int>("General", "Player Damage", 0, new ConfigDescription("Changes how many treats are gonna be delivered to your house for being such a good kid!!!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			GlobalExplosionCooldown = Plugin.BepInExConfig().Bind<int>("General", "Global Explosion Cooldown", 10, new ConfigDescription("Changes the minimum frames between a beehive exploding after another one already has", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000000000), Array.Empty<object>()));
			Radius = Plugin.BepInExConfig().Bind<float>("General", "Radius", 2.4f, new ConfigDescription("Explosion radius, Default is 2.4 and is as big as a lightning strikes kill range", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			RandomnessMult = Plugin.BepInExConfig().Bind<float>("General", "Randomness Multiplier", 1f, new ConfigDescription("Markiplies the chance it has to explode each frame, 10 is extremely unlikely and 0.1 is extremely likely", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class beeupdate
	{
		public static bool first = false;

		private static HiveMindManager bossman;

		[SerializeField]
		public static bool knockback = false;

		[SerializeField]
		public static bool visible = false;

		[SerializeField]
		public static Vector3 where = default(Vector3);

		[SerializeField]
		public static int rand = 0;

		[SerializeField]
		public static int dmg = 0;

		[SerializeField]
		public static float radius = 0f;

		public static int Framecount = 0;

		public static readonly Random getrandom = new Random();

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerControllerB __instance)
		{
			if (!first)
			{
				first = true;
				bossman = ((Component)__instance).GetComponent<HiveMindManager>();
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void beehiveexplode(GrabbableObject __instance)
		{
			//IL_0110: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			if (!GameNetworkManager.Instance.localPlayerController.isHostPlayerObject || !Config.Instance.Enabled.Value || !(((Object)__instance).name == "RedLocustHive(Clone)"))
			{
				return;
			}
			if (Framecount <= 0)
			{
				Framecount = Config.Instance.GlobalExplosionCooldown.Value;
				if (getrandom.Next((int)(800f * Config.Instance.RandomnessMult.Value)) <= getrandom.Next(10))
				{
					knockback = Config.Instance.KnockbackEnabled.Value;
					visible = Config.Instance.VisibleExplosions.Value;
					dmg = Config.Instance.MaxPlayerDamage.Value;
					radius = Config.Instance.Radius.Value;
					rand = getrandom.Next(50);
					where = __instance.itemProperties.positionOffset;
					bossman.servertime(((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.x, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.y, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.z, rand, knockback, visible, dmg, radius);
				}
			}
			else if (Framecount > 0)
			{
				Framecount--;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class HiveCreator
	{
		public static NetworkObject TheHiveMindIsReal;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void beehiveexplode(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.instance.HiveMindPrefabobj);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[BepInPlugin("Pandemonius.BeehiveBomb", "BeehiveBomb", "2.0.0")]
	[BepInDependency("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator", "0.2.5")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Pandemonius.BeehiveBomb");

		internal static Plugin instance;

		internal static ManualLogSource mls;

		private NetcodeValidator netcodebullshitgo;

		public static AssetBundle bundle;

		public GameObject HiveMindPrefabobj;

		public GameObject TheHiveMindIsReal;

		public static ConfigFile BepInExConfig()
		{
			return ((BaseUnityPlugin)instance).Config;
		}

		public void Awake()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hivebombing");
			bundle = AssetBundle.LoadFromFile(text);
			HiveMindPrefabobj = bundle.LoadAsset<GameObject>("Assets/TheHiveMind.prefab");
			HiveMindPrefabobj.AddComponent<HiveMindManager>();
			mls = Logger.CreateLogSource("Pandemonius.BeehiveBomb");
			Config.Instance.Setup();
			mls.LogMessage((object)"Welcome to the HiveMind");
			harmony.PatchAll(typeof(beeupdate));
			netcodebullshitgo = new NetcodeValidator("Pandemonius.BeehiveBomb");
			netcodebullshitgo.PatchAll();
			netcodebullshitgo.BindToPreExistingObjectByBehaviour<HiveMindManager, PlayerControllerB>();
		}
	}
	public class HiveMindManager : NetworkBehaviour
	{
		public void servertime(float x, float y, float z, float rand, bool knockback, bool visible, int dmg, float rad)
		{
			ExplodeAtClientRpc(x, y, z, rand, knockback, visible, dmg, rad);
		}

		[ServerRpc]
		public void ExplodeAtServerRpc(float x, float y, float z, float rand, bool knockback, bool visible, int dmg, float rad, ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			ExplodeAtClientRpc(x, y, z, rand, knockback, visible, dmg, rad);
		}

		[ClientRpc]
		public void ExplodeAtClientRpc(float x, float y, float z, float rand, bool knockback, bool visible, int dmg, float rad)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			Landmine.SpawnExplosion(new Vector3(x, y, z), visible, 0f, rad, dmg, knockback ? rand : 0f, (GameObject)null);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "HiveBomb";

		public const string PLUGIN_NAME = "hivebombnetcode";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}