using System;
using System.Collections;
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 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")]
[assembly: AssemblyProduct("HiveBombFixer3")]
[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 HiveBombFixer3
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HiveBomb";
public const string PLUGIN_NAME = "HiveBombFixer3";
public const string PLUGIN_VERSION = "1.0.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 ConfigEntry<bool> Debug { 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>()));
Debug = Plugin.BepInExConfig().Bind<bool>("Developer", "Logging", false, "Beats you with a log");
}
}
public class SyncConfigs : MonoBehaviour
{
public static Vector3 where = default(Vector3);
public static int rand = 0;
public void Update()
{
if (Plugin.PauseUntilCoroutine)
{
((MonoBehaviour)this).StartCoroutine(SendOnceSynced(Plugin.currentObj));
Plugin.PauseUntilCoroutine = false;
}
}
public IEnumerator SendOnceSynced(GrabbableObject __instance)
{
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Sending ping");
}
((Component)RoundManager.Instance).GetComponent<HiveMindManager>().ConfigPingServerRpc(Config.Instance.KnockbackEnabled.Value, Config.Instance.VisibleExplosions.Value, Config.Instance.Radius.Value, Config.Instance.MaxPlayerDamage.Value);
yield return (object)new WaitUntil((Func<bool>)(() => (Plugin.knockback == Config.Instance.KnockbackEnabled.Value) & (Plugin.visible == Config.Instance.VisibleExplosions.Value) & (Plugin.radius == Config.Instance.Radius.Value) & (Plugin.maxdmg == Config.Instance.MaxPlayerDamage.Value)));
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Configs updated");
}
yield return (object)new WaitForSeconds(0.025f);
rand = Plugin.getrandom.Next(50);
where = __instance.itemProperties.positionOffset;
((Component)RoundManager.Instance).GetComponent<HiveMindManager>().ExplodePingServerRpc(((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.x + where.x, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.y + where.y, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.z + where.z, rand);
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Exploding in coroutine");
}
}
}
[HarmonyPatch(typeof(GrabbableObject))]
internal class beeupdate
{
[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;
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static void beehiveexplode(GrabbableObject __instance)
{
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
{
return;
}
if (!Plugin.addedCoroutine)
{
((Component)RoundManager.Instance).gameObject.AddComponent<SyncConfigs>();
Plugin.addedCoroutine = true;
}
if (!(Config.Instance.Enabled.Value & !Plugin.PauseUntilCoroutine) || !(((Object)__instance).name == "RedLocustHive(Clone)"))
{
return;
}
if (Framecount <= 0)
{
Framecount = Config.Instance.GlobalExplosionCooldown.Value;
if (Plugin.getrandom.Next((int)(800f * Config.Instance.RandomnessMult.Value)) > Plugin.getrandom.Next(10))
{
return;
}
if (Plugin.knockback != Config.Instance.KnockbackEnabled.Value || Plugin.visible != Config.Instance.VisibleExplosions.Value || Plugin.radius != Config.Instance.Radius.Value || Plugin.maxdmg != Config.Instance.MaxPlayerDamage.Value)
{
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Trying to sync configs");
}
Plugin.currentObj = __instance;
Plugin.PauseUntilCoroutine = true;
return;
}
rand = Plugin.getrandom.Next(50);
where = __instance.itemProperties.positionOffset;
((Component)RoundManager.Instance).GetComponent<HiveMindManager>().ExplodePingServerRpc(((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.x + where.x, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.y + where.y, ((Component)((NetworkBehaviour)__instance).NetworkObject).transform.position.z + where.z, rand);
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Exploding");
}
}
else if (Framecount > 0)
{
Framecount--;
}
}
}
[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 Validator;
public GameObject TheHiveMindIsReal;
public static bool islobbyHost = false;
public static bool checkedClient = false;
public static bool knockback = true;
public static bool visible = true;
public static float radius = 0f;
public static int maxdmg = 0;
public float updatetimer = 0f;
public static bool addedCoroutine = false;
public static readonly Random getrandom = new Random();
public static bool PauseUntilCoroutine = false;
public static GrabbableObject currentObj;
public static ConfigFile BepInExConfig()
{
return ((BaseUnityPlugin)instance).Config;
}
public void Awake()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
instance = this;
mls = Logger.CreateLogSource("Pandemonius.BeehiveBomb");
Config.Instance.Setup();
harmony.PatchAll(typeof(beeupdate));
harmony.PatchAll(typeof(CheckOwnership));
harmony.PatchAll(typeof(ResetInfo));
Validator = new NetcodeValidator("Pandemonius.BeehiveBomb");
Validator.PatchAll();
Validator.BindToPreExistingObjectByBehaviour<HiveMindManager, RoundManager>();
mls.LogMessage((object)"Welcome to the HiveMind");
}
}
public class HiveMindManager : NetworkBehaviour
{
public static HiveMindManager Instance { get; private set; }
[ServerRpc(RequireOwnership = false)]
public void PingServerRpc(ServerRpcParams rpcParams = default(ServerRpcParams))
{
PongClientRpc();
}
[ClientRpc]
public void PongClientRpc()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.islobbyHost)
{
ConfigPingServerRpc(Config.Instance.KnockbackEnabled.Value, Config.Instance.VisibleExplosions.Value, Config.Instance.Radius.Value, Config.Instance.MaxPlayerDamage.Value);
}
}
[ServerRpc]
public void ConfigPingServerRpc(bool knock, bool visible, float radius, int dmg, ServerRpcParams rpcParams = default(ServerRpcParams))
{
ConfigPongClientRpc(knock, visible, radius, dmg);
}
[ClientRpc]
public void ConfigPongClientRpc(bool knock, bool visible, float radius, int dmg)
{
Plugin.knockback = knock;
Plugin.visible = visible;
Plugin.radius = radius;
Plugin.maxdmg = dmg;
}
[ServerRpc]
public void ExplodePingServerRpc(float x, float y, float z, int rand, ServerRpcParams rpcParams = default(ServerRpcParams))
{
ExplodePongClientRpc(x, y, z, rand);
}
[ClientRpc]
public void ExplodePongClientRpc(float x, float y, float z, int rand)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
try
{
Landmine.SpawnExplosion(new Vector3(x, y, z), Plugin.visible, 0f, Plugin.radius, Plugin.maxdmg, (float)(Plugin.knockback ? rand : 0), (GameObject)null, false);
}
catch
{
}
}
private void Awake()
{
if (!((NetworkBehaviour)this).IsHost)
{
((MonoBehaviour)this).StartCoroutine(WaitForSomeTime());
}
}
private IEnumerator WaitForSomeTime()
{
yield return (object)new WaitUntil((Func<bool>)(() => ((NetworkBehaviour)this).NetworkObject.IsSpawned));
PingServerRpc();
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class CheckOwnership
{
[HarmonyPatch("ConnectClientToPlayerObject")]
[HarmonyPostfix]
private static void SpawnNetworkHandler()
{
try
{
Plugin.checkedClient = true;
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
Plugin.islobbyHost = true;
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Im hosting");
}
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class ResetInfo
{
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPostfix]
public static void ResetKnownInfo()
{
Plugin.addedCoroutine = false;
Plugin.islobbyHost = false;
Plugin.checkedClient = false;
if (Object.op_Implicit((Object)(object)((Component)RoundManager.Instance).GetComponent<HiveMindManager>()))
{
Object.Destroy((Object)(object)((Component)RoundManager.Instance).GetComponent<HiveMindManager>());
}
if (Config.Instance.Debug.Value)
{
Plugin.mls.LogInfo((object)"Reset");
}
}
}
}