Decompiled source of TropicalNarwhalidays v1.0.0

BepInEx/plugins/AlwaysHearWalkie.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
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 LCAlwaysHearWalkieMod.Patches;
using Microsoft.CodeAnalysis;
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("AlwaysHearWalkie")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.4.5.0")]
[assembly: AssemblyInformationalVersion("1.4.5+598af90ecbca7dbe992d00a9f1bf49979bdb5912")]
[assembly: AssemblyProduct("Always Hear Active Walkies")]
[assembly: AssemblyTitle("AlwaysHearWalkie")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.5.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx5.PluginTemplate
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AlwaysHearWalkie";

		public const string PLUGIN_NAME = "Always Hear Active Walkies";

		public const string PLUGIN_VERSION = "1.4.5";
	}
}
namespace LCAlwaysHearWalkieMod
{
	public static class PluginInfo
	{
		public const string modGUID = "suskitech.LCAlwaysHearActiveWalkie";

		public const string modName = "LC Always Hear Active Walkies";

		public const string modVersion = "1.4.4";
	}
	[BepInPlugin("suskitech.LCAlwaysHearActiveWalkie", "LC Always Hear Active Walkies", "1.4.4")]
	public class Plugin : BaseUnityPlugin
	{
		private ConfigEntry<float> configAudibleDistance;

		public static float AudibleDistance;

		private ConfigEntry<float> configWalkieRecordingRange;

		public static float WalkieRecordingRange;

		private ConfigEntry<float> configPlayerToPlayerSpatialHearingRange;

		public static float PlayerToPlayerSpatialHearingRange;

		public static ManualLogSource Log;

		private static Plugin Instance;

		public void Awake()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			configAudibleDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AudibleDistance", 12f, "");
			AudibleDistance = configAudibleDistance.Value;
			configWalkieRecordingRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "WalkieRecordingRange", 20f, "");
			WalkieRecordingRange = configWalkieRecordingRange.Value;
			configPlayerToPlayerSpatialHearingRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PlayerToPlayerSpatialHearingRange", 20f, "");
			PlayerToPlayerSpatialHearingRange = configPlayerToPlayerSpatialHearingRange.Value;
			Log = Logger.CreateLogSource("suskitech.LCAlwaysHearActiveWalkie");
			Harmony val = new Harmony("suskitech.LCAlwaysHearActiveWalkie");
			val.PatchAll(typeof(Plugin));
			val.PatchAll(typeof(PlayerControllerBPatch));
			val.PatchAll(typeof(WalkieTalkiePatch));
			Log.LogInfo((object)"\\ /");
			Log.LogInfo((object)"/|\\");
			Log.LogInfo((object)" |----|");
			Log.LogInfo((object)" |[__]| Always Hear Active Walkies");
			Log.LogInfo((object)" |.  .| Version 1.4.4 Loaded");
			Log.LogInfo((object)" |____|");
			Log.LogInfo((object)"");
			Log.LogInfo((object)("AudibleDistance: " + AudibleDistance));
			Log.LogInfo((object)("WalkieRecordingRange: " + WalkieRecordingRange));
			Log.LogInfo((object)("PlayerToPlayerSpatialHearingRange: " + PlayerToPlayerSpatialHearingRange));
		}
	}
}
namespace LCAlwaysHearWalkieMod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		private static readonly float throttleInterval = 0.35f;

		private static float throttle = 0f;

		private static readonly float AverageDistanceToHeldWalkie = 2f;

		private static readonly float AudibleDistance = Plugin.AudibleDistance;

		private static readonly float WalkieRecordingRange = Plugin.WalkieRecordingRange;

		private static readonly float PlayerToPlayerSpatialHearingRange = Plugin.PlayerToPlayerSpatialHearingRange;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void alwaysHearWalkieTalkiesPatch(ref bool ___holdingWalkieTalkie, ref PlayerControllerB __instance)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			throttle += Time.deltaTime;
			if (throttle < throttleInterval)
			{
				return;
			}
			throttle = 0f;
			if ((Object)(object)__instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
			{
				return;
			}
			if (!GameNetworkManager.Instance.localPlayerController.isPlayerDead)
			{
				List<WalkieTalkie> list = new List<WalkieTalkie>();
				List<WalkieTalkie> list2 = new List<WalkieTalkie>();
				for (int i = 0; i < WalkieTalkie.allWalkieTalkies.Count; i++)
				{
					float num = Vector3.Distance(((Component)WalkieTalkie.allWalkieTalkies[i]).transform.position, ((Component)__instance).transform.position);
					if (num <= AudibleDistance)
					{
						if (((GrabbableObject)WalkieTalkie.allWalkieTalkies[i]).isBeingUsed)
						{
							list.Add(WalkieTalkie.allWalkieTalkies[i]);
						}
					}
					else
					{
						list2.Add(WalkieTalkie.allWalkieTalkies[i]);
					}
				}
				bool flag = list.Count > 0;
				if (flag != __instance.holdingWalkieTalkie)
				{
					___holdingWalkieTalkie = flag;
					for (int j = 0; j < list2.Count; j++)
					{
						if (j < list.Count)
						{
							list2[j].thisAudio.Stop();
						}
					}
				}
				if (!flag)
				{
					return;
				}
			}
			PlayerControllerB val = ((!GameNetworkManager.Instance.localPlayerController.isPlayerDead || !((Object)(object)GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript != (Object)null)) ? GameNetworkManager.Instance.localPlayerController : GameNetworkManager.Instance.localPlayerController.spectatedPlayerScript);
			for (int k = 0; k < StartOfRound.Instance.allPlayerScripts.Length; k++)
			{
				PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[k];
				if ((!val2.isPlayerControlled && !val2.isPlayerDead) || (Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController || val2.isPlayerDead || !val2.holdingWalkieTalkie)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)val2).transform.position);
				float num3 = float.MaxValue;
				float num4 = float.MaxValue;
				for (int l = 0; l < WalkieTalkie.allWalkieTalkies.Count; l++)
				{
					WalkieTalkie val3 = WalkieTalkie.allWalkieTalkies[l];
					if (!((GrabbableObject)val3).isBeingUsed)
					{
						continue;
					}
					float num5 = Vector3.Distance(((Component)val3.target).transform.position, ((Component)val).transform.position);
					if (num5 < num3)
					{
						num3 = num5;
					}
					if (Object.op_Implicit((Object)(object)((GrabbableObject)val3).playerHeldBy) && (!Object.op_Implicit((Object)(object)((GrabbableObject)val3).playerHeldBy) || ((GrabbableObject)val3).playerHeldBy.speakingToWalkieTalkie))
					{
						float num6 = Vector3.Distance(((Component)val3).transform.position, ((Component)val2).transform.position);
						if (num6 < num4)
						{
							num4 = num6;
						}
					}
				}
				float num7 = 1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num4);
				float num8 = 1f - Mathf.InverseLerp(AverageDistanceToHeldWalkie, WalkieRecordingRange, num3);
				float num9 = Mathf.Clamp01(1f + (num7 - num8));
				float num10 = 1f - Mathf.InverseLerp(1f, PlayerToPlayerSpatialHearingRange, num2);
				val2.voicePlayerState.Volume = Mathf.Max(num9, num10);
				if (num9 > num10)
				{
					makePlayerSoundWalkieTalkie(val2);
				}
				else
				{
					makePlayerSoundSpatial(val2);
				}
			}
			static void makePlayerSoundSpatial(PlayerControllerB playerController)
			{
				AudioSource currentVoiceChatAudioSource = playerController.currentVoiceChatAudioSource;
				AudioLowPassFilter component = ((Component)currentVoiceChatAudioSource).GetComponent<AudioLowPassFilter>();
				AudioHighPassFilter component2 = ((Component)currentVoiceChatAudioSource).GetComponent<AudioHighPassFilter>();
				OccludeAudio component3 = ((Component)currentVoiceChatAudioSource).GetComponent<OccludeAudio>();
				((Behaviour)component2).enabled = false;
				((Behaviour)component).enabled = true;
				component3.overridingLowPass = playerController.voiceMuffledByEnemy;
				currentVoiceChatAudioSource.spatialBlend = 1f;
				playerController.currentVoiceChatIngameSettings.set2D = false;
				currentVoiceChatAudioSource.bypassListenerEffects = false;
				currentVoiceChatAudioSource.bypassEffects = false;
				currentVoiceChatAudioSource.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[playerController.playerClientId];
				component.lowpassResonanceQ = 1f;
			}
			static void makePlayerSoundWalkieTalkie(PlayerControllerB playerController)
			{
				AudioSource currentVoiceChatAudioSource2 = playerController.currentVoiceChatAudioSource;
				AudioLowPassFilter component4 = ((Component)currentVoiceChatAudioSource2).GetComponent<AudioLowPassFilter>();
				AudioHighPassFilter component5 = ((Component)currentVoiceChatAudioSource2).GetComponent<AudioHighPassFilter>();
				OccludeAudio component6 = ((Component)currentVoiceChatAudioSource2).GetComponent<OccludeAudio>();
				((Behaviour)component5).enabled = true;
				((Behaviour)component4).enabled = true;
				component6.overridingLowPass = true;
				currentVoiceChatAudioSource2.spatialBlend = 0f;
				playerController.currentVoiceChatIngameSettings.set2D = true;
				currentVoiceChatAudioSource2.outputAudioMixerGroup = SoundManager.Instance.playerVoiceMixers[playerController.playerClientId];
				currentVoiceChatAudioSource2.bypassListenerEffects = false;
				currentVoiceChatAudioSource2.bypassEffects = false;
				currentVoiceChatAudioSource2.panStereo = (GameNetworkManager.Instance.localPlayerController.isPlayerDead ? 0f : 0.4f);
				component6.lowPassOverride = 4000f;
				component4.lowpassResonanceQ = 3f;
			}
		}
	}
	[HarmonyPatch(typeof(WalkieTalkie))]
	internal class WalkieTalkiePatch
	{
		[HarmonyPatch("EnableWalkieTalkieListening")]
		[HarmonyPrefix]
		private static bool alwaysHearWalkieTalkiesEnableWalkieTalkieListeningPatch(bool enable)
		{
			if (!enable)
			{
				return false;
			}
			return true;
		}
	}
}

BepInEx/plugins/ChatCommands.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChatCommands;
using ChatCommands.Commands;
using ChatCommands.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ChatCommands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChatCommands")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d9d7c116-3da7-4a2a-8b87-f83dac82c4cb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Networking
{
	public class CCMDNetworking : NetworkBehaviour
	{
		[SerializeField]
		private string netHostCommandPrefix = "[COMMAND]";

		[SerializeField]
		private string netCommandPostfix = "[/COMMAND]";

		public static CCMDNetworking instance;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Debug.LogWarning((object)"Multiple instances of CustomNetworkManager found!");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		internal static void SendHostCommand(string commandInput)
		{
			if ((Object)(object)instance == (Object)null)
			{
				Debug.LogError((object)"CCMDNetworking instance is not initialized!");
				return;
			}
			string command = instance.netHostCommandPrefix + commandInput + instance.netCommandPostfix;
			Utils.DisplayChatMessage("Host Command: " + commandInput + "\nsending to clients via RPC");
			instance.RpcExecuteCommandOnClients(command);
		}

		[ClientRpc]
		private void RpcExecuteCommandOnClients(string command)
		{
			Utils.DisplayChatMessage("Client Command: " + command);
		}
	}
}
namespace ChatCommands
{
	public static class Utils
	{
		private static bool logToChat = ChatCommands.LogToChatSetting.Value;

		private static string NetCommandPrefix = "<size=0>CCMD:";

		private static string NetHostCommandPrefix = "<size=0>CHCMD:";

		private static string NetCommandPostfix = ":CCMD</size>";

		internal static bool DisplayAsTooltip = ChatCommands.DisplayChatMessagesAsPopupSetting.Value;

		public static Vector3 CalculateSpawnPosition(string sposition)
		{
			//IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			Vector3 result = Vector3.zero;
			if (sposition == "random")
			{
				return result;
			}
			if (sposition.StartsWith("@"))
			{
				PlayerControllerB[] allPlayerScripts;
				try
				{
					allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				}
				catch (Exception ex)
				{
					LogWarning("Error getting allPlayerScripts: " + ex);
					return result;
				}
				if (sposition == "@me")
				{
					PlayerControllerB[] array = allPlayerScripts;
					foreach (PlayerControllerB val in array)
					{
						ChatCommands.mls.LogInfo((object)("Checking Playername " + val.playerUsername));
						if (val.playerUsername.Replace(" ", "").ToLower().Contains(ChatCommands.playerwhocalled.ToLower()))
						{
							ChatCommands.mls.LogInfo((object)("Found player " + val.playerUsername));
							result = ((Component)val).transform.position;
							break;
						}
					}
				}
				else
				{
					string text = sposition.Substring(1);
					string text2 = ConvertPlayername(text);
					bool flag = false;
					ChatCommands.mls.LogInfo((object)("Looking for Playername " + text2 + " or Playername " + text + "..."));
					PlayerControllerB[] array2 = allPlayerScripts;
					foreach (PlayerControllerB val2 in array2)
					{
						ChatCommands.mls.LogInfo((object)("Checking Playername " + val2.playerUsername.Replace(" ", "")));
						if (val2.playerUsername.Replace(" ", "").ToLower().Contains(text2.ToLower()) || val2.playerUsername.Replace(" ", "").ToLower().Contains(text.ToLower()))
						{
							result = ((Component)val2).transform.position;
							flag = true;
							ChatCommands.mls.LogInfo((object)("Found player " + val2.playerUsername));
							break;
						}
					}
					if (!flag)
					{
						ChatCommands.mls.LogWarning((object)"Player not found");
						DisplayChatMessage("Player not found, spawning in random position");
					}
				}
			}
			else
			{
				string[] array3 = sposition.Split(new char[1] { ',' });
				if (array3.Length == 3)
				{
					((Vector3)(ref result))..ctor(float.Parse(array3[0]), float.Parse(array3[1]), float.Parse(array3[2]));
				}
				else
				{
					ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'");
				}
			}
			return result;
		}

		public static void LogInfo(string message)
		{
			ChatCommands.mls.LogInfo((object)message);
			if (logToChat)
			{
				DisplayChatMessage(message);
			}
		}

		public static void LogWarning(string message)
		{
			ChatCommands.mls.LogWarning((object)message);
			if (logToChat)
			{
				DisplayChatError(message);
			}
		}

		public static void LogError(string message)
		{
			ChatCommands.mls.LogError((object)message);
			if (logToChat)
			{
				DisplayChatError(message);
			}
		}

		public static void DisplayChatMessage(string chatMessage)
		{
			try
			{
				string item = "<color=#FF00FF>ChatCommands</color>: <color=#FFFF00>" + chatMessage + "</color>";
				HUDManager.Instance.ChatMessageHistory.Add(item);
				UpdateChatText();
			}
			catch (Exception ex)
			{
				ChatCommands.mls.LogError((object)("Error displaying chat message: " + ex));
			}
			if (DisplayAsTooltip)
			{
				HUDManager.Instance.DisplayTip("ChatCommands", chatMessage, false, false, "LC_Tip1");
			}
		}

		public static void DisplayChatError(string errorMessage)
		{
			try
			{
				string item = "<color=#FF0000>CCMD: ERROR</color>: <color=#FF0000>" + errorMessage + "</color>";
				HUDManager.Instance.ChatMessageHistory.Add(item);
				UpdateChatText();
			}
			catch (Exception ex)
			{
				ChatCommands.mls.LogError((object)("Error displaying chat error: " + ex));
			}
			if (DisplayAsTooltip)
			{
				HUDManager.Instance.DisplayTip("ChatCommands", errorMessage, true, false, "LC_Tip1");
			}
		}

		private static void UpdateChatText()
		{
			((TMP_Text)HUDManager.Instance.chatText).text = string.Join("\n", HUDManager.Instance.ChatMessageHistory);
		}

		internal static string ConvertPlayername(string name)
		{
			ChatCommands.mls.LogInfo((object)("Converting name: " + name));
			string input = new string(name.Where((char c) => char.IsLetter(c)).ToArray());
			input = Regex.Replace(input, "[^\\w\\._]", "");
			ChatCommands.mls.LogInfo((object)("Converted name: " + input));
			return input;
		}

		internal static bool IsNetCommand(string message)
		{
			return message.StartsWith(NetCommandPrefix) && message.EndsWith(NetCommandPostfix);
		}

		internal static bool IsNetHostCommand(string message)
		{
			return message.StartsWith(NetHostCommandPrefix) && message.EndsWith(NetCommandPostfix);
		}

		internal static string ConvertFromNetCommand(string command)
		{
			LogInfo("Converting command: " + command);
			string text = command;
			if (!IsNetCommand(text))
			{
				throw new Exception("Not a valid NetCommand");
			}
			text = text.Substring(NetCommandPrefix.Length);
			text = text.Substring(0, text.Length - NetCommandPostfix.Length);
			text = ChatCommands.PrefixSetting.Value + text;
			LogInfo("Converted command: " + text);
			return text;
		}

		internal static string ConvertFromNetHostCommand(string command)
		{
			LogInfo("Converting command: " + command);
			string text = command;
			if (!IsNetHostCommand(text))
			{
				throw new Exception("Not a valid NetHostCommand");
			}
			text = text.Substring(NetHostCommandPrefix.Length);
			text = text.Substring(0, text.Length - NetCommandPostfix.Length);
			text = ChatCommands.PrefixSetting.Value + text;
			LogInfo("Converted command: " + text);
			return text;
		}

		internal static string ConvertToNetCommand(string command)
		{
			if (command.StartsWith(ChatCommands.PrefixSetting.Value))
			{
				command = command.Substring(ChatCommands.PrefixSetting.Value.Length);
			}
			LogInfo("Converting to NetCommand: " + command);
			LogInfo("Converted to NetCommand: " + NetCommandPrefix + command + NetCommandPostfix);
			return NetCommandPrefix + command + NetCommandPostfix;
		}

		internal static string ConvertToNetHostCommand(string command)
		{
			if (command.StartsWith(ChatCommands.PrefixSetting.Value))
			{
				command = command.Substring(ChatCommands.PrefixSetting.Value.Length);
			}
			LogInfo("Converting to NetHostCommand: " + command);
			LogInfo("Converted to NetHostCommand: " + NetHostCommandPrefix + command + NetCommandPostfix);
			return NetHostCommandPrefix + command + NetCommandPostfix;
		}

		internal static void SendHostCommand(string commandInput)
		{
			if (ChatCommands.isHost && ChatCommands.SendHostCommandsSetting.Value)
			{
				string text = ConvertToNetHostCommand(commandInput);
				LogInfo("Sending command to clients: " + text);
				HUDManager.Instance.AddTextToChatOnServer(text, -1);
			}
		}

		internal static void SendCommandToServer(string commandInput)
		{
			string text = ConvertToNetCommand(commandInput);
			LogInfo("Sending command to server: " + text);
			HUDManager.Instance.AddTextToChatOnServer(text, -1);
		}

		internal static SelectableLevel GetCurrentLevel()
		{
			return RoundManager.Instance.currentLevel;
		}

		internal static RoundManager GetCurrentRound()
		{
			return RoundManager.Instance;
		}
	}
	[BepInPlugin("toemmsen.ChatCommands", "ChatCommands", "2.0.0")]
	public class ChatCommands : BaseUnityPlugin
	{
		private const string modGUID = "toemmsen.ChatCommands";

		private const string modName = "ChatCommands";

		private const string modVersion = "2.0.0";

		private readonly Harmony harmony = new Harmony("toemmsen.ChatCommands");

		private static ChatCommands instance;

		internal static ManualLogSource mls = Logger.CreateLogSource("toemmsen.ChatCommands");

		public static Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>> levelEnemySpawns;

		public static Dictionary<SpawnableEnemyWithRarity, int> enemyRaritys;

		public static Dictionary<SpawnableEnemyWithRarity, AnimationCurve> enemyPropCurves;

		internal static ConfigEntry<string> PrefixSetting;

		internal static ConfigEntry<bool> HostSetting;

		internal static ConfigEntry<bool> LogToChatSetting;

		internal static ConfigEntry<bool> SendHostCommandsSetting;

		internal static ConfigEntry<bool> OverrideSpawnsSetting;

		internal static ConfigEntry<bool> EnableDebugModeSetting;

		internal static ConfigEntry<bool> DisplayChatMessagesAsPopupSetting;

		internal static bool OverrideSpawns = false;

		internal static bool AllowHostCommands = false;

		internal static bool isHost;

		internal static string playerwhocalled;

		internal static List<AllowedHostPlayer> AllowedHostPlayers = new List<AllowedHostPlayer>();

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			DisplayChatMessagesAsPopupSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Display Chat Messages As Popup", false, "Determines if chat messages are displayed as popup messages");
			PrefixSetting = ((BaseUnityPlugin)instance).Config.Bind<string>("Command Settings", "Command Prefix", "/", "An optional prefix for chat commands");
			HostSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Has to be Host", true, "(for server host only): determines if clients can also use the host commands");
			SendHostCommandsSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Send Host Commands", true, "(for server host only): determines if commands get sent to the clients, so for example god mode is enabled for them too");
			OverrideSpawnsSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Override Spawns", false, "(for server host only): determines if the spawn command overrides the default spawns. If enabled there can be spawned more than one girl etc. Can be toggled ingame by using /override command.");
			EnableDebugModeSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Enable Debug Mode", true, "Enables Unity Debug mode");
			LogToChatSetting = ((BaseUnityPlugin)instance).Config.Bind<bool>("Command Settings", "Log To Chat", false, "Enables logging to (local) chat");
			OverrideSpawns = OverrideSpawnsSetting.Value;
			AllowHostCommands = HostSetting.Value;
			enemyRaritys = new Dictionary<SpawnableEnemyWithRarity, int>();
			levelEnemySpawns = new Dictionary<SelectableLevel, List<SpawnableEnemyWithRarity>>();
			enemyPropCurves = new Dictionary<SpawnableEnemyWithRarity, AnimationCurve>();
			harmony.PatchAll(typeof(ChatCommands));
			harmony.PatchAll(typeof(global::ChatCommands.Patches.Patches));
			harmony.PatchAll(typeof(CommandController));
			harmony.PatchAll(typeof(SetCustomDeadline));
			harmony.PatchAll(typeof(SpeedHack));
			harmony.PatchAll(typeof(SpawnTruck));
			harmony.PatchAll(typeof(InfiniteAmmo));
			harmony.PatchAll(typeof(GodMode));
			harmony.PatchAll(typeof(SetMoney));
			harmony.PatchAll(typeof(SpawnMapObject));
			harmony.PatchAll(typeof(ToggleOverrideSpawns));
			mls.LogWarning((object)("\n" + "  ______                                                                                                       \n /_  __/  ____   ___    ____ ___    ____ ___    _____  ___    ____    _____                                    \n  / /    / __ \\ / _ \\  / __ `__ \\  / __ `__ \\  / ___/ / _ \\  / __ \\  / ___/                                    \n / /    / /_/ //  __/ / / / / / / / / / / / / (__  ) /  __/ / / / / (__  )                                     \n/_/_____\\____/_\\___/ /_/ /_/_/_/ /_/ /_/ /_/_/____/  \\___/ /_/ /_/ /____/                            __        \n  / ____/   / /_   ____ _  / /_         / ____/  ____    ____ ___    ____ ___   ____ _   ____   ____/ /   _____\n / /       / __ \\ / __ `/ / __/        / /      / __ \\  / __ `__ \\  / __ `__ \\ / __ `/  / __ \\ / __  /   / ___/\n/ /___    / / / // /_/ / / /_         / /___   / /_/ / / / / / / / / / / / / // /_/ /  / / / // /_/ /   (__  ) \n\\____/   /_/ /_/ \\__,_/  \\__/         \\____/   \\____/ /_/ /_/ /_/ /_/ /_/ /_/ \\__,_/  /_/ /_/ \\__,_/   /____/  \n"));
			mls.LogInfo((object)"ChatCommands loaded");
		}

		internal static void SpawnItems(Vector3 location, string itemToSpawn, int value, int amount)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			Utils.DisplayChatMessage("Trying to spawn: " + itemToSpawn);
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				if (((Object)items).name.ToLower().StartsWith(itemToSpawn))
				{
					for (int i = 0; i < amount; i++)
					{
						GameObject val = Object.Instantiate<GameObject>(items.spawnPrefab, location, Quaternion.identity, StartOfRound.Instance.propsContainer);
						val.GetComponent<GrabbableObject>().fallTime = 0f;
						val.GetComponent<GrabbableObject>().SetScrapValue(value);
						val.GetComponent<NetworkObject>().Spawn(false);
					}
					string[] obj = new string[9]
					{
						"Spawned ",
						amount.ToString(),
						" ",
						itemToSpawn,
						(amount > 1) ? "s" : "",
						" with value of:",
						value.ToString(),
						"\n at position: ",
						null
					};
					Vector3 val2 = location;
					obj[8] = ((object)(Vector3)(ref val2)).ToString();
					Utils.DisplayChatMessage(string.Concat(obj));
					return;
				}
			}
			Utils.DisplayChatError("Could not spawn: " + itemToSpawn);
		}
	}
	internal class AllowedHostPlayer
	{
		public string Name { get; set; }

		public bool AllowHostCMD { get; set; }

		public AllowedHostPlayer(string name, bool isActive)
		{
			Name = name;
			AllowHostCMD = isActive;
		}
	}
}
namespace ChatCommands.Patches
{
	internal class Patches
	{
		internal static float defaultJumpForce;

		[HarmonyPatch(typeof(RoundManager), "SpawnEnemyFromVent")]
		[HarmonyPrefix]
		private static void LogSpawnEnemyFromVent()
		{
			Utils.LogInfo("Attempting to spawn an enemy");
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPostfix]
		private static void UpdateNewInfo(ref EnemyVent[] ___allEnemyVents, ref SelectableLevel ___currentLevel)
		{
			HUDManager.Instance.chatTextField.characterLimit = 999;
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPrefix]
		private static bool ModifyLevel(ref SelectableLevel newLevel)
		{
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			if (!ChatCommands.levelEnemySpawns.ContainsKey(newLevel))
			{
				List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
				foreach (SpawnableEnemyWithRarity enemy in newLevel.Enemies)
				{
					list.Add(enemy);
				}
				ChatCommands.levelEnemySpawns.Add(newLevel, list);
			}
			ChatCommands.levelEnemySpawns.TryGetValue(newLevel, out var value);
			newLevel.Enemies = value;
			foreach (SpawnableEnemyWithRarity enemy2 in newLevel.Enemies)
			{
				Utils.LogInfo("Inside: " + enemy2.enemyType.enemyName);
				if (!ChatCommands.enemyRaritys.ContainsKey(enemy2))
				{
					ChatCommands.enemyRaritys.Add(enemy2, enemy2.rarity);
				}
				ChatCommands.enemyRaritys.TryGetValue(enemy2, out var value2);
				enemy2.rarity = value2;
			}
			foreach (SpawnableEnemyWithRarity outsideEnemy in newLevel.OutsideEnemies)
			{
				Utils.LogInfo("Outside: " + outsideEnemy.enemyType.enemyName);
				if (!ChatCommands.enemyRaritys.ContainsKey(outsideEnemy))
				{
					ChatCommands.enemyRaritys.Add(outsideEnemy, outsideEnemy.rarity);
				}
				ChatCommands.enemyRaritys.TryGetValue(outsideEnemy, out var value3);
				outsideEnemy.rarity = value3;
			}
			foreach (SpawnableEnemyWithRarity enemy3 in newLevel.Enemies)
			{
				if (!ChatCommands.enemyPropCurves.ContainsKey(enemy3))
				{
					ChatCommands.enemyPropCurves.Add(enemy3, enemy3.enemyType.probabilityCurve);
				}
				AnimationCurve value4 = new AnimationCurve();
				ChatCommands.enemyPropCurves.TryGetValue(enemy3, out value4);
				enemy3.enemyType.probabilityCurve = value4;
			}
			return true;
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPrefix]
		private static void SetIsHost()
		{
			Utils.LogInfo("Host Status: " + ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost);
			ChatCommands.isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Start")]
		[HarmonyPrefix]
		private static void SetDefaultJumpForce(ref PlayerControllerB __instance)
		{
			defaultJumpForce = __instance.jumpForce;
			Utils.LogInfo("Default Jump Force: " + defaultJumpForce);
		}

		[HarmonyPatch(typeof(Application), "get_isEditor")]
		[HarmonyPostfix]
		private static void IsEditorPatch(ref bool __result)
		{
			__result = ChatCommands.EnableDebugModeSetting.Value;
		}
	}
}
namespace ChatCommands.Commands
{
	internal class CommandController
	{
		private static string nullChatMessage = "";

		public static List<CustomChatCommand> Commands { get; } = new List<CustomChatCommand>
		{
			new SpawnEnemyCommand(),
			new SetCustomDeadline(),
			new SpawnScrapCommand(),
			new TeleportCommand(),
			new HelpCommand(),
			new ToggleLights(),
			new GetEnemies(),
			new BuyStuff(),
			new ChangeWeather(),
			new SpawnItem(),
			new GetEnemies(),
			new GetScrap(),
			new CoHost(),
			new GodMode(),
			new GetAlivePlayers(),
			new RevivePlayers(),
			new SpeedHack(),
			new SpawnTruck(),
			new GetItems(),
			new InfiniteAmmo(),
			new GetPosition(),
			new SetMoney(),
			new SpawnMapObject(),
			new TerminalCommand(),
			new ToggleHostCmd(),
			new ToggleOverrideSpawns(),
			new GetCredits()
		};


		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool ChatCommandsSubmitted(HUDManager __instance)
		{
			string text = __instance.chatTextField.text;
			if (Utility.IsNullOrWhiteSpace(text))
			{
				return true;
			}
			string username = GameNetworkManager.Instance.username;
			ChatCommands.playerwhocalled = Utils.ConvertPlayername(username);
			Utils.LogInfo("Received chat input: " + text);
			if (CheckForCommand(text))
			{
				__instance.chatTextField.text = nullChatMessage;
				GameNetworkManager.Instance.localPlayerController.isTypingChat = false;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
				HUDManager.Instance.PingHUDElement(HUDManager.Instance.Chat, 2f, 1f, 0.2f);
				HUDManager.Instance.chatTextField.text = "";
				((Behaviour)HUDManager.Instance.typingIndicator).enabled = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
		[HarmonyPrefix]
		private static bool ReadChatMessage(HUDManager __instance, ref string chatMessage, ref int playerId)
		{
			string playerUsername = __instance.playersManager.allPlayerScripts[playerId].playerUsername;
			Utils.LogInfo("Chat Message: " + chatMessage + " sent by: " + playerUsername);
			bool flag = true;
			if (Utils.IsNetCommand(chatMessage) && ChatCommands.isHost)
			{
				if (!ChatCommands.AllowHostCommands)
				{
					flag = false;
					Utils.LogWarning("Host, but not allowing commands, checking player for allowance");
					foreach (AllowedHostPlayer allowedHostPlayer in ChatCommands.AllowedHostPlayers)
					{
						if (allowedHostPlayer.Name.ToLower().Contains(playerUsername.ToLower()))
						{
							Utils.LogInfo("Player is allowed to send commands");
							flag = true;
							break;
						}
					}
				}
				if (flag)
				{
					string text = Utils.ConvertFromNetCommand(chatMessage);
					if (text.ToLower().Contains("p=@me"))
					{
						ChatCommands.playerwhocalled = Utils.ConvertPlayername(playerUsername);
					}
					Utils.LogInfo("Host, trying to handle command: " + text);
					Utils.DisplayChatMessage(playerUsername + " sent command: " + ChatCommands.PrefixSetting.Value + text);
					if (CheckForCommand(Utils.ConvertFromNetCommand(text)))
					{
						chatMessage = nullChatMessage;
						return false;
					}
					return true;
				}
				Utils.LogWarning("Player not allowed to send commands");
				chatMessage = nullChatMessage;
				return false;
			}
			if (Utils.IsNetHostCommand(chatMessage) && !ChatCommands.isHost)
			{
				string text2 = Utils.ConvertFromNetHostCommand(chatMessage);
				Utils.LogInfo("Recieved command from Host, trying to handle command: " + text2);
				ProcessNetHostCommand(text2);
				if (CheckForCommand(Utils.ConvertFromNetHostCommand(text2)))
				{
					chatMessage = nullChatMessage;
					return false;
				}
			}
			return true;
		}

		private static bool CheckForCommand(string message)
		{
			if (Utility.IsNullOrWhiteSpace(message))
			{
				return false;
			}
			foreach (CustomChatCommand command in Commands)
			{
				if (command.Handle(message))
				{
					return true;
				}
			}
			if (ChatCommands.isHost)
			{
				Utils.LogWarning("Command " + message + " not found.");
			}
			else
			{
				Utils.LogWarning("Command " + message + " not found. Sending to host.");
				Utils.SendCommandToServer(message);
			}
			return false;
		}

		private static void ProcessNetHostCommand(string commandInput)
		{
		}
	}
	internal class CommandInput
	{
		public string Command { get; private set; }

		public List<string> Args { get; private set; } = new List<string>();


		public static CommandInput Parse(string input)
		{
			Regex regex = new Regex(ChatCommands.PrefixSetting.Value + "(\\S+)(?:\\s+(\"([^\"]+)\"|\\S+))*");
			Match match = regex.Match(input);
			if (!match.Success)
			{
				return null;
			}
			CommandInput commandInput = new CommandInput();
			commandInput.Command = match.Groups[1].Value;
			GroupCollection groups = match.Groups;
			CaptureCollection captures = groups[2].Captures;
			for (int i = 0; i < captures.Count; i++)
			{
				commandInput.Args.Add(captures[i].Value.Trim(new char[1] { '"' }));
			}
			return commandInput;
		}
	}
	internal abstract class CustomChatCommand
	{
		public abstract string Name { get; }

		public abstract string Description { get; }

		public abstract string Format { get; }

		public abstract string AltFormat { get; }

		public abstract bool IsHostCommand { get; }

		public bool Handle(string message)
		{
			CommandInput commandInput = CommandInput.Parse(message);
			if (commandInput == null)
			{
				return false;
			}
			if (commandInput.Command != Format.Split(new char[1] { ' ' })[0].Trim(new char[1] { '/' }) && commandInput.Command != AltFormat.Split(new char[1] { ' ' })[0].Trim(new char[1] { '/' }))
			{
				return false;
			}
			if (IsHostCommand && !ChatCommands.isHost)
			{
				Utils.DisplayChatError("You must be the host to use this command. Trying to send this command to the host.");
				Utils.SendCommandToServer(message);
				return true;
			}
			Execute(commandInput);
			return true;
		}

		public abstract void Execute(CommandInput message);
	}
	internal class BuyStuff : CustomChatCommand
	{
		public override string Name => "Buy Stuff";

		public override string Description => "Buy stuff from the shop. Gets delivered via DropShip. (old function, you better use /term buy [itemname] instead)";

		public override string Format => "/buy [itemname]";

		public override string AltFormat => "/buyitem [itemname]";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			string text = "Item Buying";
			string text2 = "";
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			List<string> list = new List<string>
			{
				"Walkie-Talkie", "Pro Flashlight", "Normal Flashlight", "Shovel", "Lockpicker", "Stun Grenade", "Boom Box", "Inhaler", "Stun Gun", "Jet Pack",
				"Extension Ladder", "Radar Booster"
			};
			Dictionary<string, int> dictionary = new Dictionary<string, int>
			{
				{ "Walkie-Talkie", 0 },
				{ "Pro Flashlight", 4 },
				{ "Normal Flashlight", 1 },
				{ "Shovel", 2 },
				{ "Lockpicker", 3 },
				{ "Stun Grenade", 5 },
				{ "Boom Box", 6 },
				{ "Inhaler", 7 },
				{ "Stun Gun", 8 },
				{ "Jet Pack", 9 },
				{ "Extension Ladder", 10 },
				{ "Radar Booster", 11 }
			};
			if (message.Args.Count > 0)
			{
				bool flag = false;
				if (message.Args.Count > 1)
				{
					if (!int.TryParse(message.Args[1], out var result))
					{
						ChatCommands.mls.LogInfo((object)("Couldn't parse command [ " + message.Args[1] + " ]"));
						Utils.DisplayChatError("Couldn't parse command [ " + message.Args[1] + " ]");
						return;
					}
					foreach (string item in list)
					{
						if (item.ToLower().Contains(message.Args[0]))
						{
							flag = true;
							List<int> list2 = new List<int>();
							for (int i = 0; i < result; i++)
							{
								list2.Add(dictionary[item]);
							}
							val.BuyItemsServerRpc(list2.ToArray(), val.groupCredits, 0);
							text2 = "Bought " + result + " " + item + "s";
							break;
						}
					}
					if (!flag)
					{
						Utils.DisplayChatError("Couldn't figure out what [ " + message.Args[0] + " ] was.");
						return;
					}
				}
				if (!flag)
				{
					bool flag2 = false;
					foreach (string item2 in list)
					{
						if (item2.ToLower().Contains(message.Args[0]))
						{
							flag2 = true;
							int[] array = new int[1] { dictionary[item2] };
							val.BuyItemsServerRpc(array, val.groupCredits, 0);
							text2 = "Bought " + 1 + " " + item2;
						}
					}
					if (!flag2)
					{
						ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + message.Args[0] + " ] was. Trying via int parser."));
					}
					if (!int.TryParse(message.Args[0], out var result2))
					{
						ChatCommands.mls.LogInfo((object)("Couldn't figure out what [ " + message.Args[0] + " ] was. Int parser failed, please try again."));
						Utils.DisplayChatError("Couldn't figure out what [ " + message.Args[0] + " ] was. Int parser failed, please try again.");
						return;
					}
					int[] array2 = new int[1] { result2 };
					val.BuyItemsServerRpc(array2, val.groupCredits, 0);
					text2 = "Bought item with ID [" + result2 + "]";
				}
			}
			Utils.DisplayChatMessage(text + "\n" + text2);
		}
	}
	internal class ChangeWeather : CustomChatCommand
	{
		public override string Name => "Change Weather";

