Decompiled source of BoysClubMegaPack v1.11.5

BoysClubMegaPack.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BoysClubMegaPack.Patches;
using BoysClubMegaPack.Suits;
using BoysClubMegaPack.Util;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalLevelLoader;
using LethalNetworkAPI;
using ModelReplacement;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BoysClubMegaPack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BoysClubMegaPack")]
[assembly: AssemblyTitle("BoysClubMegaPack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BoysClubMegaPack
{
	public class Config : SyncedConfig2<Config>
	{
		public readonly List<ConfigEntry<int>> scrapEntries = new List<ConfigEntry<int>>();

		public readonly ConfigEntry<bool> infStamCompany;

		public readonly ConfigEntry<string> headCanonList;

		public Config(ConfigFile cfg, List<ExtendedItem> scraps)
			: base("boysclub.boysclubmod")
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00a3: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0114: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0155: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			cfg.SaveOnConfigSet = false;
			int num = 0;
			foreach (ExtendedItem scrap in scraps)
			{
				string itemName = scrap.Item.itemName;
				scrapEntries.Add(cfg.Bind<int>(new ConfigDefinition("Scrap Spawn Rate", Regex.Replace(itemName, "[^0-9a-zA-Z: .]+", "").Trim()), scrap.LevelMatchingProperties.levelTags[0].Rarity, new ConfigDescription("The weighted rarity of the " + itemName + " scrap!", (AcceptableValueBase)null, Array.Empty<object>())));
				LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(scrapEntries[num]));
				num++;
			}
			LethalConfigManager.SkipAutoGenFor("Scrap Spawn Rate");
			infStamCompany = cfg.Bind<bool>(new ConfigDefinition("Extra", "Infinite Stamina at Company"), false, new ConfigDescription("Whether to enable infinite stamina at the Company Building or not", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(infStamCompany));
			headCanonList = cfg.Bind<string>(new ConfigDefinition("Extra", "Headcanon Kewtians List"), "All", new ConfigDescription("Which characters should be treated as kewtians (No giant pictures, no planets on statues)\nAcceptable values: (Amy, Villager, Toad, Toadette, Fyre, Toon Link, None, All)", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(headCanonList));
			List<string> list = headCanonList.Value.Split(",").ToList();
			for (int i = 0; i < list.Count; i++)
			{
				if (Regex.IsMatch(list[i].ToLower(), "(?:\\b|')(amy|toad|toadette|villager|fyre|toon link)(?:\\b|')"))
				{
					Plugin.allowedHeadcanons.Add(list[i].ToLower());
				}
				if (Regex.IsMatch(list[i].ToLower(), "(?:\\b|')(none|all)(?:\\b|')"))
				{
					Plugin.allowedHeadcanons.Clear();
					Plugin.allowedHeadcanons.Add(list[i].ToLower());
				}
			}
			ClearUnusedEntries(cfg);
			cfg.Save();
			cfg.SaveOnConfigSet = true;
			ConfigManager.Register<Config>((SyncedConfig2<Config>)this);
		}

		private void ClearUnusedEntries(ConfigFile configFile)
		{
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			dictionary.Clear();
			configFile.Save();
		}
	}
	public class CustomNoisemaker : PhysicsProp
	{
		public AudioSource noiseAudio;

		public AudioSource noiseAudioFar;

		[Space(3f)]
		public AudioClip[] noiseSFX;

		public AudioClip[] noiseSFXFar;

		[Space(3f)]
		public float noiseRange;

		public float maxLoudness;

		public float minLoudness;

		public float minPitch;

		public float maxPitch;

		private Random noisemakerRandom;

		public Animator triggerAnimator;

		private bool wasJustHeld;

		private float sfxCooldown;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			noisemakerRandom = new Random((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (!noiseAudio.isPlaying && (Object)(object)noiseAudio.clip != (Object)null)
			{
				noiseAudio.clip = null;
			}
			if (!noiseAudioFar.isPlaying && (Object)(object)noiseAudioFar.clip != (Object)null)
			{
				noiseAudioFar.clip = null;
			}
			if (sfxCooldown > 0f)
			{
				sfxCooldown -= Time.deltaTime;
			}
			if (sfxCooldown < 0f)
			{
				sfxCooldown = 0f;
			}
			if (((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer != (Object)(object)this) || (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null)
			{
				wasJustHeld = false;
			}
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && (Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer == (Object)(object)this && !wasJustHeld)
			{
				if ((Object)(object)((GrabbableObject)this).itemProperties.grabSFX != (Object)null)
				{
					noiseAudio.Stop();
					noiseAudio.clip = ((GrabbableObject)this).itemProperties.grabSFX;
					noiseAudio.volume = 1f;
					noiseAudio.Play();
					WalkieTalkie.TransmitOneShotAudio(noiseAudio, ((GrabbableObject)this).itemProperties.grabSFX, 1f);
					sfxCooldown = 0.05f;
				}
				wasJustHeld = true;
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			if (!((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null))
			{
				((GrabbableObject)this).playerHeldBy.itemAudio.Stop();
			}
		}

		public override void PocketItem()
		{
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				((GrabbableObject)this).playerHeldBy.IsInspectingItem = false;
			}
			((GrabbableObject)this).isPocketed = true;
			((GrabbableObject)this).EnableItemMeshes(false);
			if ((Object)(object)((GrabbableObject)this).itemProperties.pocketSFX != (Object)null && sfxCooldown <= 0f)
			{
				noiseAudio.clip = ((GrabbableObject)this).itemProperties.pocketSFX;
				noiseAudio.volume = 1f;
				noiseAudio.Play();
				WalkieTalkie.TransmitOneShotAudio(noiseAudio, ((GrabbableObject)this).itemProperties.pocketSFX, 1f);
			}
		}

		public override void PlayDropSFX()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((GrabbableObject)this).itemProperties.dropSFX != (Object)null)
			{
				noiseAudio.clip = ((GrabbableObject)this).itemProperties.dropSFX;
				noiseAudio.Play();
				WalkieTalkie.TransmitOneShotAudio(noiseAudio, ((GrabbableObject)this).itemProperties.dropSFX, 1f);
				if (((NetworkBehaviour)this).IsOwner)
				{
					RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 8f, 0.5f, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 941);
				}
			}
			((GrabbableObject)this).hasHitGround = true;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null))
			{
				int num = noisemakerRandom.Next(0, noiseSFX.Length);
				float num2 = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
				float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
				noiseAudio.pitch = pitch;
				noiseAudio.clip = noiseSFX[num];
				noiseAudio.volume = num2;
				noiseAudio.Play();
				if ((Object)(object)noiseAudioFar != (Object)null)
				{
					noiseAudioFar.pitch = pitch;
					noiseAudioFar.clip = noiseSFXFar[num];
					noiseAudioFar.volume = num2;
					noiseAudioFar.Play();
				}
				if ((Object)(object)triggerAnimator != (Object)null)
				{
					triggerAnimator.SetTrigger("playAnim");
				}
				WalkieTalkie.TransmitOneShotAudio(noiseAudio, noiseSFX[num], num2);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, num2, 0, ((GrabbableObject)this).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
				if (minLoudness >= 0.6f && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
				{
					((GrabbableObject)this).playerHeldBy.timeSinceMakingLoudNoise = 0f;
				}
			}
		}
	}
	public class MaterialVariants : NetworkBehaviour
	{
		[HideInInspector]
		public Item itemData;

		[Tooltip("The mesh renderers to change the material of. This will use the first material in the array.")]
		public MeshRenderer[] meshRenderers;

		[Space(5f)]
		public bool ChangeScanNodeText;

		[Tooltip("The text to change to when the material is changed.")]
		public string[] scanNodeText;

		[Space(5f)]
		[Tooltip("The scan node properties to change the text of.")]
		public ScanNodeProperties scanNodeProperties;

		[HideInInspector]
		public int matID;

		public void Start()
		{
			itemData = ((Component)this).gameObject.GetComponent<GrabbableObject>().itemProperties;
			SetRenderer_ServerRpc();
		}

		[ServerRpc]
		public void SetRenderer_ServerRpc()
		{
			Random.InitState((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
			matID = Random.Range(0, itemData.materialVariants.Length);
			SetRenderer_ClientRpc(matID);
		}

		[ClientRpc]
		private void SetRenderer_ClientRpc(int matid)
		{
			if (!((Object)(object)((Component)this).gameObject.GetComponent<GrabbableObject>() != (Object)null))
			{
				return;
			}
			MeshRenderer[] array = meshRenderers;
			foreach (MeshRenderer val in array)
			{
				if (((Renderer)val).rendererPriority != 70 && ((Component)val).gameObject.layer != LayerMask.NameToLayer("UI"))
				{
					Material[] materials = ((Renderer)val).materials;
					for (int j = 0; j < materials.Length; j++)
					{
						materials[j] = itemData.materialVariants[matid];
					}
					((Renderer)val).materials = materials;
				}
			}
			if (ChangeScanNodeText)
			{
				scanNodeProperties.headerText = scanNodeText[matid];
			}
		}
	}
	[CreateAssetMenu(fileName = "PaintingManifest", menuName = "BoysClubMod/PaintingManifest")]
	public class PaintingManifest : ScriptableObject
	{
		[Tooltip("The mesh to use")]
		public Mesh paintingMesh;

		[Tooltip("What Pictures will use this mesh")]
		public List<Texture2D> paintingTextures;
	}
	public class PictureVariants : NetworkBehaviour
	{
		[Tooltip("The Manifest which houses all pictures and the mesh")]
		public static PaintingManifest paintingType;

		[Space(5f)]
		[Tooltip("What will be changed via painting type")]
		public MeshFilter[] paintingMeshes;

		[Space(5f)]
		[Tooltip("The mesh renderers to change the material of. This will use the first material in the array.")]
		public MeshRenderer[] meshRenderers;

		[HideInInspector]
		public Texture2D pictureID;

		public void Start()
		{
			SetRenderer_ServerRpc();
		}

		[ServerRpc]
		public void SetRenderer_ServerRpc()
		{
			Random.InitState((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
			pictureID = Pictures.PictureTextures[Random.Range(0, Pictures.PictureTextures.Count)];
			for (int i = 0; i < Pictures.PaintingManifests.Length; i++)
			{
				if (Pictures.PaintingManifests[i].paintingTextures.Contains(pictureID))
				{
					paintingType = Pictures.PaintingManifests[i];
				}
			}
			SetRenderer_ClientRpc(pictureID);
		}

		[ClientRpc]
		private void SetRenderer_ClientRpc(Texture2D tex)
		{
			if (!((Object)(object)((Component)this).gameObject.GetComponent<GrabbableObject>() != (Object)null))
			{
				return;
			}
			MeshRenderer[] array = meshRenderers;
			foreach (MeshRenderer val in array)
			{
				if (((Renderer)val).rendererPriority != 70 && ((Component)val).gameObject.layer != LayerMask.NameToLayer("UI"))
				{
					for (int j = 0; j < ((Renderer)val).materials.Length; j++)
					{
						((Renderer)val).materials[j].mainTexture = (Texture)(object)tex;
					}
				}
			}
			for (int k = 0; k < paintingMeshes.Length; k++)
			{
				paintingMeshes[k].mesh = paintingType.paintingMesh;
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.sigurd.csync", "5.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("boysclub.boysclubmod", "BoysClubMegaPack", "1.11.4")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "boysclub.boysclubmod";

		public const string NAME = "BoysClubMegaPack";

		public const string VERSION = "1.11.4";

		public static Plugin instance;

		internal static List<string> allowedHeadcanons = new List<string>();

		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Config Config { get; private set; } = null;


		internal static Harmony Harmony { get; private set; } = new Harmony("boysclub.boysclubmod");


		private void Awake()
		{
			instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			BoysClubMegaPack.Suits.Suits.InitSuits();
			Logger.LogInfo((object)"BoysClubMegaPack Suits Patched!");
			AssetBundleLoader.AddOnExtendedModLoadedListener((Action<ExtendedMod>)OnExtendedModRegistered, (string)null, "BoysClubMegaPack");
			BoysClubMegaPack.Patches.Patches.PatchAll();
		}

		private void OnExtendedModRegistered(ExtendedMod extendedMod)
		{
			if ((Object)(object)extendedMod == (Object)null)
			{
				return;
			}
			Config = new Config(((BaseUnityPlugin)this).Config, extendedMod.ExtendedItems);
			for (int i = 0; i < extendedMod.ExtendedItems.Count; i++)
			{
				if (extendedMod.ExtendedItems[i].LevelMatchingProperties.levelTags != null && extendedMod.ExtendedItems[i].LevelMatchingProperties.levelTags.Count > 0)
				{
					for (int j = 0; j < extendedMod.ExtendedItems[i].LevelMatchingProperties.levelTags.Count; j++)
					{
						extendedMod.ExtendedItems[i].LevelMatchingProperties.levelTags[j].Rarity = Config.scrapEntries[i].Value;
					}
				}
			}
			Pictures.RegisterPictures();
			Logger.LogInfo((object)"BoysClubMegaPack Pictures Patched!");
			Logger.LogInfo((object)"BoysClubMegaPack Scrap Patched!");
		}
	}
	public static class Assets
	{
		public static AssetBundle SuitsAssetBundle;

		public static AssetBundle PictureAssetBundle;

		public static void PopulateAssets()
		{
			if ((Object)(object)SuitsAssetBundle == (Object)null)
			{
				string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/BoysClub", "boysclubmegapacksuits");
				SuitsAssetBundle = AssetBundle.LoadFromFile(text);
			}
			if ((Object)(object)PictureAssetBundle == (Object)null)
			{
				string text2 = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/BoysClub", "boysclubpictures");
				PictureAssetBundle = AssetBundle.LoadFromFile(text2);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BoysClubMegaPack";

		public const string PLUGIN_NAME = "BoysClubMegaPack";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BoysClubMegaPack.Suits
{
	public class Suits
	{
		public static void InitSuits()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			ModelReplacementAPI.RegisterSuitModelReplacement("Amy Rose", typeof(MRAMYROSESUITMODEL));
			ModelReplacementAPI.RegisterSuitModelReplacement("Toon Link", typeof(MRTOONLINKSUIT));
			Harmony val = new Harmony("com.boysclub.megapacksuits");
			val.PatchAll();
		}
	}
	public class MRAMYROSESUITMODEL : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			return Assets.SuitsAssetBundle.LoadAsset<GameObject>("AmyRoseSuitModel");
		}
	}
	public class MRTOONLINKSUIT : BodyReplacementBase
	{
		protected override GameObject LoadAssetsAndReturnModel()
		{
			return Assets.SuitsAssetBundle.LoadAsset<GameObject>("ToonLinkSuit");
		}
	}
}
namespace BoysClubMegaPack.Util
{
	public class Pictures
	{
		public static PaintingManifest[] PaintingManifests;

		public static List<Texture2D> PictureTextures = new List<Texture2D>();

		public static void RegisterPictures()
		{
			PaintingManifests = Assets.PictureAssetBundle.LoadAllAssets<PaintingManifest>();
			PaintingManifest[] paintingManifests = PaintingManifests;
			foreach (PaintingManifest paintingManifest in paintingManifests)
			{
				foreach (Texture2D paintingTexture in paintingManifest.paintingTextures)
				{
					if ((!Plugin.allowedHeadcanons.Contains("none".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "\\W*(_AMY|_TOADETTE|_TOAD|_VILLAGER|_FYRE|_TL)\\W*")) && (Plugin.allowedHeadcanons.Contains("all".TrimStart()) || ((Plugin.allowedHeadcanons.Contains("amy".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_AMY")) && (Plugin.allowedHeadcanons.Contains("villager".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_VILLAGER")) && (Plugin.allowedHeadcanons.Contains("toon link".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_TL")) && (Plugin.allowedHeadcanons.Contains("toadette".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_TOADETTE")) && (Plugin.allowedHeadcanons.Contains("toad".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_TOAD") || Regex.IsMatch(((Object)paintingTexture).name, "_TOADETTE")) && (Plugin.allowedHeadcanons.Contains("fyre".TrimStart()) || !Regex.IsMatch(((Object)paintingTexture).name, "_FYRE")))))
					{
						PictureTextures.Add(paintingTexture);
					}
				}
			}
		}
	}
	internal class UtilEffects
	{
		public static IEnumerator Explosion(int range, float waitTime = 0f, GrabbableObject obj = null, Vector3 position = default(Vector3), bool destroy = false)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(waitTime);
			Landmine.SpawnExplosion(((Object)(object)obj != (Object)null) ? ((Component)obj).transform.position : position, true, (float)range, (float)(range * 2), 50, 1f, (GameObject)null, false);
			if (destroy && (Object)(object)obj != (Object)null)
			{
				DestroyObjectServerRpc(NetworkObjectReference.op_Implicit(((Component)obj).GetComponent<NetworkObject>()));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public static void DestroyObjectServerRpc(NetworkObjectReference obj)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			DestroyObjectClientRpc(obj);
		}

		[ClientRpc]
		private static void DestroyObjectClientRpc(NetworkObjectReference obj)
		{
			NetworkObject val = default(NetworkObject);
			if (((NetworkObjectReference)(ref obj)).TryGet(ref val, (NetworkManager)null))
			{
				DestroyObject(((Component)val).gameObject.GetComponentInChildren<GrabbableObject>());
			}
		}

		private static void DestroyObject(GrabbableObject grabbableObject)
		{
			if ((Object)(object)grabbableObject != (Object)null)
			{
				FlashlightItem val = (FlashlightItem)(object)((grabbableObject is FlashlightItem) ? grabbableObject : null);
				if (val != null && ((GrabbableObject)val).isBeingUsed)
				{
					((GrabbableObject)val).isBeingUsed = false;
					val.usingPlayerHelmetLight = false;
					((Behaviour)val.flashlightBulbGlow).enabled = false;
					val.SwitchFlashlight(false);
				}
				grabbableObject.DestroyObjectInHand(grabbableObject.playerHeldBy);
				((Component)grabbableObject).GetComponentInParent<NetworkObject>().Despawn(true);
			}
		}

		public static void Damage(PlayerControllerB player, int damageNb, int animation = 0, bool criticalBlood = true, bool hasSfx = true)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (criticalBlood && player.health - damageNb <= 20)
			{
				player.bleedingHeavily = true;
			}
			player.DamagePlayer(damageNb, hasSfx, true, (CauseOfDeath)0, animation, false, default(Vector3));
		}

		[ServerRpc(RequireOwnership = false)]
		public static void HealPlayerServerRpc(ulong playerID, int health)
		{
			HealPlayerClientRpc(playerID, health);
		}

		[ClientRpc]
		private static void HealPlayerClientRpc(ulong playerID, int health)
		{
			Heal(playerID, health);
		}

		public static void Heal(ulong playerID, int health)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerID];
			val.health = health;
			val.criticallyInjured = false;
			val.bleedingHeavily = false;
			val.playerBodyAnimator.SetBool("Limp", false);
			HUDManager.Instance.UpdateHealthUI(health, false);
		}

		public static void Message(string title, string bottom, bool warning = false)
		{
			HUDManager.Instance.DisplayTip(title, bottom, warning, false, "LC_Tip1");
		}

		public static void Spawn(string scrapName, Vector3 position)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Item val = ((IEnumerable<Item>)StartOfRound.Instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item i) => ((Object)i).name.Equals(scrapName)));
			GameObject val2 = Object.Instantiate<GameObject>(val.spawnPrefab, position, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
			val2.GetComponent<NetworkObject>().Spawn(false);
			GrabbableObject component = val2.GetComponent<GrabbableObject>();
			((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation);
			component.fallTime = 0f;
			component.FallToGround(true);
			Random.InitState((int)val2.GetComponent<NetworkObject>().NetworkObjectId);
			component.SetScrapValue((int)((float)Random.Range(val.minValue, val.maxValue) * RoundManager.Instance.scrapValueMultiplier));
		}
	}
}
namespace BoysClubMegaPack.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infiniteSprintPatch(ref float ___sprintMeter)
		{
			if (Plugin.Config.infStamCompany.Value && ((Object)StartOfRound.Instance.currentLevel).name == "CompanyBuildingLevel" && !StartOfRound.Instance.inShipPhase)
			{
				___sprintMeter = 1f;
			}
		}
	}
	internal class Patches
	{
		public static void PatchAll()
		{
			Plugin.Harmony.PatchAll(typeof(Plugin));
			Plugin.Harmony.PatchAll();
		}
	}
}
namespace BoysClubMegaPack.Effects
{
	public class BoysClubEffects : MonoBehaviour
	{
		private GrabbableObject go;

		private PlayerControllerB previousPlayerHeldBy;

		private ScanNodeProperties scanNode;

		public bool healOverTime;

		[SerializeField]
		private float healSpeed = 1f;

		private float healTimer = 0f;

		public bool spinOverTime;

		[SerializeField]
		private float spinSpeed = 1f;

		[SerializeField]
		private Transform spinObj;

		public bool boggle;

		public bool rotateOnInspect;

		[SerializeField]
		private Vector3 inspectRotation;

		public bool randomScanNumber;

		[SerializeField]
		private string rsnScanName;

		[SerializeField]
		private Vector2 rsnMinMax;

		private void Awake()
		{
			go = ((Component)this).GetComponent<GrabbableObject>();
			scanNode = ((Component)this).GetComponentInChildren<ScanNodeProperties>();
		}

		private void Start()
		{
			if (randomScanNumber)
			{
				RandomScanNumber();
			}
		}

		private void Update()
		{
			if (healOverTime)
			{
				HealOverTime();
			}
			if (spinOverTime)
			{
				SpinOverTime();
			}
			if (boggle)
			{
				Boggle();
			}
		}

		private void LateUpdate()
		{
			if (rotateOnInspect)
			{
				RotateOnInspect();
			}
		}

		protected void HealOverTime()
		{
			if (!go.isHeld || go.isHeldByEnemy || (Object)(object)go.playerHeldBy == (Object)null || (Object)(object)go.playerHeldBy.currentlyHeldObjectServer != (Object)(object)go || go.playerHeldBy.health >= 100)
			{
				healTimer = 0f;
				return;
			}
			healTimer += healSpeed * Time.deltaTime;
			if (!(healTimer < 1f))
			{
				UtilEffects.HealPlayerServerRpc(StartOfRound.Instance.localPlayerController.playerClientId, go.playerHeldBy.health + (int)healTimer);
				healTimer %= 1f;
			}
		}

		protected void SpinOverTime()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)spinObj == (Object)null))
			{
				spinObj.Rotate(Vector3.up * spinSpeed * Time.deltaTime);
			}
		}

		protected void Boggle()
		{
			if ((Object)(object)go.playerHeldBy != (Object)null)
			{
				int num = 0;
				for (int i = 0; i < go.playerHeldBy.ItemSlots.Length; i++)
				{
					if (!((Object)(object)go.playerHeldBy.ItemSlots[i] == (Object)null) && !((Object)(object)((Component)go.playerHeldBy.ItemSlots[i]).GetComponent<BoysClubEffects>() == (Object)null) && ((Component)go.playerHeldBy.ItemSlots[i]).GetComponent<BoysClubEffects>().boggle)
					{
						num++;
					}
				}
				if ((Object)(object)previousPlayerHeldBy != (Object)(object)go.playerHeldBy)
				{
					previousPlayerHeldBy = go.playerHeldBy;
				}
				go.playerHeldBy.drunkness = Mathf.Clamp((float)num / 6.1538463f, 0f, 1f);
			}
			else if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				previousPlayerHeldBy.drunkness = 0f;
				previousPlayerHeldBy = null;
			}
		}

		protected void RotateOnInspect()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)go.playerHeldBy == (Object)null) && go.playerHeldBy.IsInspectingItem && (Object)(object)go.playerHeldBy.currentlyHeldObjectServer == (Object)(object)go && (Object)(object)go.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				((Component)go).transform.rotation = go.parentObject.rotation;
				((Component)go).transform.Rotate(inspectRotation);
			}
		}

		protected void RandomScanNumber()
		{
			if (!((Object)(object)scanNode == (Object)null))
			{
				Random.InitState((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
				scanNode.headerText = rsnScanName + " #" + Random.RandomRangeInt((int)rsnMinMax.x, (int)rsnMinMax.y + 1);
			}
		}
	}
	public class BrutalStare : MonoBehaviour
	{
		[SerializeField]
		private Transform marioHead;

		private PlayerControllerB player;

		private GrabbableObject go;

		private void Start()
		{
			player = GameNetworkManager.Instance.localPlayerController;
			go = ((Component)this).GetComponent<GrabbableObject>();
		}

		private void Update()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player == (Object)null) && !((Object)(object)marioHead == (Object)null) && (Object)(object)((Component)this).gameObject.GetComponent<GrabbableObject>() != (Object)null)
			{
				if ((Object)(object)go.playerHeldBy != (Object)(object)player || go.playerHeldBy.IsInspectingItem)
				{
					marioHead.LookAt(2f * marioHead.position - player.cameraContainerTransform.position);
				}
				if ((Object)(object)go.playerHeldBy == (Object)(object)player && !go.playerHeldBy.IsInspectingItem)
				{
					marioHead.localRotation = Quaternion.Euler(0f, 188f, 0f);
				}
			}
		}
	}
	public class CoomerSpeech : MonoBehaviour
	{
		private CustomNoisemaker nm;

		private AudioSource source;

		public float updateStep = 0.02f;

		public int sampleDataLength = 1024;

		public Transform mouth;

		private float mouthInitX;

		private float mouthInitY;

		private float currentUpdateTime = 0f;

		private float clipLoudness;

		private float[] clipSampleData;

		private void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			nm = ((Component)this).GetComponent<CustomNoisemaker>();
			clipSampleData = new float[sampleDataLength];
			mouthInitX = mouth.localPosition.x;
			mouthInitY = mouth.localPosition.y;
		}

		private void Update()
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mouth == (Object)null)
			{
				return;
			}
			source = ((!((Object)(object)((GrabbableObject)nm).playerHeldBy != (Object)null)) ? nm.noiseAudio : (((Object)(object)nm.noiseAudio == (Object)null && (Object)(object)((GrabbableObject)nm).playerHeldBy.itemAudio != (Object)null) ? ((GrabbableObject)nm).playerHeldBy.itemAudio : nm.noiseAudio));
			if ((Object)(object)source.clip == (Object)null)
			{
				mouth.localPosition = Vector3.Lerp(mouth.localPosition, new Vector3(mouthInitX, mouthInitY, mouth.localPosition.z), 0.6f);
				return;
			}
			currentUpdateTime += Time.deltaTime;
			if (currentUpdateTime >= updateStep)
			{
				currentUpdateTime = 0f;
				source.clip.GetData(clipSampleData, source.timeSamples);
				clipLoudness = 0f;
				float[] array = clipSampleData;
				foreach (float num in array)
				{
					clipLoudness += Mathf.Abs(num);
				}
				clipLoudness /= sampleDataLength;
			}
			mouth.localPosition = Vector3.Lerp(mouth.localPosition, new Vector3(Mathf.Clamp(mouthInitX + clipLoudness * 30f, mouthInitX, mouthInitX + 0.85f), Mathf.Clamp(mouthInitY + clipLoudness * 20f, mouthInitY, mouthInitY + 0.28f), mouth.localPosition.z), 0.8f);
		}
	}
	public class FoodProp : GrabbableObject
	{
		public int healPower = 50;

		public float staminaPower = 0.5f;

		public Vector3? originalPosition = null;

		public Vector3? originalRotation = null;

		public AudioClip eatSound;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if ((Object)(object)base.playerHeldBy != (Object)null && !base.playerHeldBy.activatingItem)
			{
				originalPosition = base.itemProperties.positionOffset;
				originalRotation = base.itemProperties.rotationOffset;
				UpdatePosRotServerRpc(new Vector3(0.1f, 0.1f, 0f), new Vector3(90f, 90f, -90f));
				base.playerHeldBy.activatingItem = buttonDown;
				base.playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", buttonDown);
				((MonoBehaviour)this).StartCoroutine(FoodEffect(base.playerHeldBy));
			}
		}

		private IEnumerator FoodEffect(PlayerControllerB player)
		{
			yield return (object)new WaitForSeconds(0.8f);
			base.playerHeldBy.itemAudio.clip = eatSound;
			base.playerHeldBy.itemAudio.volume = 1f;
			base.playerHeldBy.itemAudio.Play();
			WalkieTalkie.TransmitOneShotAudio(base.playerHeldBy.itemAudio, base.playerHeldBy.itemAudio.clip, 1f);
			UpdatePosRotServerRpc((Vector3)(originalPosition.HasValue ? originalPosition.Value : default(Vector3)), (Vector3)(originalRotation.HasValue ? originalRotation.Value : default(Vector3)));
			player.playerBodyAnimator.SetBool("useTZPItem", false);
			player.activatingItem = false;
			if (!player.isPlayerDead)
			{
				ulong playerID = StartOfRound.Instance.localPlayerController.playerClientId;
				player.sprintMeter += staminaPower;
				player.sprintMeter = Mathf.Clamp(player.sprintMeter, 0f, 1f);
				UtilEffects.HealPlayerServerRpc(playerID, (player.health + healPower > 100) ? 100 : (player.health + healPower));
				UtilEffects.DestroyObjectServerRpc(NetworkObjectReference.op_Implicit(((Component)this).gameObject.GetComponent<NetworkObject>()));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void UpdatePosRotServerRpc(Vector3 newPos, Vector3 newRot)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			UpdatePosRotClientRpc(newPos, newRot);
		}

		[ClientRpc]
		private void UpdatePosRotClientRpc(Vector3 newPos, Vector3 newRot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			base.itemProperties.positionOffset = newPos;
			base.itemProperties.rotationOffset = newRot;
		}
	}
	internal class PCExplosion : NoisemakerProp
	{
		public LethalClientMessage<Vector3> pcBoomID;

		public override void Start()
		{
			((NoisemakerProp)this).Start();
			pcBoomID = new LethalClientMessage<Vector3>("boysclubPCExplosionID" + ((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId, (Action<Vector3>)null, (Action<Vector3, ulong>)null);
			pcBoomID.OnReceivedFromClient += SpawnExplosionNetwork;
		}

		private void SpawnExplosionNetwork(Vector3 position, ulong clientId)
		{
			((MonoBehaviour)this).StartCoroutine(SpawnTheExplosion());
		}

		private IEnumerator SpawnTheExplosion()
		{
			yield return ((MonoBehaviour)this).StartCoroutine(UtilEffects.Explosion(5, 2.75f, (GrabbableObject)(object)this));
			UtilEffects.Spawn("PileOfAshItem", ((Component)this).transform.position + Vector3.up);
			UtilEffects.DestroyObjectServerRpc(NetworkObjectReference.op_Implicit(((Component)this).gameObject.GetComponent<NetworkObject>()));
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			((NoisemakerProp)this).ItemActivate(used, buttonDown);
			if (buttonDown && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				pcBoomID.SendAllClients(((Component)((GrabbableObject)this).playerHeldBy).transform.position, true, false);
			}
		}
	}
	public class SpawnObjectOnScrapPoints : MonoBehaviour
	{
		private GrabbableObject item;

		[SerializeField]
		private bool isKewtianPlanets;

		public Transform objContainer;

		private List<Transform> objSpots = new List<Transform>();

		public GameObject[] objPrefabs;

		public void Start()
		{
			item = ((Component)this).gameObject.GetComponent<GrabbableObject>();
			if (isKewtianPlanets && ((Plugin.allowedHeadcanons.Contains("none".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "\\W*(Amy Rose Statue|Toadette Statue|Toad Statue|Villager Statue|Tenacious Fyre|Toon Link Statue)\\W*")) || (!Plugin.allowedHeadcanons.Contains("all".TrimStart()) && ((!Plugin.allowedHeadcanons.Contains("amy".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Amy Rose Statue")) || (!Plugin.allowedHeadcanons.Contains("villager".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Villager Statue")) || (!Plugin.allowedHeadcanons.Contains("toon link".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Toon Link Statue")) || (!Plugin.allowedHeadcanons.Contains("toadette".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Toadette Statue")) || (!Plugin.allowedHeadcanons.Contains("toad".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Toad Statue")) || (!Plugin.allowedHeadcanons.Contains("fyre".TrimStart()) && Regex.IsMatch(item.itemProperties.itemName, "Tenacious Fyre"))))))
			{
				((Behaviour)this).enabled = false;
			}
			else
			{
				if ((Object)(object)objContainer == (Object)null)
				{
					return;
				}
				foreach (Transform item in from go in ((Component)objContainer).GetComponentsInChildren<Transform>()
					where (Object)(object)go != (Object)(object)objContainer
					select go)
				{
					objSpots.Add(item);
				}
				if (objSpots.Count != 0 && !((Object)(object)objContainer == (Object)null) && !((Object)(object)this.item == (Object)null))
				{
					Random.InitState((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
					if (Random.Range(0, 5) == 0)
					{
						GameObject val = Object.Instantiate<GameObject>(objPrefabs[Random.Range(0, objPrefabs.Length)], objSpots[Random.Range(0, objSpots.Count)]);
					}
				}
			}
		}
	}
	internal class TielExplosion : PhysicsProp
	{
		public LethalClientMessage<Vector3> tielBoomID;

		[SerializeField]
		private Transform hoodDown;

		[SerializeField]
		private Transform hoodUp;

		[SerializeField]
		private Transform tiel;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			tielBoomID = new LethalClientMessage<Vector3>("boysclubtielBoomID" + ((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId, (Action<Vector3>)null, (Action<Vector3, ulong>)null);
			tielBoomID.OnReceivedFromClient += SpawnExplosionNetwork;
			Random.InitState((int)((Component)this).gameObject.GetComponent<NetworkObject>().NetworkObjectId);
			int num = Random.RandomRangeInt(0, 2);
			Transform obj = tiel;
			if (obj != null)
			{
				((Component)obj).gameObject.GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, (float)((num == 1) ? 100 : 0));
			}
			Transform obj2 = hoodUp;
			if (obj2 != null)
			{
				((Component)obj2).gameObject.SetActive(num != 1);
			}
			Transform obj3 = hoodDown;
			if (obj3 != null)
			{
				((Component)obj3).gameObject.SetActive(num == 1);
			}
		}

		private void SpawnExplosionNetwork(Vector3 position, ulong clientId)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(UtilEffects.Explosion(8, 0f, (GrabbableObject)(object)this));
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && (Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
			{
				tielBoomID.SendAllClients(((Component)((GrabbableObject)this).playerHeldBy).transform.position, true, false);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}