Decompiled source of German AIO Memepack v1.3.1

BepInEx/plugins/AIO Memepack.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCSoundTool;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AIO Memepack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AIO Memepack")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("15158709-8f1c-44eb-abf8-90eb79e9d414")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AIO_Memepack
{
	internal class AudioManager
	{
		private static List<AudioClip> loadedClips = new List<AudioClip>();

		public static AudioClip getAudioClip(string filename)
		{
			if (loadedClips.Count == 0 || !isClipLoaded(filename))
			{
				AudioClip audioClip = SoundTool.GetAudioClip("Dom3005-German_AIO_Memepack", "AIO Memepack", filename);
				((Object)audioClip).name = filename;
				loadedClips.Add(audioClip);
				return audioClip;
			}
			return getLoadedClip(filename);
		}

		public static AudioClip getRandomClip(params string[] filenames)
		{
			return getAudioClip(filenames[Random.Range(0, filenames.Length)]);
		}

		public static AudioClip[] getAllClips(params string[] filenames)
		{
			AudioClip[] array = (AudioClip[])(object)new AudioClip[filenames.Length];
			for (int i = 0; i < filenames.Length; i++)
			{
				array[i] = getAudioClip(filenames[i]);
			}
			return array;
		}

		private static AudioClip getLoadedClip(string filename)
		{
			foreach (AudioClip loadedClip in loadedClips)
			{
				if (((Object)loadedClip).name == filename)
				{
					return loadedClip;
				}
			}
			return null;
		}

		private static bool isClipLoaded(string filename)
		{
			foreach (AudioClip loadedClip in loadedClips)
			{
				if (((Object)loadedClip).name == filename)
				{
					return true;
				}
			}
			return false;
		}

		public static AudioSource createAudioSource(Vector3 position, Transform parent, float distance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			AudioSource obj = Object.Instantiate<GameObject>(new GameObject(), position, Quaternion.identity, parent).AddComponent<AudioSource>();
			obj.maxDistance = distance;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			return obj;
		}
	}
	public class AudioCollection
	{
		public List<AudioClip> clips;

		public string collectionName;

		public AudioCollection(List<AudioClip> _clips, string _name)
		{
			clips = _clips;
			collectionName = _name;
		}
	}
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class BoomboxPatch
	{
		private static int currentSongIndex;

		private static PlayerActions playerActions;

		[HarmonyPatch("UseUpBatteries")]
		[HarmonyPrefix]
		public static bool depleteBattery(ref BoomboxItem __instance)
		{
			((GrabbableObject)__instance).insertedBattery.charge = 1f;
			return false;
		}

		[HarmonyPatch("StartMusic")]
		[HarmonyPrefix]
		public static bool StartMusic(ref bool startMusic, ref BoomboxItem __instance)
		{
			if (startMusic)
			{
				__instance.boomboxAudio.clip = NextSong(__instance);
				__instance.boomboxAudio.pitch = 1f;
				__instance.boomboxAudio.Play();
				((GrabbableObject)__instance).isBeingUsed = true;
				__instance.isPlayingMusic = true;
				return false;
			}
			return true;
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void Update(ref BoomboxItem __instance)
		{
			((GrabbableObject)__instance).insertedBattery.charge = 1f;
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void Start(ref BoomboxItem __instance)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			BoomboxItem inst = __instance;
			playerActions = new PlayerActions();
			MovementActions movement = playerActions.Movement;
			((MovementActions)(ref movement)).QEItemInteract.performed += delegate(CallbackContext ctx)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				PlayNextSong(ctx, inst);
			};
			movement = playerActions.Movement;
			((MovementActions)(ref movement)).Enable();
		}

		public static void PlayNextSong(CallbackContext context, BoomboxItem __instance)
		{
			if (!((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)null) && ((GrabbableObject)__instance).playerHeldBy.playerClientId == StartOfRound.Instance.localPlayerController.playerClientId && ((CallbackContext)(ref context)).control.path.EndsWith("q"))
			{
				((GrabbableObject)__instance).UseItemOnClient(false);
				((GrabbableObject)__instance).UseItemOnClient(true);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public static void PlayNextServerRpc(BoomboxItem __instance, AudioClip nextClip)
		{
			__instance.boomboxAudio.clip = nextClip;
			__instance.boomboxAudio.pitch = 1f;
			__instance.boomboxAudio.Play();
			((GrabbableObject)__instance).isBeingUsed = true;
			__instance.isPlayingMusic = true;
			PlayNextClient(__instance, nextClip);
		}

		[ClientRpc]
		public static void PlayNextClient(BoomboxItem __instance, AudioClip clip)
		{
			__instance.boomboxAudio.clip = clip;
			__instance.boomboxAudio.pitch = 1f;
			__instance.boomboxAudio.Play();
			((GrabbableObject)__instance).isBeingUsed = true;
			__instance.isPlayingMusic = true;
		}

		public static AudioClip NextSong(BoomboxItem __instance)
		{
			return __instance.musicAudios[Random.Range(0, __instance.musicAudios.Length)];
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	internal class BrackenPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref FlowermanAI __instance)
		{
			__instance.crackNeckSFX = AudioManager.getRandomClip("bluetooth.mp3");
		}
	}
	[HarmonyPatch(typeof(HoarderBugAI))]
	internal class BugPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref HoarderBugAI __instance)
		{
			((Component)__instance).gameObject.GetComponentInChildren<MeshFilter>().mesh = null;
			__instance.chitterSFX = AudioManager.getAllClips("happy.mp3", "yippee.mp3", "ich-bins-farid.mp3");
			__instance.angryScreechSFX = AudioManager.getAllClips("bing-bong.mp3", "pimmelberger.mp3");
		}
	}
	internal static class ConfigManager
	{
		private const string CONFIG_FILE_NAME = "aio_memepack.cfg";

		private static ConfigFile _config;

		public static ConfigEntry<float> _flashlightStrength;

		public static ConfigEntry<int> _shovelStrength;

		public static ConfigEntry<int> _dropshipFirstWait;

		public static ConfigEntry<int> _dropshipNormalWait;

		public static ConfigEntry<bool> _enableBoomboxSpawner;

		public static ConfigEntry<bool> _enableInfiniteSprint;

		public static ConfigEntry<bool> _enableFlashlightColors;

		public static ConfigEntry<bool> _disableEarlyLeaveVote;

		public static ConfigEntry<bool> _overrideSoundToolConfig;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			_config = new ConfigFile(Path.Combine(Paths.ConfigPath, "aio_memepack.cfg"), true);
			_flashlightStrength = _config.Bind<float>("Config", "flashlightIntensity", 5f, "Basegame uses 1.0");
			_shovelStrength = _config.Bind<int>("Config", "shovelStrength", 2, "Damage the shovel does\nBasegame uses 1.0");
			_dropshipFirstWait = _config.Bind<int>("Config", "dropshipFirstWait", 5, "Basegame uses 20");
			_dropshipNormalWait = _config.Bind<int>("Config", "dropshipNormalWait", 5, "Basegame uses 40");
			_enableBoomboxSpawner = _config.Bind<bool>("Config", "enableBoomboxSpawner", true, "Spawns a boombox on the first run of the game");
			_enableInfiniteSprint = _config.Bind<bool>("Config", "enableInfiniteSprint", true, "Allows the player to sprint indefinetly");
			_enableFlashlightColors = _config.Bind<bool>("Config", "enableFlashlightColors", true, "Makes each flashlight have a random color");
			_disableEarlyLeaveVote = _config.Bind<bool>("Config", "disableEarlyLeaveVote", true, "Removes the feature for dead players to vote to leave early");
			_overrideSoundToolConfig = _config.Bind<bool>("Config", "overrideSoundToolConfig", true, "Overrides the network config variables of the LC Soundtool mod, which make this mod work");
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositDeskPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref DepositItemsDesk __instance)
		{
			shuffleSounds(__instance);
			AudioSource speakerAudio = __instance.speakerAudio;
			speakerAudio.maxDistance *= 3f;
			AudioSource speakerAudio2 = __instance.speakerAudio;
			speakerAudio2.volume *= 1.5f;
		}

		[HarmonyPatch("OpenShutDoor")]
		[HarmonyPrefix]
		public static void toggleDoor(ref DepositItemsDesk __instance)
		{
			shuffleSounds(__instance);
		}

		private static void shuffleSounds(DepositItemsDesk __instance)
		{
			__instance.rumbleSFX = AudioManager.getRandomClip("traut-euch.mp3", "rehehehe.mp3");
			__instance.doorOpenSFX = AudioManager.getRandomClip("trymacs-hier.mp3", "rehehehe.mp3");
			__instance.rewardGood = AudioManager.getRandomClip("yippee.mp3");
			__instance.microphoneAudios = AudioManager.getAllClips("hier-ist-alles-super.mp3", "chicken-nuggets.mp3", "monte-schonen-abend.mp3", "kaltes-wasser.mp3", "skull-guitar.mp3");
		}
	}
	[HarmonyPatch(typeof(ItemDropship))]
	internal class DropshipPatch
	{
		private static int firstWaitTime;

		private static int normalWaitTime;

		public static Terminal terminal;

		private static StartOfRound playerManager;

		private static List<int> itemDelivery;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ref ItemDropship __instance)
		{
			firstWaitTime = ConfigManager._dropshipFirstWait.Value;
			normalWaitTime = ConfigManager._dropshipNormalWait.Value;
			string[] array = new string[2] { "wuhlmaus-apored.mp3", "chinese-rap-song.mp3" };
			string filename = array[Random.Range(0, array.Length)];
			((Component)((Component)__instance).transform.Find("Music")).GetComponent<AudioSource>().clip = AudioManager.getAudioClip(filename);
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool Update(ref ItemDropship __instance)
		{
			object value = Traverse.Create((object)__instance).Field("terminalScript").GetValue();
			terminal = (Terminal)((value is Terminal) ? value : null);
			object value2 = Traverse.Create((object)__instance).Field("playersManager").GetValue();
			playerManager = (StartOfRound)((value2 is StartOfRound) ? value2 : null);
			itemDelivery = Traverse.Create((object)__instance).Field("itemsToDeliver").GetValue() as List<int>;
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			if (!__instance.deliveringOrder)
			{
				if (terminal.orderedItemsFromTerminal.Count > 0)
				{
					if (playerManager.shipHasLanded)
					{
						ItemDropship obj = __instance;
						obj.shipTimer += Time.deltaTime;
					}
					if (__instance.playersFirstOrder)
					{
						__instance.playersFirstOrder = false;
						__instance.shipTimer = firstWaitTime;
					}
					if (__instance.shipTimer > (float)normalWaitTime)
					{
						LandShipOnServer(ref __instance);
					}
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch("LandShipOnServer")]
		[HarmonyPrefix]
		private static bool LandShipOnServer(ref ItemDropship __instance)
		{
			__instance.shipTimer = 0f;
			itemDelivery.Clear();
			itemDelivery.AddRange(terminal.orderedItemsFromTerminal);
			terminal.orderedItemsFromTerminal.Clear();
			__instance.playersFirstOrder = false;
			__instance.deliveringOrder = true;
			__instance.LandShipClientRpc();
			return false;
		}
	}
	[HarmonyPatch(typeof(FlashlightItem))]
	internal class FlashlightPatch
	{
		private static Light lightbulb;

		private static float initialIntensity;

		private static float intensityMultiplier;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref FlashlightItem __instance)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			lightbulb = __instance.flashlightBulb;
			initialIntensity = lightbulb.intensity * intensityMultiplier;
			Light obj = lightbulb;
			obj.spotAngle *= 1.1f;
			if (ConfigManager._enableFlashlightColors.Value)
			{
				float num = (float)Random.Range(50, 100) / 100f;
				float num2 = (float)Random.Range(50, 100) / 100f;
				float num3 = (float)Random.Range(50, 100) / 100f;
				lightbulb.color = new Color(num, num2, num3);
			}
			Item itemProperties = ((GrabbableObject)__instance).itemProperties;
			itemProperties.batteryUsage *= 3f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void Update(ref FlashlightItem __instance)
		{
			intensityMultiplier = ConfigManager._flashlightStrength.Value;
			initialIntensity = lightbulb.intensity * intensityMultiplier;
		}
	}
	internal class GUIManager
	{
		public static Canvas myCanvas;

		public static TextMeshPro CreateText(Vector2 position, string text)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_004e: 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)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject();
			if ((Object)(object)myCanvas == (Object)null)
			{
				myCanvas = new GameObject("aio_memeCanvas").AddComponent<Canvas>();
			}
			val.transform.SetParent(((Component)myCanvas).transform);
			TextMeshPro val2 = val.AddComponent<TextMeshPro>();
			((TMP_Text)val2).text = text;
			val.transform.position = Vector2.op_Implicit(position);
			return val2;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HudManagerPatch
	{
		private static TextMeshPro shipScrapText;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void Start(ref HUDManager __instance)
		{
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void Update(ref HUDManager __instance)
		{
			int num = calculateShiploot();
			int value = Traverse.Create((object)__instance).Field("totalScrapScannedDisplayNum").GetValue<int>();
			((TMP_Text)__instance.totalValueText).text = $"<size=10>Scan: {value}\nIn ship: {num}</size>";
		}

		private static int calculateShiploot()
		{
			GrabbableObject[] componentsInChildren = GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>();
			int num = 0;
			GrabbableObject[] array = componentsInChildren;
			foreach (GrabbableObject val in array)
			{
				if (val.itemProperties.isScrap)
				{
					num += val.scrapValue;
				}
			}
			return num;
		}
	}
	internal class ItemManager
	{
		public static List<Item> allItems = StartOfRound.Instance.allItemsList.itemsList;

		public static Item getItemNew(int id)
		{
			return Object.Instantiate<Item>(allItems[id]);
		}

		public static Item getItem(int id)
		{
			return allItems[id];
		}

		public static GameObject spawnItemID(int id, Vector3 pos)
		{
			//IL_0010: 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)
			GameObject obj = Object.Instantiate<GameObject>(allItems[id].spawnPrefab, pos, Quaternion.identity, StartOfRound.Instance.propsContainer);
			obj.GetComponent<GrabbableObject>().fallTime = 0f;
			obj.GetComponent<NetworkObject>().Spawn(false);
			return obj;
		}

		public static GameObject spawnItem(Item item, Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(item.spawnPrefab, pos, Quaternion.identity, StartOfRound.Instance.propsContainer);
			obj.GetComponent<GrabbableObject>().itemProperties = item;
			obj.GetComponent<NetworkObject>().Spawn(false);
			return obj;
		}

		public static void RegisterScrap()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			Item item = GenerateItemStats(getItemNew(50), "Jägermeister", 56, 100, 100, "jaegermeister.mp3");
			SetItemModel(item, "Jaeger.prefab", "jaegermeister");
			AddItemToSpawnpool(item, 75);
			Item obj = GenerateItemStats(getItemNew(41), "Chicken Nuggets", 50, 50, 100, "chicken-nuggets.mp3");
			BoxCollider component = obj.spawnPrefab.GetComponent<BoxCollider>();
			component.size *= 2f;
			SetItemModel(obj, "ChickenNuggets.prefab");
			AddItemToSpawnpool(obj, 75);
			LogItemIds();
		}

		public static void PatchItems()
		{
			getItem(1).toolTips = new string[2] { "Toggle on/off: [LMB]", "Next song: [Q]" };
			getItem(1).canBeGrabbedBeforeGameStart = true;
			Shovel component = getItem(10).spawnPrefab.GetComponent<Shovel>();
			component.shovelHitForce *= ConfigManager._shovelStrength.Value;
			getItem(20).grabSFX = AudioManager.getAudioClip("michi.mp3");
			getItem(25).spawnPrefab.GetComponent<NoisemakerProp>().noiseSFX = (AudioClip[])(object)new AudioClip[1] { AudioManager.getAudioClip("goofy-ahh.mp3") };
			getItem(25).spawnPrefab.GetComponent<NoisemakerProp>().noiseSFXFar = (AudioClip[])(object)new AudioClip[1] { AudioManager.getAudioClip("goofy-ahh.mp3") };
			getItem(44).grabSFX = AudioManager.getAudioClip("pickle-rick.mp3");
		}

		private static Item GenerateItemStats(Item baseItem, string itemName, int worth, int min, int max, string grabFX)
		{
			baseItem.itemName = itemName;
			baseItem.creditsWorth = worth;
			baseItem.minValue = min;
			baseItem.maxValue = max;
			baseItem.grabSFX = AudioManager.getAudioClip(grabFX);
			baseItem.itemId = StartOfRound.Instance.allItemsList.itemsList.Count;
			return baseItem;
		}

		private static void SetItemModel(Item item, string prefabName, string bundleName = "items")
		{
			GameObject val = Utils.loadGameObject(prefabName, Utils.loadBundle(bundleName));
			((Object)item.spawnPrefab).name = item.itemName;
			item.spawnPrefab.GetComponent<MeshFilter>().mesh = val.GetComponentInChildren<MeshFilter>().mesh;
			((Renderer)item.spawnPrefab.GetComponent<MeshRenderer>()).materials = ((Renderer)val.GetComponentInChildren<MeshRenderer>()).materials;
			item.spawnPrefab.GetComponent<GrabbableObject>().itemProperties = item;
			((Component)item.spawnPrefab.transform.GetChild(0)).GetComponent<ScanNodeProperties>().headerText = item.itemName;
		}

		private static void AddItemToSpawnpool(Item item, int rarity)
		{
			StartOfRound.Instance.allItemsList.itemsList.Add(item);
			Utils.addItemToAllLevels(item, rarity);
		}

		public static void LogItemIds()
		{
			for (int i = 0; i < allItems.Count; i++)
			{
				MemepackBase.logger.LogInfo((object)$"{i} - {allItems[i]}");
			}
		}
	}
	[HarmonyPatch(typeof(JesterAI))]
	internal class JesterPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref JesterAI __instance)
		{
			__instance.popGoesTheWeaselTheme = AudioManager.getAudioClip("freebird-0.mp3");
			__instance.popUpSFX = AudioManager.getAudioClip("freebird-1.mp3");
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class LeverPatch
	{
		private static bool enableBoomboxSpawner;

		private static bool hasSpawnedBoombox;

		[HarmonyPatch("PullLever")]
		[HarmonyPrefix]
		public static bool PullLever(ref StartMatchLever __instance)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			int num = Random.Range(1, 19);
			__instance.playersManager.openingHangarDoorAudio = AudioManager.getAudioClip($"weis ({num}).mp3");
			AudioSource shipDoorAudioSource = __instance.playersManager.shipDoorAudioSource;
			shipDoorAudioSource.maxDistance *= 3f;
			AudioSource shipDoorAudioSource2 = __instance.playersManager.shipDoorAudioSource;
			shipDoorAudioSource2.volume *= 1.5f;
			if (__instance.leverHasBeenPulled)
			{
				__instance.StartGame();
				enableBoomboxSpawner = ConfigManager._enableBoomboxSpawner.Value;
				hasSpawnedBoombox = GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<BoomboxItem>().Length != 0;
				if (enableBoomboxSpawner && !hasSpawnedBoombox)
				{
					ItemManager.spawnItemID(1, ((Component)__instance).transform.position + new Vector3(-1f, 2f, 0f));
					hasSpawnedBoombox = true;
				}
			}
			else
			{
				__instance.EndGame();
			}
			MemepackBase.logger.LogInfo((object)((Component)__instance).transform.position);
			return false;
		}

		private static IEnumerator stopPlayerAfter(AudioSource source, float waitFor)
		{
			yield return (object)new WaitForSeconds(waitFor);
			while (source.volume > 0f)
			{
				source.volume -= Time.deltaTime * 0.25f;
			}
			source.Stop();
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start()
		{
			if (!ConfigManager._overrideSoundToolConfig.Value)
			{
				return;
			}
			foreach (ConfigDefinition key2 in ((BaseUnityPlugin)SoundTool.Instance).Config.Keys)
			{
				string key = key2.Key;
				if (key == "EnableNetworking" || key == "SyncUnityRandomSeed")
				{
					((BaseUnityPlugin)SoundTool.Instance).Config[key2].BoxedValue = true;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class MinePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void Start(ref Landmine __instance)
		{
			if (((NetworkBehaviour)__instance).NetworkManager.IsHost)
			{
				SetSoundsClientRpc(__instance, AudioManager.getRandomClip("discord-notification.mp3", "vine-boom.mp3", "bonk.mp3"), AudioManager.getRandomClip("was-zitterstn-so.mp3", "bomb-planted.mp3"));
			}
		}

		[ClientRpc]
		private static void SetSoundsClientRpc(Landmine __instance, AudioClip clip1, AudioClip clip2)
		{
			__instance.mineDetonate = clip1;
			__instance.mineDetonateFar = __instance.mineDetonate;
			__instance.minePress = clip2;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(PlayerControllerB __instance)
		{
			if (ConfigManager._enableInfiniteSprint.Value)
			{
				((Component)__instance.sprintMeterUI).gameObject.SetActive(false);
				__instance.sprintTime = 100f;
			}
		}

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void LateUpdate(PlayerControllerB __instance)
		{
			if (ConfigManager._enableInfiniteSprint.Value && __instance.sprintMeter <= 0.5f)
			{
				__instance.sprintMeter = 1f;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CalculateNormalLookingInput")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CalculateNormalInput(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 60f)
				{
					instruction.operand = 80f;
					break;
				}
			}
			return instructions;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "CalculateSmoothLookingInput")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CalculateSmoothInput(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 60f)
				{
					instruction.operand = 80f;
					break;
				}
			}
			return instructions;
		}

		[HarmonyPatch("KillPlayerClientRpc")]
		[HarmonyPrefix]
		public static void KillPlayerClient(ref PlayerControllerB __instance)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[11]
			{
				"auto-machen-so.mp3", "bigmac.mp3", "das-gibt-ne-6.mp3", "ekg.mp3", "fart.mp3", "harry-potter.mp3", "roblox-death.mp3", "skill-issue.mp3", "snore-mimimi.mp3", "vine-boom.mp3",
				"fortnite-knock.mp3"
			};
			AudioClip audioClip = AudioManager.getAudioClip(array[Random.Range(0, array.Length)]);
			AudioManager.createAudioSource(((Component)__instance).transform.position, null, 100f).PlayOneShot(audioClip);
		}
	}
	[BepInPlugin("dom3005.aio_memepack", "AIO Memepack", "1.3.0")]
	public class MemepackBase : BaseUnityPlugin
	{
		private const string mod_guid = "dom3005.aio_memepack";

		private const string mod_name = "AIO Memepack";

		private const string mod_version = "1.3.0";

		private readonly Harmony harmony = new Harmony("dom3005.aio_memepack");

		public static MemepackBase instance;

		internal static ManualLogSource logger;

		private void Awake()
		{
			instance = this;
			logger = Logger.CreateLogSource("dom3005.aio_memepack");
			logger.LogMessage((object)"Loaded AIO Memepack version 1.3.0!");
			ConfigManager.Init();
			harmony.PatchAll();
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
	}
	[HarmonyPatch(typeof(Shovel))]
	internal class ShovelPatch
	{
		[HarmonyPatch("HitShovel")]
		[HarmonyPostfix]
		private static void HitShovel(ref Shovel __instance)
		{
			AudioClip[] allClips = AudioManager.getAllClips("bonk.mp3", "tf2-bonk.mp3", "discord-notification.mp3");
			RoundManager.PlayRandomClip(__instance.shovelAudio, allClips, true, 1f, 0);
		}
	}
	[HarmonyPatch(typeof(SandSpiderAI))]
	internal class SpiderPatch
	{
		[HarmonyPatch("TriggerChaseWithPlayer")]
		[HarmonyPostfix]
		public static void TriggerChase(ref SandSpiderAI __instance)
		{
			((EnemyAI)__instance).creatureSFX.PlayOneShot(AudioManager.getAudioClip("ich-bin-eine-spinne.mp3"));
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("playersFiredGameOver")]
		[HarmonyPrefix]
		private static void playersFiredGameOver(ref StartOfRound __instance)
		{
			string[] array = new string[3] { "outro-song.mp3", "subway-surfer-bass-boosted.mp3", "in-hamburg-sagt-man-tschuss.mp3" };
			AudioClip audioClip = AudioManager.getAudioClip(array[Random.Range(0, array.Length)]);
			__instance.alarmSFX = audioClip;
			__instance.firedVoiceSFX = AudioManager.getRandomClip("monte_maybe_next_time.mp3", "traut-euch.mp3", "was-zitterstn-so.mp3");
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void Start_prefix()
		{
			ItemManager.RegisterScrap();
			ItemManager.PatchItems();
		}
	}
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class ThumperPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref CrawlerAI __instance)
		{
			__instance.hitWallSFX = AudioManager.getAllClips("pimmelberger.mp3");
			((EnemyAI)__instance).dieSFX = AudioManager.getAudioClip("snore-mimimi.mp3");
			__instance.longRoarSFX = AudioManager.getAllClips("was-zitterstn-so.mp3", "chinese-rap-song.mp3", "bing-bong.mp3");
			__instance.eatPlayerSFX = AudioManager.getAudioClip("number-one-victory-royale.mp3");
			__instance.shortRoar = AudioManager.getAudioClip("skull-guitar.mp3");
			__instance.bitePlayerSFX = AudioManager.getAudioClip("heheheha.mp3");
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void Update(ref TimeOfDay __instance)
		{
			if (ConfigManager._disableEarlyLeaveVote.Value)
			{
				__instance.votedShipToLeaveEarlyThisRound = true;
			}
		}
	}
	internal class Utils
	{
		private static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();

		public static AssetBundle loadBundle(string bundlename)
		{
			if (loadedBundles.ContainsKey(bundlename))
			{
				return loadedBundles[bundlename];
			}
			string text = Path.Combine(Paths.PluginPath, "AIO Memepack", bundlename);
			if (!File.Exists(text))
			{
				text = Path.Combine(Paths.PluginPath, "Dom3005-German_AIO_Memepack", "AIO Memepack", bundlename);
				if (!File.Exists(text))
				{
					MemepackBase.logger.LogError((object)("Could not find bundle \"" + bundlename + "\""));
					MemepackBase.logger.LogError((object)(text ?? ""));
					return null;
				}
			}
			MemepackBase.logger.LogInfo((object)text);
			AssetBundle val = AssetBundle.LoadFromFile(text);
			loadedBundles.Add(bundlename, val);
			return val;
		}

		public static GameObject loadGameObject(string filename, AssetBundle bundle)
		{
			return bundle.LoadAsset<GameObject>(filename);
		}

		public static Material loadMaterial(string filename, AssetBundle bundle)
		{
			return bundle.LoadAsset<Material>(filename);
		}

		public static void addItemToAllLevels(Item item, int rarity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			SpawnableItemWithRarity val = new SpawnableItemWithRarity();
			val.rarity = rarity;
			val.spawnableItem = item;
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			for (int i = 0; i < levels.Length; i++)
			{
				levels[i].spawnableScrap.Add(val);
			}
		}

		public static void ReplaceAllScrap(Item item, int rarity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			SpawnableItemWithRarity val = new SpawnableItemWithRarity();
			val.rarity = rarity;
			val.spawnableItem = item;
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel obj in levels)
			{
				obj.spawnableScrap.Clear();
				obj.maxScrap *= 2;
				obj.minScrap *= 2;
				obj.spawnableScrap.Add(val);
			}
		}

		public static void logComponents(GameObject go)
		{
			Component[] components = go.GetComponents<Component>();
			foreach (Component val in components)
			{
				MemepackBase.logger.LogInfo((object)((object)val).ToString());
			}
		}

		public static void logComponentsRecursively(GameObject go)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in go.transform)
			{
				logComponents(((Component)item).gameObject);
			}
		}

		public static void logChildren(GameObject go)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			foreach (Transform item in go.transform)
			{
				Transform val = item;
				MemepackBase.logger.LogInfo((object)((object)val).ToString());
			}
		}
	}
	[HarmonyPatch(typeof(EnemyVent))]
	internal class VentPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void Update(ref EnemyVent __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.occupied && __instance.ventAudio.isPlaying)
			{
				AudioSource obj = AudioManager.createAudioSource(((Component)__instance).transform.position, ((Component)__instance).transform, 10f);
				obj.clip = AudioManager.getAudioClip("trymacs-hier.mp3");
				obj.loop = false;
				obj.Play();
			}
		}
	}
	[HarmonyPatch(typeof(WalkieTalkie))]
	internal class WalkietalkiePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void Start(ref FlashlightItem __instance)
		{
			Item itemProperties = ((GrabbableObject)__instance).itemProperties;
			itemProperties.batteryUsage *= 3f;
		}
	}
}