		public override string Description => "Change Weather to a specific type.";

		public override string Format => "/changeweather [weathername]";

		public override string AltFormat => "/chwe [weathername]";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			string text = "Weather Change";
			string text2 = "";
			if (message.Args.Count > 0)
			{
				switch (message.Args[0].ToLower())
				{
				case "rain":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)1;
					break;
				case "eclipse":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)5;
					break;
				case "flood":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)4;
					break;
				case "dust":
				case "fog":
				case "mist":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)0;
					break;
				case "storm":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)2;
					break;
				case "none":
					Utils.GetCurrentRound().timeScript.currentLevelWeather = (LevelWeatherType)(-1);
					break;
				default:
					Utils.LogInfo("Couldn't figure out what [ " + message.Args[1] + " ] was.");
					text2 = "Couldn't figure out what [ " + message.Args[1] + " ] was.";
					break;
				}
				text2 = "tried to change the weather to " + message.Args[0];
			}
			Utils.DisplayChatMessage(text + "\n" + text2);
		}
	}
	internal class CoHost : CustomChatCommand
	{
		public override string Name => "Give Co-Host to a player";

		public override string Description => "Gives co-host to a player, which allows them to use host commands, when you turned them off for everyone else.";

		public override string Format => "/cohost [playername]";

		public override string AltFormat => "/hostcmd [playername]";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			string name = message.Args[0];
			name = Utils.ConvertPlayername(name);
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			bool flag = false;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (Utils.ConvertPlayername(val.playerUsername).ToLower().Contains(name.ToLower()))
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ChatCommands.mls.LogWarning((object)"Player not found");
				Utils.DisplayChatError("Player " + name + " not found!!!");
				return;
			}
			bool flag2 = false;
			foreach (AllowedHostPlayer allowedHostPlayer in ChatCommands.AllowedHostPlayers)
			{
				if (Utils.ConvertPlayername(allowedHostPlayer.Name).ToLower().Contains(name.ToLower()))
				{
					allowedHostPlayer.AllowHostCMD = !allowedHostPlayer.AllowHostCMD;
					Utils.DisplayChatMessage("Host Commands for " + name + " set to" + allowedHostPlayer.AllowHostCMD);
					flag2 = true;
					break;
				}
			}
			if (!flag2)
			{
				ChatCommands.AllowedHostPlayers.Add(new AllowedHostPlayer(name, isActive: true));
				Utils.DisplayChatMessage("Host Commands for " + name + " set to true");
			}
		}
	}
	internal class GetAlivePlayers : CustomChatCommand
	{
		public override string Name => "Get Alive Players";

		public override string Description => "Returns a list of all players and if they are alive or dead.";

		public override string Format => "/getalive";

		public override string AltFormat => "/getap";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			string text = "";
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				text = text + val.playerUsername + " is " + (val.isPlayerDead ? "Dead" : "Alive") + "\n";
			}
			Utils.DisplayChatMessage(text);
		}
	}
	internal class GetCredits : CustomChatCommand
	{
		public override string Name => "View Credits";

		public override string Description => "Shows the credits for the ChatCommands mod.";

		public override string Format => "/getcredits";

		public override string AltFormat => "/credits";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			Utils.DisplayChatMessage("<color=#FF00FF>Credits:</color>\nChatCommands by Toemmsen96 and Chrigi. Visit the GitHub page for more information and to report issues:\n<color=#0000FF>github.com/Toemmsen96/ChatCommands/</color>");
		}
	}
	internal class GetEnemies : CustomChatCommand
	{
		public override string Name => "Get Spawnable Enemies";

		public override string Description => "Gets the spawnable enemies for the current level.";

		public override string Format => "/getenemies";

		public override string AltFormat => "/enemies";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			string text = "";
			SelectableLevel currentLevel = Utils.GetCurrentLevel();
			string text2 = "Enemies:";
			string text3 = "";
			if ((Object)(object)currentLevel == (Object)null)
			{
				Utils.DisplayChatError("Level is null.");
			}
			if (ChatCommands.levelEnemySpawns == null)
			{
				Utils.DisplayChatError("levelEnemySpawns is null.");
			}
			if (ChatCommands.levelEnemySpawns.TryGetValue(currentLevel, out var value))
			{
				currentLevel.Enemies = value;
				text += "<color=#FF00FF>Inside: </color><color=#FFFF00>";
				text3 = "<color=#FF00FF>Inside: </color><color=#FFFF00>";
				if (currentLevel.Enemies.Count == 0)
				{
					text += "None";
					text3 += "None";
				}
				else
				{
					foreach (SpawnableEnemyWithRarity enemy in currentLevel.Enemies)
					{
						Utils.LogInfo("Inside: " + enemy.enemyType.enemyName);
						text = text + enemy.enemyType.enemyName + ", ";
						text3 = text3 + enemy.enemyType.enemyName + ", ";
					}
				}
				text += "\n</color><color=#FF00FF>Outside: </color>";
				text3 += "\n</color><color=#FF00FF>Outside: </color>";
				if (currentLevel.OutsideEnemies.Count == 0)
				{
					text += "None";
					text3 += "None";
				}
				else
				{
					foreach (SpawnableEnemyWithRarity outsideEnemy in currentLevel.OutsideEnemies)
					{
						Utils.LogInfo("Outside: " + outsideEnemy.enemyType.enemyName);
						text = text + outsideEnemy.enemyType.enemyName + ", ";
						text3 = text3 + outsideEnemy.enemyType.enemyName + ", ";
					}
				}
				Utils.DisplayChatMessage(text);
			}
			Utils.DisplayChatMessage(text2 + "\n" + text3);
		}
	}
	internal class GetItems : CustomChatCommand
	{
		public override string Name => "Get ALL Spawnable Items";

		public override string Description => "Gets the spawnable items you can spawn with /spawnitem or /spwitm.";

		public override string Format => "/getitems";

		public override string AltFormat => "/items";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			string text = "<color=yellow>Spawnable Items:</color>\n";
			foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
			{
				text = text + ((Object)items).name + "\n";
			}
			Utils.DisplayChatMessage(text);
		}
	}
	internal class GetPosition : CustomChatCommand
	{
		public override string Name => "Get your current Position";

		public override string Description => "Returns your current position.";

		public override string Format => "/getposition";

		public override string AltFormat => "/getpos";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			string text = "<color=yellow>Current Position:</color>\n";
			Vector3 position = ((Component)StartOfRound.Instance.localPlayerController).transform.position;
			text = text + "X: " + position.x + "\n";
			text = text + "Y: " + position.y + "\n";
			text = text + "Z: " + position.z + "\n";
			Utils.DisplayChatMessage(text);
		}
	}
	internal class GetScrap : CustomChatCommand
	{
		public override string Name => "Get Spawnable Scrap Items";

		public override string Description => "Gets the spawnable scrap items for the current level.";

		public override string Format => "/getscrap";

		public override string AltFormat => "/scrap";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			SelectableLevel currentLevel = Utils.GetCurrentLevel();
			if ((Object)(object)currentLevel == (Object)null)
			{
				Utils.DisplayChatError("Level is null.");
				return;
			}
			int count = Utils.GetCurrentLevel().spawnableScrap.Count;
			string text = ((Object)Utils.GetCurrentLevel().spawnableScrap[0].spawnableItem.spawnPrefab).name;
			for (int i = 1; i < count; i++)
			{
				text += ", ";
				text += ((Object)Utils.GetCurrentLevel().spawnableScrap[i].spawnableItem.spawnPrefab).name;
			}
			HUDManager.Instance.DisplayTip("Spawnable Scrap", text, false, false, "LC_Tip1");
			Utils.DisplayChatMessage("Spawnable Scrap: " + text);
		}
	}
	internal class GodMode : CustomChatCommand
	{
		private static bool isGod;

		public override string Name => "Toggle God Mode";

		public override string Description => "Toggles if invincibility is enabled.";

		public override string Format => "/godmode";

		public override string AltFormat => "/god";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			if (ChatCommands.isHost)
			{
				isGod = !isGod;
				Utils.SendHostCommand(message.Command);
			}
			else
			{
				isGod = !isGod;
			}
			Utils.DisplayChatMessage("God Mode: " + (isGod ? "Enabled" : "Disabled"));
		}

		[HarmonyPatch(typeof(PlayerControllerB), "AllowPlayerDeath")]
		[HarmonyPrefix]
		private static bool OverrideDeath()
		{
			return !isGod;
		}

		[HarmonyPatch(typeof(MouthDogAI), "OnCollideWithPlayer")]
		[HarmonyPrefix]
		private static bool OverrideDeath2()
		{
			return !isGod;
		}

		[HarmonyPatch(typeof(ForestGiantAI), "GrabPlayerServerRpc")]
		[HarmonyPrefix]
		private static bool OverrideDeath3()
		{
			return !isGod;
		}
	}
	internal class HelpCommand : CustomChatCommand
	{
		public override string Name => "View Help";

		public override string Description => "Displays a list of available commands with their format. Use <color=#00FFFF>/help [command]</color> to get more information about a specific command.";

		public override string Format => "/help ([command])";

		public override string AltFormat => "/h ([command])";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count == 0)
			{
				string text = "";
				string text2 = "";
				foreach (CustomChatCommand command in CommandController.Commands)
				{
					text = text + "<color=#00FFFF>" + command.Format + "</color> - Alt: " + command.AltFormat + "\n";
					text2 = text2 + command.Name + ": Format: " + command.Format + " - Alt: " + command.AltFormat + "\nDescription: " + command.Description + ", " + (command.IsHostCommand ? "For Host only" : "Host and Client") + "\n";
				}
				Utils.LogInfo(text2);
				Utils.DisplayChatMessage(text);
				return;
			}
			string value = message.Args[0].ToLower();
			CustomChatCommand customChatCommand = null;
			foreach (CustomChatCommand command2 in CommandController.Commands)
			{
				if (command2.Format.ToLower().Contains(value) || command2.AltFormat.ToLower().Contains(value) || command2.Name.ToLower().Contains(value))
				{
					customChatCommand = command2;
					break;
				}
			}
			if (customChatCommand != null)
			{
				Utils.DisplayChatMessage($"<color=#771615>Command</color>: <color=#00FFFF>{customChatCommand.Name}</color>\n<color=#771615>Description</color>: {customChatCommand.Description}\n<color=#771615>Format</color>: {customChatCommand.Format}\n<color=#771615>Alternative Format</color>: {customChatCommand.AltFormat}\nHost only Command: {customChatCommand.IsHostCommand}");
			}
			else
			{
				Utils.DisplayChatError("Command not found.");
			}
		}
	}
	internal class InfiniteAmmo : CustomChatCommand
	{
		private static bool EnableInfiniteAmmo;

		public override string Name => "Infinite Ammo";

		public override string Description => "Toggle Infinite Ammo.";

		public override string Format => "/infammo";

		public override string AltFormat => "/ammo";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			EnableInfiniteAmmo = !EnableInfiniteAmmo;
			Utils.DisplayChatMessage("Infinite Ammo: " + (EnableInfiniteAmmo ? "Enabled" : "Disabled"));
			if (ChatCommands.isHost)
			{
				Utils.SendHostCommand(message.Command);
			}
		}

		[HarmonyPatch(typeof(ShotgunItem), "ItemActivate")]
		[HarmonyPrefix]
		private static void ItemActivateGunPatch(ref ShotgunItem __instance)
		{
			if (EnableInfiniteAmmo)
			{
				__instance.shellsLoaded = 2;
			}
		}
	}
	internal class RevivePlayers : CustomChatCommand
	{
		public override string Name => "Revive all players";

		public override string Description => "Revives everyone.";

		public override string Format => "/revive";

		public override string AltFormat => "/rev";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count == 0)
			{
				StartOfRound.Instance.ReviveDeadPlayers();
			}
		}
	}
	internal class SetCustomDeadline : CustomChatCommand
	{
		private static bool EnableCustomDeadline = false;

		private static int CustomDeadline = 6;

		private static bool SetNewCustomDeadline = false;

		public override string Name => "Set Custom Deadline";

		public override string Description => "Sets a custom deadline for the game. If no argument is provided, the custom deadline will be toggled.";

		public override string Format => "/deadline [days]";

		public override string AltFormat => "/dl [days]";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count > 0)
			{
				if (int.TryParse(message.Args[0], out var result))
				{
					CustomDeadline = result;
					Utils.DisplayChatMessage("Deadline set to " + CustomDeadline + " days");
					EnableCustomDeadline = true;
					SetNewCustomDeadline = true;
				}
				else
				{
					CustomDeadline = int.MinValue;
					Utils.DisplayChatMessage("Deadline set to default");
					EnableCustomDeadline = false;
					SetNewCustomDeadline = false;
				}
			}
			else
			{
				EnableCustomDeadline = !EnableCustomDeadline;
				Utils.DisplayChatMessage("Deadline set to" + (EnableCustomDeadline ? "custom" : "default"));
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")]
		[HarmonyPrefix]
		private static void PatchDeadline(TimeOfDay __instance)
		{
			if (ChatCommands.isHost && EnableCustomDeadline && SetNewCustomDeadline)
			{
				__instance.quotaVariables.deadlineDaysAmount = CustomDeadline;
				__instance.timeUntilDeadline = (float)(__instance.quotaVariables.deadlineDaysAmount + CustomDeadline) * __instance.totalTime;
				TimeOfDay.Instance.timeUntilDeadline = (int)(TimeOfDay.Instance.totalTime * (float)TimeOfDay.Instance.quotaVariables.deadlineDaysAmount);
				TimeOfDay.Instance.SyncTimeClientRpc(__instance.globalTime, (int)__instance.timeUntilDeadline);
				((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n " + TimeOfDay.Instance.daysUntilDeadline;
				SetNewCustomDeadline = false;
			}
			else if (ChatCommands.isHost && EnableCustomDeadline)
			{
				StartOfRound.Instance.companyBuyingRate = 1f - (float)(TimeOfDay.Instance.daysUntilDeadline / CustomDeadline);
				if (TimeOfDay.Instance.daysUntilDeadline == 0)
				{
					StartOfRound.Instance.companyBuyingRate = 1f;
				}
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
		[HarmonyPostfix]
		private static void ResetDeadline(TimeOfDay __instance)
		{
			if (ChatCommands.isHost && EnableCustomDeadline && !SetNewCustomDeadline)
			{
				SetNewCustomDeadline = true;
			}
		}
	}
	internal class SetMoney : CustomChatCommand
	{
		private static int customMoney;

		private static bool infMoney;

		public override string Name => "Set Money";

		public override string Description => "Set Terminal Money to defined value, or without value to toggle infinite money.";

		public override string Format => "/setmoney ([value])";

		public override string AltFormat => "/money ([value])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count == 1)
			{
				if (int.TryParse(message.Args[0], out var result))
				{
					customMoney = result;
					Terminal val = Object.FindObjectOfType<Terminal>();
					val.groupCredits = customMoney;
					Utils.DisplayChatMessage("Money set to: " + customMoney);
				}
				else
				{
					Utils.DisplayChatError("Invalid money value");
				}
			}
			else
			{
				infMoney = !infMoney;
				Utils.DisplayChatMessage("Infinite Money: " + (infMoney ? "Enabled" : "Disabled"));
			}
		}

		[HarmonyPatch(typeof(Terminal), "RunTerminalEvents")]
		[HarmonyPostfix]
		private static void InfiniteCredits(ref int ___groupCredits)
		{
			if (ChatCommands.isHost && infMoney)
			{
				___groupCredits = 99999;
			}
		}
	}
	internal class SpawnEnemyCommand : CustomChatCommand
	{
		public override string Name => "Spawn Enemy";

		public override string Description => "Spawns an enemy at the specified location. Either use the player's position or specify a position. Position, state and amount are optional. Use them with the following format: position=@(playername/me) amount=(number) state=(alive/dead)";

		public override string Format => "/spawnenemy [enemyname] ([p=position]) ([a=amount]) ([s=state])";

		public override string AltFormat => "/spweny [enemyname] ([a=amount]) ([s=state]) ([p=position])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			string text = "Spawned Enemies";
			string text2 = "";
			if ((Object)(object)Utils.GetCurrentLevel() == (Object)null || ChatCommands.levelEnemySpawns == null || Utils.GetCurrentLevel().Enemies == null)
			{
				text = "Command";
				text2 = (((Object)(object)Utils.GetCurrentLevel() == (Object)null) ? "Unable to send command since currentLevel is null." : "Unable to send command since levelEnemySpawns is null.");
				Utils.DisplayChatError(text + "\n" + text2);
			}
			if (message.Args.Count < 1)
			{
				text = "Command Error";
				text2 = "Missing Arguments For Spawn\n'/spawnenemy <name> (amount=<amount>) (state=<state>) (position={random, @me, @<playername>})";
				Utils.DisplayChatError(text + "\n" + text2);
			}
			int num = 1;
			string text3 = "alive";
			Vector3 val = Vector3.zero;
			string text4 = "random";
			string[] array = message.Args.Skip(1).ToArray();
			string text5 = message.Args[0];
			string[] array2 = array;
			foreach (string text6 in array2)
			{
				string[] array3 = text6.Split(new char[1] { '=' });
				switch (array3[0])
				{
				case "a":
				case "amount":
					num = int.Parse(array3[1]);
					Utils.LogInfo($"{num}");
					break;
				case "s":
				case "state":
					text3 = array3[1];
					Utils.LogInfo(text3);
					break;
				case "p":
				case "position":
					text4 = array3[1];
					Utils.LogInfo(text4);
					break;
				}
			}
			if (text4 != "random")
			{
				val = Utils.CalculateSpawnPosition(text4);
				if (val == Vector3.zero && text4 != "random")
				{
					ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'");
					text4 = "random";
				}
			}
			if (text5.Length <= 1)
			{
				return;
			}
			bool flag = false;
			string text7 = "";
			foreach (SpawnableEnemyWithRarity enemy in Utils.GetCurrentLevel().Enemies)
			{
				if (!enemy.enemyType.enemyName.ToLower().Contains(text5.ToLower()))
				{
					continue;
				}
				try
				{
					flag = true;
					text7 = enemy.enemyType.enemyName;
					if (text4 == "random")
					{
						SpawnEnemy(enemy, num, inside: true, new Vector3(0f, 0f, 0f));
					}
					else
					{
						SpawnEnemy(enemy, num, inside: true, val);
					}
					Utils.LogInfo("Spawned " + enemy.enemyType.enemyName);
				}
				catch
				{
					Utils.LogInfo("Could not spawn enemy");
				}
				text2 = "Spawned: " + text7;
				break;
			}
			if (flag)
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity outsideEnemy in Utils.GetCurrentLevel().OutsideEnemies)
			{
				if (!outsideEnemy.enemyType.enemyName.ToLower().Contains(text5.ToLower()))
				{
					continue;
				}
				try
				{
					flag = true;
					text7 = outsideEnemy.enemyType.enemyName;
					Utils.LogInfo(outsideEnemy.enemyType.enemyName);
					Utils.LogInfo("The index of " + outsideEnemy.enemyType.enemyName + " is " + Utils.GetCurrentLevel().OutsideEnemies.IndexOf(outsideEnemy));
					if (text4 == "random")
					{
						SpawnEnemy(outsideEnemy, num, inside: false, new Vector3(0f, 0f, 0f));
					}
					else
					{
						SpawnEnemy(outsideEnemy, num, inside: false, val);
					}
					Utils.LogInfo("Spawned " + outsideEnemy.enemyType.enemyName);
				}
				catch (Exception ex)
				{
					Utils.LogInfo("Could not spawn enemy");
					Utils.LogInfo("The game tossed an error: " + ex.Message);
				}
				text2 = "Spawned " + num + " " + text7 + ((num > 1) ? "s" : "");
				break;
			}
		}

		internal static void SpawnEnemy(SpawnableEnemyWithRarity enemy, int amount, bool inside, Vector3 location)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			if (!ChatCommands.isHost)
			{
				return;
			}
			if (location.x != 0f && location.y != 0f && location.z != 0f && inside)
			{
				try
				{
					for (int i = 0; i < amount; i++)
					{
						Utils.GetCurrentRound().SpawnEnemyOnServer(location, 0f, Utils.GetCurrentLevel().Enemies.IndexOf(enemy));
					}
					return;
				}
				catch
				{
					Utils.LogWarning("Failed to spawn enemies, check your command.");
					return;
				}
			}
			if (location.x != 0f && location.y != 0f && location.z != 0f && !inside)
			{
				try
				{
					int j;
					for (j = 0; j < amount; j++)
					{
						Object.Instantiate<GameObject>(Utils.GetCurrentLevel().OutsideEnemies[Utils.GetCurrentLevel().OutsideEnemies.IndexOf(enemy)].enemyType.enemyPrefab, location, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
					}
					Utils.LogInfo($"You wanted to spawn: {amount} enemies");
					string text = j.ToString();
					Vector3 val = location;
					Utils.LogInfo("Spawned an enemy. Total Spawned: " + text + "at position:" + ((object)(Vector3)(ref val)).ToString());
					return;
				}
				catch
				{
					Utils.LogInfo("Failed to spawn enemies, check your command.");
					return;
				}
			}
			if (inside)
			{
				try
				{
					int k;
					for (k = 0; k < amount; k++)
					{
						Utils.GetCurrentRound().SpawnEnemyOnServer(Utils.GetCurrentRound().allEnemyVents[Random.Range(0, Utils.GetCurrentRound().allEnemyVents.Length)].floorNode.position, Utils.GetCurrentRound().allEnemyVents[k].floorNode.eulerAngles.y, Utils.GetCurrentLevel().Enemies.IndexOf(enemy));
					}
					Utils.LogInfo($"You wanted to spawn: {amount} enemies");
					Utils.LogInfo("Total Spawned: " + k);
					return;
				}
				catch
				{
					Utils.LogInfo("Failed to spawn enemies, check your command.");
					return;
				}
			}
			int l;
			for (l = 0; l < amount; l++)
			{
				Object.Instantiate<GameObject>(Utils.GetCurrentLevel().OutsideEnemies[Utils.GetCurrentLevel().OutsideEnemies.IndexOf(enemy)].enemyType.enemyPrefab, GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length - 1)].transform.position, Quaternion.Euler(Vector3.zero)).gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
			}
			Utils.LogInfo($"You wanted to spawn: {amount} enemies");
			Utils.LogInfo("Total Spawned: " + l);
		}
	}
	internal class SpawnItem : CustomChatCommand
	{
		public override string Name => "Spawn Item";

		public override string Description => "Spawns Items at a specified position or at a random position. Args are optional, use them like this: p=@me a=5 v=1234.\n Note: Value doesnt work for everything.";

		public override string Format => "/spawnitem [itemname] ([p=position]) ([a=amount]) ([v=value])";

		public override string AltFormat => "/spwitm [itemname] ([a=amount]) ([p=position]) ([v=value])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			string itemToSpawn = message.Args[0].ToLower();
			int num = 1;
			Vector3 val = Vector3.zero;
			string text = "random";
			int num2 = 1000;
			IEnumerable<string> enumerable = message.Args.Skip(1);
			foreach (string item in enumerable)
			{
				string[] array = item.Split(new char[1] { '=' });
				switch (array[0])
				{
				case "a":
				case "amount":
					num = int.Parse(array[1]);
					ChatCommands.mls.LogInfo((object)$"Amount {num}");
					break;
				case "p":
				case "position":
					text = array[1];
					ChatCommands.mls.LogInfo((object)text);
					break;
				case "v":
				case "value":
					num2 = int.Parse(array[1]);
					ChatCommands.mls.LogInfo((object)$"Value {num2}");
					break;
				}
			}
			if (text != "random")
			{
				val = Utils.CalculateSpawnPosition(text);
				if (val == Vector3.zero && text != "random")
				{
					ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'");
					text = "random";
				}
			}
			ChatCommands.SpawnItems(val, itemToSpawn, num2, num);
		}
	}
	internal class SpawnMapObject : CustomChatCommand
	{
		private static GameObject minePrefab;

		private static GameObject turretPrefab;

		private static GameObject spikeRoofPrefab;

		public override string Name => "Spawn Map Object";

		public override string Description => "Spawns Map Object at the specified location. Either use the player's position or specify a position. Position and amount are optional. Use them with the following format: position=@(playername/me) amount=(number)";

		public override string Format => "/spawnobject [objectname] ([p=position]) ([a=amount])";

		public override string AltFormat => "/spwobj [objectname] ([a=amount]) ([p=position])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0571: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Utils.GetCurrentLevel() == (Object)null || Utils.GetCurrentLevel().spawnableMapObjects == null)
			{
				Utils.LogError("Unable to send command since currentLevel or spawnableMapObjects is null.");
				Utils.DisplayChatError("Unable to send command since currentLevel or spawnableMapObjects is null.");
				return;
			}
			if (message.Args.Count < 1)
			{
				Utils.LogError("Missing Arguments For Spawn\n'/spawnmapobj <name> (amount=<amount>) (position={random, @me, @<playername>})");
				Utils.DisplayChatError("Missing Arguments For Spawn\n'/spawnmapobj <name> (amount=<amount>) (position={random, @me, @<playername>})");
				return;
			}
			string text = message.Args[0].ToLower();
			int num = 1;
			Vector3 val = Vector3.zero;
			string text2 = "random";
			IEnumerable<string> enumerable = message.Args.Skip(1);
			foreach (string item in enumerable)
			{
				string[] array = item.Split(new char[1] { '=' });
				switch (array[0])
				{
				case "a":
				case "amount":
					num = int.Parse(array[1]);
					Utils.LogInfo($"Amount {num}");
					break;
				case "p":
				case "position":
					text2 = array[1];
					Utils.LogInfo(text2);
					break;
				}
			}
			if (text2 != "random")
			{
				val = Utils.CalculateSpawnPosition(text2);
				if (val == Vector3.zero && text2 != "random")
				{
					Utils.LogWarning("Position Invalid, Using Default 'random'");
					text2 = "random";
				}
			}
			Vector3 val2;
			if (text == "mine" || text == "landmine")
			{
				if ((Object)(object)minePrefab == (Object)null)
				{
					Utils.LogWarning("Mine not found");
					return;
				}
				for (int i = 0; i < num; i++)
				{
					if (text2 == "random")
					{
						val = ((!(Random.value > 0.5f)) ? GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length)].transform.position : Utils.GetCurrentRound().allEnemyVents[Random.Range(0, Utils.GetCurrentRound().allEnemyVents.Length)].floorNode.position);
					}
					val2 = val;
					Utils.LogInfo("Spawning mine at position:" + ((object)(Vector3)(ref val2)).ToString());
					GameObject val3 = Object.Instantiate<GameObject>(minePrefab, val, Quaternion.identity, Utils.GetCurrentRound().mapPropsContainer.transform);
					val3.GetComponent<NetworkObject>().Spawn(true);
					val2 = val;
					Utils.DisplayChatMessage("Spawned mine at position:" + ((object)(Vector3)(ref val2)).ToString());
				}
				return;
			}
			switch (text)
			{
			case "turret":
			{
				if ((Object)(object)turretPrefab == (Object)null)
				{
					Utils.LogWarning("Turret not found");
					break;
				}
				for (int k = 0; k < num; k++)
				{
					if (text2 == "random")
					{
						val = ((!(Random.value > 0.5f)) ? GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length)].transform.position : Utils.GetCurrentRound().allEnemyVents[Random.Range(0, Utils.GetCurrentRound().allEnemyVents.Length)].floorNode.position);
					}
					val2 = val;
					Utils.LogInfo("Spawning turret at position:" + ((object)(Vector3)(ref val2)).ToString());
					GameObject val5 = Object.Instantiate<GameObject>(turretPrefab, val, Quaternion.identity, Utils.GetCurrentRound().mapPropsContainer.transform);
					val5.GetComponent<NetworkObject>().Spawn(true);
					val2 = val;
					Utils.DisplayChatMessage("Spawned turret at position:" + ((object)(Vector3)(ref val2)).ToString());
				}
				break;
			}
			default:
				if (!(text == "trap"))
				{
					Utils.LogWarning("Object not found");
					Utils.DisplayChatError("Object not found");
					break;
				}
				goto case "spikeroof";
			case "spikeroof":
			case "spike":
			{
				if ((Object)(object)spikeRoofPrefab == (Object)null)
				{
					Utils.LogWarning("Spike Roof not found");
					break;
				}
				for (int j = 0; j < num; j++)
				{
					if (text2 == "random")
					{
						val = ((!(Random.value > 0.5f)) ? GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length)].transform.position : Utils.GetCurrentRound().allEnemyVents[Random.Range(0, Utils.GetCurrentRound().allEnemyVents.Length)].floorNode.position);
					}
					val2 = val;
					Utils.LogInfo("Spawning spike roof at position:" + ((object)(Vector3)(ref val2)).ToString());
					GameObject val4 = Object.Instantiate<GameObject>(spikeRoofPrefab, val, Quaternion.identity, Utils.GetCurrentRound().mapPropsContainer.transform);
					val4.GetComponent<NetworkObject>().Spawn(true);
					val2 = val;
					Utils.DisplayChatMessage("Spawned spike roof at position:" + ((object)(Vector3)(ref val2)).ToString());
				}
				break;
			}
			}
		}

		public void AddToSpawnableMapObjects(SpawnableMapObject newObject)
		{
			SpawnableMapObject[] array = (SpawnableMapObject[])(object)new SpawnableMapObject[RoundManager.Instance.currentLevel.spawnableMapObjects.Length + 1];
			for (int i = 0; i < RoundManager.Instance.currentLevel.spawnableMapObjects.Length; i++)
			{
				array[i] = RoundManager.Instance.currentLevel.spawnableMapObjects[i];
			}
			array[RoundManager.Instance.currentLevel.spawnableMapObjects.Length] = newObject;
			RoundManager.Instance.currentLevel.spawnableMapObjects = array;
		}

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")]
		[HarmonyPrefix]
		private static void GetRoundManagerRef(ref RoundManager __instance)
		{
			if (!ChatCommands.isHost)
			{
				return;
			}
			Utils.LogInfo("Host, getting mine ref...");
			Landmine[] source = Object.FindObjectsOfType<Landmine>();
			Utils.LogInfo("Found: " + source.Count() + " Mines on this level");
			Turret[] source2 = Object.FindObjectsOfType<Turret>();
			Utils.LogInfo("Found: " + source2.Count() + " Turrets on this level");
			SpawnableMapObject[] spawnableMapObjects = __instance.currentLevel.spawnableMapObjects;
			foreach (SpawnableMapObject val in spawnableMapObjects)
			{
				Utils.LogInfo("Found: " + ((object)val.prefabToSpawn).ToString());
				if (((Object)val.prefabToSpawn).name.ToLower().Contains("turret"))
				{
					turretPrefab = val.prefabToSpawn;
					Utils.LogInfo("Found Turret");
				}
				if (((Object)val.prefabToSpawn).name.ToLower().Contains("mine"))
				{
					minePrefab = val.prefabToSpawn;
					Utils.LogInfo("Found Mine");
				}
				if (((Object)val.prefabToSpawn).name.ToLower().Contains("spikeroof"))
				{
					spikeRoofPrefab = val.prefabToSpawn;
					Utils.LogInfo("Found Spike Roof");
				}
			}
		}
	}
	internal class SpawnScrapCommand : CustomChatCommand
	{
		public override string Name => "Spawn Scrap";

		public override string Description => "Spawns Scrap at the specified location. Either use the player's position or specify a position. Position, value and amount are optional. Use them with the following format: position=@(playername/me) amount=(number) value=(number)";

		public override string Format => "/spawnscrap [scrapname] ([p=position]) ([a=amount]) ([v=value])";

		public override string AltFormat => "/spwscr [scrapname] ([a=amount]) ([v=value]) ([p=position])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string text2 = "";
			if ((Object)(object)Utils.GetCurrentLevel() == (Object)null)
			{
				Utils.DisplayChatError("Unable to send command since currentLevel is null.");
				return;
			}
			if (message.Args.Count < 1)
			{
				text = "Command Error";
				text2 = "Missing Arguments For Spawn\n'/spawnscrap <name> (amount=<amount>) (position={random, @me, @<playername>})";
				Utils.DisplayChatError(text + "\n" + text2);
				HUDManager.Instance.DisplayTip(text, text2, true, false, "LC_Tip1");
				return;
			}
			string text3 = message.Args[0].ToLower();
			int num = 1;
			Vector3 val = Vector3.zero;
			string text4 = "random";
			int num2 = 1000;
			string[] array = message.Args.Skip(1).ToArray();
			string[] array2 = array;
			foreach (string text5 in array2)
			{
				string[] array3 = text5.Split(new char[1] { '=' });
				switch (array3[0])
				{
				case "v":
				case "value":
					num2 = int.Parse(array3[1]);
					Utils.LogInfo($"Value {num2}");
					break;
				case "a":
				case "amount":
					num = int.Parse(array3[1]);
					Utils.LogInfo($"Amount {num}");
					break;
				case "p":
				case "position":
					text4 = array3[1];
					Utils.LogInfo(text4);
					break;
				}
			}
			if (text4 != "random")
			{
				val = Utils.CalculateSpawnPosition(text4);
				if (val == Vector3.zero && text4 != "random")
				{
					Utils.LogWarning("Position Invalid, Using Default 'random'");
					text4 = "random";
				}
			}
			Vector3 val4;
			if (text3 == "gun")
			{
				for (int j = 0; j < Utils.GetCurrentLevel().Enemies.Count(); j++)
				{
					if (((Object)Utils.GetCurrentLevel().Enemies[j].enemyType).name == "Nutcracker")
					{
						GameObject val2 = Object.Instantiate<GameObject>(Utils.GetCurrentLevel().Enemies[j].enemyType.enemyPrefab, new Vector3(float.MinValue, float.MinValue, float.MinValue), Quaternion.identity);
						NutcrackerEnemyAI component = val2.GetComponent<NutcrackerEnemyAI>();
						Utils.LogInfo("Spawning " + num + " gun" + ((num > 1) ? "s" : ""));
						for (int k = 0; k < num; k++)
						{
							GameObject val3 = Object.Instantiate<GameObject>(component.gunPrefab, val, Quaternion.identity, Utils.GetCurrentRound().spawnedScrapContainer);
							GrabbableObject component2 = val3.GetComponent<GrabbableObject>();
							component2.startFallingPosition = val;
							component2.targetFloorPosition = component2.GetItemFloorPosition(val);
							component2.SetScrapValue(num2);
							((NetworkBehaviour)component2).NetworkObject.Spawn(false);
						}
						text = "Spawned gun";
						string[] obj = new string[8]
						{
							"Spawned ",
							num.ToString(),
							" gun",
							(num > 1) ? "s" : "",
							"with value of:",
							num2.ToString(),
							"\n at position: ",
							null
						};
						val4 = val;
						obj[7] = ((object)(Vector3)(ref val4)).ToString();
						text2 = string.Concat(obj);
						break;
					}
				}
			}
			int num3 = Utils.GetCurrentLevel().spawnableScrap.Count();
			bool flag = false;
			for (int l = 0; l < num3; l++)
			{
				Item scrap = Utils.GetCurrentLevel().spawnableScrap[l].spawnableItem;
				if (!(((Object)scrap.spawnPrefab).name.ToLower() == text3))
				{
					continue;
				}
				GameObject spawnPrefab = scrap.spawnPrefab;
				bool flag2 = text4 == "random";
				List<RandomScrapSpawn> list = null;
				if (flag2)
				{
					RandomScrapSpawn[] source = Object.FindObjectsOfType<RandomScrapSpawn>();
					list = ((scrap.spawnPositionTypes != null && scrap.spawnPositionTypes.Count != 0) ? source.Where((RandomScrapSpawn x) => scrap.spawnPositionTypes.Contains(x.spawnableItems) && !x.spawnUsed).ToList() : source.ToList());
				}
				Utils.LogInfo("Spawning " + num + " " + ((Object)spawnPrefab).name + ((num > 1) ? "s" : ""));
				for (int m = 0; m < num; m++)
				{
					if (flag2)
					{
						RandomScrapSpawn val5 = list[Utils.GetCurrentRound().AnomalyRandom.Next(0, list.Count)];
						val = Utils.GetCurrentRound().GetRandomNavMeshPositionInRadiusSpherical(((Component)val5).transform.position, val5.itemSpawnRange, Utils.GetCurrentRound().navHit) + Vector3.up * scrap.verticalOffset;
					}
					GameObject val6 = Object.Instantiate<GameObject>(spawnPrefab, val, Quaternion.identity, Utils.GetCurrentRound().spawnedScrapContainer);
					GrabbableObject component3 = val6.GetComponent<GrabbableObject>();
					component3.startFallingPosition = val;
					component3.targetFloorPosition = component3.GetItemFloorPosition(val);
					component3.SetScrapValue(num2);
					((NetworkBehaviour)component3).NetworkObject.Spawn(false);
					text = "Spawned " + ((Object)spawnPrefab).name;
					string[] obj2 = new string[9]
					{
						"Spawned ",
						num.ToString(),
						" ",
						((Object)spawnPrefab).name,
						(num > 1) ? "s" : "",
						" with value of:",
						num2.ToString(),
						"\n at position: ",
						null
					};
					val4 = val;
					obj2[8] = ((object)(Vector3)(ref val4)).ToString();
					text2 = string.Concat(obj2);
				}
				flag = true;
				break;
			}
			if (!flag)
			{
				Utils.LogWarning("Could not spawn " + text3);
				text = "Command Error";
				text2 = "Could not spawn " + text3 + ".\nHave you checked using /getscrap if the scrap you are trying to spawn\n is even spawnable?";
			}
			Utils.DisplayChatMessage(text + "\n" + text2);
		}
	}
	internal class SpawnTruck : CustomChatCommand
	{
		public static GameObject truckPrefab;

		public override string Name => "Spawn Truck";

		public override string Description => "Spawns the Truck, either at the default position or at a specified position.";

		public override string Format => "/spawntruck ([p=position])";

		public override string AltFormat => "/spwtrk ([p=position])";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (message.Args.Count < 1)
			{
				Object.Instantiate<GameObject>(truckPrefab, StartOfRound.Instance.groundOutsideShipSpawnPosition.position, Quaternion.identity, RoundManager.Instance.VehiclesContainer).gameObject.GetComponent<NetworkObject>().Spawn(false);
				return;
			}
			Vector3 zero = Vector3.zero;
			zero = Utils.CalculateSpawnPosition(message.Args[0]);
			if (zero == Vector3.zero)
			{
				zero = StartOfRound.Instance.groundOutsideShipSpawnPosition.position;
			}
			Object.Instantiate<GameObject>(truckPrefab, zero, Quaternion.identity, RoundManager.Instance.VehiclesContainer).gameObject.GetComponent<NetworkObject>().Spawn(false);
		}

		[HarmonyPatch(typeof(QuickMenuManager), "Start")]
		[HarmonyPostfix]
		private static void GetTruckPrefab(QuickMenuManager __instance)
		{
			truckPrefab = __instance.truckPrefab;
		}
	}
	internal class SpeedHack : CustomChatCommand
	{
		private static float defaultJumpForce = 13f;

		private static float moddedJumpForce = 25f;

		private static float moddedSprintSpeed = 5f;

		private static bool speedHack = false;

		public override string Name => "Speed Hack";

		public override string Description => "Toggles Speed Hack, if speed is provided it will set the speed to that value.\n If jump force is provided it will set the jump force to that value.";

		public override string Format => "/speed ([speed]) ([jumpforce])";

		public override string AltFormat => "/speedhack ([speed]) ([jumpforce])";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count == 1)
			{
				if (float.TryParse(message.Args[0], out var result))
				{
					moddedSprintSpeed = result;
					speedHack = true;
					Utils.DisplayChatMessage("Speed Hack enabled with speed: " + moddedSprintSpeed);
					if (ChatCommands.SendHostCommandsSetting.Value && ChatCommands.isHost)
					{
						Utils.SendHostCommand(message.Command + moddedSprintSpeed);
					}
				}
				else
				{
					Utils.DisplayChatError("Invalid speed value");
				}
			}
			else if (message.Args.Count == 2)
			{
				if (float.TryParse(message.Args[0], out var result2))
				{
					moddedSprintSpeed = result2;
					if (float.TryParse(message.Args[1], out var result3))
					{
						moddedJumpForce = result3;
						speedHack = true;
						Utils.DisplayChatMessage("Speed Hack enabled with speed: " + moddedSprintSpeed + " and jump force: " + moddedJumpForce);
						if (ChatCommands.SendHostCommandsSetting.Value && ChatCommands.isHost)
						{
							Utils.SendHostCommand(message.Command + " " + moddedSprintSpeed + " " + moddedJumpForce);
						}
					}
					else
					{
						Utils.DisplayChatError("Invalid jump force value");
					}
				}
				else
				{
					Utils.DisplayChatError("Invalid speed value");
				}
			}
			else if (message.Args.Count > 2)
			{
				Utils.DisplayChatError("Too many arguments");
			}
			else
			{
				speedHack = !speedHack;
				if (!speedHack)
				{
					moddedSprintSpeed = 0f;
					moddedJumpForce = defaultJumpForce;
				}
				Utils.DisplayChatMessage("Speed Hack: " + (speedHack ? "Enabled" : "Disabled"));
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPrefix]
		private static void SpeedHackFunc(ref float ___jumpForce, ref float ___sprintMeter, ref float ___sprintMultiplier, ref bool ___isSprinting, ref float ___targetFOV)
		{
			defaultJumpForce = global::ChatCommands.Patches.Patches.defaultJumpForce;
			if (speedHack)
			{
				___jumpForce = moddedJumpForce;
				___sprintMeter = 1f;
				if (___isSprinting)
				{
					___sprintMultiplier = moddedSprintSpeed;
					___targetFOV *= moddedSprintSpeed;
				}
				else
				{
					___sprintMultiplier = 1f;
				}
			}
			else
			{
				___jumpForce = defaultJumpForce;
			}
		}
	}
	internal class TeleportCommand : CustomChatCommand
	{
		public override string Name => "Teleport";

		public override string Description => "Teleport to where you want. Use the following format: position=@(playername/me) or position=(random) or without arguments to teleport to the terminal.";

		public override string Format => "/teleport [position=(random/@<playername>/@me)]";

		public override string AltFormat => "/tp [position=(random/@<playername>/@me)]";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			//IL_0001: 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_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			string text = ((message.Args.Count > 0) ? message.Args[0] : "");
			string text2 = "random";
			if (!Utility.IsNullOrWhiteSpace(text))
			{
				if (text.ToLower().StartsWith("p="))
				{
					text2 = text.ToLower().Substring(2);
					if (text2 != "random")
					{
						val = Utils.CalculateSpawnPosition(text2);
						if (val == Vector3.zero && text2 != "random")
						{
							ChatCommands.mls.LogWarning((object)"Position Invalid, Using Default 'random'");
							text2 = "random";
						}
					}
					if (text2 == "random" && (Object)(object)Utils.GetCurrentRound() != (Object)null && (Object)(object)Utils.GetCurrentLevel() != (Object)null)
					{
						Random random = new Random(StartOfRound.Instance.randomMapSeed + 17 + (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
						Vector3 position = RoundManager.Instance.insideAINodes[random.Next(0, RoundManager.Instance.insideAINodes.Length)].transform.position;
						Debug.DrawRay(position, Vector3.up * 1f, Color.red);
						position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1);
						Debug.DrawRay(position + Vector3.right * 0.01f, Vector3.up * 3f, Color.green);
						val = position;
					}
					GameNetworkManager.Instance.localPlayerController.beamUpParticle.Play();
					GameNetworkManager.Instance.localPlayerController.beamOutBuildupParticle.Play();
					GameNetworkManager.Instance.localPlayerController.TeleportPlayer(val, false, 0f, false, true);
					Utils.DisplayChatMessage("Teleported to " + text2);
					return;
				}
				string name = text.ToLower();
				name = Utils.ConvertPlayername(name);
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				PlayerControllerB[] array = allPlayerScripts;
				foreach (PlayerControllerB val2 in array)
				{
					if (val2.playerUsername.ToLower().Contains(name))
					{
						GameNetworkManager.Instance.localPlayerController.beamUpParticle.Play();
						GameNetworkManager.Instance.localPlayerController.beamOutBuildupParticle.Play();
						GameNetworkManager.Instance.localPlayerController.TeleportPlayer(((Component)val2).transform.position, false, 0f, false, true);
						Utils.DisplayChatMessage("Teleported to " + val2.playerUsername);
						break;
					}
				}
			}
			else
			{
				Terminal val3 = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val3 != (Object)null)
				{
					GameNetworkManager.Instance.localPlayerController.beamUpParticle.Play();
					GameNetworkManager.Instance.localPlayerController.beamOutBuildupParticle.Play();
					GameNetworkManager.Instance.localPlayerController.TeleportPlayer(((Component)val3).transform.position, false, 0f, false, true);
					Utils.DisplayChatMessage("Teleported to Terminal");
				}
			}
		}
	}
	internal class TerminalCommand : CustomChatCommand
	{
		public override string Name => "Send Terminal Command";

		public override string Description => "Send a terminal commmand to the terminal and receive a response.";

		public override string Format => "/term [terminalcommand]";

		public override string AltFormat => "/terminal [terminalcommand]";

		public override bool IsHostCommand => false;

		public override void Execute(CommandInput message)
		{
			if (message.Args.Count == 0)
			{
				Utils.DisplayChatError("No command entered.");
				return;
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			string text = string.Join(" ", message.Args);
			if ((Object)(object)val == (Object)null)
			{
				Utils.DisplayChatError("Terminal not found.");
				return;
			}
			val.BeginUsingTerminal();
			val.currentText = "";
			val.screenText.text = text;
			val.OnSubmit();
			Utils.DisplayChatMessage("Command sent: " + text);
			delayedTerminalCommand(val, text);
		}

		private static async void delayedTerminalCommand(Terminal term, string command)
		{
			SelectableLevel[] moonsCatalogueList = term.moonsCatalogueList;
			foreach (SelectableLevel level in moonsCatalogueList)
			{
				if (level.PlanetName.ToLower().Contains(command.ToLower()))
				{
					Utils.LogInfo("Found Moon: " + command);
					await Task.Delay(300);
					term.currentText = "";
					term.screenText.text = "confirm";
					term.OnSubmit();
					break;
				}
			}
			if (command.ToLower().Contains("buy"))
			{
				Utils.LogInfo("Trying to buy");
				await Task.Delay(300);
				term.currentText = "";
				term.screenText.text = "confirm";
				term.OnSubmit();
			}
			await Task.Delay(300);
			term.QuitTerminal(true);
		}
	}
	internal class ToggleHostCmd : CustomChatCommand
	{
		public override string Name => "Toggle Host Commands";

		public override string Description => "Toggle if connecting clients can use host commands.";

		public override string Format => "/togglehostcmd";

		public override string AltFormat => "/thcmd";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			ChatCommands.AllowHostCommands = !ChatCommands.AllowHostCommands;
			Utils.DisplayChatMessage("Host Commands: " + (ChatCommands.AllowHostCommands ? "Enabled" : "Disabled"));
		}
	}
	internal class ToggleLights : CustomChatCommand
	{
		public override string Name => "Toggle Lights";

		public override string Description => "Toggles the lights on and off.";

		public override string Format => "/togglelights";

		public override string AltFormat => "/toglig";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			BreakerBox val = Object.FindObjectOfType<BreakerBox>();
			if ((Object)(object)val != (Object)null)
			{
				if (val.isPowerOn)
				{
					Utils.GetCurrentRound().TurnBreakerSwitchesOff();
					Utils.GetCurrentRound().TurnOnAllLights(false);
					val.isPowerOn = false;
					Utils.DisplayChatMessage("Turned the lights off");
				}
				else
				{
					Utils.GetCurrentRound().PowerSwitchOnClientRpc();
					Utils.DisplayChatMessage("Turned the lights on");
				}
			}
			else
			{
				Utils.DisplayChatError("Unable to find BreakerBox, need to be in a level with lights to use this command.");
			}
		}
	}
	internal class ToggleOverrideSpawns : CustomChatCommand
	{
		private static bool OverrideSpawns;

		public override string Name => "Toggle Overrride Spawns";

		public override string Description => "Toggles if Monster Spawns are overriden or not. This affects how many monsters spawn with the spawn command and natural spawns.";

		public override string Format => "/override";

		public override string AltFormat => "/ovr";

		public override bool IsHostCommand => true;

		public override void Execute(CommandInput message)
		{
			OverrideSpawns = !OverrideSpawns;
			Utils.DisplayChatMessage("Override Spawns: " + (OverrideSpawns ? "Enabled" : "Disabled"));
		}

		[HarmonyPatch(typeof(RoundManager), "EnemyCannotBeSpawned")]
		[HarmonyPrefix]
		private static bool OverrideCannotSpawn()
		{
			if (OverrideSpawns)
			{
				return false;
			}
			return true;
		}
	}
}

BepInEx/plugins/CustomSounds.dll

Decompiled 5 hours 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.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using CustomSounds.Networking;
using CustomSounds.Patches;
using HarmonyLib;
using LCSoundTool;
using TMPro;
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: AssemblyTitle("CustomSounds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomSounds")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9e086160-a7fd-4721-ba09-3e8534cb7011")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace CustomSounds
{
	[BepInPlugin("CustomSounds", "Custom Sounds", "2.3.2")]
	public class Plugin : BaseUnityPlugin
	{
		public struct SoundData
		{
			public string SoundName;

			public float? RandomPercentage;

			public string CustomName;

			public string FilePath;

			public string FileExtension;

			public string PackName;

			public string AudioSource;

			public string DirectoryPath;

			public string RelativeDirectoryPath;
		}

		public class FolderTree
		{
			public Dictionary<string, FolderTree> SubFolders { get; set; }

			public List<SoundData> Files { get; set; }

			public FolderTree()
			{
				SubFolders = new Dictionary<string, FolderTree>();
				Files = new List<SoundData>();
			}
		}

		public static class SoundDataProcessor
		{
			public static FolderTree BuildFolderTree(List<SoundData> soundDataList)
			{
				FolderTree folderTree = new FolderTree();
				foreach (SoundData soundData in soundDataList)
				{
					string relativeDirectoryPath = soundData.RelativeDirectoryPath;
					string[] array = relativeDirectoryPath.Split(Path.DirectorySeparatorChar, '\u0001');
					FolderTree folderTree2 = folderTree;
					string[] array2 = array;
					foreach (string key in array2)
					{
						if (!folderTree2.SubFolders.ContainsKey(key))
						{
							folderTree2.SubFolders[key] = new FolderTree();
						}
						folderTree2 = folderTree2.SubFolders[key];
					}
					folderTree2.Files.Add(soundData);
				}
				return folderTree;
			}

			public static string DisplayTree(bool isListing, FolderTree tree, int indent = 0, bool isRoot = true, int soundCount = 0)
			{
				StringBuilder stringBuilder = new StringBuilder();
				if (isRoot)
				{
					soundCount = CountSounds(tree);
					string text = (isListing ? "Listing all currently loaded custom sounds:" : "Customsounds reloaded.");
					stringBuilder.AppendLine(text + $" ({soundCount} sounds)");
				}
				foreach (KeyValuePair<string, FolderTree> subFolder in tree.SubFolders)
				{
					if (isRoot)
					{
						stringBuilder.Append("\n");
					}
					string text2 = subFolder.Key;
					if (text2.EndsWith("-AS"))
					{
						text2 = subFolder.Key.Substring(0, subFolder.Key.Length - 3) + " (AudioSource)";
					}
					stringBuilder.AppendLine(new string(' ', indent * 2) + ((indent > 0) ? "∟ " : "") + text2 + " :");
					stringBuilder.Append(DisplayTree(isListing, subFolder.Value, indent + 1, isRoot: false));
				}
				foreach (SoundData file in tree.Files)
				{
					string text3 = ((!file.RandomPercentage.HasValue) ? "" : $" (Random: {file.RandomPercentage * 100f}%)");
					string text4 = ((file.CustomName == "") ? "" : (" [" + file.CustomName + "]"));
					stringBuilder.AppendLine(new string(' ', indent * 2) + "- " + file.SoundName + text3 + text4 + " [" + file.FileExtension.ToUpper() + "]");
				}
				return stringBuilder.ToString();
			}

			private static int CountSounds(FolderTree tree)
			{
				int num = tree.Files.Count;
				foreach (KeyValuePair<string, FolderTree> subFolder in tree.SubFolders)
				{
					num += CountSounds(subFolder.Value);
				}
				return num;
			}
		}

		private const string PLUGIN_GUID = "CustomSounds";

		private const string PLUGIN_NAME = "Custom Sounds";

		private const string PLUGIN_VERSION = "2.3.2";

		public static Plugin Instance;

		internal ManualLogSource logger;

		private Harmony harmony;

		public HashSet<string> currentSounds = new HashSet<string>();

		public HashSet<string> oldSounds = new HashSet<string>();

		public HashSet<string> modifiedSounds = new HashSet<string>();

		public Dictionary<string, string> soundHashes = new Dictionary<string, string>();

		public Dictionary<string, string> soundPacks = new Dictionary<string, string>();

		public static bool hasAcceptedSync = false;

		public static List<SoundData> soundDataList = new List<SoundData>();

		public static bool Initialized { get; private set; }

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (!((Object)(object)Instance == (Object)null))
			{
				return;
			}
			Instance = this;
			logger = Logger.CreateLogSource("CustomSounds");
			harmony = new Harmony("CustomSounds");
			harmony.PatchAll(typeof(TerminalParsePlayerSentencePatch));
			modifiedSounds = new HashSet<string>();
			string customSoundsFolderPath = GetCustomSoundsFolderPath();
			if (!Directory.Exists(customSoundsFolderPath))
			{
				logger.LogInfo((object)"\"CustomSounds\" folder not found. Creating it now.");
				string path = Path.Combine(customSoundsFolderPath, "YourOwnSoundPack");
				Directory.CreateDirectory(path);
				string contents = "If you're interested in creating your own sound pack, please refer to the 'For Sound Packs Creator' section on the CustomSounds Thunderstore page. If you simply wish to replace a few sounds on your own, you can drop the desired sounds into the 'YourOwnSoundPack' folder.";
				File.WriteAllText(Path.Combine(customSoundsFolderPath, "READ-ME-PLEASE.txt"), contents);
			}
			string path2 = Path.Combine(Paths.BepInExConfigPath);
			try
			{
				List<string> list = File.ReadAllLines(path2).ToList();
				int num = list.FindIndex((string line) => line.StartsWith("HideManagerGameObject"));
				if (num != -1 && list[num].Contains("false"))
				{
					logger.LogInfo((object)"\"HideManagerGameObject\" value not correctly set. Fixing it now.");
					list[num] = "HideManagerGameObject = true";
					File.WriteAllLines(path2, list);
					harmony.PatchAll(typeof(MenuPatcher));
				}
				else if (num != -1)
				{
					logger.LogInfo((object)"\"HideManagerGameObject\" is correctly set to true.");
				}
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Error modifying config file: " + ex.Message));
			}
			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);
					}
				}
			}
			logger.LogInfo((object)"Plugin CustomSounds is loaded!");
		}

		internal void Start()
		{
			Initialize();
		}

		internal void OnDestroy()
		{
			Initialize();
		}

		internal void Initialize()
		{
			if (!Initialized)
			{
				Initialized = true;
				ReloadSounds();
			}
		}

		private void OnApplicationQuit()
		{
		}

		public GameObject LoadNetworkPrefabFromEmbeddedResource()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "CustomSounds.Bundle.audionetworkhandler";
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				Debug.LogError((object)"Asset bundle not found in embedded resources.");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			AssetBundle val = AssetBundle.LoadFromMemory(array);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"Failed to load AssetBundle from memory.");
				return null;
			}
			return val.LoadAsset<GameObject>("audionetworkhandler");
		}

		public string GetCustomSoundsFolderPath()
		{
			return Path.Combine(Paths.PluginPath, "CustomSounds");
		}

		public void RevertSounds()
		{
			if (currentSounds == null || currentSounds.Count == 0)
			{
				logger.LogInfo((object)"No sounds to revert.");
				return;
			}
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string currentSound in currentSounds)
			{
				string text = currentSound;
				if (currentSound.Contains("-"))
				{
					text = currentSound.Substring(0, currentSound.IndexOf("-"));
				}
				if (!hashSet.Contains(text))
				{
					logger.LogInfo((object)(text + " restored."));
					SoundTool.RestoreAudioClip(text);
					hashSet.Add(text);
				}
			}
			logger.LogInfo((object)"Original game sounds restored.");
		}

		public void ReloadSounds()
		{
			oldSounds = new HashSet<string>(currentSounds);
			currentSounds.Clear();
			modifiedSounds.Clear();
			soundDataList.Clear();
			string directoryName = Path.GetDirectoryName(Paths.PluginPath);
			ProcessDirectory(directoryName);
		}

		private string GetRelativePathToCustomSounds(string filePath)
		{
			Debug.Log((object)("FilePath: " + filePath));
			string[] array = filePath.Split(new char[1] { Path.DirectorySeparatorChar });
			int num = Array.IndexOf(array, "CustomSounds");
			if (num == -1 || num == array.Length - 1)
			{
				return "";
			}
			string[] paths = array.Skip(num + 1).ToArray();
			return Path.Combine(paths);
		}

		private void ProcessDirectory(string directoryPath)
		{
			string[] directories = Directory.GetDirectories(directoryPath, "*", SearchOption.AllDirectories);
			foreach (string text in directories)
			{
				string fileName = Path.GetFileName(text);
				ProcessSoundFiles(text, fileName);
			}
		}

		private void ProcessSoundFiles(string directoryPath, string packName)
		{
			string[] array = new string[3] { "*.wav", "*.ogg", "*.mp3" };
			string[] array2 = array;
			foreach (string searchPattern in array2)
			{
				string[] files = Directory.GetFiles(directoryPath, searchPattern);
				foreach (string text in files)
				{
					if (text.Contains("CustomSounds"))
					{
						ProcessSingleFile(text, packName);
					}
				}
			}
		}

		private void ProcessSingleFile(string file, string packName)
		{
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
			(string soundName, float? percentage, string customName) tuple = ParseSoundFileName(fileNameWithoutExtension);
			string item = tuple.soundName;
			float? item2 = tuple.percentage;
			string item3 = tuple.customName;
			string fileExtension = Path.GetExtension(file).TrimStart(new char[1] { '.' }).ToLower();
			string relativePathToCustomSounds = GetRelativePathToCustomSounds(file);
			string fileName = Path.GetFileName(Path.GetDirectoryName(file));
			string text = (fileName.EndsWith("-AS") ? fileName.Substring(0, fileName.Length - 3) : null);
			SoundData soundData = default(SoundData);
			soundData.SoundName = item;
			soundData.RandomPercentage = item2;
			soundData.CustomName = item3;
			soundData.FilePath = file;
			soundData.FileExtension = fileExtension;
			soundData.PackName = packName;
			soundData.AudioSource = text;
			soundData.DirectoryPath = Path.GetDirectoryName(file);
			soundData.RelativeDirectoryPath = Path.GetDirectoryName(relativePathToCustomSounds);
			SoundData item4 = soundData;
			soundDataList.Add(item4);
			string text2 = "Sound replaced: " + item;
			if (item4.RandomPercentage.HasValue)
			{
				text2 += $" (Percentage = {item4.RandomPercentage.Value * 100f}%)";
			}
			if (!string.IsNullOrEmpty(item4.CustomName))
			{
				text2 = text2 + " (Custom Name = " + item4.CustomName + ")";
			}
			text2 = text2 + " (File Extension = " + item4.FileExtension + ")";
			Debug.Log((object)text2);
			AudioClip audioClip = SoundTool.GetAudioClip(Path.GetDirectoryName(file), file);
			((Object)audioClip).name = fileNameWithoutExtension;
			currentSounds.Add(item4.SoundName);
			if (item4.RandomPercentage.HasValue)
			{
				if (item4.AudioSource != null)
				{
					SoundTool.ReplaceAudioClip(item4.SoundName, audioClip, item4.RandomPercentage.Value, item4.AudioSource);
				}
				else
				{
					SoundTool.ReplaceAudioClip(item4.SoundName, audioClip, item4.RandomPercentage.Value);
				}
			}
			else if (text != null)
			{
				SoundTool.ReplaceAudioClip(item4.SoundName, audioClip, item4.AudioSource);
			}
			else
			{
				SoundTool.ReplaceAudioClip(item4.SoundName, audioClip);
			}
		}

		private (string soundName, float? percentage, string customName) ParseSoundFileName(string fullSoundName)
		{
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullSoundName);
			string[] array = fileNameWithoutExtension.Split(new char[1] { '-' });
			string s = array[^1];
			if (int.TryParse(s, out var result))
			{
				string item = array[0];
				string item2 = string.Join(" ", array.Skip(1).Take(array.Length - 2));
				float value = (float)result / 100f;
				return (item, value, item2);
			}
			return (array[0], null, string.Join(" ", array.Skip(1)));
		}
	}
}
namespace CustomSounds.Patches
{
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		private static GameObject networkHandlerHost;

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPrefix]
		public static void Init()
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = Plugin.Instance.LoadNetworkPrefabFromEmbeddedResource();
				networkPrefab.AddComponent<AudioNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				Plugin.Instance.logger.LogInfo((object)"Created AudioNetworkHandler prefab");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
				{
					Plugin.Instance.logger.LogInfo((object)"Spawning network handler");
					networkHandlerHost = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
					if (networkHandlerHost.GetComponent<NetworkObject>().IsSpawned)
					{
						Debug.Log((object)"NetworkObject is spawned and active.");
					}
					else
					{
						Debug.Log((object)"Failed to spawn NetworkObject.");
					}
					networkHandlerHost.GetComponent<NetworkObject>().Spawn(true);
					if ((Object)(object)AudioNetworkHandler.Instance != (Object)null)
					{
						Debug.Log((object)"Successfully accessed AudioNetworkHandler instance.");
					}
					else
					{
						Debug.Log((object)"AudioNetworkHandler instance is null.");
					}
				}
			}
			catch
			{
				Plugin.Instance.logger.LogError((object)"Failed to spawned network handler");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		private static void DestroyNetworkHandler()
		{
			try
			{
				if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
				{
					Plugin.Instance.logger.LogInfo((object)"Destroying network handler");
					Object.Destroy((Object)(object)networkHandlerHost);
					networkHandlerHost = null;
				}
			}
			catch
			{
				Plugin.Instance.logger.LogError((object)"Failed to destroy network handler");
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuPatcher
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void StartPostFix(MenuManager __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(DelayedMainMenuModification());
		}

		private static IEnumerator DelayedMainMenuModification()
		{
			yield return (object)new WaitForSeconds(0f);
			ChangeHostButtonFromMainMenu();
		}

		private static void ChangeHostButtonFromMainMenu()
		{
			Debug.Log((object)"Attempting to add a description to the Host button...");
			GameObject val = GameObject.Find("MenuContainer");
			Transform val2 = ((val != null) ? val.transform.Find("MainButtons") : null);
			object obj;
			if (val2 == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val2.Find("HostButton");
				obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			}
			GameObject val3 = (GameObject)obj;
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null))
			{
				string text = ((TMP_Text)val3.GetComponentInChildren<TextMeshProUGUI>()).text;
				((TMP_Text)val3.GetComponentInChildren<TextMeshProUGUI>()).text = "<line-height=0.28em>" + text + "\n<size=8><color=#B0B0B0>     Please restart the game for <color=#E6B800>CustomSounds</color> to work properly!</color></size></line-height>";
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
	public static class TerminalParsePlayerSentencePatch
	{
		public static bool Prefix(Terminal __instance, ref TerminalNode __result)
		{
			string[] array = __instance.screenText.text.Split(new char[1] { '\n' });
			if (array.Length == 0)
			{
				return true;
			}
			string[] array2 = array.Last().Trim().ToLower()
				.Split(new char[1] { ' ' });
			if (array2.Length == 0 || (array2[0] != "customsounds" && array2[0] != "cs"))
			{
				return true;
			}
			Plugin.Instance.logger.LogInfo((object)("Received terminal command: " + string.Join(" ", array2)));
			if (array2.Length > 1 && (array2[0] == "customsounds" || array2[0] == "cs"))
			{
				switch (array2[1])
				{
				case "reload":
				case "rl":
					Plugin.Instance.RevertSounds();
					Plugin.Instance.ReloadSounds();
					__result = CreateTerminalNode(Plugin.SoundDataProcessor.DisplayTree(isListing: false, Plugin.SoundDataProcessor.BuildFolderTree(Plugin.soundDataList)));
					return false;
				case "revert":
				case "rv":
					Plugin.Instance.RevertSounds();
					__result = CreateTerminalNode("Game sounds reverted to original.\n\n");
					return false;
				case "list":
				case "l":
					__result = CreateTerminalNode(Plugin.SoundDataProcessor.DisplayTree(isListing: true, Plugin.SoundDataProcessor.BuildFolderTree(Plugin.soundDataList)));
					return false;
				case "help":
				case "h":
					if (NetworkManager.Singleton.IsHost)
					{
						__result = CreateTerminalNode("CustomSounds commands \n(Can also be used with 'CS' as an alias).\n\n>CUSTOMSOUNDS LIST/L\nTo display all currently loaded sounds\n\n>CUSTOMSOUNDS RELOAD/RL\nTo reload and apply sounds from the 'CustomSounds' folder and its subfolders.\n\n>CUSTOMSOUNDS REVERT/RV\nTo unload all custom sounds and restore original game sounds\n\n");
					}
					else
					{
						__result = CreateTerminalNode("CustomSounds commands \n(Can also be used with 'CS' as an alias).\n\n>CUSTOMSOUNDS LIST/L\nTo display all currently loaded sounds\n\n>CUSTOMSOUNDS RELOAD/RL\nTo reload and apply sounds from the 'CustomSounds' folder and its subfolders.\n\n>CUSTOMSOUNDS REVERT/RV\nTo unload all custom sounds and restore original game sounds\n\n");
					}
					return false;
				case "sync":
				case "s":
					__result = CreateTerminalNode("/!\\ ERROR /!\\ \nThis command is not supported in this version of CustomSounds\n\n");
					return false;
				case "unsync":
				case "u":
					__result = CreateTerminalNode("/!\\ ERROR /!\\ \nThis command is not supported in this version of CustomSounds\n\n");
					return false;
				case "fu":
				case "force-unsync":
					__result = CreateTerminalNode("/!\\ ERROR /!\\ \nThis command is not supported in this version of CustomSounds\n\n");
					return false;
				default:
					__result = CreateTerminalNode("Unknown customsounds command.\n\n");
					return false;
				}
			}
			return true;
		}

		private static TerminalNode CreateTerminalNode(string message)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = message;
			val.clearPreviousText = true;
			return val;
		}
	}
}
namespace CustomSounds.Networking
{
	public class AudioNetworkHandler : NetworkBehaviour
	{
		public static AudioNetworkHandler Instance { get; private set; }

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected internal override string __getTypeName()
		{
			return "AudioNetworkHandler";
		}
	}
}

BepInEx/plugins/HealthMetrics.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HealthMetrics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HealthMetrics")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eba7b111-51e5-4353-807d-1268e6290901")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HealthMetrics
{
	[BepInPlugin("Matsuura.HealthMetrics", "HealthMetrics", "1.0.0")]
	public class HealthMetricsBase : BaseUnityPlugin
	{
		private const string modGUID = "Matsuura.HealthMetrics";

		private const string modName = "HealthMetrics";

		private const string modVersion = "1.0.0";

		private readonly Harmony _harmony = new Harmony("Matsuura.HealthMetrics");

		private static HealthMetricsBase _instance;

		private static ManualLogSource _logSource;

		internal void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
			}
			if (_logSource == null)
			{
				_logSource = Logger.CreateLogSource("Matsuura.HealthMetrics");
			}
			_harmony.PatchAll();
			_logSource.LogInfo((object)"HealthMetrics Awake");
		}

		internal static void Log(string message)
		{
			if (_logSource != null)
			{
				_logSource.LogInfo((object)message);
			}
		}

		internal static void LogD(string message)
		{
			if (_logSource != null)
			{
				_logSource.LogDebug((object)message);
			}
		}
	}
}
namespace HealthMetrics.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HealthHUDPatches
	{
		private static TextMeshProUGUI _healthText;

		private static readonly string DefaultValueHealthText = " ¤";

		public static int _oldValuehealthValueForUpdater = 0;

		public static int _healthValueForUpdater = 100;

		private static readonly Color _healthyColor = Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)0, byte.MaxValue));

		private static readonly Color _criticalHealthColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue));

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Start(ref HUDManager __instance)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("HealthHUDDisplay");
			val.AddComponent<RectTransform>();
			TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
			RectTransform rectTransform = ((TMP_Text)obj).rectTransform;
			((Transform)rectTransform).SetParent(((Component)__instance.PTTIcon).transform, false);
			rectTransform.anchoredPosition = new Vector2(8f, -57f);
			((TMP_Text)obj).font = ((TMP_Text)__instance.controlTipLines[0]).font;
			((TMP_Text)obj).fontSize = 16f;
			((TMP_Text)obj).text = "100";
			((Graphic)obj).color = _healthyColor;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)0;
			((Behaviour)obj).enabled = true;
			_healthText = obj;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void Update()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_healthText != (Object)null && _healthValueForUpdater != _oldValuehealthValueForUpdater)
			{
				_oldValuehealthValueForUpdater = _healthValueForUpdater;
				if (_healthValueForUpdater > 0)
				{
					((TMP_Text)_healthText).text = _healthValueForUpdater.ToString().PadLeft((_healthValueForUpdater < 10) ? 2 : 3, ' ');
				}
				else
				{
					((TMP_Text)_healthText).text = DefaultValueHealthText;
				}
				double percentage = (double)_healthValueForUpdater / 100.0;
				((Graphic)_healthText).color = ColorInterpolation(_criticalHealthColor, _healthyColor, percentage);
			}
		}

		public static int LinearInterpolation(int start, int end, double percentage)
		{
			return start + (int)Math.Round(percentage * (double)(end - start));
		}

		public static Color ColorInterpolation(Color start, Color end, double percentage)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			return new Color(hexToFloat(LinearInterpolation(floatToHex(start.r), floatToHex(end.r), percentage)), hexToFloat(LinearInterpolation(floatToHex(start.g), floatToHex(end.g), percentage)), hexToFloat(LinearInterpolation(floatToHex(start.b), floatToHex((int)end.b), percentage)), 1f);
		}

		public static float hexToFloat(int hex)
		{
			return (float)hex / 255f;
		}

		public static int floatToHex(float f)
		{
			return (int)f * 255;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerPatches
	{
		[HarmonyPrefix]
		[HarmonyPatch("LateUpdate")]
		private static void LateUpdate_Prefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject))
			{
				HealthHUDPatches._healthValueForUpdater = ((__instance.health >= 0) ? __instance.health : 0);
			}
		}
	}
}

BepInEx/plugins/HelmetCamera.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("HelmetCamera")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HelmetCamera")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b99c4d46-5f13-47b3-a5af-5e3f37772e77")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HelmetCamera
{
	[BepInPlugin("RickArg.lethalcompany.helmetcameras", "Helmet_Cameras", "2.1.5")]
	public class PluginInit : BaseUnityPlugin
	{
		public static Harmony _harmony;

		public static ConfigEntry<int> config_isHighQuality;

		public static ConfigEntry<int> config_renderDistance;

		public static ConfigEntry<int> config_cameraFps;

		private void Awake()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			config_isHighQuality = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "monitorResolution", 0, "Low FPS affection. High Quality mode. 0 - vanilla (48x48), 1 - vanilla+ (128x128), 2 - mid quality (256x256), 3 - high quality (512x512), 4 - Very High Quality (1024x1024)");
			config_renderDistance = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "renderDistance", 20, "Low FPS affection. Render distance for helmet camera.");
			config_cameraFps = ((BaseUnityPlugin)this).Config.Bind<int>("MONITOR QUALITY", "cameraFps", 30, "Very high FPS affection. FPS for helmet camera. To increase YOUR fps, you should low cameraFps value.");
			_harmony = new Harmony("HelmetCamera");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Helmet_Cameras is loaded with version 2.1.5!");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"--------Helmet camera patch done.---------");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RickArg.lethalcompany.helmetcameras";

		public const string PLUGIN_NAME = "Helmet_Cameras";

		public const string PLUGIN_VERSION = "2.1.5";
	}
	public class Plugin : MonoBehaviour
	{
		private RenderTexture renderTexture;

		private bool isMonitorChanged = false;

		private GameObject helmetCameraNew;

		private bool isSceneLoaded = false;

		private bool isCoroutineStarted = false;

		private int currentTransformIndex;

		private int resolution = 0;

		private int renderDistance = 50;

		private float cameraFps = 30f;

		private float elapsed;

		private void Awake()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			resolution = PluginInit.config_isHighQuality.Value;
			renderDistance = PluginInit.config_renderDistance.Value;
			cameraFps = PluginInit.config_cameraFps.Value;
			switch (resolution)
			{
			case 0:
				renderTexture = new RenderTexture(48, 48, 24);
				break;
			case 1:
				renderTexture = new RenderTexture(128, 128, 24);
				break;
			case 2:
				renderTexture = new RenderTexture(256, 256, 24);
				break;
			case 3:
				renderTexture = new RenderTexture(512, 512, 24);
				break;
			case 4:
				renderTexture = new RenderTexture(1024, 1024, 24);
				break;
			}
		}

		public void Start()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			isCoroutineStarted = false;
			while ((Object)(object)helmetCameraNew == (Object)null)
			{
				helmetCameraNew = new GameObject("HelmetCamera");
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "MainMenu")
			{
				activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "InitScene")
				{
					activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).name != "InitSceneLaunchOptions")
					{
						isSceneLoaded = true;
						Debug.Log((object)"[HELMET_CAMERAS] Starting coroutine...");
						((MonoBehaviour)this).StartCoroutine(LoadSceneEnter());
						return;
					}
				}
			}
			isSceneLoaded = false;
			isMonitorChanged = false;
		}

		private IEnumerator LoadSceneEnter()
		{
			Debug.Log((object)"[HELMET_CAMERAS] 5 seconds for init mode... Please wait...");
			yield return (object)new WaitForSeconds(5f);
			isCoroutineStarted = true;
			if ((Object)(object)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera") != (Object)null)
			{
				Debug.Log((object)"[HELMET_CAMERAS] Ship camera founded...");
				if (!isMonitorChanged)
				{
					((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube").GetComponent<MeshRenderer>()).materials[2].mainTexture = ((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture;
					((Renderer)GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001").GetComponent<MeshRenderer>()).materials[2].mainTexture = (Texture)(object)renderTexture;
					helmetCameraNew.AddComponent<Camera>();
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false;
					helmetCameraNew.GetComponent<Camera>().targetTexture = renderTexture;
					helmetCameraNew.GetComponent<Camera>().cullingMask = 20649983;
					helmetCameraNew.GetComponent<Camera>().farClipPlane = renderDistance;
					helmetCameraNew.GetComponent<Camera>().nearClipPlane = 0.55f;
					isMonitorChanged = true;
					Debug.Log((object)"[HELMET_CAMERAS] Monitors were changed...");
					Debug.Log((object)"[HELMET_CAMERAS] Turning off vanilla internal ship camera");
					((Behaviour)GameObject.Find("Environment/HangarShip/Cameras/ShipCamera").GetComponent<Camera>()).enabled = false;
				}
			}
		}

		public void Update()
		{
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			bool flag = isSceneLoaded && isCoroutineStarted;
			if (flag && StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
			{
				helmetCameraNew.SetActive(true);
				elapsed += Time.deltaTime;
				if (elapsed > 1f / cameraFps)
				{
					elapsed = 0f;
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = true;
				}
				else
				{
					((Behaviour)helmetCameraNew.GetComponent<Camera>()).enabled = false;
				}
				GameObject val = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorScript");
				currentTransformIndex = val.GetComponent<ManualCameraRenderer>().targetTransformIndex;
				TransformAndName val2 = val.GetComponent<ManualCameraRenderer>().radarTargets[currentTransformIndex];
				if (!val2.isNonPlayer)
				{
					try
					{
						helmetCameraNew.transform.SetPositionAndRotation(val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").position + new Vector3(0f, 0f, 0f), val2.transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/HelmetLights").rotation * Quaternion.Euler(0f, 0f, 0f));
						DeadBodyInfo[] array = Object.FindObjectsOfType<DeadBodyInfo>();
						for (int i = 0; i < array.Length; i++)
						{
							if (array[i].playerScript.playerUsername == val2.name)
							{
								helmetCameraNew.transform.SetPositionAndRotation(((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").position, ((Component)array[i]).gameObject.transform.Find("spine.001/spine.002/spine.003").rotation * Quaternion.Euler(0f, 0f, 0f));
							}
						}
						return;
					}
					catch (NullReferenceException)
					{
						Debug.Log((object)"[HELMET_CAMERAS] ERROR NULL REFERENCE");
						return;
					}
				}
				helmetCameraNew.transform.SetPositionAndRotation(val2.transform.position + new Vector3(0f, 1.6f, 0f), val2.transform.rotation * Quaternion.Euler(0f, -90f, 0f));
			}
			else if (flag && !StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
			{
				helmetCameraNew.SetActive(false);
			}
		}
	}
}
namespace HelmetCamera.Patches
{
	[HarmonyPatch]
	internal class HelmetCamera
	{
		public static void InitCameras()
		{
			GameObject val = GameObject.Find("Environment/HangarShip/Cameras/ShipCamera");
			val.AddComponent<Plugin>();
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		public static void InitCamera(ref ManualCameraRenderer __instance)
		{
			InitCameras();
		}
	}
}

BepInEx/plugins/LethalPaintings.dll

Decompiled 5 hours ago
using System;
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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")]
[assembly: AssemblyCompany("LethalPaintings")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalPaintings")]
[assembly: AssemblyTitle("LethalPaintings")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPaintings
{
	internal class Patches
	{
		private static ManualLogSource Logger { get; set; }

		public static void Init(ManualLogSource logger)
		{
			Logger = logger;
		}

		[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
		[HarmonyPostfix]
		private static void SetScrapValuePatch(GrabbableObject __instance)
		{
			if (__instance.itemProperties.itemName == "Painting")
			{
				UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[0]);
				UpdateTexture(Plugin.PaintingFiles, __instance.itemProperties.materialVariants[1]);
			}
		}

		private static void UpdateTexture(IReadOnlyList<string> files, Material material)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (files.Count != 0)
			{
				int index = Plugin.Rand.Next(files.Count);
				Texture2D val = new Texture2D(2, 2);
				Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index]));
				ImageConversion.LoadImage(val, File.ReadAllBytes(files[index]));
				material.mainTexture = (Texture)(object)val;
			}
		}
	}
	[BepInPlugin("LethalPaintings", "LethalPaintings", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static List<string> PosterFolders = new List<string>();

		public static readonly List<string> PaintingFiles = new List<string>();

		public static Random Rand = new Random();

		private void Awake()
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPaintings", SearchOption.AllDirectories).ToList();
			foreach (string posterFolder in PosterFolders)
			{
				string[] files = Directory.GetFiles(Path.Combine(posterFolder, "paintings"));
				foreach (string text in files)
				{
					if (Path.GetExtension(text) != ".old")
					{
						PaintingFiles.Add(text);
					}
				}
			}
			Patches.Init(((BaseUnityPlugin)this).Logger);
			new Harmony("LethalPaintings").PatchAll(typeof(Patches));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPaintings is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPaintings";

		public const string PLUGIN_NAME = "LethalPaintings";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

BepInEx/plugins/LethalPosters.dll

Decompiled 5 hours ago
using System;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName = ".NET Framework 4.7")]
[assembly: AssemblyCompany("LethalPosters")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyDescription("LethalCopmany posters API")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalPosters")]
[assembly: AssemblyTitle("LethalPosters")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LethalPosters
{
	internal class Config
	{
		private static ConfigFile ConfigFile { get; set; }

		static Config()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			ConfigFile = new ConfigFile(Paths.ConfigPath + "\\LethalPosters.cfg", true);
			foreach (string posterFolder in Plugin.PosterFolders)
			{
				int num = posterFolder.IndexOf("plugins\\", StringComparison.Ordinal) + "plugins\\".Length;
				int num2 = posterFolder.IndexOf("\\LethalPosters", num, StringComparison.Ordinal);
				string text = posterFolder.Substring(num, num2 - num);
				if (!ConfigFile.Bind<bool>(text, "Enabled", true, "Enable or disable " + text).Value)
				{
					Directory.Move(posterFolder, posterFolder + ".Disabled");
				}
			}
		}
	}
	internal class Patches
	{
		private static ManualLogSource Logger { get; set; }

		public static void Init(ManualLogSource logger)
		{
			Logger = logger;
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			Logger.LogInfo((object)"Patching Start in StartOfRound");
			UpdateMaterials(0);
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void GenerateNewLevelClientRpcPatch(int randomSeed)
		{
			Logger.LogInfo((object)"Patching GenerateNewLevelClientRpc in RoundManager");
			UpdateMaterials(randomSeed);
		}

		private static void UpdateMaterials(int seed)
		{
			Logger.LogInfo((object)"Patching the textures");
			Plugin.Rand = new Random(seed);
			Material[] materials = ((Renderer)GameObject.Find("HangarShip/Plane.001").GetComponent<MeshRenderer>()).materials;
			UpdateTexture(Plugin.PosterFiles, materials[0]);
			UpdateTexture(Plugin.TipFiles, materials[1]);
		}

		private static void UpdateTexture(IReadOnlyList<string> files, Material material)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (files.Count != 0)
			{
				int index = Plugin.Rand.Next(files.Count);
				Texture2D val = new Texture2D(2, 2);
				Logger.LogInfo((object)("Patching " + ((Object)material).name + " with " + files[index]));
				ImageConversion.LoadImage(val, File.ReadAllBytes(files[index]));
				material.mainTexture = (Texture)(object)val;
			}
		}
	}
	[BepInPlugin("LethalPosters", "LethalPosters", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static List<string> PosterFolders = new List<string>();

		public static readonly List<string> PosterFiles = new List<string>();

		public static readonly List<string> TipFiles = new List<string>();

		public static Random Rand = new Random();

		private void Awake()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			PosterFolders = Directory.GetDirectories(Paths.PluginPath, "LethalPosters", SearchOption.AllDirectories).ToList();
			foreach (string posterFolder in PosterFolders)
			{
				string[] files = Directory.GetFiles(Path.Combine(posterFolder, "posters"));
				foreach (string text in files)
				{
					if (Path.GetExtension(text) != ".old")
					{
						PosterFiles.Add(text);
					}
				}
				files = Directory.GetFiles(Path.Combine(posterFolder, "tips"));
				foreach (string text2 in files)
				{
					if (Path.GetExtension(text2) != ".old")
					{
						TipFiles.Add(text2);
					}
				}
			}
			Patches.Init(((BaseUnityPlugin)this).Logger);
			new Harmony("LethalPosters").PatchAll(typeof(Patches));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin LethalPosters (1.0.0) is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LethalPosters";

		public const string PLUGIN_NAME = "LethalPosters";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}

BepInEx/plugins/LethalRegeneration.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalRegeneration.config;
using LethalRegeneration.patches;
using LethalRegeneration.utils;
using Microsoft.CodeAnalysis;
using Unity.Collections;
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(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("LethalRegeneration")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Natural health regeneration mod with customizable parameters that syncs with host")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+4c3a2fec85925ed84ea5f29c722c886eeed1977f")]
[assembly: AssemblyProduct("LethalRegeneration")]
[assembly: AssemblyTitle("LethalRegeneration")]
[assembly: AssemblyVersion("1.2.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 LethalRegeneration
{
	[BepInPlugin("Toskan4134.LethalRegeneration", "LethalRegeneration", "1.3.0")]
	public class LethalRegenerationBase : BaseUnityPlugin
	{
		private const string modGUID = "Toskan4134.LethalRegeneration";

		private const string modName = "LethalRegeneration";

		private const string modVersion = "1.3.0";

		private readonly Harmony patcher = new Harmony("Toskan4134.LethalRegeneration");

		public static LethalRegenerationBase Instance;

		public static Configuration Config { get; internal set; }

		public static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("LethalRegeneration");
			Config = new Configuration(((BaseUnityPlugin)this).Config);
			try
			{
				patcher.PatchAll(typeof(HUDManagerPatch));
				patcher.PatchAll(typeof(Configuration));
				patcher.PatchAll(typeof(TerminalPatch));
				patcher.PatchAll(typeof(GameNetworkManagerPatch));
				patcher.PatchAll(typeof(StartOfRoundPatch));
				patcher.PatchAll(typeof(StartMatchLeverPatch));
				Logger.LogInfo((object)"Loaded Succesfully\r\n      ___________________\r\n     /                   |\r\n    |_______      _______|\r\n     ___    |    |\r\n    |   |___|    |______\r\n    |                   \\\r\n     \\______      ___    |\r\n     ___    |    |   |   |\r\n    |   |__ |    | __|   |\r\n    |      ||    ||      |\r\n     \\_____||____||_____/\r\n   LethalRegeneration 1.3.0\r\n        By Toskan4134\r\n");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)ex);
			}
		}
	}
}
namespace LethalRegeneration.utils
{
	public class TerminalUtils
	{
		public static TerminalKeyword CreateTerminalKeyword(string word, bool isVerb = false, CompatibleNoun[] compatibleNouns = null, TerminalNode specialKeywordResult = null, TerminalKeyword defaultVerb = null, bool accessTerminalObjects = false)
		{
			TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)val).name = word;
			val.word = word;
			val.isVerb = isVerb;
			val.compatibleNouns = compatibleNouns;
			val.specialKeywordResult = specialKeywordResult;
			val.defaultVerb = defaultVerb;
			val.accessTerminalObjects = accessTerminalObjects;
			return val;
		}

		public static TerminalKeyword GetTerminalKeyword(Terminal __instance, string word)
		{
			return __instance.terminalNodes.allKeywords.First((TerminalKeyword keyword) => keyword.word == word);
		}
	}
}
namespace LethalRegeneration.patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManagerPatch
	{
		[HarmonyPatch("SaveGameValues")]
		[HarmonyPostfix]
		public static void SaveGameValuesPatch(GameNetworkManager __instance)
		{
			if (!__instance.isHostingGame)
			{
				return;
			}
			try
			{
				ES3.Save<bool>("LethalRegeneration_healingUpgradeUnlocked", ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked, __instance.currentSaveFileName);
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error while trying to save game values when disconnecting as host: {arg}");
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		private static PlayerControllerB playerControllerB;

		private static int currentTicksPerRegeneration = 0;

		private static int currentTicksPerRegenerationOutsideShip = 0;

		public static int currentRegenerationLimitPerPlayer = regenerationLimitPerPlayer;

		private static int ticksPerRegeneration => ConfigurationSync<Configuration>.Instance.TicksPerRegeneration;

		private static int regenerationPower => ConfigurationSync<Configuration>.Instance.RegenerationPower;

		private static bool regenerationOutsideShip => ConfigurationSync<Configuration>.Instance.RegenerationOutsideShip;

		private static int ticksPerRegenerationOutsideShip => ConfigurationSync<Configuration>.Instance.TicksPerRegenerationOutsideShip;

		private static int regenerationPowerOutsideShip => ConfigurationSync<Configuration>.Instance.RegenerationPowerOutsideShip;

		private static bool healingUpgradeUnlocked => ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked;

		private static bool healingUpgradeEnabled => ConfigurationSync<Configuration>.Instance.HealingUpgradeEnabled;

		private static int maxHealth => StartMatchLeverPatch.maxHealth;

		public static int regenerationLimitPerPlayer => ConfigurationSync<Configuration>.Instance.RegenerationLimitPerPlayer;

		[HarmonyPatch("SetClock")]
		[HarmonyPostfix]
		public static void healingPostfix()
		{
			playerControllerB = GameNetworkManager.Instance.localPlayerController;
			if ((healingUpgradeEnabled && !healingUpgradeUnlocked) || (regenerationLimitPerPlayer != -1 && currentRegenerationLimitPerPlayer <= 0) || !((NetworkBehaviour)playerControllerB).IsOwner || playerControllerB.isPlayerDead || !playerControllerB.AllowPlayerDeath() || playerControllerB.health >= maxHealth)
			{
				return;
			}
			if (playerControllerB.isInHangarShipRoom)
			{
				if (currentTicksPerRegeneration == 0)
				{
					currentTicksPerRegeneration = ticksPerRegeneration;
					LethalRegenerationBase.Logger.LogInfo((object)("Healed " + regenerationPower));
					int num = playerControllerB.health + regenerationPower;
					currentRegenerationLimitPerPlayer -= regenerationPower;
					playerControllerB.health = ((num > maxHealth) ? maxHealth : num);
					HUDManager.Instance.UpdateHealthUI(playerControllerB.health, false);
					playerControllerB.DamagePlayerClientRpc(-regenerationPower, playerControllerB.health);
					if (playerControllerB.health >= 10 && playerControllerB.criticallyInjured)
					{
						playerControllerB.MakeCriticallyInjured(false);
					}
				}
				currentTicksPerRegeneration--;
			}
			else
			{
				if (!regenerationOutsideShip || playerControllerB.isInHangarShipRoom)
				{
					return;
				}
				if (currentTicksPerRegenerationOutsideShip == 0)
				{
					currentTicksPerRegenerationOutsideShip = ticksPerRegenerationOutsideShip;
					LethalRegenerationBase.Logger.LogInfo((object)("Healed " + regenerationPowerOutsideShip));
					int num2 = playerControllerB.health + regenerationPowerOutsideShip;
					currentRegenerationLimitPerPlayer -= regenerationPowerOutsideShip;
					playerControllerB.health = ((num2 > maxHealth) ? maxHealth : num2);
					HUDManager.Instance.UpdateHealthUI(playerControllerB.health, false);
					playerControllerB.DamagePlayerClientRpc(-regenerationPowerOutsideShip, playerControllerB.health);
					if (playerControllerB.health >= 10 && playerControllerB.criticallyInjured)
					{
						playerControllerB.MakeCriticallyInjured(false);
					}
				}
				currentTicksPerRegenerationOutsideShip--;
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	public class StartMatchLeverPatch
	{
		public static int maxHealth = 100;

		[HarmonyPatch("PlayLeverPullEffectsClientRpc")]
		[HarmonyPostfix]
		public static void StartGameHpPostfix(ref StartOfRound ___playersManager, ref bool ___leverHasBeenPulled)
		{
			if (___leverHasBeenPulled)
			{
				maxHealth = ___playersManager.localPlayerController.health;
				HUDManagerPatch.currentRegenerationLimitPerPlayer = HUDManagerPatch.regenerationLimitPerPlayer;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		public static void ResetShip()
		{
			ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = false;
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalPatch
	{
		private static Item item;

		private static TerminalNode buyNode1;

		private static TerminalNode buyNode2;

		private static TerminalNode CannotAfford;

		private static TerminalNode AlreadyUnlocked;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void StartTerminalPatch(Terminal __instance)
		{
			//IL_001f: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Expected O, but got Unknown
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Expected O, but got Unknown
			if (ConfigurationSync<Configuration>.Instance.HealingUpgradeEnabled)
			{
				item = new Item
				{
					itemName = "Natural Regeneration",
					creditsWorth = ConfigurationSync<Configuration>.Instance.HealingUpgradePrice,
					saveItemVariable = true
				};
				TerminalKeyword terminalKeyword = TerminalUtils.GetTerminalKeyword(__instance, "buy");
				TerminalNode result = terminalKeyword.compatibleNouns[0].result.terminalOptions[1].result;
				CannotAfford = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)CannotAfford).name = "LethalRegeneration_CannotAfford";
				CannotAfford.displayText = $"You could not afford these items!\nYour balance is [playerCredits]. Total cost of these items is ${item.creditsWorth}\r\n\r\n";
				CannotAfford.clearPreviousText = false;
				CannotAfford.maxCharactersToType = 25;
				CannotAfford.playSyncedClip = 1;
				AlreadyUnlocked = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)AlreadyUnlocked).name = "LethalRegeneration_AlreadyUnlocked";
				AlreadyUnlocked.displayText = "This has already been unlocked for your ship!\r\n\r\n";
				AlreadyUnlocked.clearPreviousText = true;
				AlreadyUnlocked.maxCharactersToType = 25;
				AlreadyUnlocked.playSyncedClip = 1;
				TerminalKeyword terminalKeyword2 = TerminalUtils.GetTerminalKeyword(__instance, "info");
				string itemName = item.itemName;
				TerminalKeyword keyword3 = TerminalUtils.CreateTerminalKeyword(itemName.ToLowerInvariant().Replace(" ", "-"), isVerb: false, null, null, terminalKeyword);
				if (__instance.terminalNodes.allKeywords.Any((TerminalKeyword kw) => kw.word == keyword3.word))
				{
					LethalRegenerationBase.Logger.LogInfo((object)("Keyword " + keyword3.word + " already registed, skipping."));
				}
				int shipUnlockableID = StartOfRound.Instance.unlockablesList.unlockables.FindIndex((UnlockableItem unlockable) => unlockable.unlockableName == item.itemName);
				buyNode2 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)buyNode2).name = "LethalRegeneration_" + itemName.Replace(" ", "-") + "BuyNode2";
				buyNode2.displayText = "Ordered the " + itemName + ". Your new balance is [playerCredits].\n\nFrom now on you will regenerate health as time goes by.\r\n\r\n";
				buyNode2.clearPreviousText = true;
				buyNode2.maxCharactersToType = 15;
				buyNode2.buyItemIndex = -1;
				buyNode2.shipUnlockableID = shipUnlockableID;
				buyNode2.buyUnlockable = true;
				buyNode2.creatureName = itemName;
				buyNode2.isConfirmationNode = false;
				buyNode2.itemCost = item.creditsWorth;
				buyNode2.playSyncedClip = 0;
				buyNode1 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)buyNode1).name = "LethalRegeneration_" + itemName.Replace(" ", "-") + "BuyNode1";
				buyNode1.displayText = "You have requested to order the " + itemName + " upgrade.\nTotal cost of items: " + item.creditsWorth + ".\n\nPlease CONFIRM or DENY.\r\n\r\n";
				buyNode1.clearPreviousText = true;
				buyNode1.maxCharactersToType = 35;
				buyNode1.buyItemIndex = -1;
				buyNode1.shipUnlockableID = shipUnlockableID;
				buyNode1.creatureName = itemName;
				buyNode1.isConfirmationNode = true;
				buyNode1.overrideOptions = true;
				buyNode1.itemCost = item.creditsWorth;
				buyNode1.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2]
				{
					new CompatibleNoun
					{
						noun = __instance.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "confirm"),
						result = buyNode2
					},
					new CompatibleNoun
					{
						noun = __instance.terminalNodes.allKeywords.First((TerminalKeyword keyword2) => keyword2.word == "deny"),
						result = result
					}
				};
				List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
				list.Add(keyword3);
				__instance.terminalNodes.allKeywords = list.ToArray();
				List<CompatibleNoun> list2 = terminalKeyword.compatibleNouns.ToList();
				list2.Add(new CompatibleNoun
				{
					noun = keyword3,
					result = buyNode1
				});
				terminalKeyword.compatibleNouns = list2.ToArray();
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val).name = "LethalRegeneration_" + itemName.Replace(" ", "-") + "InfoNode";
				if (ConfigurationSync<Configuration>.Instance.RegenerationOutsideShip)
				{
					val.displayText = $"Your health regenerates inside and outside the ship\n\nINSIDE THE SHIP\nThe healing is activated each {ConfigurationSync<Configuration>.Instance.TicksPerRegeneration} ticks\nThe healing power is {ConfigurationSync<Configuration>.Instance.RegenerationPower}hp per tick\n\nOUTSIDE THE SHIP\nThe healing is activated each {ConfigurationSync<Configuration>.Instance.TicksPerRegenerationOutsideShip} ticks\nThe healing power is {ConfigurationSync<Configuration>.Instance.RegenerationPowerOutsideShip}hp per tick\nThe regeneration limit per player is {ConfigurationSync<Configuration>.Instance.RegenerationLimitPerPlayer}hp per round\n\n";
				}
				else
				{
					val.displayText = $"Your health regenerates only inside the ship\n\nThe healing is activated each {ConfigurationSync<Configuration>.Instance.TicksPerRegeneration} ticks\nThe healing power is {ConfigurationSync<Configuration>.Instance.RegenerationPower}hp per tick\nThe regeneration limit per player is {ConfigurationSync<Configuration>.Instance.RegenerationLimitPerPlayer}hp per round\n\n";
				}
				val.clearPreviousText = true;
				val.maxCharactersToType = 25;
				__instance.terminalNodes.allKeywords = list.ToArray();
				List<CompatibleNoun> list3 = terminalKeyword2.compatibleNouns.ToList();
				list3.Add(new CompatibleNoun
				{
					noun = keyword3,
					result = val
				});
				terminalKeyword2.compatibleNouns = list3.ToArray();
				LethalRegenerationBase.Logger.LogInfo((object)("Registered " + itemName));
			}
		}

		[HarmonyPatch("TextPostProcess")]
		[HarmonyPrefix]
		public static void TextPostProcessPatch_Prefix(ref string modifiedDisplayText, TerminalNode node, ref string __result)
		{
			if (ConfigurationSync<Configuration>.Instance.HealingUpgradeEnabled && modifiedDisplayText.Contains("[buyableItemsList]") && modifiedDisplayText.Contains("[unlockablesSelectionList]"))
			{
				int num = modifiedDisplayText.IndexOf(":");
				string itemName = item.itemName;
				int creditsWorth = item.creditsWorth;
				string value = $"\n* {itemName}    //    Price: ${creditsWorth}";
				modifiedDisplayText = modifiedDisplayText.Insert(num + 1, value);
			}
		}

		[HarmonyPatch("LoadNewNode")]
		[HarmonyPrefix]
		public static void LoadNewNodePatch_Prefix(ref TerminalNode node, Terminal __instance)
		{
			if (!((Object)node).name.StartsWith("LethalRegeneration"))
			{
				return;
			}
			string text = ((Object)node).name.Split(new char[1] { '_' })[1];
			string text2 = text;
			string text3 = text2;
			if (!(text3 == "Natural-RegenerationBuyNode2"))
			{
				if (text3 == "Natural-RegenerationBuyNode1" && __instance.groupCredits < item.creditsWorth)
				{
					node = CannotAfford;
				}
				return;
			}
			if (ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked)
			{
				node = AlreadyUnlocked;
				return;
			}
			int num = __instance.groupCredits - item.creditsWorth;
			__instance.SyncGroupCreditsServerRpc(num, __instance.numberOfItemsInDropship);
			ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = true;
			ConfigurationSync<Configuration>.Synced = false;
			if (ConfigurationSync<Configuration>.IsHost)
			{
				ConfigurationSync<Configuration>.Instance.BroadcastHealingUpgradeStatusToClients();
			}
			else
			{
				ConfigurationSync<Configuration>.Instance.SendHealingUpgradeStatusToHost();
			}
		}
	}
}
namespace LethalRegeneration.config
{
	[Serializable]
	public class Configuration : ConfigurationSync<Configuration>
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnReceiveBroadcastedHealingUpgradeStatus;

			public static HandleNamedMessageDelegate <1>__OnRequestSync;

			public static HandleNamedMessageDelegate <2>__OnReceiveHealingUpgradeStatus;

			public static HandleNamedMessageDelegate <3>__OnReceiveSync;
		}

		public const int DefaultTicksPerRegeneration = 2;

		public const int DefaultRegenerationPower = 5;

		public const bool DefaultregenerationOutsideShip = false;

		public const bool DefaultHealingUpgradeEnabled = false;

		public const int DefaultHealingUpgradePrice = 800;

		[NonSerialized]
		private readonly ConfigFile configFile;

		public bool HealingUpgradeUnlocked { get; set; }

		public int TicksPerRegeneration { get; private set; }

		public int RegenerationPower { get; private set; }

		public bool RegenerationOutsideShip { get; private set; }

		public int TicksPerRegenerationOutsideShip { get; private set; }

		public int RegenerationPowerOutsideShip { get; private set; }

		public bool HealingUpgradeEnabled { get; private set; }

		public int HealingUpgradePrice { get; private set; }

		public int RegenerationLimitPerPlayer { get; private set; }

		public Configuration(ConfigFile cfg)
		{
			ConfigurationSync<Configuration>.Instance = this;
			configFile = cfg;
			InitConfigEntries();
			LethalRegenerationBase.Logger.LogInfo((object)"Configuration Set");
		}

		private void InitConfigEntries()
		{
			RegenerationPower = NewEntry("Values", "Regeneration Power", 5, "Amount of health regenerated INSIDE the ship each time triggered (Between 1 an 100)");
			TicksPerRegeneration = NewEntry("Values", "Ticks Per Regeneration", 2, "Number of ticks until the regeneration is triggered INSIDE the ship (1 tick equals each time the minutes of the clock are changed)");
			RegenerationOutsideShip = NewEntry("Values", "Enable Regeneration Outside Ship", defaultVal: false, "Whether health is regenerated also outside the ship or only inside.");
			RegenerationPowerOutsideShip = NewEntry("Values", "Regeneration Power Outside Ship", 5, "Amount of health regenerated OUTSIDE the ship each time triggered, requires Regeneration Outside The Ship enabled (Between 1 an 100)");
			TicksPerRegenerationOutsideShip = NewEntry("Values", "Ticks Per Regeneration Outside Ship", 2, "Number of ticks until the regeneration is triggered OUTSIDE the ship, requires Regeneration Outside The Ship enabled (1 tick equals each time the minutes of the clock are changed)");
			HealingUpgradeEnabled = NewEntry("Values", "Regeneration As Upgrade", defaultVal: false, "Makes natural health regeneration an upgrade for the ship and has to be purchased to make it work.");
			HealingUpgradePrice = NewEntry("Values", "Upgrade Price", 800, "Changes the price of ship upgrade for health regeneration. Only works if ship upgrade is enabled");
			RegenerationLimitPerPlayer = NewEntry("Values", "Regeneration Limit Per Player", -1, "Regeneration limit in a round (If the value is '-1' this option will be unlimited)");
			RegenerationPower = ((100 >= RegenerationPower && RegenerationPower > 0) ? RegenerationPower : 5);
			TicksPerRegeneration = ((TicksPerRegeneration > 0) ? TicksPerRegeneration : 2);
			RegenerationPowerOutsideShip = ((100 >= RegenerationPowerOutsideShip && RegenerationPowerOutsideShip > 0) ? RegenerationPowerOutsideShip : 5);
			TicksPerRegenerationOutsideShip = ((TicksPerRegenerationOutsideShip > 0) ? TicksPerRegenerationOutsideShip : 2);
			HealingUpgradePrice = ((HealingUpgradePrice > 0) ? HealingUpgradePrice : 800);
		}

		private T NewEntry<T>(string category, string key, T defaultVal, string desc)
		{
			return configFile.Bind<T>(category, key, defaultVal, desc).Value;
		}

		public static void RequestSync()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigurationSync<Configuration>.IsClient)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
			try
			{
				ConfigurationSync<Configuration>.MessageManager.SendNamedMessage("LethalRegeneration_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnRequestSync(ulong clientId, FastBufferReader _)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigurationSync<Configuration>.IsHost)
			{
				return;
			}
			LethalRegenerationBase.Logger.LogInfo((object)$"Config sync request received from client: {clientId}");
			byte[] array = ConfigurationSync<Configuration>.SerializeToBytes(ConfigurationSync<Configuration>.Instance);
			int num = array.Length;
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(array.Length + 4, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				ConfigurationSync<Configuration>.MessageManager.SendNamedMessage("LethalRegeneration_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
			catch (Exception arg)
			{
				LethalRegenerationBase.Logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}");
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveSync(ulong _, FastBufferReader reader)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				LethalRegenerationBase.Logger.LogError((object)"Config sync error: Could not begin reading buffer.");
				return;
			}
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			if (!((FastBufferReader)(ref reader)).TryBeginRead(num))
			{
				LethalRegenerationBase.Logger.LogError((object)"Config sync error: Host could not sync.");
				return;
			}
			byte[] data = new byte[num];
			((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
			ConfigurationSync<Configuration>.UpdateInstance(data);
			LethalRegenerationBase.Logger.LogInfo((object)"Successfully synced config with host.");
		}

		public void SendHealingUpgradeStatusToHost()
		{
			//IL_0028: 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)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigurationSync<Configuration>.IsClient)
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				try
				{
					int num = (HealingUpgradeUnlocked ? 1 : 0);
					((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
					ConfigurationSync<Configuration>.MessageManager.SendNamedMessage("LethalRegeneration_SendHealingUpgradeStatus", 0uL, val, (NetworkDelivery)3);
				}
				finally
				{
					((IDisposable)(FastBufferWriter)(ref val)).Dispose();
				}
			}
		}

		public static void OnReceiveHealingUpgradeStatus(ulong _, FastBufferReader reader)
		{
			//IL_001e: 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)
			if (ConfigurationSync<Configuration>.IsHost)
			{
				if (((FastBufferReader)(ref reader)).TryBeginRead(4))
				{
					int num = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
					ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = num == 1;
					LethalRegenerationBase.Logger.LogInfo((object)$"Received sent HealingUpgrade status: {ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked}");
					ConfigurationSync<Configuration>.Instance.BroadcastHealingUpgradeStatusToClients();
				}
				else
				{
					LethalRegenerationBase.Logger.LogError((object)"Error reading healingUpgradeUnlocked status.");
				}
			}
		}

		public void BroadcastHealingUpgradeStatusToClients()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigurationSync<Configuration>.IsHost)
			{
				return;
			}
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
			try
			{
				int num = (HealingUpgradeUnlocked ? 1 : 0);
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				foreach (ulong key in NetworkManager.Singleton.ConnectedClients.Keys)
				{
					ConfigurationSync<Configuration>.MessageManager.SendNamedMessage("LethalRegeneration_BroadcastHealingUpgradeStatus", key, val, (NetworkDelivery)3);
				}
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
		}

		public static void OnReceiveBroadcastedHealingUpgradeStatus(ulong _, FastBufferReader reader)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigurationSync<Configuration>.IsClient && !ConfigurationSync<Configuration>.IsHost)
			{
				if (((FastBufferReader)(ref reader)).TryBeginRead(4))
				{
					int num = default(int);
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
					ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = num == 1;
					LethalRegenerationBase.Logger.LogInfo((object)$"Received broadcasted healingUpgradeUnlocked status: {ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked}");
					ConfigurationSync<Configuration>.Synced = true;
				}
				else
				{
					LethalRegenerationBase.Logger.LogError((object)"Error reading broadcasted healingUpgradeUnlocked status.");
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		public static void InitializeLocalPlayer()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = false;
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			object obj = <>O.<0>__OnReceiveBroadcastedHealingUpgradeStatus;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = OnReceiveBroadcastedHealingUpgradeStatus;
				<>O.<0>__OnReceiveBroadcastedHealingUpgradeStatus = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler("LethalRegeneration_BroadcastHealingUpgradeStatus", (HandleNamedMessageDelegate)obj);
			if (ConfigurationSync<Configuration>.IsHost)
			{
				CustomMessagingManager messageManager = ConfigurationSync<Configuration>.MessageManager;
				object obj2 = <>O.<1>__OnRequestSync;
				if (obj2 == null)
				{
					HandleNamedMessageDelegate val2 = OnRequestSync;
					<>O.<1>__OnRequestSync = val2;
					obj2 = (object)val2;
				}
				messageManager.RegisterNamedMessageHandler("LethalRegeneration_OnRequestConfigSync", (HandleNamedMessageDelegate)obj2);
				CustomMessagingManager messageManager2 = ConfigurationSync<Configuration>.MessageManager;
				object obj3 = <>O.<2>__OnReceiveHealingUpgradeStatus;
				if (obj3 == null)
				{
					HandleNamedMessageDelegate val3 = OnReceiveHealingUpgradeStatus;
					<>O.<2>__OnReceiveHealingUpgradeStatus = val3;
					obj3 = (object)val3;
				}
				messageManager2.RegisterNamedMessageHandler("LethalRegeneration_SendHealingUpgradeStatus", (HandleNamedMessageDelegate)obj3);
				ConfigurationSync<Configuration>.Synced = true;
				ConfigurationSync<Configuration>.Instance.HealingUpgradeUnlocked = ES3.Load<bool>("LethalRegeneration_healingUpgradeUnlocked", GameNetworkManager.Instance.currentSaveFileName, false);
			}
			else
			{
				CustomMessagingManager messageManager3 = ConfigurationSync<Configuration>.MessageManager;
				object obj4 = <>O.<3>__OnReceiveSync;
				if (obj4 == null)
				{
					HandleNamedMessageDelegate val4 = OnReceiveSync;
					<>O.<3>__OnReceiveSync = val4;
					obj4 = (object)val4;
				}
				messageManager3.RegisterNamedMessageHandler("LethalRegeneration_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj4);
				ConfigurationSync<Configuration>.Synced = false;
				RequestSync();
			}
		}
	}
	[Serializable]
	public class ConfigurationSync<T>
	{
		public static T Instance { get; internal set; }

		public static bool Synced { get; internal set; }

		internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager;

		internal static bool IsClient => NetworkManager.Singleton.IsClient;

		internal static bool IsHost => NetworkManager.Singleton.IsHost;

		internal static byte[] SerializeToBytes(T val)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream memoryStream = new MemoryStream();
			try
			{
				binaryFormatter.Serialize(memoryStream, val);
				return memoryStream.ToArray();
			}
			catch (Exception arg)
			{
				LethalRegenerationBase.Logger.LogError((object)$"Error serializing instance: {arg}");
				return null;
			}
		}

		internal static T DeserializeFromBytes(byte[] data)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			using MemoryStream serializationStream = new MemoryStream(data);
			try
			{
				return (T)binaryFormatter.Deserialize(serializationStream);
			}
			catch (Exception arg)
			{
				LethalRegenerationBase.Logger.LogError((object)$"Error deserializing instance: {arg}");
				return default(T);
			}
		}

		internal static void UpdateInstance(byte[] data)
		{
			Instance = DeserializeFromBytes(data);
			Synced = true;
		}
	}
}

BepInEx/plugins/LetMeLookDown.dll

Decompiled 5 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LetMeLookDown")]
[assembly: AssemblyDescription("Mod made by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LetMeLookDown")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9c88d54-8f01-44a7-be0d-bd61d38aadcb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LetMeLookDown
{
	[BepInPlugin("FlipMods.LetMeLookDown", "LetMeLookDown", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private static Plugin instance;

		public static float maxAngle = 80f;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			_harmony = new Harmony("LetMeLookDown");
			_harmony.PatchAll();
			instance = this;
			Log("LetMeLookDown mod loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.LetMeLookDown";

		public const string PLUGIN_NAME = "LetMeLookDown";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace LetMeLookDown.Patches
{
	[HarmonyPatch]
	internal class AdjustSmoothLookingPatcher
	{
		[HarmonyPatch(typeof(PlayerControllerB), "CalculateSmoothLookingInput")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f)
				{
					list[i].operand = Plugin.maxAngle;
					break;
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	internal class AdjustNormalLookingPatcher
	{
		[HarmonyPatch(typeof(PlayerControllerB), "CalculateNormalLookingInput")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 60f)
				{
					list[i].operand = Plugin.maxAngle;
					break;
				}
			}
			return list.AsEnumerable();
		}
	}
}

BepInEx/plugins/MooMoo/MooMooScrap.dll

Decompiled 5 hours ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using LethalLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MooMooScrap")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MooMooScrap")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8634ae26-9ef9-48af-bf47-551889156106")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("shamburg.MooMooScrap", "MooMoo_Scrap", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private const string GUID = "shamburg.MooMooScrap";

	private const string NAME = "MooMoo_Scrap";

	private const string VERSION = "1.0.0";

	public static Plugin instance;

	private void Awake()
	{
		instance = this;
		Item obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "moomoobundle")).LoadAsset<Item>("Assets/MooMoo/MooMooItem.asset");
		NetworkPrefabs.RegisterNetworkPrefab(obj.spawnPrefab);
		Utilities.FixMixerGroups(obj.spawnPrefab);
		Items.RegisterScrap(obj, 40, (LevelTypes)(-1));
		TerminalNode obj2 = ScriptableObject.CreateInstance<TerminalNode>();
		obj2.clearPreviousText = true;
		obj2.displayText = "moo";
	}
}

BepInEx/plugins/MoreItems.dll

Decompiled 5 hours ago
using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreItems.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("MoreItems")]
[assembly: AssemblyTitle("MoreItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreItems
{
	[BepInPlugin("MoreItems", "MoreItems", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("MoreItems");

		private void Awake()
		{
			try
			{
				harmony.PatchAll(typeof(GameNetworkManagerPatch));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreItems is loaded!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin MoreItems failed to load and threw an exception:\n" + ex.Message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoreItems";

		public const string PLUGIN_NAME = "MoreItems";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreItems.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		private const int newMaxItemCapacity = 999;

		[HarmonyPatch("SaveItemsInShip")]
		[HarmonyPrefix]
		private static void IncreaseShipItemCapacity()
		{
			StartOfRound.Instance.maxShipItemCapacity = 999;
			Logger.CreateLogSource("MoreItems").LogInfo((object)$"Maximum amount of items that can be saved set to {999} just before saving.");
		}
	}
}

BepInEx/plugins/NeedyCats.dll

Decompiled 5 hours 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using Unity.Netcode.Samples;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NeedyCats")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NeedyCats")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c7d3e258-85ed-4246-9766-b0915f7aec88")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace NeedyCats
{
	public class CatFoodProp : GrabbableObject
	{
		public Animator animator;

		public AudioSource noiseAudio;

		public AudioClip removeLidAudio;

		public GameObject catfoodMeshFull;

		public GameObject catfoodMeshHalf;

		public float FeedLength = 528f;

		private float feedingTimer;

		private bool isOpen;

		[HideInInspector]
		public bool IsFeeding;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			animator = ((Component)this).GetComponent<Animator>();
			NeedyCatsBase.Instance.AllCatFoods.Add(this);
			AudioMixer diageticMixer = SoundManager.Instance.diageticMixer;
			noiseAudio.outputAudioMixerGroup = diageticMixer.FindMatchingGroups("SFX")[0];
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += NetworkManager_OnClientConnectedCallback;
		}

		public override void OnDestroy()
		{
			NeedyCatsBase.Instance.AllCatFoods.Remove(this);
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback -= NetworkManager_OnClientConnectedCallback;
			((NetworkBehaviour)this).OnDestroy();
		}

		public override void LoadItemSaveData(int saveData)
		{
			((MonoBehaviour)this).StartCoroutine(NetworkSafeLoadItemSaveData(saveData));
		}

		private IEnumerator NetworkSafeLoadItemSaveData(int saveData)
		{
			yield return (object)new WaitUntil((Func<bool>)(() => ((NetworkBehaviour)this).IsSpawned));
			if (((NetworkBehaviour)this).IsServer)
			{
				<>n__0(saveData);
				if ((saveData & 1) == 1)
				{
					isOpen = true;
					feedingTimer = 0f;
					LateJoinerOpenCanClientRpc();
					UpdateCatFoodStatusClientRpc("Empty");
				}
			}
		}

		public override int GetItemDataToSave()
		{
			int num = 0;
			return num | (isOpen ? 1 : 0);
		}

		private void NetworkManager_OnClientConnectedCallback(ulong clientId)
		{
			//IL_000d: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			ClientRpcParams val = default(ClientRpcParams);
			val.Send = new ClientRpcSendParams
			{
				TargetClientIds = new ulong[1] { clientId }
			};
			ClientRpcParams clientRpcParams = val;
			if (isOpen)
			{
				LateJoinerOpenCanClientRpc(clientRpcParams);
				if (feedingTimer <= 0f)
				{
					UpdateCatFoodStatusClientRpc("Empty", clientRpcParams);
				}
				else if (feedingTimer < FeedLength / 2f)
				{
					UpdateCatFoodStatusClientRpc("Half (6 hours)", clientRpcParams);
				}
				else
				{
					UpdateCatFoodStatusClientRpc("Full (12 hours)", clientRpcParams);
				}
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (IsFeeding && ((NetworkBehaviour)this).IsServer)
			{
				feedingTimer -= Time.deltaTime;
				if (feedingTimer <= 0f)
				{
					IsFeeding = false;
				}
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!isOpen && ((NetworkBehaviour)this).IsOwner)
			{
				OpenCanServerRpc();
			}
		}

		public override void SetControlTipsForItem()
		{
			if (isOpen)
			{
				HUDManager.Instance.ClearControlTips();
				HUDManager.Instance.ChangeControlTipMultiple((string[])null, true, base.itemProperties);
			}
			else
			{
				((GrabbableObject)this).SetControlTipsForItem();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void OpenCanServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3509606797u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3509606797u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					OpenCanClientRpc();
					IsFeeding = true;
					feedingTimer = FeedLength;
					((MonoBehaviour)this).StartCoroutine(UpdateCatFoodStatusCoroutine());
				}
			}
		}

		[ClientRpc]
		public void OpenCanClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1094053100u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1094053100u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				isOpen = true;
				base.playerHeldBy.doingUpperBodyEmote = 1.16f;
				base.playerHeldBy.playerBodyAnimator.SetTrigger("PullGrenadePin");
				animator.SetTrigger("use");
				((MonoBehaviour)this).StartCoroutine(OpenCanCoroutine());
				((Component)this).GetComponentInChildren<ScanNodeProperties>().headerText = "Cat food (Opened)";
				if (((NetworkBehaviour)this).IsOwner && base.isHeld)
				{
					((GrabbableObject)this).SetControlTipsForItem();
				}
			}
		}

		private IEnumerator OpenCanCoroutine()
		{
			yield return (object)new WaitForSeconds(0.7f);
			noiseAudio.PlayOneShot(removeLidAudio, 1f);
		}

		[ClientRpc]
		public void LateJoinerOpenCanClientRpc(ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1289399889u, clientRpcParams, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 1289399889u, clientRpcParams, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					isOpen = true;
					((Component)this).GetComponentInChildren<ScanNodeProperties>().headerText = "Cat food (Opened)";
					animator.SetTrigger("use");
				}
			}
		}

		private IEnumerator UpdateCatFoodStatusCoroutine()
		{
			UpdateCatFoodStatusClientRpc("Full (12 hours)");
			yield return (object)new WaitForSeconds(FeedLength / 2f);
			UpdateCatFoodStatusClientRpc("Half (6 hours)");
			yield return (object)new WaitForSeconds(FeedLength / 2f);
			UpdateCatFoodStatusClientRpc("Empty");
		}

		[ClientRpc]
		public void UpdateCatFoodStatusClientRpc(string statusText, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1085257088u, clientRpcParams, (RpcDelivery)0);
				bool flag = statusText != null;
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val)).WriteValueSafe(statusText, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1085257088u, clientRpcParams, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				switch (statusText)
				{
				case "Full (12 hours)":
					catfoodMeshFull.SetActive(true);
					catfoodMeshHalf.SetActive(false);
					break;
				case "Half (6 hours)":
					catfoodMeshFull.SetActive(false);
					catfoodMeshHalf.SetActive(true);
					break;
				default:
					catfoodMeshFull.SetActive(false);
					catfoodMeshHalf.SetActive(false);
					break;
				}
				((Component)this).GetComponentInChildren<ScanNodeProperties>().subText = statusText;
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CatFoodProp()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3509606797u, new RpcReceiveHandler(__rpc_handler_3509606797));
			NetworkManager.__rpc_func_table.Add(1094053100u, new RpcReceiveHandler(__rpc_handler_1094053100));
			NetworkManager.__rpc_func_table.Add(1289399889u, new RpcReceiveHandler(__rpc_handler_1289399889));
			NetworkManager.__rpc_func_table.Add(1085257088u, new RpcReceiveHandler(__rpc_handler_1085257088));
		}

		private static void __rpc_handler_3509606797(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CatFoodProp)(object)target).OpenCanServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1094053100(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CatFoodProp)(object)target).OpenCanClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1289399889(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: 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)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CatFoodProp)(object)target).LateJoinerOpenCanClientRpc(client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1085257088(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string statusText = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref statusText, false);
				}
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CatFoodProp)(object)target).UpdateCatFoodStatusClientRpc(statusText, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CatFoodProp";
		}
	}
	public class MouthDogAICollisionDetect : MonoBehaviour
	{
		public NeedyCatProp catScript;

		private void OnTriggerStay(Collider other)
		{
			if (!((GrabbableObject)catScript).reachedFloorTarget || !((Component)other).CompareTag("Enemy"))
			{
				return;
			}
			EnemyAICollisionDetect component = ((Component)other).gameObject.GetComponent<EnemyAICollisionDetect>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.mainScript != (Object)(object)catScript)
			{
				EnemyAI mainScript = component.mainScript;
				MouthDogAI val = (MouthDogAI)(object)((mainScript is MouthDogAI) ? mainScript : null);
				if (val != null && val.inLunge)
				{
					NeedyCatProp needyCatProp = catScript;
					EnemyAI mainScript2 = component.mainScript;
					needyCatProp.OnCollideWithDog(other, (MouthDogAI)(object)((mainScript2 is MouthDogAI) ? mainScript2 : null));
				}
			}
		}
	}
	public class NeedyCatProp : GrabbableObject, INoiseListener
	{
		[Space(3f)]
		public Animator animator;

		public AudioSource audioSource;

		public SkinnedMeshRenderer skinnedMeshRenderer;

		public Material[] materials;

		[Space(3f)]
		public Vector2 IntervalMeow;

		public Vector2 IntervalMove;

		public Vector2 IntervalSitAnimChange;

		public Vector2 IntervalIdleAnimChange;

		public float WalkingSpeed = 1f;

		public float RunningSpeed = 8f;

		private (int, float)[] placeableMeowInterval;

		[HideInInspector]
		public (string, int)[] CatNames;

		private float timeBeforeNextMove = 1f;

		private float timeBeforeNextMeow = 1f;

		private float timeBeforeNextSitAnim = 1f;

		private int sitAnimationsLength = 3;

		private float timeBeforeNextIdleAnim = 1f;

		private int idleAnimationsLength = 4;

		private float timeBeforeTryFlee = -1f;

		private float timeBeforeTryFleeLength = 2.5f;

		private bool isSitting;

		private bool isFleeing;

		private bool isFeeding;

		private int materialIndex;

		private int nameIndex;

		private bool hasLoadedSave;

		private HoarderBugItem hoarderBugItem;

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

		public AudioClip[] fleeSFX;

		public AudioClip[] calmSFX;

		[Space(3f)]
		public float noiseRange = 65f;

		public float maxLoudness = 1f;

		public float minLoudness = 0.95f;

		public float minPitch = 0.9f;

		public float maxPitch = 1f;

		private NavMeshAgent agent;

		private Random random;

		[Space(3f)]
		public Vector3 destination;

		private GameObject[] allAINodes;

		private NavMeshPath navmeshPath;

		private float velX;

		private float velY;

		private Vector3 previousPosition;

		private Vector3 agentLocalVelocity;

		private IEnumerator fleeCoroutine;

		private ClientNetworkTransform clientNetworkTransform;

		private bool isBeingHoarded
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				if (hoarderBugItem != null)
				{
					return Vector3.Distance(((Component)this).transform.position, hoarderBugItem.itemNestPosition) < 2f;
				}
				return false;
			}
		}

		public void Awake()
		{
		}

		public override void Start()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			((GrabbableObject)this).Start();
			try
			{
				if ((Object)(object)agent == (Object)null)
				{
					agent = ((Component)this).GetComponent<NavMeshAgent>();
				}
				if ((Object)(object)animator == (Object)null)
				{
					animator = ((Component)this).GetComponentInChildren<Animator>();
				}
				if ((Object)(object)skinnedMeshRenderer == (Object)null)
				{
					skinnedMeshRenderer = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>();
				}
				clientNetworkTransform = ((Component)this).GetComponent<ClientNetworkTransform>();
				random = new Random(StartOfRound.Instance.randomMapSeed + 85);
				GameObject[] first = GameObject.FindGameObjectsWithTag("AINode");
				GameObject[] second = GameObject.FindGameObjectsWithTag("OutsideAINode");
				allAINodes = first.Concat(second).ToArray();
				agent.updatePosition = false;
				destination = ((Component)this).transform.position;
				navmeshPath = new NavMeshPath();
				AudioMixer diageticMixer = SoundManager.Instance.diageticMixer;
				audioSource.outputAudioMixerGroup = diageticMixer.FindMatchingGroups("SFX")[0];
				((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback += NetworkManager_OnClientConnectedCallback;
				NetworkManager.Singleton.SceneManager.OnLoadComplete += new OnLoadCompleteDelegateHandler(SceneManager_OnLoadComplete);
				placeableMeowInterval = new(int, float)[3]
				{
					(22, 15f),
					(21, 4f),
					(4, 10f)
				};
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Error when initializing variables for {((Object)((Component)this).gameObject).name} : {arg}");
			}
			if (((NetworkBehaviour)this).IsServer && !hasLoadedSave)
			{
				nameIndex = Random.Range(0, CatNames.Length);
				SetCatNameServerRpc(CatNames[nameIndex].Item1);
				if (CatNames[nameIndex].Item2 != -1)
				{
					materialIndex = CatNames[nameIndex].Item2;
				}
				else
				{
					materialIndex = Random.Range(0, materials.Length);
				}
				SetCatMaterialServerRpc(materialIndex);
			}
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).NetworkManager.OnClientConnectedCallback -= NetworkManager_OnClientConnectedCallback;
			((NetworkBehaviour)this).OnDestroy();
		}

		private void NetworkManager_OnClientConnectedCallback(ulong obj)
		{
			if (((NetworkBehaviour)this).IsServer)
			{
				SetCatMaterialServerRpc(materialIndex);
				SetCatNameServerRpc(CatNames[nameIndex].Item1);
				if (isSitting)
				{
					MakeCatSitServerRpc(sit: true);
				}
			}
		}

		private void SceneManager_OnLoadComplete(ulong clientId, string sceneName, LoadSceneMode loadSceneMode)
		{
			GameObject[] first = GameObject.FindGameObjectsWithTag("AINode");
			GameObject[] second = GameObject.FindGameObjectsWithTag("OutsideAINode");
			allAINodes = first.Concat(second).ToArray();
		}

		public override void LoadItemSaveData(int saveData)
		{
			((MonoBehaviour)this).StartCoroutine(NetworkSafeLoadItemSaveData(saveData));
		}

		private IEnumerator NetworkSafeLoadItemSaveData(int saveData)
		{
			yield return ((NetworkBehaviour)this).IsSpawned;
			if (((NetworkBehaviour)this).IsServer)
			{
				<>n__0(saveData);
				int catMaterialServerRpc = (saveData >> 16) & 0xFFFF;
				int num = saveData & 0xFFFF;
				if (num > CatNames.Length)
				{
					num = Random.Range(0, CatNames.Length);
				}
				SetCatNameServerRpc(CatNames[num].Item1);
				if (CatNames[num].Item2 != -1)
				{
					catMaterialServerRpc = CatNames[num].Item2;
				}
				SetCatMaterialServerRpc(catMaterialServerRpc);
				materialIndex = catMaterialServerRpc;
				nameIndex = num;
				hasLoadedSave = true;
			}
		}

		public override int GetItemDataToSave()
		{
			return (materialIndex << 16) | nameIndex;
		}

		private void SynchronizeAnimator(float maxSpeed = 4f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			agentLocalVelocity = ((Component)animator).transform.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
			animator.SetBool("move", ((Vector3)(ref agentLocalVelocity)).magnitude > 0.05f);
			velX = Mathf.Lerp(velX, agentLocalVelocity.x, 10f * Time.deltaTime);
			animator.SetFloat("velx", Mathf.Clamp(velX, 0f - maxSpeed, maxSpeed));
			velY = Mathf.Lerp(velY, agentLocalVelocity.z, 10f * Time.deltaTime);
			animator.SetFloat("vely", Mathf.Clamp(velY, 0f - maxSpeed, maxSpeed));
			previousPosition = ((Component)this).transform.position;
		}

		public override void GrabItem()
		{
			animator.SetBool("move", false);
			animator.SetFloat("velx", 0f);
			animator.SetFloat("vely", 0f);
			animator.SetBool("held", true);
			animator.ResetTrigger("sit");
			isSitting = false;
			isFleeing = false;
			StopCatFleeServerRpc();
			if (fleeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(fleeCoroutine);
			}
			((GrabbableObject)this).GrabItem();
			if (((NetworkBehaviour)this).IsOwner)
			{
				HUDManager.Instance.DisplayTip("Cat Facts", "Too noisy? Give your cat a pet to quiet it down for a bit!", false, true, "LC_NeedyCatsTip");
			}
		}

		public override void DiscardItem()
		{
			animator.SetBool("held", false);
			((GrabbableObject)this).DiscardItem();
		}

		public override void GrabItemFromEnemy(EnemyAI enemy)
		{
			base.isHeldByEnemy = true;
			animator.SetBool("move", false);
			animator.SetFloat("velx", 0f);
			animator.SetFloat("vely", 0f);
			animator.SetBool("held", true);
			animator.ResetTrigger("sit");
			isSitting = false;
			isFleeing = false;
			StopCatFleeServerRpc();
			if (fleeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(fleeCoroutine);
			}
			((GrabbableObject)this).GrabItemFromEnemy(enemy);
			if (((NetworkBehaviour)this).IsServer)
			{
				HoarderBugAI val = (HoarderBugAI)(object)((enemy is HoarderBugAI) ? enemy : null);
				if (val != null)
				{
					hoarderBugItem = (((Object)(object)val.heldItem.itemGrabbableObject == (Object)(object)this) ? val.heldItem : null);
				}
			}
		}

		public override void DiscardItemFromEnemy()
		{
			base.isHeldByEnemy = false;
			animator.SetBool("held", false);
			((GrabbableObject)this).DiscardItemFromEnemy();
		}

		public override void Update()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)clientNetworkTransform).enabled = !base.isHeld && !base.isHeldByEnemy;
			if (((NetworkBehaviour)this).IsServer && !base.isHeld && !base.isHeldByEnemy && !((NetworkBehaviour)this).IsOwner)
			{
				((Component)this).GetComponent<NetworkObject>().RemoveOwnership();
			}
			if (!isFleeing && !base.isInElevator && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
			{
				((Behaviour)agent).enabled = !base.isHeld && !base.isHeldByEnemy && base.reachedFloorTarget && !(base.fallTime < 1f);
				if (base.fallTime >= 1f && !base.reachedFloorTarget)
				{
					base.targetFloorPosition = ((Component)this).transform.position;
					destination = ((Component)this).transform.position;
					previousPosition = ((Component)this).transform.position;
					((Behaviour)agent).enabled = true;
				}
			}
			if (!base.isHeld && !base.isHeldByEnemy && base.fallTime >= 1f && !base.reachedFloorTarget && animator.GetBool("held"))
			{
				animator.SetBool("held", false);
			}
			if (!isFleeing)
			{
				if (base.isHeld || base.isHeldByEnemy || !base.reachedFloorTarget || base.fallTime < 1f || base.isInElevator)
				{
					((GrabbableObject)this).Update();
				}
				if (((NetworkBehaviour)this).IsServer && !base.isHeld && !base.isHeldByEnemy && (base.isInElevator || isBeingHoarded) && !isSitting)
				{
					MakeCatSitServerRpc(sit: true);
				}
				else if (((NetworkBehaviour)this).IsServer && !base.isHeld && !base.isHeldByEnemy && !base.isInElevator && !isBeingHoarded && isSitting && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
				{
					MakeCatSitServerRpc(sit: false);
				}
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				if (isSitting)
				{
					if (timeBeforeNextSitAnim <= 0f)
					{
						SetCatSitAnimationServerRpc(Random.Range(0, sitAnimationsLength));
						timeBeforeNextSitAnim = Random.Range(IntervalSitAnimChange.x, IntervalSitAnimChange.y);
					}
					timeBeforeNextSitAnim -= Time.deltaTime;
				}
				else
				{
					if (timeBeforeNextIdleAnim <= 0f)
					{
						SetCatIdleAnimationServerRpc(Random.Range(0, idleAnimationsLength));
						timeBeforeNextIdleAnim = Random.Range(IntervalIdleAnimChange.x, IntervalIdleAnimChange.y);
					}
					timeBeforeNextIdleAnim -= Time.deltaTime;
				}
				if (timeBeforeNextMeow <= 0f)
				{
					MakeCatMeowServerRpc();
					float num = CalculateCatMeowInterval();
					timeBeforeNextMeow = Random.Range(IntervalMeow.x + num, IntervalMeow.y + num);
				}
				timeBeforeNextMeow -= Time.deltaTime;
				if (timeBeforeTryFlee >= 0f)
				{
					timeBeforeTryFlee -= Time.deltaTime;
				}
				if (!isFleeing)
				{
					if (!base.isHeld && !base.isHeldByEnemy && !base.isInElevator && !isBeingHoarded && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
					{
						if (timeBeforeNextMove <= 0f)
						{
							SetRandomDestination();
							timeBeforeNextMove = Random.Range(IntervalMove.x, IntervalMove.y);
						}
						timeBeforeNextMove -= Time.deltaTime;
						((Component)this).transform.position = agent.nextPosition;
					}
				}
				else if (isFleeing)
				{
					((Component)this).transform.position = agent.nextPosition;
					base.targetFloorPosition = ((Component)this).transform.position;
				}
			}
			if (!base.isHeld && !base.isHeldByEnemy)
			{
				SynchronizeAnimator();
			}
		}

		public float CalculateCatMeowInterval()
		{
			float num = 0f;
			if (base.isInElevator)
			{
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (val.isInElevator)
					{
						num += 6f;
						break;
					}
				}
				(int, float)[] array = placeableMeowInterval;
				for (int j = 0; j < array.Length; j++)
				{
					(int, float) tuple = array[j];
					if (StartOfRound.Instance.SpawnedShipUnlockables.ContainsKey(tuple.Item1))
					{
						num += tuple.Item2;
					}
				}
			}
			if (!NeedyCatsBase.Instance.CatFoodSilence.Value && CheckForCatFood())
			{
				num += 120f;
			}
			return num;
		}

		public bool CheckForCatFood()
		{
			//IL_0030: 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)
			foreach (CatFoodProp allCatFood in NeedyCatsBase.Instance.AllCatFoods)
			{
				if (((GrabbableObject)allCatFood).reachedFloorTarget && allCatFood.IsFeeding && Vector3.Distance(((Component)allCatFood).transform.position, ((Component)this).transform.position) < 10f)
				{
					return true;
				}
			}
			return false;
		}

		public void SetDestinationToPosition(Vector3 position, bool checkForPath = false)
		{
			//IL_00c4: 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)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (checkForPath)
			{
				position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 1.75f, -1);
				navmeshPath = new NavMeshPath();
				if (!agent.CalculatePath(position, navmeshPath))
				{
					Debug.Log((object)(((Object)((Component)this).gameObject).name + " calculatepath returned false."));
					return;
				}
				if (Vector3.Distance(navmeshPath.corners[navmeshPath.corners.Length - 1], RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 2.7f, -1)) > 1.55f)
				{
					Debug.Log((object)(((Object)((Component)this).gameObject).name + " path calculation went wrong."));
					return;
				}
			}
			destination = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, -1f, -1);
			agent.SetDestination(destination);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (((NetworkBehaviour)this).IsOwner)
			{
				MakeCatCalmServerRpc();
			}
		}

		public void SetRandomDestination()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position + Random.insideUnitSphere * 5f;
			agent.speed = WalkingSpeed;
			SetDestinationToPosition(position);
		}

		private void PlayCatNoise(AudioClip[] array, bool audible = true)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			int num = random.Next(0, array.Length);
			float num2 = (float)random.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
			float pitch = (float)random.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
			audioSource.pitch = pitch;
			audioSource.PlayOneShot(array[num], num2);
			WalkieTalkie.TransmitOneShotAudio(audioSource, array[num], num2 - 0.4f);
			if (audible)
			{
				float num3 = (base.isInElevator ? (noiseRange - 2.5f) : noiseRange);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, num3, num2, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 8881);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void MakeCatMeowServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3454429685u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3454429685u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			if (!isFeeding && CheckForCatFood())
			{
				isFeeding = true;
				return;
			}
			if (isFeeding && !CheckForCatFood())
			{
				isFeeding = false;
			}
			if (!NeedyCatsBase.Instance.CatFoodSilence.Value || !CheckForCatFood())
			{
				MakeCatMeowClientRpc();
			}
		}

		[ClientRpc]
		public void MakeCatMeowClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1946573138u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1946573138u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					PlayCatNoise(noiseSFX);
					animator.SetTrigger("meow");
				}
			}
		}

		[ClientRpc]
		public void MakeCatFleeClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2532932337u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2532932337u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					animator.SetBool("sit", false);
					PlayCatNoise(fleeSFX);
					animator.SetTrigger("meow");
					((Component)this).transform.SetParent((Transform)null, true);
					isFleeing = true;
					base.isInElevator = false;
					isSitting = false;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void StopCatFleeServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3642870494u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3642870494u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					StopCatFleeClientRpc();
				}
			}
		}

		[ClientRpc]
		public void StopCatFleeClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2708699245u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2708699245u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					isFleeing = false;
				}
			}
		}

		[ServerRpc]
		public void MakeCatCalmServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2784153610u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2784153610u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				float num = CalculateCatMeowInterval();
				timeBeforeNextMeow = Random.Range(IntervalMeow.x + num + 3f, IntervalMeow.y + num + 6f);
				MakeCatCalmClientRpc();
			}
		}

		public void OnCollideWithDog(Collider other, MouthDogAI mouthDogAI)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || !(timeBeforeTryFlee <= 0f))
			{
				return;
			}
			if (Random.Range(0f, 100f) > NeedyCatsBase.Instance.CatFleeDogsChance.Value)
			{
				timeBeforeTryFlee = timeBeforeTryFleeLength;
				return;
			}
			Vector3 val = ((Component)other).transform.position - ((Component)this).transform.position;
			((Behaviour)agent).enabled = true;
			Vector3 position = ((Component)this).transform.position - ((Vector3)(ref val)).normalized * 40f;
			GameObject[] array = allAINodes.OrderBy((GameObject x) => Vector3.Distance(position, x.transform.position)).ToArray();
			agent.nextPosition = ((Component)this).transform.position;
			SetDestinationToPosition(array[0].transform.position);
			agent.speed = RunningSpeed;
			timeBeforeNextMove = Random.Range(IntervalMove.x + 5f, IntervalMove.y + 10f);
			timeBeforeNextMeow = Random.Range(IntervalMeow.x, IntervalMeow.y);
			timeBeforeTryFlee = timeBeforeTryFleeLength;
			if (fleeCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(fleeCoroutine);
			}
			fleeCoroutine = FleeCoroutine(timeBeforeNextMove);
			((MonoBehaviour)this).StartCoroutine(fleeCoroutine);
			MakeCatFleeClientRpc();
		}

		public IEnumerator FleeCoroutine(float time)
		{
			yield return (object)new WaitForSeconds(time);
			StopCatFleeClientRpc();
		}

		[ClientRpc]
		public void MakeCatCalmClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2302897036u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2302897036u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.playerHeldBy.doingUpperBodyEmote = 1.16f;
					base.playerHeldBy.playerBodyAnimator.SetTrigger("PullGrenadePin2");
					((MonoBehaviour)this).StartCoroutine(PlayCatCalmNoiseDelayed());
				}
			}
		}

		private IEnumerator PlayCatCalmNoiseDelayed()
		{
			yield return (object)new WaitForSeconds(0.5f);
			PlayCatNoise(calmSFX, audible: false);
		}

		[ServerRpc]
		public void MakeCatSitServerRpc(bool sit)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2411027775u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref sit, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2411027775u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				MakeCatSitClientRpc(sit);
			}
		}

		[ClientRpc]
		public void MakeCatSitClientRpc(bool sit)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3921800473u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref sit, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3921800473u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					animator.SetBool("sit", sit);
					isSitting = sit;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetCatMaterialServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2046492207u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2046492207u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetCatMaterialClientRpc(index);
				}
			}
		}

		[ClientRpc]
		public void SetCatMaterialClientRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3875721248u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3875721248u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && (Object)(object)skinnedMeshRenderer != (Object)null)
				{
					((Renderer)skinnedMeshRenderer).sharedMaterial = materials[index];
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetCatNameServerRpc(string name)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3049925245u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3049925245u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SetCatNameClientRpc(name);
			}
		}

		[ClientRpc]
		public void SetCatNameClientRpc(string name)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1321450034u, val, (RpcDelivery)0);
				bool flag = name != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(name, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1321450034u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				((Component)this).GetComponentInChildren<ScanNodeProperties>().headerText = "Cat (" + name + ")";
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetCatIdleAnimationServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1770904636u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1770904636u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetCatIdleAnimationClientRpc(index);
				}
			}
		}

		[ClientRpc]
		public void SetCatIdleAnimationClientRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(283245169u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 283245169u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					animator.SetInteger("idleAnimation", index);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetCatSitAnimationServerRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1062797608u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1062797608u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					SetCatSitAnimationClientRpc(index);
				}
			}
		}

		[ClientRpc]
		public void SetCatSitAnimationClientRpc(int index)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4162097660u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, index);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4162097660u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					animator.SetInteger("sitAnimation", index);
				}
			}
		}

		public virtual void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (base.isHeld || base.isHeldByEnemy || noiseID == 8881 || noiseID == 75 || noiseID == 5 || noiseID == 94 || base.isInShipRoom || !StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap)
			{
				return;
			}
			Vector3 val = noisePosition - ((Component)this).transform.position;
			if (!(((Vector3)(ref val)).magnitude < 5f) || !(noiseLoudness > 0.8f))
			{
				return;
			}
			PlayCatNoise(fleeSFX);
			if (((NetworkBehaviour)this).IsServer)
			{
				Vector3 position = ((Component)this).transform.position - ((Vector3)(ref val)).normalized * 20f;
				GameObject[] array = allAINodes.OrderBy((GameObject x) => Vector3.Distance(position, x.transform.position)).ToArray();
				SetDestinationToPosition(array[0].transform.position);
				agent.speed = RunningSpeed;
				timeBeforeNextMove = Random.Range(IntervalMove.x + 1f, IntervalMove.y + 2f);
			}
		}

		[CompilerGenerated]
		[DebuggerHidden]
		private void <>n__0(int saveData)
		{
			((GrabbableObject)this).LoadItemSaveData(saveData);
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_NeedyCatProp()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3454429685u, new RpcReceiveHandler(__rpc_handler_3454429685));
			NetworkManager.__rpc_func_table.Add(1946573138u, new RpcReceiveHandler(__rpc_handler_1946573138));
			NetworkManager.__rpc_func_table.Add(2532932337u, new RpcReceiveHandler(__rpc_handler_2532932337));
			NetworkManager.__rpc_func_table.Add(3642870494u, new RpcReceiveHandler(__rpc_handler_3642870494));
			NetworkManager.__rpc_func_table.Add(2708699245u, new RpcReceiveHandler(__rpc_handler_2708699245));
			NetworkManager.__rpc_func_table.Add(2784153610u, new RpcReceiveHandler(__rpc_handler_2784153610));
			NetworkManager.__rpc_func_table.Add(2302897036u, new RpcReceiveHandler(__rpc_handler_2302897036));
			NetworkManager.__rpc_func_table.Add(2411027775u, new RpcReceiveHandler(__rpc_handler_2411027775));
			NetworkManager.__rpc_func_table.Add(3921800473u, new RpcReceiveHandler(__rpc_handler_3921800473));
			NetworkManager.__rpc_func_table.Add(2046492207u, new RpcReceiveHandler(__rpc_handler_2046492207));
			NetworkManager.__rpc_func_table.Add(3875721248u, new RpcReceiveHandler(__rpc_handler_3875721248));
			NetworkManager.__rpc_func_table.Add(3049925245u, new RpcReceiveHandler(__rpc_handler_3049925245));
			NetworkManager.__rpc_func_table.Add(1321450034u, new RpcReceiveHandler(__rpc_handler_1321450034));
			NetworkManager.__rpc_func_table.Add(1770904636u, new RpcReceiveHandler(__rpc_handler_1770904636));
			NetworkManager.__rpc_func_table.Add(283245169u, new RpcReceiveHandler(__rpc_handler_283245169));
			NetworkManager.__rpc_func_table.Add(1062797608u, new RpcReceiveHandler(__rpc_handler_1062797608));
			NetworkManager.__rpc_func_table.Add(4162097660u, new RpcReceiveHandler(__rpc_handler_4162097660));
		}

		private static void __rpc_handler_3454429685(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).MakeCatMeowServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1946573138(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).MakeCatMeowClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2532932337(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).MakeCatFleeClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3642870494(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).StopCatFleeServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2708699245(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).StopCatFleeClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2784153610(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).MakeCatCalmServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2302897036(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).MakeCatCalmClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2411027775(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				bool sit = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sit, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).MakeCatSitServerRpc(sit);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3921800473(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool sit = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sit, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).MakeCatSitClientRpc(sit);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2046492207(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catMaterialServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catMaterialServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).SetCatMaterialServerRpc(catMaterialServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3875721248(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catMaterialClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catMaterialClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).SetCatMaterialClientRpc(catMaterialClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3049925245(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string catNameServerRpc = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref catNameServerRpc, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).SetCatNameServerRpc(catNameServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1321450034(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string catNameClientRpc = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref catNameClientRpc, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).SetCatNameClientRpc(catNameClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1770904636(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catIdleAnimationServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catIdleAnimationServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).SetCatIdleAnimationServerRpc(catIdleAnimationServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_283245169(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catIdleAnimationClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catIdleAnimationClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).SetCatIdleAnimationClientRpc(catIdleAnimationClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1062797608(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catSitAnimationServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catSitAnimationServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((NeedyCatProp)(object)target).SetCatSitAnimationServerRpc(catSitAnimationServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4162097660(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int catSitAnimationClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref catSitAnimationClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((NeedyCatProp)(object)target).SetCatSitAnimationClientRpc(catSitAnimationClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "NeedyCatProp";
		}
	}
	public class NoiseListenerRedirect : MonoBehaviour, INoiseListener
	{
		private INoiseListener target;

		public void Awake()
		{
			target = ((Component)((Component)this).transform.parent).GetComponent<INoiseListener>();
		}

		public void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot, int noiseID)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			INoiseListener obj = target;
			if (obj != null)
			{
				obj.DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
			}
		}
	}
	[BepInPlugin("Jordo.NeedyCats", "Needy Cats", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class NeedyCatsBase : BaseUnityPlugin
	{
		public static class Assets
		{
			public static string mainAssetBundleName = "needycats";

			public static AssetBundle MainAssetBundle = null;

			private static string GetAssemblyName()
			{
				return Assembly.GetExecutingAssembly().FullName.Split(new char[1] { ',' })[0];
			}

			public static void PopulateAssets()
			{
				if ((Object)(object)MainAssetBundle == (Object)null)
				{
					using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName))
					{
						MainAssetBundle = AssetBundle.LoadFromStream(stream);
					}
				}
			}
		}

		private const string modGUID = "Jordo.NeedyCats";

		private const string modName = "Needy Cats";

		private const string modVersion = "1.2.2";

		private readonly Harmony harmony = new Harmony("Jordo.NeedyCats");

		public static NeedyCatsBase Instance;

		private static List<(string, int)> catNames = new List<(string, int)>();

		private static ConfigEntry<int> spawnRate;

		private static ConfigEntry<string> catNamesConfig;

		public ConfigEntry<bool> CatFoodSilence;

		public ConfigEntry<float> CatFleeDogsChance;

		public List<CatFoodProp> AllCatFoods = new List<CatFoodProp>();

		internal static ManualLogSource mls;

		private string defaultCatNames = "One:Stripes,Bella,Tigger,Chloe,Shadow,Luna,Oreo,Oliver,Kitty,Lucy,Molly,Jasper,Smokey,Gizmo,Simba,Tiger,Charlie,Angel,Jack,Lily,Peanut,Toby,Baby,Loki,Midnight,Milo,Princess,Sophie,Harley,Max,Missy,Rocky,Zoe,CoCo,Misty,Nala,Oscar,Pepper,Sasha,Buddy,Pumpkin,Kiki,Mittens,Bailey,Callie,Lucky,Patches:Spots,Simon,Garfield:Orange,George,Maggie,Sammy,Sebastian,Boots,Cali,Felix,Lilly,Phoebe,Sassy,Tucker,Bandit,Dexter,Fiona,Jake,Precious,Romeo,Snickers,Socks,Daisy,Gracie,Lola,Sadie,Sox,Casper,Fluffy,Marley,Minnie,Sweetie,Ziggy,Belle,Blackie,Chester,Frankie,Ginger,Muffin,Murphy,Rusty,Scooter,Batman,Boo,Cleo,Izzy,Jasmine,Mimi,Sugar,Cupcake,Dusty,Leo,Noodle,Panda,Peaches";

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Jordo.NeedyCats");
			PatchNetcode();
			Assets.PopulateAssets();
			spawnRate = ((BaseUnityPlugin)this).Config.Bind<int>("NeedyCats", "Spawn rate", 20, "[Server-side] Sets the cat's spawn rate (This affects all moons).");
			CatFoodSilence = ((BaseUnityPlugin)this).Config.Bind<bool>("NeedyCats", "Cat food behaviour", false, "[Server-side] What behaviour will the cat food have on the cats?\nIf false, delays the meows by a significant amount (default, recommended for multiplayer),\nIf true, silences all meows (recommended for solo play).");
			CatFleeDogsChance = ((BaseUnityPlugin)this).Config.Bind<float>("NeedyCats", "Chance of cats fleeing dogs", 15f, "[Server-side] When a cat is actively attacked by one or multiple dogs, it has a chance to flee away from the dog.");
			catNamesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("NeedyCats", "Cat names", defaultCatNames, "[Server-side] Possible cat names separated by a colon (,). If the cat's name is followed by ':', you can input a material that'll be forced for that name among the following: Black, White, Spots, Boots, Orange, Stripes. You can find an image showcasing each material on the mod's wiki on Thunderstore. This list must contain at least one name. Example string: 'Daisy,Garfield:Orange,Chloe'");
			string[] array = catNamesConfig.Value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				string[] array2 = text.Split(new char[1] { ':' });
				catNames.Add((array2[0], (array2.Length > 1) ? GetMaterialID(array2[1]) : (-1)));
			}
			harmony.PatchAll(typeof(NeedyCatsBase));
			mls.LogInfo((object)"Initialized Needy Cats");
		}

		private int GetMaterialID(string name)
		{
			return name.ToLower() switch
			{
				"black" => 0, 
				"white" => 1, 
				"boots" => 2, 
				"spots" => 3, 
				"orange" => 4, 
				"stripes" => 5, 
				_ => -1, 
			};
		}

		private void PatchNetcode()
		{
			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);
					}
				}
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		[HarmonyPostfix]
		private static void AddNeedyCatsToNetworkManager(GameNetworkManager __instance)
		{
			GameObject[] array = Assets.MainAssetBundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array)
			{
				((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(val);
			}
			mls.LogInfo((object)"Added NeedyCats prefabs to Network Manager.");
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void AddNeedyCatsToItems(StartOfRound __instance)
		{
			Item val = Assets.MainAssetBundle.LoadAsset<Item>("CatItem");
			Item val2 = Assets.MainAssetBundle.LoadAsset<Item>("CatFoodItem");
			Item[] array = Assets.MainAssetBundle.LoadAllAssets<Item>();
			foreach (Item item in array)
			{
				if (!__instance.allItemsList.itemsList.Contains(item))
				{
					__instance.allItemsList.itemsList.Add(item);
				}
			}
			mls.LogInfo((object)"Added NeedyCats items to items list.");
		}

		[HarmonyPatch(typeof(Terminal), "Awake")]
		[HarmonyPrefix]
		private static void AddNeedyCatsToTerminal(Terminal __instance)
		{
			TerminalKeyword buyKeyword = __instance.terminalNodes.allKeywords.First((TerminalKeyword x) => x.word == "buy");
			AddItemToTerminal("CatFoodItem", "CatFoodKeyword", "BuyCatFoodNode", "ConfirmCatFoodNode");
			void AddItemToTerminal(string itemName, string keywordName, string buyNodeName, string confirmNodeName)
			{
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Expected O, but got Unknown
				Item item = Assets.MainAssetBundle.LoadAsset<Item>(itemName);
				TerminalKeyword keyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>(keywordName);
				keyword.defaultVerb = buyKeyword;
				TerminalNode val = Assets.MainAssetBundle.LoadAsset<TerminalNode>(buyNodeName);
				TerminalNode val2 = Assets.MainAssetBundle.LoadAsset<TerminalNode>(confirmNodeName);
				List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
				if (!list.Contains(keyword))
				{
					list.Add(keyword);
				}
				__instance.terminalNodes.allKeywords = list.ToArray();
				List<CompatibleNoun> list2 = buyKeyword.compatibleNouns.ToList();
				if (((IEnumerable<CompatibleNoun>)list2).FirstOrDefault((Func<CompatibleNoun, bool>)((CompatibleNoun x) => (Object)(object)x.noun == (Object)(object)keyword)) == null)
				{
					list2.Add(new CompatibleNoun
					{
						noun = keyword,
						result = val
					});
				}
				buyKeyword.compatibleNouns = list2.ToArray();
				List<Item> list3 = __instance.buyableItemsList.ToList();
				if (!list3.Contains(item))
				{
					list3.Add(item);
				}
				__instance.buyableItemsList = list3.ToArray();
				val.buyItemIndex = (val2.buyItemIndex = __instance.buyableItemsList.Length - 1);
			}
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		private static void AddNeedyCatsToAllLevels(RoundManager __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Item item = Assets.MainAssetBundle.LoadAsset<Item>("CatItem");
			SpawnableItemWithRarity val = new SpawnableItemWithRarity();
			val.rarity = spawnRate.Value;
			val.spawnableItem = item;
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val2 in levels)
			{
				if (!val2.spawnableScrap.Any((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)item))
				{
					val2.spawnableScrap.Add(val);
				}
			}
			mls.LogInfo((object)"Added NeedyCats to all levels.");
		}

		[HarmonyPatch(typeof(HoarderBugAI), "GrabTargetItemIfClose")]
		[HarmonyPrefix]
		private static bool GrabTargetItemIfClose(HoarderBugAI __instance)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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)
			//IL_007c: 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)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			float num = ((__instance.targetItem is NeedyCatProp) ? 1f : 0.75f);
			if ((Object)(object)__instance.targetItem != (Object)null && __instance.heldItem == null && Vector3.Distance(((Component)__instance).transform.position, ((Component)__instance.targetItem).transform.position) < num)
			{
				if (!((EnemyAI)__instance).SetDestinationToPosition(__instance.nestPosition, true))
				{
					__instance.nestPosition = ((EnemyAI)__instance).ChooseClosestNodeToPosition(((Component)__instance).transform.position, false, 0).position;
					((EnemyAI)__instance).SetDestinationToPosition(__instance.nestPosition, false);
				}
				NetworkObject component = ((Component)__instance.targetItem).GetComponent<NetworkObject>();
				((EnemyAI)__instance).SwitchToBehaviourStateOnLocalClient(1);
				__instance.GrabItem(component);
				__instance.sendingGrabOrDropRPC = true;
				__instance.GrabItemServerRpc(NetworkObjectReference.op_Implicit(component));
				return true;
			}
			return false;
		}

		[HarmonyPatch(typeof(NeedyCatProp), "Awake")]
		[HarmonyPrefix]
		private static void AddNeedyCatsNames(NeedyCatProp __instance)
		{
			__instance.CatNames = catNames.ToArray();
		}
	}
}

BepInEx/plugins/NiceChat.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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 TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("NiceChat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.7.0")]
[assembly: AssemblyInformationalVersion("1.2.7+4c75d1accc36435e7d9457468e2b00c4c86d6e92")]
[assembly: AssemblyProduct("NiceChat")]
[assembly: AssemblyTitle("NiceChat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.7.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 NiceChat
{
	public interface IServerVar : IDisposable
	{
		static List<IServerVar> AllServerVars;

		void TryRegister();

		static IServerVar()
		{
			AllServerVars = new List<IServerVar>();
		}
	}
	public class ServerVar<T> : IServerVar, IDisposable where T : IEquatable<T>
	{
		public delegate void ReadFromReader<T1>(FastBufferReader reader, out T1 value);

		private T value;

		private Action<FastBufferWriter, T> writeValue;

		private ReadFromReader<T> readValue;

		public string Id { get; init; }

		public T Value
		{
			get
			{
				return value;
			}
			set
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer)
				{
					if (!EqualityComparer<T>.Default.Equals(this.value, value))
					{
						this.value = value;
						if (NetworkManager.Singleton.IsConnectedClient)
						{
							Plugin.log.LogDebug((object)$"[{Id}] Broadcasting new value \"{value}\" to all clients");
							FastBufferWriter val = default(FastBufferWriter);
							((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
							writeValue(val, value);
							NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(Id, val, (NetworkDelivery)3);
						}
					}
				}
				else
				{
					Plugin.log.LogWarning((object)("Client tried to set ServerVar \"" + Id + "\""));
				}
			}
		}

		public ServerVar(string id, Action<FastBufferWriter, T> write, ReadFromReader<T> read, T defaultValue = default(T))
		{
			value = defaultValue;
			Id = (string.IsNullOrEmpty(id) ? "taffyko.NiceChat" : ("taffyko.NiceChat." + id));
			writeValue = write;
			readValue = read;
			IServerVar.AllServerVars.Add(this);
			((IServerVar)this).TryRegister();
			Plugin.cleanupActions.Add(Dispose);
		}

		private void Handler(ulong senderClientId, FastBufferReader messagePayload)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (senderClientId != NetworkManager.Singleton.LocalClientId)
			{
				if (NetworkManager.Singleton.IsServer)
				{
					FastBufferWriter val = default(FastBufferWriter);
					((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
					writeValue(val, value);
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(Id, senderClientId, val, (NetworkDelivery)3);
					Plugin.log.LogDebug((object)$"[{Id}] Responded to request from {senderClientId} with value: \"{value}\"");
				}
				else
				{
					readValue(messagePayload, out value);
					Plugin.log.LogDebug((object)$"[{Id}] Received update from {senderClientId} with value: \"{value}\"");
				}
			}
		}

		private void OnClientConnectedCallback(ulong clientId)
		{
			if (clientId == NetworkManager.Singleton.LocalClientId)
			{
				((IServerVar)this).TryRegister();
			}
		}

		public void Dispose()
		{
			Plugin.log.LogDebug((object)("[" + Id + "] Disposed ServerVar"));
			if ((Object)(object)NetworkManager.Singleton != (Object)null)
			{
				NetworkManager.Singleton.OnClientConnectedCallback -= OnClientConnectedCallback;
				if (NetworkManager.Singleton.IsConnectedClient)
				{
					NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(Id);
				}
			}
			IServerVar.AllServerVars.Remove(this);
		}

		void IServerVar.TryRegister()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			Plugin.log.LogDebug((object)$"[{Id}] Attempting to register. NetworkManager: {(Object)(object)NetworkManager.Singleton != (Object)null}, Connected: {(Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsConnectedClient}");
			if (!((Object)(object)NetworkManager.Singleton != (Object)null))
			{
				return;
			}
			NetworkManager.Singleton.OnClientConnectedCallback += OnClientConnectedCallback;
			if (NetworkManager.Singleton.IsConnectedClient)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(Id, new HandleNamedMessageDelegate(Handler));
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(Id, new HandleNamedMessageDelegate(Handler));
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler(Id, new HandleNamedMessageDelegate(Handler));
				Plugin.log.LogDebug((object)("[" + Id + "] Registered ServerVar"));
				if (!NetworkManager.Singleton.IsServer)
				{
					NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(Id, 0uL, new FastBufferWriter(0, (Allocator)2, -1), (NetworkDelivery)3);
					Plugin.log.LogDebug((object)$"[{Id}] Sent request from {NetworkManager.Singleton.LocalClientId} to {0uL}");
				}
			}
		}
	}
	[HarmonyPatch]
	internal class NetworkingPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Awake_Postfix()
		{
			foreach (IServerVar allServerVar in IServerVar.AllServerVars)
			{
				allServerVar.TryRegister();
			}
		}
	}
	[BepInPlugin("taffyko.NiceChat", "NiceChat", "1.2.7")]
	public class Plugin : BaseUnityPlugin
	{
		private delegate bool ParseConfigValue<T>(string input, out T output);

		public const string modGUID = "taffyko.NiceChat";

		public const string modName = "NiceChat";

		public const string modVersion = "1.2.7";

		private readonly Harmony harmony = new Harmony("taffyko.NiceChat");

		public static ManualLogSource log = null;

		internal static List<Action> cleanupActions = new List<Action>();

		public static int MaxMessageHistory { get; private set; }

		public static float DefaultFontSize { get; private set; }

		public static bool EnlargeChatWindow { get; private set; }

		public static int CharacterLimit { get; private set; }

		public static float MessageRange { get; private set; }

		public static bool HearDeadPlayers { get; private set; }

		public static bool EnableTimestamps { get; private set; }

		public static bool TagMessageStatus { get; private set; }

		public static bool ShowScrollbar { get; private set; }

		public static float FadeOpacity { get; private set; }

		public static float FadeTimeAfterMessage { get; private set; }

		public static float FadeTimeAfterOwnMessage { get; private set; }

		public static float FadeTimeAfterUnfocused { get; private set; }

		public static bool GuiFadeFix { get; private set; }

		public static bool SpectatorChatHideOtherHudElements { get; private set; }

		public static Color InputTextColor { get; private set; }

		private void Awake()
		{
			ConfigInit();
			log = Logger.CreateLogSource("NiceChat");
			log.LogInfo((object)"Loading taffyko.NiceChat");
			ServerVars.characterLimit = new ServerVar<int>("characterLimit", delegate(FastBufferWriter writer, int v)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref writer)).WriteValueSafe<int>(ref v, default(ForPrimitives));
			}, delegate(FastBufferReader r, out int v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferReader)(ref r)).ReadValueSafe<int>(ref v, default(ForPrimitives));
			}, 49);
			ServerVars.hearDeadPlayers = new ServerVar<bool>("hearDeadPlayers", delegate(FastBufferWriter writer, bool v)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref writer)).WriteValueSafe<bool>(ref v, default(ForPrimitives));
			}, delegate(FastBufferReader r, out bool v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref v, default(ForPrimitives));
			}, defaultValue: false);
			ServerVars.messageRange = new ServerVar<float>("messageRange", delegate(FastBufferWriter writer, float v)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferWriter)(ref writer)).WriteValueSafe<float>(ref v, default(ForPrimitives));
			}, delegate(FastBufferReader r, out float v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref v, default(ForPrimitives));
			}, 25f);
			ServerVars.modVersion = new ServerVar<string>("", delegate(FastBufferWriter writer, string v)
			{
				((FastBufferWriter)(ref writer)).WriteValueSafe(v, false);
			}, delegate(FastBufferReader r, out string v)
			{
				((FastBufferReader)(ref r)).ReadValueSafe(ref v, false);
			});
			harmony.PatchAll(Assembly.GetExecutingAssembly());
		}

		private void OnDestroy()
		{
		}

		private void ConfigInit()
		{
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Config.Bind<string>("README", "README", "", "All config values are text-based, as a workaround to make it possible for default values to change in future updates.\r\n\r\nSee https://github.com/taffyko/LCNiceChat/issues/3 for more information.\r\n\r\nIf you enter an invalid value, it will change back to \"default\" when the game starts.");
			Color vanillaValue = default(Color);
			ColorUtility.TryParseHtmlString("#585ed1d4", ref vanillaValue);
			ConfEntry("Chat", "MaxMessageHistory", 15, "Set the maximum number of messages in history before the oldest messages begin to disappear (NOTE: Long message histories can negatively impact performance)", int.TryParse, 4);
			ConfEntry("Chat", "DefaultFontSize", 11f, "Font size.", float.TryParse, 13f);
			ConfEntry("Chat", "EnlargeChatWindow", defaultValue: true, "Increases the size of the chat area.", bool.TryParse);
			ConfEntry("Chat", "CharacterLimit", 1000, "Maximum character limit for messages in your lobby.", int.TryParse, hostControlled: true);
			ConfEntry("Chat", "MessageRange", 25f, "Maximum distance from which messages between living players can be heard without a walkie-talkie.", float.TryParse, 25f, hostControlled: true);
			ConfEntry("Chat", "HearDeadPlayers", defaultValue: false, "When enabled, allows living players to hear messages from dead players.", bool.TryParse, hostControlled: true);
			ConfEntry("Chat", "EnableTimestamps", defaultValue: true, "Adds timestamps to messages whenever the clock is visible.", bool.TryParse);
			ConfEntry("Chat", "TagMessageStatus", defaultValue: false, "Adds tags like *WALKIE* and *DEAD* to messages in addition to the color-coding.", bool.TryParse);
			ConfEntry("Chat", "ShowScrollbar", defaultValue: true, "If false, the scrollbar is permanently hidden even when the chat input is focused.", bool.TryParse);
			ConfEntry("Chat", "InputTextColor", Color.white, "Default color of text in the input field", (ParseConfigValue<Color>)ColorUtility.TryParseHtmlString, vanillaValue, hostControlled: false);
			ConfEntry("Fade Behaviour", "FadeOpacity", 0f, "The opacity of the chat when it fades from inactivity. 0.0 makes the chat fade away completely.", float.TryParse, 0.2f);
			ConfEntry("Fade Behaviour", "FadeTimeAfterMessage", 4f, "The amount of seconds before the chat fades out after a message is sent by another player.", float.TryParse, 4f);
			ConfEntry("Fade Behaviour", "FadeTimeAfterOwnMessage", 2f, "The amount of seconds before the chat fades out after a message is sent by you.", float.TryParse, 2f);
			ConfEntry("Fade Behaviour", "FadeTimeAfterUnfocused", 1f, "The amount of seconds before the chat fades out after the chat input is unfocused.", float.TryParse, 1f);
			ConfEntry("Compatibility", "GuiFadeFix", defaultValue: true, "Workaround to prevent other UI elements (like the indicator from LethalLoudnessMeter) from also fading out when the chat fades", bool.TryParse);
			ConfEntry("Compatibility", "SpectatorChatHideOtherHudElements", defaultValue: true, "For spectator chat, ensures that only the chat window is shown, and that irrelevant HUD elements (inventory/etc.) are hidden.", bool.TryParse);
		}

		private static bool NoopParse(string input, out string output)
		{
			output = input;
			return true;
		}

		private void ConfEntry<T>(string category, string name, T defaultValue, string description, ParseConfigValue<T> tryParse, bool hostControlled = false)
		{
			ConfEntryInternal(category, name, defaultValue, description, tryParse, hostControlled);
		}

		private void ConfEntry<T>(string category, string name, T defaultValue, string description, ParseConfigValue<T> tryParse, T vanillaValue, bool hostControlled = false)
		{
			ConfEntryInternal(category, name, defaultValue, description, tryParse, hostControlled, ConfEntryToString(vanillaValue));
		}

		private void ConfEntryInternal<T>(string category, string name, T defaultValue, string description, ParseConfigValue<T> tryParse, bool hostControlled = false, string? vanillaValueText = null)
		{
			ParseConfigValue<T> tryParse2 = tryParse;
			T defaultValue2 = defaultValue;
			PropertyInfo property = typeof(Plugin).GetProperty(name);
			string text = "[default: " + ConfEntryToString(defaultValue2) + "]\n" + description;
			text += (hostControlled ? "\n(This setting is overridden by the lobby host)" : "\n(This setting's effect applies to you only)");
			if (vanillaValueText != null)
			{
				text = text + "\n(The original value of this setting in the base-game is " + vanillaValueText + ")";
			}
			ConfigEntry<string> config = ((BaseUnityPlugin)this).Config.Bind<string>(category, name, "default", text);
			if (string.IsNullOrEmpty(config.Value))
			{
				config.Value = "default";
			}
			T output;
			bool flag = tryParse2(config.Value, out output) && config.Value != "default";
			property.SetValue(null, flag ? output : defaultValue2);
			if (!flag)
			{
				config.Value = "default";
			}
			EventHandler loadConfig = delegate
			{
				T output2;
				bool flag2 = tryParse2(config.Value, out output2) && config.Value != "default";
				property.SetValue(null, flag2 ? output2 : defaultValue2);
			};
			config.SettingChanged += loadConfig;
			cleanupActions.Add(delegate
			{
				config.SettingChanged -= loadConfig;
				property.SetValue(null, defaultValue2);
			});
		}

		private string ConfEntryToString(object? value)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (value == null)
			{
				return "null";
			}
			Type type = value.GetType();
			if (type == typeof(float))
			{
				return $"{(float)value:0.0#####}";
			}
			if (type == typeof(Color))
			{
				return "#" + ColorUtility.ToHtmlStringRGBA((Color)value);
			}
			return value.ToString();
		}
	}
	public static class ServerVars
	{
		public static ServerVar<int> characterLimit;

		public static ServerVar<bool> hearDeadPlayers;

		public static ServerVar<float> messageRange;

		public static ServerVar<string> modVersion;
	}
	[HarmonyPatch]
	internal class Patches
	{
		public class CustomFields
		{
			public DateTime? connectTime;

			public bool networkReady;

			public InputAction? shiftAction;

			public InputAction? scrollAction;

			public TMP_Text? chatText;

			public TMP_InputField? chatTextField;

			public TextMeshProUGUI? chatTextFieldGui;

			public float previousChatTextHeight;

			public float previousScrollPosition;

			public RectTransform? hudBottomLeftCorner;

			public RectTransform? chatContainer;

			public RectTransform? chatTextBgRect;

			public RectTransform? chatTextFieldRect;

			public RectTransform? chatTextRect;

			public RectTransform? scrollContainerRect;

			public CanvasGroup? scrollbarCanvasGroup;

			public ScrollRect? scroll;

			public Scrollbar? scrollbar;

			public Action? restoreHiddenHudElementsAction;

			public List<Action> cleanupActions = new List<Action>();
		}

		private record MessageContext(int senderId, bool walkie, bool senderDead);

		public static Dictionary<PlayerControllerB, CustomFields> fields = new Dictionary<PlayerControllerB, CustomFields>();

		public static (HUDElement, float originalOpacity)[] hiddenElements = new(HUDElement, float)[0];

		private static MethodInfo MethodInfo_GetChatMessageNameOpeningTag = typeof(Patches).GetMethod("GetChatMessageNameOpeningTag");

		private static MethodInfo MethodInfo_GetChatMessageNameClosingTag = typeof(Patches).GetMethod("GetChatMessageNameClosingTag");

		private static MethodInfo stringEqual = typeof(string).GetMethod("op_Equality", new Type[2]
		{
			typeof(string),
			typeof(string)
		});

		private static MessageContext? messageContext = null;

		private static MethodInfo MethodInfo_Vector3_Distance = typeof(Vector3).GetMethod("Distance");

		private static MethodInfo MethodInfo_CanHearPreflight = typeof(Patches).GetMethod("CanHearPreflight");

		private static float timeAtLastCheck = 0f;

		private static MethodInfo getCharacterLimit = typeof(Patches).GetMethod("GetCharacterLimit");

		private static FieldInfo FieldInfo_isPlayerDead = typeof(PlayerControllerB).GetField("isPlayerDead");

		private static bool IsLocalPlayer(PlayerControllerB __instance)
		{
			return (Object)(object)__instance == (Object)(object)StartOfRound.Instance?.localPlayerController;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		private static void Player_Awake(PlayerControllerB __instance)
		{
			reload(__instance);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void Player_Update(PlayerControllerB __instance)
		{
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_084f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_0869: Unknown result type (might be due to invalid IL or missing references)
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_088e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0898: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0503: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Expected O, but got Unknown
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_0764: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0900: Unknown result type (might be due to invalid IL or missing references)
			//IL_096e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0973: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a94: Unknown result type (might be due to invalid IL or missing references)
			reload(__instance);
			if (!IsLocalPlayer(__instance) || (Object)(object)HUDManager.Instance == (Object)null)
			{
				return;
			}
			CustomFields customFields = fields[__instance];
			if (__instance.isPlayerDead)
			{
				HUDManager hud = HUDManager.Instance;
				if (hud.HUDContainer.GetComponent<CanvasGroup>().alpha == 0f)
				{
					hud.HUDAnimator.SetTrigger("revealHud");
					hud.ClearControlTips();
				}
				if (Plugin.SpectatorChatHideOtherHudElements && customFields.restoreHiddenHudElementsAction == null)
				{
					HUDElement[] array = (HUDElement[])Traverse.Create((object)hud).Field("HUDElements").GetValue();
					Transform bottomMiddle = hud.HUDContainer.transform.Find("BottomMiddle");
					(HUDElement item, float)[] hudElementsAlphas = array.Select((HUDElement item) => (item, Mathf.Max(item.targetAlpha, item.canvasGroup.alpha))).ToArray();
					customFields.restoreHiddenHudElementsAction = delegate
					{
						(HUDElement, float)[] array3 = hudElementsAlphas;
						for (int j = 0; j < array3.Length; j++)
						{
							var (val12, num6) = array3[j];
							if (val12 != hud.Chat)
							{
								hud.PingHUDElement(val12, 0f, num6, num6);
							}
						}
						if ((Object)(object)bottomMiddle != (Object)null)
						{
							((Component)bottomMiddle).gameObject.SetActive(true);
						}
					};
					HUDElement[] array2 = array;
					foreach (HUDElement val in array2)
					{
						if (val != hud.Chat)
						{
							hud.PingHUDElement(val, 0f, 0f, 0f);
						}
					}
					if ((Object)(object)bottomMiddle != (Object)null)
					{
						((Component)bottomMiddle).gameObject.SetActive(false);
					}
				}
			}
			if (customFields.restoreHiddenHudElementsAction != null && (!__instance.isPlayerDead || !Plugin.SpectatorChatHideOtherHudElements))
			{
				customFields.restoreHiddenHudElementsAction();
				customFields.restoreHiddenHudElementsAction = null;
			}
			if ((Object)(object)customFields.chatTextField != (Object)null)
			{
				customFields.chatTextField.characterLimit = ServerVars.characterLimit.Value;
				customFields.chatTextField.lineLimit = 0;
				if (customFields.shiftAction != null && customFields.shiftAction.IsPressed())
				{
					customFields.chatTextField.lineType = (LineType)2;
				}
				else
				{
					customFields.chatTextField.lineType = (LineType)1;
				}
			}
			if ((Object)(object)customFields.chatText != (Object)null)
			{
				customFields.chatText.fontSize = Plugin.DefaultFontSize;
				if (customFields.chatText.text.Length > customFields.chatText.maxVisibleCharacters)
				{
					int num = customFields.chatText.maxVisibleCharacters / 10;
					while (customFields.chatText.text.Length > customFields.chatText.maxVisibleCharacters - num)
					{
						customFields.chatText.text = customFields.chatText.text.Remove(0, HUDManager.Instance.ChatMessageHistory[0].Length);
						HUDManager.Instance.ChatMessageHistory.RemoveAt(0);
					}
				}
			}
			if ((Object)(object)customFields.chatTextFieldGui != (Object)null)
			{
				((Graphic)customFields.chatTextFieldGui).color = Plugin.InputTextColor;
			}
			if (!((Object)(object)customFields.chatText != (Object)null) || !((Object)(object)customFields.chatTextRect != (Object)null) || !((Object)(object)customFields.chatTextBgRect != (Object)null) || !((Object)(object)customFields.chatTextFieldRect != (Object)null))
			{
				return;
			}
			if (Plugin.EnlargeChatWindow)
			{
				customFields.chatTextBgRect.anchorMin = new Vector2(0.35f, 0.5f);
				customFields.chatTextBgRect.anchorMax = new Vector2(0.8f, 0.5f);
				customFields.chatTextFieldRect.anchorMin = new Vector2(0.3f, 0.5f);
				customFields.chatTextFieldRect.anchorMax = new Vector2(0.8f, 0.5f);
			}
			else
			{
				customFields.chatTextBgRect.anchorMin = new Vector2(0.5f, 0.5f);
				customFields.chatTextBgRect.anchorMax = new Vector2(0.5f, 0.5f);
				customFields.chatTextFieldRect.anchorMin = new Vector2(0.5f, 0.5f);
				customFields.chatTextFieldRect.anchorMax = new Vector2(0.5f, 0.5f);
			}
			Rect rect;
			if ((Object)(object)customFields.scrollContainerRect == (Object)null)
			{
				Transform obj = ((Transform)customFields.chatTextBgRect).parent.Find("ChatScrollContainer");
				customFields.scrollContainerRect = ((obj != null) ? ((Component)obj).GetComponent<RectTransform>() : null);
				if ((Object)(object)customFields.scrollContainerRect == (Object)null)
				{
					GameObject val2 = new GameObject
					{
						name = "ChatScrollContainer"
					};
					customFields.scrollContainerRect = val2.AddComponent<RectTransform>();
					customFields.scrollContainerRect.anchorMin = Vector2.zero;
					customFields.scrollContainerRect.anchorMax = Vector2.one;
					customFields.scrollContainerRect.offsetMin = new Vector2(0f, 40f);
					customFields.scrollContainerRect.offsetMax = new Vector2(0f, -3f);
					((Transform)customFields.scrollContainerRect).SetParent((Transform)(object)customFields.chatTextBgRect, false);
					GameObject val3 = new GameObject
					{
						name = "ScrollMask"
					};
					RectTransform val4 = val3.AddComponent<RectTransform>();
					val3.AddComponent<Image>().sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0f, 0f));
					val3.AddComponent<Mask>().showMaskGraphic = false;
					((Transform)val4).SetParent((Transform)(object)customFields.scrollContainerRect, false);
					val4.anchorMin = Vector2.zero;
					val4.anchorMax = Vector2.one;
					val4.offsetMin = Vector2.zero;
					val4.offsetMax = Vector2.zero;
					((Transform)customFields.chatTextRect).SetParent((Transform)(object)val4, false);
					LayoutElement val5 = default(LayoutElement);
					((Component)customFields.chatText).gameObject.TryGetComponent<LayoutElement>(ref val5);
					Object.Destroy((Object)(object)val5);
					val5 = ((Component)customFields.chatText).gameObject.AddComponent<LayoutElement>();
					LayoutElement obj2 = val5;
					rect = val4.rect;
					obj2.minHeight = ((Rect)(ref rect)).height;
					customFields.chatText.alignment = (TextAlignmentOptions)1025;
					ContentSizeFitter val6 = default(ContentSizeFitter);
					((Component)customFields.chatText).gameObject.TryGetComponent<ContentSizeFitter>(ref val6);
					Object.Destroy((Object)(object)val6);
					ContentSizeFitter obj3 = ((Component)customFields.chatText).gameObject.AddComponent<ContentSizeFitter>();
					obj3.verticalFit = (FitMode)2;
					obj3.horizontalFit = (FitMode)0;
					customFields.scroll = val2.AddComponent<ScrollRect>();
					customFields.scroll.content = customFields.chatTextRect;
					customFields.scroll.viewport = val4;
					customFields.scroll.vertical = true;
					customFields.scroll.horizontal = false;
					customFields.scroll.verticalNormalizedPosition = 0f;
					GameObject val7 = new GameObject
					{
						name = "Scrollbar"
					};
					customFields.scrollbarCanvasGroup = val7.AddComponent<CanvasGroup>();
					RectTransform val8 = val7.AddComponent<RectTransform>();
					((Transform)val8).SetParent((Transform)(object)customFields.scrollContainerRect, false);
					val8.anchorMin = new Vector2(1f, 0f);
					val8.anchorMax = Vector2.one;
					val8.offsetMin = new Vector2(-7f, 0f);
					val8.offsetMax = new Vector2(-5f, -5f);
					customFields.scrollbar = val7.AddComponent<Scrollbar>();
					Image obj4 = val7.AddComponent<Image>();
					obj4.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0f, 0f));
					((Graphic)obj4).color = new Color(0.34509805f, 0.36862746f, 0.81960785f, 10f / 51f);
					GameObject val9 = new GameObject
					{
						name = "ScrollbarHandle"
					};
					RectTransform val10 = val9.AddComponent<RectTransform>();
					((Transform)val10).SetParent((Transform)(object)val8, false);
					val10.offsetMin = Vector2.zero;
					val10.offsetMax = Vector2.zero;
					Image obj5 = val9.AddComponent<Image>();
					obj5.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0f, 0f));
					((Graphic)obj5).color = Color.white;
					((Graphic)obj5).color = new Color(0.34509805f, 0.36862746f, 0.81960785f, 0.4392157f);
					customFields.scrollbar.handleRect = val10;
					customFields.scrollbar.direction = (Direction)2;
					customFields.scroll.verticalScrollbar = customFields.scrollbar;
				}
			}
			LayoutElement val11 = default(LayoutElement);
			((Component)customFields.chatText).gameObject.TryGetComponent<LayoutElement>(ref val11);
			if ((Object)(object)val11 != (Object)null)
			{
				RectTransform component = ((Component)((Transform)customFields.chatTextRect).parent).GetComponent<RectTransform>();
				LayoutElement obj6 = val11;
				rect = component.rect;
				obj6.minHeight = ((Rect)(ref rect)).height;
				RectTransform? chatTextRect = customFields.chatTextRect;
				rect = component.rect;
				chatTextRect.sizeDelta = new Vector2(((Rect)(ref rect)).width - 12f, customFields.chatTextRect.sizeDelta.y);
				((Transform)customFields.chatTextRect).localPosition = Vector2.op_Implicit(new Vector2(0f, ((Transform)customFields.chatTextRect).localPosition.y));
			}
			if (!((Object)(object)customFields.chatTextField != (Object)null))
			{
				return;
			}
			if (customFields.chatTextField.isFocused && customFields.scrollAction != null && (Object)(object)customFields.scroll != (Object)null)
			{
				float num2 = customFields.scrollAction.ReadValue<Vector2>().y / 120f;
				float num3 = num2;
				rect = customFields.chatTextRect.rect;
				num2 = num3 / ((Rect)(ref rect)).height;
				num2 *= 30f;
				ScrollRect? scroll = customFields.scroll;
				scroll.verticalNormalizedPosition += num2;
			}
			if (!((Object)(object)customFields.scroll != (Object)null) || !((Object)(object)customFields.scrollbar != (Object)null) || !((Object)(object)customFields.scrollbarCanvasGroup != (Object)null))
			{
				return;
			}
			float preferredHeight = customFields.chatText.preferredHeight;
			rect = customFields.scrollContainerRect.rect;
			if (preferredHeight < ((Rect)(ref rect)).height)
			{
				((Graphic)((Component)customFields.scrollbar.handleRect).GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
			}
			else
			{
				((Graphic)((Component)customFields.scrollbar.handleRect).GetComponent<Image>()).color = new Color(0.34509805f, 0.36862746f, 0.81960785f, 0.4392157f);
			}
			if (customFields.chatTextField.isFocused)
			{
				HUDManager.Instance.Chat.targetAlpha = 1f;
				rect = customFields.chatTextRect.rect;
				if (((Rect)(ref rect)).height != customFields.previousChatTextHeight)
				{
					if (customFields.chatTextField.isFocused)
					{
						float verticalNormalizedPosition = customFields.scroll.verticalNormalizedPosition;
						rect = customFields.chatTextRect.rect;
						if (verticalNormalizedPosition >= 100f / ((Rect)(ref rect)).height)
						{
							float num4 = (1f - customFields.previousScrollPosition) * customFields.previousChatTextHeight;
							rect = customFields.chatTextRect.rect;
							float num5 = ((Rect)(ref rect)).height - num4;
							ScrollRect? scroll2 = customFields.scroll;
							rect = customFields.chatTextRect.rect;
							scroll2.verticalNormalizedPosition = num5 / ((Rect)(ref rect)).height;
							goto IL_0ab5;
						}
					}
					customFields.scroll.verticalNormalizedPosition = 0f;
					goto IL_0ab5;
				}
			}
			else
			{
				customFields.scroll.verticalNormalizedPosition = 0f;
			}
			goto IL_0ae1;
			IL_0ae1:
			customFields.scrollbarCanvasGroup.alpha = ((Plugin.ShowScrollbar && customFields.chatTextField.isFocused) ? 1f : 0f);
			customFields.previousScrollPosition = customFields.scroll.verticalNormalizedPosition;
			return;
			IL_0ab5:
			rect = customFields.chatTextRect.rect;
			customFields.previousChatTextHeight = ((Rect)(ref rect)).height;
			goto IL_0ae1;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "OnDestroy")]
		[HarmonyPostfix]
		private static void OnDestroy(PlayerControllerB __instance)
		{
			if (IsLocalPlayer(__instance) && fields.ContainsKey(__instance))
			{
				foreach (Action cleanupAction in fields[__instance].cleanupActions)
				{
					cleanupAction();
				}
			}
			fields.Remove(__instance);
		}

		private static void reload(PlayerControllerB __instance)
		{
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			CustomFields f;
			if (!fields.ContainsKey(__instance))
			{
				fields[__instance] = new CustomFields();
				f = fields[__instance];
				f.cleanupActions.Add(delegate
				{
					if (f.restoreHiddenHudElementsAction != null)
					{
						f.restoreHiddenHudElementsAction();
					}
				});
			}
			else
			{
				f = fields[__instance];
			}
			if (!IsLocalPlayer(__instance))
			{
				return;
			}
			if ((Object)(object)f.hudBottomLeftCorner == (Object)null)
			{
				ref RectTransform? hudBottomLeftCorner = ref f.hudBottomLeftCorner;
				Transform obj = HUDManager.Instance.HUDContainer.transform.Find("BottomLeftCorner");
				hudBottomLeftCorner = (RectTransform?)(object)((obj is RectTransform) ? obj : null);
			}
			if (((NetworkBehaviour)__instance).NetworkManager.IsConnectedClient && ((NetworkBehaviour)__instance).NetworkManager.IsServer)
			{
				ServerVars.characterLimit.Value = Plugin.CharacterLimit;
				ServerVars.modVersion.Value = "1.2.7";
				ServerVars.hearDeadPlayers.Value = Plugin.HearDeadPlayers;
				ServerVars.messageRange.Value = Plugin.MessageRange;
			}
			if ((Object)(object)f.chatTextField == (Object)null)
			{
				f.chatTextField = HUDManager.Instance?.chatTextField;
			}
			if ((Object)(object)f.chatText == (Object)null)
			{
				f.chatText = (TMP_Text?)(object)HUDManager.Instance?.chatText;
			}
			if ((Object)(object)f.chatTextFieldRect == (Object)null && (Object)(object)f.chatTextField != (Object)null)
			{
				((Component)f.chatTextField).TryGetComponent<RectTransform>(ref f.chatTextFieldRect);
			}
			if ((Object)(object)f.chatTextFieldGui == (Object)null && (Object)(object)f.chatTextField != (Object)null)
			{
				CustomFields customFields = f;
				Transform obj2 = ((Component)f.chatTextField).transform.Find("Text Area/Text");
				customFields.chatTextFieldGui = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
			}
			if ((Object)(object)f.chatTextRect == (Object)null && (Object)(object)f.chatText != (Object)null)
			{
				((Component)f.chatText).TryGetComponent<RectTransform>(ref f.chatTextRect);
			}
			if ((Object)(object)f.chatTextBgRect == (Object)null && (Object)(object)f.chatTextField != (Object)null)
			{
				Transform obj3 = ((Component)f.chatTextField).transform.parent.Find("Image");
				if (obj3 != null)
				{
					((Component)obj3).TryGetComponent<RectTransform>(ref f.chatTextBgRect);
				}
			}
			if (f.shiftAction == null)
			{
				f.shiftAction = __instance.playerActions.FindAction("taffyko.NiceChat.Shift", false);
				if (f.shiftAction == null)
				{
					__instance.playerActions.Disable();
					MovementActions movement = __instance.playerActions.Movement;
					f.shiftAction = InputActionSetupExtensions.AddAction(MovementActions.op_Implicit(movement), "taffyko.NiceChat.Shift", (InputActionType)1, ((InputControl)Keyboard.current.shiftKey).path, (string)null, (string)null, (string)null, (string)null);
					__instance.playerActions.Enable();
				}
				InputAction? shiftAction = f.shiftAction;
				if (shiftAction != null)
				{
					shiftAction.Enable();
				}
			}
			if (f.scrollAction == null)
			{
				f.scrollAction = __instance.playerActions.FindAction("taffyko.NiceChat.Scroll", false);
				if (f.scrollAction == null)
				{
					__instance.playerActions.Disable();
					MovementActions movement2 = __instance.playerActions.Movement;
					f.scrollAction = InputActionSetupExtensions.AddAction(MovementActions.op_Implicit(movement2), "taffyko.NiceChat.Scroll", (InputActionType)0, ((InputControl)Mouse.current.scroll).path, (string)null, (string)null, (string)null, (string)null);
					__instance.playerActions.Enable();
				}
			}
			if (Plugin.GuiFadeFix)
			{
				if ((Object)(object)f.chatContainer == (Object)null)
				{
					GameObject val = new GameObject("taffyko.NiceChat.ChatContainer");
					f.chatContainer = val.AddComponent<RectTransform>();
					val.AddComponent<CanvasGroup>();
					((Transform)f.chatContainer).SetParent((Transform)(object)f.hudBottomLeftCorner, false);
				}
				RectTransform? chatTextFieldRect = f.chatTextFieldRect;
				if ((Object)(object)((chatTextFieldRect != null) ? ((Transform)chatTextFieldRect).parent : null) != (Object)(object)f.chatContainer)
				{
					RectTransform? chatTextFieldRect2 = f.chatTextFieldRect;
					if (chatTextFieldRect2 != null)
					{
						((Transform)chatTextFieldRect2).SetParent((Transform)(object)f.chatContainer);
					}
					RectTransform? chatTextBgRect = f.chatTextBgRect;
					if (chatTextBgRect != null)
					{
						((Transform)chatTextBgRect).SetParent((Transform)(object)f.chatContainer);
					}
					HUDManager.Instance.Chat.canvasGroup = ((Component)f.chatContainer).GetComponent<CanvasGroup>();
					((Component)f.hudBottomLeftCorner).GetComponent<CanvasGroup>().alpha = 1f;
				}
				return;
			}
			RectTransform? chatTextFieldRect3 = f.chatTextFieldRect;
			if ((Object)(object)((chatTextFieldRect3 != null) ? ((Transform)chatTextFieldRect3).parent : null) != (Object)(object)f.hudBottomLeftCorner)
			{
				RectTransform? chatTextFieldRect4 = f.chatTextFieldRect;
				if (chatTextFieldRect4 != null)
				{
					((Transform)chatTextFieldRect4).SetParent((Transform)(object)f.hudBottomLeftCorner);
				}
				RectTransform? chatTextBgRect2 = f.chatTextBgRect;
				if (chatTextBgRect2 != null)
				{
					((Transform)chatTextBgRect2).SetParent((Transform)(object)f.hudBottomLeftCorner);
				}
				HUDManager.Instance.Chat.canvasGroup = ((Component)f.hudBottomLeftCorner).GetComponent<CanvasGroup>();
			}
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool SubmitChat_performed_Prefix()
		{
			InputAction? shiftAction = fields[StartOfRound.Instance.localPlayerController].shiftAction;
			if (shiftAction == null)
			{
				return true;
			}
			return !shiftAction.IsPressed();
		}

		[HarmonyPatch(typeof(HUDManager), "PingHUDElement")]
		[HarmonyPrefix]
		private static void PingHUDElementPrefix(HUDElement element, ref float delay, float startAlpha, ref float endAlpha)
		{
			if (element != null && element == HUDManager.Instance?.Chat)
			{
				endAlpha = Plugin.FadeOpacity;
				if (delay == 4f)
				{
					delay = Plugin.FadeTimeAfterMessage;
				}
				else if (delay == 2f)
				{
					delay = Plugin.FadeTimeAfterOwnMessage;
				}
				else if (delay == 1f)
				{
					delay = Plugin.FadeTimeAfterUnfocused;
				}
			}
		}

		public static string GetChatMessageNameOpeningTag()
		{
			string text = "#FF0000";
			string text2 = "";
			if (Plugin.EnableTimestamps && TimeOfDay.Instance.currentDayTimeStarted && (Object)(object)HUDManager.Instance?.clockNumber != (Object)null && ((((UIBehaviour)HUDManager.Instance.clockNumber).IsActive() && HUDManager.Instance.Clock.targetAlpha > 0f) || StartOfRound.Instance.localPlayerController.isPlayerDead))
			{
				text2 = text2 + "<color=#7069ff>[" + ((TMP_Text)HUDManager.Instance.clockNumber).text.Replace("\n", "") + "] </color>";
			}
			if (!(messageContext != null))
			{
				goto IL_010c;
			}
			if (messageContext.senderDead)
			{
				text2 += "<color=#878787>";
				if (Plugin.TagMessageStatus)
				{
					text2 += "*DEAD* ";
				}
			}
			else
			{
				if (!messageContext.walkie)
				{
					goto IL_010c;
				}
				text2 += "<color=#00AA00>";
				if (Plugin.TagMessageStatus)
				{
					text2 += "*WALKIE* ";
				}
			}
			goto IL_011e;
			IL_011e:
			messageContext = null;
			return text2;
			IL_010c:
			text2 = text2 + "<color=" + text + ">";
			goto IL_011e;
		}

		public static string GetChatMessageNameClosingTag()
		{
			return "</color>: <color=#FFFF00>";
		}

		public static bool _HelperMessageSentByLocalPlayer(HUDManager instance, string chatMessage, int playerId)
		{
			if ((int)Traverse.Create((object)instance).Field("__rpc_exec_stage").GetValue() == 2 && playerId >= 0 && playerId < StartOfRound.Instance.allPlayerScripts.Length && IsLocalPlayer(StartOfRound.Instance.allPlayerScripts[playerId]))
			{
				return true;
			}
			return false;
		}

		[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> transpiler_AddPlayerChatMessageClientRpc(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
			yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null);
			yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null);
			yield return new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("_HelperMessageSentByLocalPlayer"));
			Label label = generator.DefineLabel();
			CodeInstruction nopInstruction = new CodeInstruction(OpCodes.Nop, (object)null);
			nopInstruction.labels.Add(label);
			CodeInstruction retInstruction = new CodeInstruction(OpCodes.Ret, (object)null);
			yield return new CodeInstruction(OpCodes.Brfalse, (object)label);
			yield return retInstruction;
			yield return nopInstruction;
			foreach (CodeInstruction instruction in instructions)
			{
				yield return instruction;
			}
		}

		private static bool PlayerCanHearMessage(int senderId, int recipientId, out MessageContext? messageContext)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			messageContext = null;
			if (senderId < 0)
			{
				return true;
			}
			if ((Object)(object)HUDManager.Instance == (Object)null)
			{
				return true;
			}
			if (HUDManager.Instance.playersManager.allPlayerScripts.Length <= senderId || HUDManager.Instance.playersManager.allPlayerScripts.Length <= recipientId)
			{
				return true;
			}
			PlayerControllerB val = HUDManager.Instance.playersManager.allPlayerScripts[senderId];
			PlayerControllerB val2 = HUDManager.Instance.playersManager.allPlayerScripts[recipientId];
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return true;
			}
			bool flag = val.holdingWalkieTalkie && val2.holdingWalkieTalkie;
			messageContext = new MessageContext(senderId, flag, val.isPlayerDead);
			if (val2.isPlayerDead)
			{
				return true;
			}
			if (val.isPlayerDead)
			{
				if (ServerVars.hearDeadPlayers.Value || val2.isPlayerDead)
				{
					return true;
				}
				return false;
			}
			if (flag)
			{
				return true;
			}
			if (Vector3.Distance(((Component)val).transform.position, ((Component)val2).transform.position) <= ServerVars.messageRange.Value)
			{
				return true;
			}
			return false;
		}

		public static bool RecipientCanHear(int recipientId)
		{
			if (StartOfRound.Instance.localPlayerController.isPlayerDead)
			{
				return true;
			}
			MessageContext messageContext;
			return PlayerCanHearMessage((int)StartOfRound.Instance.localPlayerController.playerClientId, recipientId, out messageContext);
		}

		public static bool CanHearPreflight(int senderId)
		{
			MessageContext messageContext;
			bool num = PlayerCanHearMessage(senderId, (int)StartOfRound.Instance.localPlayerController.playerClientId, out messageContext);
			if (num)
			{
				Patches.messageContext = messageContext;
			}
			return num;
		}

		[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> transpiler_CanHearMessageOverride(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			bool deadCheckFound = false;
			bool distanceCheckFound = false;
			using IEnumerator<CodeInstruction> e = instructions.GetEnumerator();
			while (e.MoveNext())
			{
				if (!deadCheckFound && e.Current.opcode == OpCodes.Ldfld && (FieldInfo)e.Current.operand == FieldInfo_isPlayerDead)
				{
					deadCheckFound = true;
					for (int i = 0; i < 5; i++)
					{
						yield return e.Current;
						e.MoveNext();
					}
					yield return new CodeInstruction(OpCodes.Nop, (object)null);
					e.MoveNext();
				}
				else if (!distanceCheckFound && e.Current.opcode == OpCodes.Call && (MethodInfo)e.Current.operand == MethodInfo_Vector3_Distance)
				{
					distanceCheckFound = true;
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					for (int j = 0; j < 4; j++)
					{
						e.MoveNext();
					}
					yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)MethodInfo_CanHearPreflight);
				}
				yield return e.Current;
			}
		}

		public static bool _ShouldSuppressDuplicateMessage(string message, string senderName)
		{
			float num = Time.fixedUnscaledTime - timeAtLastCheck;
			timeAtLastCheck = Time.fixedUnscaledTime;
			if (string.IsNullOrEmpty(senderName))
			{
				return true;
			}
			if (num >= 0f && num < 0.1f)
			{
				return true;
			}
			return false;
		}

		public static int _GetMaxMessageCount()
		{
			return Plugin.MaxMessageHistory;
		}

		[HarmonyPatch(typeof(HUDManager), "AddChatMessage")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> transpiler_AddChatMessage(IEnumerable<CodeInstruction> instructions)
		{
			bool foundMaxMessageCount = false;
			bool foundPreviousMessageComparison = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!foundMaxMessageCount && instruction.opcode == OpCodes.Ldc_I4_4)
				{
					yield return new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("_GetMaxMessageCount"));
					foundMaxMessageCount = true;
					continue;
				}
				if (!foundPreviousMessageComparison && instruction.opcode == OpCodes.Call && instruction.operand == stringEqual)
				{
					foundPreviousMessageComparison = true;
					yield return instruction;
					yield return new CodeInstruction(OpCodes.Ldarg_1, (object)null);
					yield return new CodeInstruction(OpCodes.Ldarg_2, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("_ShouldSuppressDuplicateMessage"));
					yield return new CodeInstruction(OpCodes.And, (object)null);
					continue;
				}
				if (instruction.opcode == OpCodes.Ldstr)
				{
					switch ((string)instruction.operand)
					{
					case "<color=#FF0000>":
						yield return new CodeInstruction(OpCodes.Call, (object)MethodInfo_GetChatMessageNameOpeningTag);
						continue;
					case "</color>: <color=#FFFF00>'":
						yield return new CodeInstruction(OpCodes.Call, (object)MethodInfo_GetChatMessageNameClosingTag);
						continue;
					case "'</color>":
						yield return new CodeInstruction(OpCodes.Ldstr, (object)"</color>");
						continue;
					}
				}
				yield return instruction;
			}
		}

		public static int GetCharacterLimit()
		{
			return Plugin.CharacterLimit + 1;
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyPatch(typeof(HUDManager), "EnableChat_performed")]
		[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageServerRpc")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> transpiler_GeneralOverrides(IEnumerable<CodeInstruction> instructions)
		{
			bool foundCharacterLimit = false;
			bool foundPlayerDeadCheck = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!foundCharacterLimit && instruction.opcode == OpCodes.Ldc_I4_S)
				{
					if ((sbyte)instruction.operand == 50)
					{
						foundCharacterLimit = true;
						yield return new CodeInstruction(OpCodes.Call, (object)getCharacterLimit);
						continue;
					}
				}
				else if (!foundPlayerDeadCheck && instruction.opcode == OpCodes.Ldfld && (FieldInfo)instruction.operand == FieldInfo_isPlayerDead)
				{
					foundPlayerDeadCheck = true;
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
					continue;
				}
				yield return instruction;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "SubmitChat_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> transpiler_SubmitChat_performed(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			bool distanceCheckFound = false;
			using IEnumerator<CodeInstruction> e = instructions.GetEnumerator();
			while (e.MoveNext())
			{
				if (!distanceCheckFound && e.Current.opcode == OpCodes.Call && (MethodInfo)e.Current.operand == MethodInfo_Vector3_Distance)
				{
					distanceCheckFound = true;
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
					for (int i = 0; i < 12; i++)
					{
						e.MoveNext();
					}
					yield return new CodeInstruction(OpCodes.Ldloc_0, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)typeof(Patches).GetMethod("RecipientCanHear"));
				}
				yield return e.Current;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "AddTextToChatOnServer")]
		[HarmonyPrefix]
		private static void AddTextToChatOnServer_Prefix(HUDManager __instance, int playerId)
		{
			if (playerId >= 0 && playerId < StartOfRound.Instance.allPlayerScripts.Length && IsLocalPlayer(StartOfRound.Instance.allPlayerScripts[playerId]))
			{
				CanHearPreflight(playerId);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NiceChat";

		public const string PLUGIN_NAME = "NiceChat";

		public const string PLUGIN_VERSION = "1.2.7";
	}
}
namespace System.Runtime.CompilerServices
{
	internal static class IsExternalInit
	{
	}
	internal class RequiredMemberAttribute : Attribute
	{
	}
	internal class CompilerFeatureRequiredAttribute : Attribute
	{
		public CompilerFeatureRequiredAttribute(string name)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	public sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
}

BepInEx/plugins/OpoloScrap/OpoloScrapItem.dll

Decompiled 5 hours 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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("OpoloScrapItem")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A scrap item in the shape of Opolo the Wyvern!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OpoloScrapItem")]
[assembly: AssemblyTitle("OpoloScrapItem")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OpoloScrapItem
{
	[BepInPlugin("OpoloScrapItem", "OpoloScrapItem", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static AssetBundle Assets;

		private int opoRarity = 30;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin OpoloScrapItem is loaded!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "opoloscrapbundle"));
			if ((Object)(object)Assets == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"OpoloScrapItem could not load its required Assets.");
			}
			Item val = Assets.LoadAsset<Item>("assets/opoloscrap.asset");
			((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)val).name);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, opoRarity, (LevelTypes)(-1));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OpoloScrapItem";

		public const string PLUGIN_NAME = "OpoloScrapItem";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

BepInEx/plugins/PersistentPurchases.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UIElements.Collections;

[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("PersistentPurchases")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Keeps bought ship objects after failing to meet quota")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("PersistentPurchases")]
[assembly: AssemblyTitle("PersistentPurchases")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PersistentPurchases
{
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPriority(-23)]
		public static void generateConfig()
		{
			Plugin.setupConfig(StartOfRound.Instance.unlockablesList.unlockables);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		public static void storeUnlocked(StartOfRound __instance, out List<Tuple<int, Vector3, Vector3>> __state)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			Plugin.log.LogInfo((object)"Taking note of bought unlockables");
			__state = new List<Tuple<int, Vector3, Vector3>>();
			List<UnlockableItem> unlockables = __instance.unlockablesList.unlockables;
			for (int i = 0; i < unlockables.Count; i++)
			{
				Plugin.log.LogDebug((object)$"{unlockables[i].unlockableName} - unlocked({unlockables[i].hasBeenUnlockedByPlayer}) - should persist({Plugin.unlockableConfig[i].Value})");
				if (unlockables[i].hasBeenUnlockedByPlayer && Plugin.unlockableConfig[i].Value)
				{
					__state.Add(Tuple.Create<int, Vector3, Vector3>(i, unlockables[i].placedPosition, unlockables[i].placedRotation));
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		public static void loadUnlocked(StartOfRound __instance, List<Tuple<int, Vector3, Vector3>> __state)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			Plugin.log.LogInfo((object)"Rebuying unlockables");
			foreach (Tuple<int, Vector3, Vector3> item in __state)
			{
				Plugin.log.LogDebug((object)__instance.unlockablesList.unlockables[item.Item1].unlockableName);
				UnlockableItem val = __instance.unlockablesList.unlockables[item.Item1];
				__instance.BuyShipUnlockableServerRpc(item.Item1, TimeOfDay.Instance.quotaVariables.startingCredits);
				if (__instance.SpawnedShipUnlockables.ContainsKey(item.Item1))
				{
					NetworkObject component = DictionaryExtensions.Get<int, GameObject>((IDictionary<int, GameObject>)__instance.SpawnedShipUnlockables, item.Item1, (GameObject)null).GetComponent<NetworkObject>();
					if ((Object)(object)component != (Object)null)
					{
						ShipBuildModeManager.Instance.StoreObjectServerRpc(NetworkObjectReference.op_Implicit(component), 0);
					}
					else
					{
						Plugin.log.LogWarning((object)("Failed to find NetworkObject for " + val.unlockableName));
					}
				}
				else
				{
					Plugin.log.LogWarning((object)("SpawnedShipUnlockables did not contain " + val.unlockableName));
				}
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
	public class RemoveUneccesaryAndAnnoyingReset
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			Plugin.log.LogInfo((object)"Beginning patching of GameNetworkManager.ResetSavedGameValues");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], typeof(GameNetworkManager).GetMethod("ResetUnlockablesListValues")))
				{
					flag = true;
					list[i - 1].opcode = OpCodes.Nop;
					list[i].opcode = OpCodes.Nop;
					list[i].operand = null;
					break;
				}
			}
			if (flag)
			{
				Plugin.log.LogInfo((object)"Patched GameNetworkManager.ResetSavedGameValues");
			}
			else
			{
				Plugin.log.LogError((object)"Failed to patch GameNetworkManager.ResetSavedGameValues!");
			}
			return list.AsEnumerable();
		}
	}
	[BepInPlugin("PersistentPurchases", "PersistentPurchases", "1.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<bool> placeUnlockables;

		public static ManualLogSource log = new ManualLogSource("PersistentPurchases");

		public static Harmony harmony = new Harmony("PersistentPurchases");

		public static string[] knownFurniture = new string[19]
		{
			"Cozy lights", "Television", "Cupboard", "File Cabinet", "Toilet", "Shower", "Light switch", "Record player", "Table", "Bunkbeds",
			"Terminal", "Romantic table", "JackOLantern", "Welcome mat", "Goldfish", "Plushie pajama man", "SmallRug", "LargeRug", "FatalitiesSign"
		};

		public static List<ConfigFile> despair = new List<ConfigFile>();

		public static List<ConfigEntry<bool>> unlockableConfig = new List<ConfigEntry<bool>>();

		private void Awake()
		{
			Logger.Sources.Add((ILogSource)(object)log);
			despair.Add(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(Patches));
			harmony.PatchAll(typeof(RemoveUneccesaryAndAnnoyingReset));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin PersistentPurchases is loaded!");
		}

		public static void setupConfig(List<UnlockableItem> unlockables)
		{
			log.LogInfo((object)$"Registering {unlockables.Count} unlockables");
			for (int i = 0; i < unlockables.Count; i++)
			{
				log.LogDebug((object)(unlockables[i].unlockableName ?? ""));
				unlockableConfig.Add(despair[0].Bind<bool>("Unlockables", unlockables[i].unlockableName, unlockables[i].unlockableType == 0 || knownFurniture.Contains(unlockables[i].unlockableName), (ConfigDescription)null));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PersistentPurchases";

		public const string PLUGIN_NAME = "PersistentPurchases";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}

BepInEx/plugins/Scraps64/SM64Scrap.dll

Decompiled 5 hours 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 HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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("SM64Scrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SM64Scrap")]
[assembly: AssemblyTitle("SM64Scrap")]
[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 SM64Scrap
{
	[BepInPlugin("SM64Scrap", "SM64 Scrap", "2.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "SM64Scrap";

		private const string NAME = "SM64 Scrap";

		private const string VERSION = "2.2.0";

		private ConfigEntry<int> configStarSpawnWeight;

		private ConfigEntry<LevelTypes> configStarMoonSpawns;

		private ConfigEntry<int> configCoinSpawnWeight;

		private ConfigEntry<LevelTypes> configCoinMoonSpawns;

		private ConfigEntry<int> configBlueCoinSpawnWeight;

		private ConfigEntry<LevelTypes> configBlueCoinMoonSpawns;

		private ConfigEntry<int> configRedCoinSpawnWeight;

		private ConfigEntry<LevelTypes> configRedCoinMoonSpawns;

		private ConfigEntry<int> configBlockSpawnWeight;

		private ConfigEntry<LevelTypes> configBlockMoonSpawns;

		private ConfigEntry<int> configMIPSSpawnWeight;

		private ConfigEntry<LevelTypes> configMIPSMoonSpawns;

		private ConfigEntry<int> configBobOmbSpawnWeight;

		private ConfigEntry<LevelTypes> configBobOmbMoonSpawns;

		private ConfigEntry<int> configOneUpSpawnWeight;

		private ConfigEntry<LevelTypes> configOneUpMoonSpawns;

		private ConfigEntry<int> configCapSpawnWeight;

		private ConfigEntry<LevelTypes> configCapMoonSpawns;

		private ConfigEntry<int> configBowserKeySpawnWeight;

		private ConfigEntry<LevelTypes> configBowserKeyMoonSpawns;

		private ConfigEntry<int> configShellSpawnWeight;

		private ConfigEntry<LevelTypes> configShellMoonSpawns;

		private ConfigEntry<int> configSM64PaintingsSpawnWeight;

		private ConfigEntry<LevelTypes> configSM64PaintingsMoonSpawns;

		public static Plugin instance;

		private void Awake()
		{
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			configStarSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Star", "Spawn Weight", 15, "How many Power Stars will appear (higher value = more spawns)");
			configStarMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Star", "Spawn Locations", (LevelTypes)15356, "Choose which moons the Power Star will spawn on");
			configCoinSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Coin", "Spawn Weight", 45, "How many Coins will appear (higher value = more spawns)");
			configCoinMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Coin", "Spawn Locations", (LevelTypes)15356, "Choose which moons Coins will spawn on");
			configBlueCoinSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Blue Coin", "Spawn Weight", 30, "How many Blue Coins will appear (higher value = more spawns)");
			configBlueCoinMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Blue Coin", "Spawn Locations", (LevelTypes)15356, "Choose which moons Blue Coins will spawn on");
			configRedCoinSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Red Coin", "Spawn Weight", 35, "How many Red Coins will appear (higher value = more spawns)");
			configRedCoinMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Red Coin", "Spawn Locations", (LevelTypes)15356, "Choose which moons Red Coins will spawn on");
			configBlockSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Red ? Block", "Spawn Weight", 25, "How many Red ? Blocks will appear (higher value = more spawns)");
			configBlockMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Red ? Block", "Spawn Locations", (LevelTypes)15356, "Choose which moons Red ? Blocks will spawn on");
			configBobOmbSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Bob-Omb", "Spawn Weight", 20, "How many Bob-Ombs will appear (higher value = more spawns)");
			configBobOmbMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Bob-Omb", "Spawn Locations", (LevelTypes)15356, "Choose which moons Bob-Ombs will spawn on");
			configCapSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Marios Cap", "Spawn Weight", 10, "How many of Mario's Cap will appear (higher value = more spawns)");
			configCapMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Marios Cap", "Spawn Locations", (LevelTypes)15356, "Choose which moons Mario's Cap will spawn on");
			configMIPSSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("MIPS", "Spawn Weight", 5, "How many MIPS will appear (higher value = more spawns)");
			configMIPSMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("MIPS", "Spawn Locations", (LevelTypes)15356, "Choose which moons MIPS will spawn on");
			configBowserKeySpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Bowser Key", "Spawn Weight", 10, "How many Bowser Keys will appear (higher value = more spawns)");
			configBowserKeyMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Bowser Key", "Spawn Locations", (LevelTypes)15356, "Choose which moons Bowser Keys will spawn on");
			configOneUpSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("1-Up", "Spawn Weight", 32, "How many 1-Up's will appear (higher value = more spawns)");
			configOneUpMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("1-Up", "Spawn Locations", (LevelTypes)15356, "Choose which moons 1-Up's will spawn on");
			configShellSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Koopa Shell", "Spawn Weight", 38, "How many Koopa Shells will appear (higher value = more spawns)");
			configShellMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Koopa Shell", "Spawn Locations", (LevelTypes)15356, "Choose which moons Koopa Shells will spawn on");
			configSM64PaintingsSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Paintings", "Spawn Weight", 15, "How many paintings will appear (higher value = more spawns)");
			configSM64PaintingsMoonSpawns = ((BaseUnityPlugin)this).Config.Bind<LevelTypes>("Paintings", "Spawn Locations", (LevelTypes)15356, "Choose which moons paintings will spawn on");
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sm64scrap");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Item val2 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Star/StarItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, configStarSpawnWeight.Value, configStarMoonSpawns.Value);
			Item val3 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Coins/CoinItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
			Utilities.FixMixerGroups(val3.spawnPrefab);
			Items.RegisterScrap(val3, configCoinSpawnWeight.Value, configCoinMoonSpawns.Value);
			Item val4 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Coins/RedCoinItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
			Utilities.FixMixerGroups(val4.spawnPrefab);
			Items.RegisterScrap(val4, configRedCoinSpawnWeight.Value, configRedCoinMoonSpawns.Value);
			Item val5 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Coins/BlueCoinItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val5.spawnPrefab);
			Utilities.FixMixerGroups(val5.spawnPrefab);
			Items.RegisterScrap(val5, configBlueCoinSpawnWeight.Value, configBlueCoinMoonSpawns.Value);
			Item val6 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Shell/ShellItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val6.spawnPrefab);
			Utilities.FixMixerGroups(val6.spawnPrefab);
			Items.RegisterScrap(val6, configShellSpawnWeight.Value, configShellMoonSpawns.Value);
			Item val7 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Q_Block/QBlockItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val7.spawnPrefab);
			Utilities.FixMixerGroups(val7.spawnPrefab);
			Items.RegisterScrap(val7, configBlockSpawnWeight.Value, configBlockMoonSpawns.Value);
			Item val8 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/bob-omb/BobOmbItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val8.spawnPrefab);
			Utilities.FixMixerGroups(val8.spawnPrefab);
			Items.RegisterScrap(val8, configBobOmbSpawnWeight.Value, configBobOmbMoonSpawns.Value);
			Item val9 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Cap/CapItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val9.spawnPrefab);
			Utilities.FixMixerGroups(val9.spawnPrefab);
			Items.RegisterScrap(val9, configCapSpawnWeight.Value, configCapMoonSpawns.Value);
			Item val10 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/MIPS/MIPSItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val10.spawnPrefab);
			Utilities.FixMixerGroups(val10.spawnPrefab);
			Items.RegisterScrap(val10, configMIPSSpawnWeight.Value, configMIPSMoonSpawns.Value);
			Item val11 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/1Up/OneUpItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val11.spawnPrefab);
			Utilities.FixMixerGroups(val11.spawnPrefab);
			Items.RegisterScrap(val11, configOneUpSpawnWeight.Value, configOneUpMoonSpawns.Value);
			Item val12 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/BowserKey/BowserKeyItem.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val12.spawnPrefab);
			Utilities.FixMixerGroups(val12.spawnPrefab);
			Items.RegisterScrap(val12, configBowserKeySpawnWeight.Value, configBowserKeyMoonSpawns.Value);
			Item val13 = val.LoadAsset<Item>("Assets/LethalCompany/Mods/Scrap/Paintings/FancyPaintingSM64.asset");
			NetworkPrefabs.RegisterNetworkPrefab(val13.spawnPrefab);
			Utilities.FixMixerGroups(val13.spawnPrefab);
			Items.RegisterScrap(val13, configSM64PaintingsSpawnWeight.Value, configSM64PaintingsMoonSpawns.Value);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "SM64Scrap");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded SM64 Scrap");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SM64Scrap";

		public const string PLUGIN_NAME = "SM64Scrap";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace SM64Scrap.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	public class ExampleTVPatch
	{
		[HarmonyPatch("SwitchTVLocalClient")]
		[HarmonyPrefix]
		private static void SwitchTVPrefix(TVScript __instance)
		{
			StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(__instance.tvOn);
		}
	}
}

BepInEx/plugins/ShipLoot.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ShipLoot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("ShipLoot")]
[assembly: AssemblyCopyright("Copyright © tinyhoot 2023")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace ShipLoot
{
	[BepInPlugin("com.github.tinyhoot.ShipLoot", "ShipLoot", "1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class ShipLoot : BaseUnityPlugin
	{
		public const string GUID = "com.github.tinyhoot.ShipLoot";

		public const string NAME = "ShipLoot";

		public const string VERSION = "1.1";

		internal static ShipLootConfig Config;

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Config = new ShipLootConfig(((BaseUnityPlugin)this).Config);
			Config.RegisterOptions();
			new Harmony("com.github.tinyhoot.ShipLoot").PatchAll(Assembly.GetExecutingAssembly());
		}

		private void Start()
		{
			SetLobbyCompatibility();
		}

		private void SetLobbyCompatibility()
		{
			if (!Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				return;
			}
			MethodInfo methodInfo = AccessTools.Method("LobbyCompatibility.Features.PluginHelper:RegisterPlugin", (Type[])null, (Type[])null);
			if ((object)methodInfo == null)
			{
				Log.LogWarning((object)"Found LobbyCompatibility mod but failed to find plugin register API method!");
				return;
			}
			Log.LogDebug((object)"Registering compatibility with LobbyCompatibility.");
			try
			{
				methodInfo.Invoke(null, new object[4]
				{
					"com.github.tinyhoot.ShipLoot",
					new Version("1.1"),
					0,
					0
				});
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to register plugin compatibility with LobbyCompatibility.\n{arg}");
				return;
			}
			Log.LogDebug((object)"Successfully registered with LobbyCompatibility.");
		}
	}
	internal class ShipLootConfig
	{
		private readonly ConfigFile _configFile;

		public ConfigEntry<float> DisplayTime;

		public ShipLootConfig(ConfigFile configFile)
		{
			_configFile = configFile;
		}

		public void RegisterOptions()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			DisplayTime = _configFile.Bind<float>("General", "DisplayTime", 5f, new ConfigDescription("How long to display the total scrap value for, counted in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
		}
	}
}
namespace ShipLoot.Patches
{
	[HarmonyPatch]
	internal class HudManagerPatcher
	{
		private static GameObject _ship;

		private static GameObject _totalCounter;

		private static TextMeshProUGUI _textMesh;

		private static float _displayTimeLeft;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(HUDManager), "PingScan_performed")]
		private static void OnScan(HUDManager __instance, CallbackContext context)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && ((CallbackContext)(ref context)).performed && __instance.CanPlayerScan() && !(__instance.playerPingingScan > -0.5f) && (StartOfRound.Instance.inShipPhase || GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom))
			{
				if (!Object.op_Implicit((Object)(object)_ship))
				{
					_ship = GameObject.Find("/Environment/HangarShip");
				}
				if (!Object.op_Implicit((Object)(object)_totalCounter))
				{
					CopyValueCounter();
				}
				float num = CalculateLootValue();
				((TMP_Text)_textMesh).text = $"SHIP: ${num:F0}";
				_displayTimeLeft = ShipLoot.Config.DisplayTime.Value;
				if (!_totalCounter.activeSelf)
				{
					((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ShipLootCoroutine());
				}
			}
		}

		private static IEnumerator ShipLootCoroutine()
		{
			_totalCounter.SetActive(true);
			while (_displayTimeLeft > 0f)
			{
				float displayTimeLeft = _displayTimeLeft;
				_displayTimeLeft = 0f;
				yield return (object)new WaitForSeconds(displayTimeLeft);
			}
			_totalCounter.SetActive(false);
		}

		private static float CalculateLootValue()
		{
			List<GrabbableObject> list = (from obj in _ship.GetComponentsInChildren<GrabbableObject>()
				where obj.itemProperties.isScrap && !(obj is RagdollGrabbableObject)
				select obj).ToList();
			ShipLoot.Log.LogDebug((object)"Calculating total ship scrap value.");
			CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap)
			{
				ShipLoot.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}");
			});
			return list.Sum((GrabbableObject scrap) => scrap.scrapValue);
		}

		private static void CopyValueCounter()
		{
			//IL_0066: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter");
			if (!Object.op_Implicit((Object)(object)val))
			{
				ShipLoot.Log.LogError((object)"Failed to find ValueCounter object to copy!");
			}
			_totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false);
			_totalCounter.transform.Translate(0f, 1f, 0f);
			Vector3 localPosition = _totalCounter.transform.localPosition;
			_totalCounter.transform.localPosition = new Vector3(localPosition.x + 50f, -50f, localPosition.z);
			_textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>();
		}
	}
}

BepInEx/plugins/SnowyHolidayDropship.dll

Decompiled 5 hours ago
using System;
using System.Collections;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SnowyHolidayDropship")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Brings back the holiday dropship on snowy moons.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+6ec1f5cb3bc009193c846a17bde66665b3d4524a")]
[assembly: AssemblyProduct("SnowyHolidayDropship")]
[assembly: AssemblyTitle("SnowyHolidayDropship")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SnowyHolidayDropship
{
	internal static class DropshipDecorator
	{
		private static ItemDropship shipScript;

		private static AudioClip music;

		private static AudioClip musicFar;

		private static AudioClip musicJolly;

		private static AudioClip musicFarJolly;

		private static AudioClip musicOld;

		private static AudioClip musicFarOld;

		private static Mesh ship;

		private static Mesh shipJolly;

		private static GameObject star;

		private static GameObject shipObject;

		private static MeshFilter shipComponent;

		private static AudioSource musicComponent;

		private static AudioSource musicFarComponent;

		private static Random rand = new Random();

		private static bool initialized;

		private static bool landed;

		private static bool seeded;

		private static GameObject artificeBlizzard;

		internal static void Init(ItemDropship itemDropship)
		{
			initialized = false;
			shipScript = itemDropship;
			try
			{
				Transform transform = ((Component)shipScript).transform;
				star = ((Component)transform.Find("Star")).gameObject;
				shipObject = ((Component)transform.Find("ItemShip")).gameObject;
				shipComponent = shipObject.GetComponent<MeshFilter>();
				Transform obj = transform.Find("Music");
				musicComponent = ((Component)obj).GetComponent<AudioSource>();
				musicFarComponent = ((Component)obj.Find("Music (1)")).GetComponent<AudioSource>();
				Plugin.Logger.LogInfo((object)"Successfully cached all dropship object references");
				ship = shipComponent.sharedMesh;
				music = musicComponent.clip;
				musicFar = musicFarComponent.clip;
				Plugin.Logger.LogInfo((object)"Successfully cached all pre-existing asset references");
				if ((Object)(object)musicJolly == (Object)null || (Object)(object)musicFarJolly == (Object)null || (Object)(object)shipJolly == (Object)null || (Object)(object)musicOld == (Object)null)
				{
					AssetBundle obj2 = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "snowyholidaydropship"));
					musicJolly = obj2.LoadAsset<AudioClip>("IcecreamTruckV2Christmas");
					musicFarJolly = obj2.LoadAsset<AudioClip>("IcecreamTruckV2ChristmasFar");
					musicOld = obj2.LoadAsset<AudioClip>("IcecreamTruck");
					musicFarOld = obj2.LoadAsset<AudioClip>("IcecreamTruckV1Far");
					shipJolly = obj2.LoadAsset<Mesh>("MainShipPart");
					obj2.Unload(false);
					Plugin.Logger.LogInfo((object)"Successfully cached all asset bundle references");
				}
				if (((Object)StartOfRound.Instance.currentLevel).name == "ArtificeLevel" && Chainloader.PluginInfos.ContainsKey("butterystancakes.lethalcompany.artificeblizzard"))
				{
					artificeBlizzard = GameObject.Find("/Systems/Audio/BlizzardAmbience");
					if ((Object)(object)artificeBlizzard != (Object)null)
					{
						Plugin.Logger.LogInfo((object)"Artifice Blizzard compatibility success");
					}
				}
				initialized = true;
				landed = false;
				seeded = false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)"Failed to capture references to all the dropship objects - are you playing on a modded moon?");
				Plugin.Logger.LogError((object)"Please send the information below to the developer, and mention what moon this error occurred on");
				Plugin.Logger.LogError((object)ex);
			}
		}

		internal static void RedecorateDropship(bool vehicle = false)
		{
			if (!initialized || landed)
			{
				return;
			}
			landed = true;
			if (!seeded)
			{
				rand = new Random(StartOfRound.Instance.randomMapSeed);
				Plugin.Logger.LogInfo((object)$"RNG initialized (Seed: {StartOfRound.Instance.randomMapSeed})");
				seeded = true;
			}
			Plugin.Logger.LogInfo((object)"Roll chance for holiday");
			bool flag = RandomChance(IsSnowLevel() ? ((double)Plugin.configSnowyChance.Value) : ((double)Plugin.configNormalChance.Value));
			Plugin.Logger.LogInfo((object)"Roll chance for old music");
			bool flag2 = RandomChance(Plugin.configLegacyChance.Value);
			if (vehicle)
			{
				shipComponent.mesh = ship;
				star.SetActive(false);
				Plugin.Logger.LogInfo((object)"Dropship: Normal (delivering vehicle)");
				return;
			}
			if (flag)
			{
				shipComponent.mesh = shipJolly;
				musicComponent.clip = musicJolly;
				musicFarComponent.clip = musicFarJolly;
				star.SetActive(true);
				Plugin.Logger.LogInfo((object)"Dropship: Holiday");
				return;
			}
			shipComponent.mesh = ship;
			if (flag2)
			{
				musicComponent.clip = musicOld;
				musicFarComponent.clip = musicFarOld;
				Plugin.Logger.LogInfo((object)"Dropship: Normal (old music)");
			}
			else
			{
				musicComponent.clip = music;
				musicFarComponent.clip = musicFar;
				Plugin.Logger.LogInfo((object)"Dropship: Normal");
			}
			star.SetActive(false);
		}

		internal static void DropshipLeave()
		{
			landed = false;
			if (initialized && star.activeSelf)
			{
				((MonoBehaviour)shipScript).StartCoroutine(DisableStarInSky());
			}
		}

		internal static IEnumerator DisableStarInSky()
		{
			float start = Time.time;
			Plugin.Logger.LogInfo((object)"Holiday: Upon reaching orbit, disable star");
			while (shipObject.activeSelf)
			{
				yield return null;
			}
			star.SetActive(false);
			Plugin.Logger.LogInfo((object)$"Holiday: Star disabled after {Time.time - start}s");
		}

		private static bool RandomChance(double chance)
		{
			double num = rand.NextDouble();
			Plugin.Logger.LogInfo((object)$"RNG: {num} < {chance}");
			if (!(chance >= 1.0))
			{
				if (chance > 0.0)
				{
					return num < chance;
				}
				return false;
			}
			return true;
		}

		private static bool IsSnowLevel()
		{
			if (StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints)
			{
				if (!((Object)(object)artificeBlizzard == (Object)null))
				{
					return artificeBlizzard.activeSelf;
				}
				return true;
			}
			return false;
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.snowyholidaydropship", "Snowy Holiday Dropship", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "butterystancakes.lethalcompany.snowyholidaydropship";

		private const string PLUGIN_NAME = "Snowy Holiday Dropship";

		private const string PLUGIN_VERSION = "1.1.0";

		public static ConfigEntry<float> configSnowyChance;

		public static ConfigEntry<float> configNormalChance;

		public static ConfigEntry<float> configLegacyChance;

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 1f);
			string text = " (0 = never, 1 = guaranteed, or anything in between - 0.5 = 50% chance)";
			configSnowyChance = ((BaseUnityPlugin)this).Config.Bind<float>("Random", "SnowyChance", 1f, new ConfigDescription("The percentage chance for the dropship to be holiday-themed on snowy moons." + text, (AcceptableValueBase)(object)val, Array.Empty<object>()));
			configNormalChance = ((BaseUnityPlugin)this).Config.Bind<float>("Random", "NormalChance", 0f, new ConfigDescription("The percentage chance for the dropship to be holiday-themed on normal moons." + text, (AcceptableValueBase)(object)val, Array.Empty<object>()));
			configLegacyChance = ((BaseUnityPlugin)this).Config.Bind<float>("Random", "LegacyChance", 0f, new ConfigDescription("The percentage chance for the normal dropship to use the old music, showcased in an early teaser video." + text, (AcceptableValueBase)(object)val, Array.Empty<object>()));
			new Harmony("butterystancakes.lethalcompany.snowyholidaydropship").PatchAll();
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Snowy Holiday Dropship v1.1.0 loaded");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SnowyHolidayDropship";

		public const string PLUGIN_NAME = "SnowyHolidayDropship";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace SnowyHolidayDropship.Patches
{
	[HarmonyPatch]
	internal class SnowyHolidayDropshipPatches
	{
		[HarmonyPatch(typeof(ItemDropship), "Start")]
		[HarmonyPostfix]
		public static void ItemDropshipPostStart(ItemDropship __instance)
		{
			DropshipDecorator.Init(__instance);
		}

		[HarmonyPatch(typeof(ItemDropship), "LandShipClientRpc")]
		[HarmonyPostfix]
		public static void PostLandShipClientRpc()
		{
			DropshipDecorator.RedecorateDropship();
		}

		[HarmonyPatch(typeof(ItemDropship), "ShipLeave")]
		[HarmonyPatch(typeof(ItemDropship), "FinishDeliveringVehicleClientRpc")]
		[HarmonyPostfix]
		public static void ItemDropshipPostShipLeave()
		{
			DropshipDecorator.DropshipLeave();
		}

		[HarmonyPatch(typeof(ItemDropship), "DeliverVehicleClientRpc")]
		[HarmonyPostfix]
		public static void PostDeliverVehicleClientRpc()
		{
			DropshipDecorator.RedecorateDropship(vehicle: true);
		}
	}
}

BepInEx/plugins/TVLoader.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using TVLoader.Utils;
using UnityEngine;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TVLoader")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TVLoader")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e59845a7-f2f7-4416-9a61-ca1939ce6e2d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TVLoader
{
	[BepInPlugin("rattenbonkers.TVLoader", "TVLoader", "1.1.2")]
	public class TVLoaderPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "rattenbonkers.TVLoader";

		private const string PluginName = "TVLoader";

		private const string VersionString = "1.1.2";

		private static readonly Harmony Harmony = new Harmony("rattenbonkers.TVLoader");

		public static ManualLogSource Log = new ManualLogSource("TVLoader");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.PatchAll();
			VideoManager.Load();
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("PluginName: {0}, VersionString: {1} is loaded. Video Count: {2}", "TVLoader", "1.1.2", VideoManager.Videos.Count));
		}
	}
}
namespace TVLoader.Utils
{
	internal static class VideoManager
	{
		public static List<string> Videos = new List<string>();

		public static void Load()
		{
			string[] directories = Directory.GetDirectories(Paths.PluginPath);
			foreach (string text in directories)
			{
				string path = Path.Combine(Paths.PluginPath, text, "Television Videos");
				if (Directory.Exists(path))
				{
					string[] files = Directory.GetFiles(path, "*.mp4");
					Videos.AddRange(files);
					TVLoaderPlugin.Log.LogInfo((object)$"{text} has {files.Length} videos.");
				}
			}
			string path2 = Path.Combine(Paths.PluginPath, "Television Videos");
			if (!Directory.Exists(path2))
			{
				Directory.CreateDirectory(path2);
			}
			string[] files2 = Directory.GetFiles(path2, "*.mp4");
			Videos.AddRange(files2);
			TVLoaderPlugin.Log.LogInfo((object)$"Global has {files2.Length} videos.");
			TVLoaderPlugin.Log.LogInfo((object)$"Loaded {Videos.Count} total.");
		}
	}
}
namespace TVLoader.Patches
{
	[HarmonyPatch(typeof(TVScript))]
	internal class TVScriptPatches
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static EventHandler <>9__13_0;

			internal void <PrepareVideo>b__13_0(VideoPlayer source)
			{
				TVLoaderPlugin.Log.LogInfo((object)"Prepared next video!");
			}
		}

		private static FieldInfo currentClipProperty = typeof(TVScript).GetField("currentClip", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo currentTimeProperty = typeof(TVScript).GetField("currentClipTime", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo wasTvOnLastFrameProp = typeof(TVScript).GetField("wasTvOnLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo timeSinceTurningOffTVProp = typeof(TVScript).GetField("timeSinceTurningOffTV", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo setMatMethod = typeof(TVScript).GetMethod("SetTVScreenMaterial", BindingFlags.Instance | BindingFlags.NonPublic);

		private static MethodInfo onEnableMethod = typeof(TVScript).GetMethod("OnEnable", BindingFlags.Instance | BindingFlags.NonPublic);

		private static bool tvHasPlayedBefore = false;

		private static RenderTexture renderTexture;

		private static VideoPlayer currentVideoPlayer;

		private static VideoPlayer nextVideoPlayer;

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static bool Update(TVScript __instance)
		{
			if ((Object)(object)currentVideoPlayer == (Object)null)
			{
				currentVideoPlayer = ((Component)__instance).GetComponent<VideoPlayer>();
				renderTexture = currentVideoPlayer.targetTexture;
				if (VideoManager.Videos.Count > 0)
				{
					PrepareVideo(__instance, 0);
				}
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("TurnTVOnOff")]
		public static bool TurnTVOnOff(TVScript __instance, bool on)
		{
			TVLoaderPlugin.Log.LogInfo((object)$"VideoPlayer Resolution: {((Texture)currentVideoPlayer.targetTexture).width}x{((Texture)currentVideoPlayer.targetTexture).height}");
			TVLoaderPlugin.Log.LogInfo((object)$"TVOnOff: {on}");
			if (VideoManager.Videos.Count == 0)
			{
				return false;
			}
			int num = (int)currentClipProperty.GetValue(__instance);
			if (on && tvHasPlayedBefore)
			{
				num = (num + 1) % VideoManager.Videos.Count;
				currentClipProperty.SetValue(__instance, num);
			}
			__instance.tvOn = on;
			if (on)
			{
				PlayVideo(__instance);
				__instance.tvSFX.PlayOneShot(__instance.switchTVOn);
				WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOn, 1f);
			}
			else
			{
				__instance.video.Stop();
				__instance.tvSFX.PlayOneShot(__instance.switchTVOff);
				WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOff, 1f);
			}
			setMatMethod.Invoke(__instance, new object[1] { on });
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("TVFinishedClip")]
		public static bool TVFinishedClip(TVScript __instance, VideoPlayer source)
		{
			if (!__instance.tvOn || GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				return false;
			}
			TVLoaderPlugin.Log.LogInfo((object)"TVFinishedClip");
			int num = (int)currentClipProperty.GetValue(__instance);
			if (VideoManager.Videos.Count > 0)
			{
				num = (num + 1) % VideoManager.Videos.Count;
			}
			currentTimeProperty.SetValue(__instance, 0f);
			currentClipProperty.SetValue(__instance, num);
			PlayVideo(__instance);
			return false;
		}

		private static void PrepareVideo(TVScript instance, int index = -1)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			if (index == -1)
			{
				index = (int)currentClipProperty.GetValue(instance) + 1;
			}
			if ((Object)(object)nextVideoPlayer != (Object)null && ((Component)nextVideoPlayer).gameObject.activeInHierarchy)
			{
				Object.Destroy((Object)(object)nextVideoPlayer);
			}
			nextVideoPlayer = ((Component)instance).gameObject.AddComponent<VideoPlayer>();
			nextVideoPlayer.playOnAwake = false;
			nextVideoPlayer.isLooping = false;
			nextVideoPlayer.source = (VideoSource)1;
			nextVideoPlayer.controlledAudioTrackCount = 1;
			nextVideoPlayer.audioOutputMode = (VideoAudioOutputMode)1;
			nextVideoPlayer.SetTargetAudioSource((ushort)0, instance.tvSFX);
			nextVideoPlayer.url = "file://" + VideoManager.Videos[index % VideoManager.Videos.Count];
			nextVideoPlayer.skipOnDrop = true;
			nextVideoPlayer.Prepare();
			VideoPlayer obj = nextVideoPlayer;
			object obj2 = <>c.<>9__13_0;
			if (obj2 == null)
			{
				EventHandler val = delegate
				{
					TVLoaderPlugin.Log.LogInfo((object)"Prepared next video!");
				};
				<>c.<>9__13_0 = val;
				obj2 = (object)val;
			}
			obj.prepareCompleted += (EventHandler)obj2;
		}

		private static void PlayVideo(TVScript instance)
		{
			tvHasPlayedBefore = true;
			if (VideoManager.Videos.Count != 0)
			{
				if ((Object)(object)nextVideoPlayer != (Object)null)
				{
					VideoPlayer val = currentVideoPlayer;
					instance.video = (currentVideoPlayer = nextVideoPlayer);
					nextVideoPlayer = null;
					TVLoaderPlugin.Log.LogInfo((object)$"Destroy {val}");
					Object.Destroy((Object)(object)val);
					onEnableMethod.Invoke(instance, new object[0]);
				}
				currentTimeProperty.SetValue(instance, 0f);
				instance.video.targetTexture = renderTexture;
				instance.video.Play();
				PrepareVideo(instance);
			}
		}
	}
}