Decompiled source of HandicappedCompany v0.5.2

HandicapCompany.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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 Dissonance;
using GameNetcodeStuff;
using HandicapCompany.patches;
using HarmonyLib;
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("HandicapCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Your Mod Description Goes Here")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d9d03daed31d739cc780ab658165604aefbf021f")]
[assembly: AssemblyProduct("HandicapCompany")]
[assembly: AssemblyTitle("HandicapCompany")]
[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 HandicapCompany
{
	[BepInPlugin("org.agmas.HandicapCompany", "Handicap Company", "0.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "org.agmas.HandicapCompany";

		private const string modName = "Handicap Company";

		private const string modVersion = "0.3.0";

		public float timeSinceLastDmg = 0f;

		public float modScareFactor = 0f;

		public int ogSense = 0;

		public bool stopHandicapStacking = false;

		public bool blind = false;

		public bool mute = false;

		public bool palsy = false;

		public bool deaf = false;

		public bool crippled = false;

		public bool illiterate = false;

		public bool introvert = false;

		public bool extrovert = false;

		public bool weak = false;

		public bool weighty = false;

		public bool paranoid = false;

		public bool conductive = false;

		public bool hyperactive = false;

		public bool talkative = false;

		public bool drunk = false;

		public bool intipShown = false;

		public bool extipShown = false;

		public ConfigEntry<string> availableHandicaps;

		public List<int> available;

		public ConfigEntry<int> handicapChance;

		public ConfigEntry<int> chatAnnouncement;

		public ConfigEntry<bool> allowMuteWhileMuted;

		public ConfigEntry<bool> allowMuteWhileSolo;

		public ConfigEntry<bool> allowIntroExtroWhileSolo;

		private ConfigEntry<string> prv;

		private readonly Harmony harmony = new Harmony("org.agmas.HandicapCompany");

		public static Plugin Instance;

		public ManualLogSource mls;

		public void reloadConfig()
		{
			mls.LogInfo((object)"Load/Reload Config");
			availableHandicaps = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AvailableHandicaps", "Blind,Deaf,Mute,Legs,NoUI,Intro,Weak,Weight,Paranoid,Conduct,Extro,Hyper,Drunk", "All the available handicaps, sperated by \",\". Does not sync between host and client.");
			handicapChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HandiChance", 100, "Chance to be handicapped. Does not sync between host and client.");
			chatAnnouncement = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Chat Announcement Type", 0, "0 = Announces in chat normally.\n1 = Compact, only sends \"[HC] handicap\".\n2 = No message.");
			mls.LogInfo((object)("Binding Finished, Reading info from: " + availableHandicaps.Value));
			allowMuteWhileMuted = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto-Disable", "Allow Mute while Muted", false, "Allows you to get mute when your microphone settings are off.");
			allowMuteWhileSolo = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto-Disable", "Allow Mute when Solo", false, "Allows you to get mute when you're alone.");
			allowIntroExtroWhileSolo = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto-Disable", "Allow Verts while Solo", false, "Allows you to get Introvet/Extrovert when you're alone.\nTHIS USES THE SANITY VALUES, WHICH IN SINGLEPLAYER, RISE WHEN IN THE SHIP OR FACILITY, BUT LOWER OUTSIDE.");
			available = new List<int>();
			string[] array = availableHandicaps.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				mls.LogInfo((object)text);
				switch (text.ToLower())
				{
				case "blind":
					available.Add(0);
					break;
				case "deaf":
					available.Add(3);
					break;
				case "mute":
					available.Add(1);
					break;
				case "palsy":
					available.Add(2);
					break;
				case "legs":
					available.Add(4);
					break;
				case "noui":
					available.Add(5);
					break;
				case "intro":
					available.Add(6);
					break;
				case "weight":
					available.Add(7);
					break;
				case "weak":
					available.Add(8);
					break;
				case "paranoid":
					available.Add(9);
					break;
				case "conduct":
					available.Add(10);
					break;
				case "extro":
					available.Add(11);
					break;
				case "hyper":
					available.Add(12);
					break;
				case "talk":
					available.Add(13);
					break;
				case "drunk":
					available.Add(14);
					break;
				}
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("org.agmas.HandicapCompany");
			mls.LogInfo((object)"We're up and running!");
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(RoundManagerPatch));
			harmony.PatchAll(typeof(IngamePlayerSettingsPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(TerminalPach));
			mls.LogInfo((object)"Binding Config");
			prv = ((BaseUnityPlugin)this).Config.Bind<string>("__Do not touch", "prv", "0.4.3", "Do not change, Used to automatically add new handicaps when they come out!");
			reloadConfig();
			if (prv.Value != "0.4.5")
			{
				((ConfigEntryBase)availableHandicaps).SetSerializedValue("Blind,Deaf,Mute,Legs,NoUI,Intro,Weak,Weight,Paranoid,Conduct,Extro,Hyper,Talk,Drunk");
				((ConfigEntryBase)prv).SetSerializedValue("0.4.5");
				reloadConfig();
			}
			mls.LogInfo((object)available);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HandicapCompany";

		public const string PLUGIN_NAME = "HandicapCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace HandicapCompany.patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void FadeToNothing(ref HUDManager __instance)
		{
			if (Plugin.Instance.illiterate)
			{
				__instance.HideHUD(true);
			}
		}

		[HarmonyPatch("UpdateHealthUI")]
		[HarmonyPrefix]
		public static bool FadeToNothing3(ref HUDManager __instance)
		{
			if (Plugin.Instance.illiterate)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("PingHUDElement")]
		[HarmonyPrefix]
		public static bool FadeToNothing2(ref HUDManager __instance)
		{
			if (Plugin.Instance.illiterate)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(IngamePlayerSettings))]
	internal class IngamePlayerSettingsPatch
	{
		[HarmonyPatch(typeof(IngamePlayerSettings), "SaveSettingsToPrefs")]
		[HarmonyPrefix]
		public static bool gammaPatch2(IngamePlayerSettings __instance)
		{
			if (Plugin.Instance.blind && Plugin.Instance.mute && Plugin.Instance.palsy && Plugin.Instance.deaf)
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "You cannot change settings when \nbeing blind, deaf, mute or palsy!", false, false, "LC_Tip1");
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "UpdateGameToMatchSettings")]
		[HarmonyPostfix]
		public static void gammaPatch(IngamePlayerSettings __instance)
		{
			if (Plugin.Instance.blind)
			{
				__instance.ChangeGamma(-95, -500f);
			}
			if (Plugin.Instance.mute)
			{
				__instance.settings.micEnabled = false;
			}
			if (Plugin.Instance.palsy)
			{
				__instance.settings.lookSensitivity = -Plugin.Instance.ogSense;
			}
			if (Plugin.Instance.deaf)
			{
				__instance.ChangeMasterVolume(0);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch(typeof(PlayerControllerB), "SpectateNextPlayer")]
		[HarmonyPostfix]
		private static void undo(PlayerControllerB __instance)
		{
			Plugin.Instance.stopHandicapStacking = false;
			Plugin.Instance.mute = false;
			Plugin.Instance.deaf = false;
			if (Plugin.Instance.palsy)
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "If you are still palsy, please go to the settings and\nreset your sensitivity manually.\nI don't know why this happens, thanks", false, false, "LC_Tip1");
				IngamePlayerSettings.Instance.settings.lookSensitivity = Plugin.Instance.ogSense;
			}
			Plugin.Instance.palsy = false;
			Plugin.Instance.blind = false;
			Plugin.Instance.talkative = false;
			Plugin.Instance.drunk = false;
			GameNetworkManager.Instance.localPlayerController.drunkness = 0f;
			Plugin.Instance.crippled = false;
			Plugin.Instance.introvert = false;
			Plugin.Instance.illiterate = false;
			Plugin.Instance.weak = false;
			Plugin.Instance.weighty = false;
			Plugin.Instance.paranoid = false;
			Plugin.Instance.conductive = false;
			Plugin.Instance.extrovert = false;
			Plugin.Instance.hyperactive = false;
			GameNetworkManager.Instance.localPlayerController.carryWeight = 1f;
			HUDManager.Instance.HideHUD(false);
			IngamePlayerSettings.Instance.LoadSettingsFromPrefs();
			IngamePlayerSettings.Instance.UpdateGameToMatchSettings();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SetPlayerSanityLevel")]
		[HarmonyPostfix]
		public static void insanity(PlayerControllerB __instance)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.Instance.introvert && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				if (__instance.insanitySpeedMultiplier > 0f)
				{
					__instance.insanitySpeedMultiplier += 1.5f;
				}
				if (__instance.insanitySpeedMultiplier < 0f)
				{
					__instance.insanitySpeedMultiplier -= 0.7f;
				}
				__instance.insanityLevel = Mathf.MoveTowards(__instance.insanityLevel, __instance.maxInsanityLevel, (float)((double)(Time.deltaTime * (0f - __instance.insanitySpeedMultiplier)) * 1.4));
				if (__instance.insanityLevel < 0f)
				{
					__instance.insanityLevel = 0f;
				}
				if (__instance.insanityLevel > 50f)
				{
					__instance.insanityLevel = 50f;
				}
				if (__instance.insanityLevel >= 50f)
				{
					Plugin.Instance.modScareFactor = 0.76f;
					if ((double)Plugin.Instance.timeSinceLastDmg >= 0.35)
					{
						__instance.DamagePlayer(1, true, true, (CauseOfDeath)10, 0, false, default(Vector3));
						Plugin.Instance.timeSinceLastDmg = 0f;
					}
				}
				else if (__instance.insanityLevel >= 45f)
				{
					Plugin.Instance.modScareFactor = 0.42f;
					if (!Plugin.Instance.intipShown)
					{
						Plugin.Instance.intipShown = true;
						HUDManager.Instance.DisplayTip("Handicap Company", "Get away from people!\nYou'll start taking damage due to\nbeing introverted!", true, false, "LC_Tip1");
					}
				}
				else if (__instance.insanityLevel >= 35f)
				{
					Plugin.Instance.modScareFactor = 0.15f;
				}
			}
			if (!Plugin.Instance.extrovert || !((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				return;
			}
			if (__instance.insanitySpeedMultiplier < 0f)
			{
				__instance.insanitySpeedMultiplier -= 1.5f;
			}
			if (__instance.insanitySpeedMultiplier > 0f)
			{
				__instance.insanitySpeedMultiplier += 0.7f;
			}
			__instance.insanityLevel = Mathf.MoveTowards(__instance.insanityLevel, __instance.maxInsanityLevel, (float)((double)(Time.deltaTime * __instance.insanitySpeedMultiplier) * 1.4));
			if (__instance.insanityLevel < 0f)
			{
				__instance.insanityLevel = 0f;
			}
			if (__instance.insanityLevel > 50f)
			{
				__instance.insanityLevel = 50f;
			}
			if (__instance.insanityLevel >= 50f)
			{
				Plugin.Instance.modScareFactor = 0.76f;
				if ((double)Plugin.Instance.timeSinceLastDmg >= 0.35)
				{
					__instance.DamagePlayer(1, true, true, (CauseOfDeath)10, 0, false, default(Vector3));
					Plugin.Instance.timeSinceLastDmg = 0f;
				}
			}
			else if (__instance.insanityLevel >= 45f)
			{
				Plugin.Instance.modScareFactor = 0.42f;
				if (!Plugin.Instance.extipShown)
				{
					Plugin.Instance.extipShown = true;
					HUDManager.Instance.DisplayTip("Handicap Company", "Get back to people!\nYou'll start taking damage due to\nbeing extroverted!", true, false, "LC_Tip1");
				}
			}
			else if (__instance.insanityLevel >= 35f)
			{
				Plugin.Instance.modScareFactor = 0.15f;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Crouch")]
		[HarmonyPrefix]
		public static bool gammaPatch5(PlayerControllerB __instance)
		{
			if (Plugin.Instance.hyperactive && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Crouch_performed")]
		[HarmonyPrefix]
		public static bool nuhUh(PlayerControllerB __instance)
		{
			if (Plugin.Instance.hyperactive && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "nuh uh", false, false, "LC_Tip1");
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		public static void gammaPatch(PlayerControllerB __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: 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_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: 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_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: 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_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.Instance.hyperactive && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && StartOfRound.Instance.shipHasLanded)
			{
				if (((Vector2)(ref __instance.moveInputVector)).Equals(Vector2.zero))
				{
					Plugin.Instance.modScareFactor += (float)((double)Time.deltaTime * 1.5);
					if (Plugin.Instance.modScareFactor > 0.74f)
					{
						Plugin.Instance.modScareFactor = 0.74f;
					}
					if (Plugin.Instance.modScareFactor >= 0.74f && Plugin.Instance.timeSinceLastDmg > 0.025f)
					{
						Plugin.Instance.timeSinceLastDmg = 0f;
						__instance.DamagePlayer(1, true, true, (CauseOfDeath)8, 0, false, default(Vector3));
					}
				}
				else
				{
					Plugin.Instance.modScareFactor -= Time.deltaTime / 2f;
				}
			}
			Plugin.Instance.timeSinceLastDmg += Time.deltaTime;
			float modScareFactor = Plugin.Instance.modScareFactor;
			Plugin.Instance.modScareFactor -= Time.deltaTime / 100f;
			if (Plugin.Instance.modScareFactor < 0f)
			{
				Plugin.Instance.modScareFactor = 0f;
			}
			if (Plugin.Instance.modScareFactor > 1f)
			{
				Plugin.Instance.modScareFactor = 1f;
			}
			if (StartOfRound.Instance.fearLevel < Plugin.Instance.modScareFactor)
			{
				StartOfRound.Instance.fearLevel = Plugin.Instance.modScareFactor;
			}
			else if (Plugin.Instance.modScareFactor < modScareFactor)
			{
				StartOfRound.Instance.fearLevel = Plugin.Instance.modScareFactor;
			}
			if (Plugin.Instance.paranoid && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && Plugin.Instance.timeSinceLastDmg > 15f)
			{
				Plugin.Instance.timeSinceLastDmg = 0f;
				switch (new Random().Next(0, 10))
				{
				case 0:
					__instance.DamagePlayer(0, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
					break;
				case 1:
					RoundManager.Instance.FlickerLights(true, false);
					break;
				case 2:
					HUDManager.Instance.DisplayTip("boo", "did i scare you", true, false, "LC_Tip1");
					break;
				}
			}
			if (Plugin.Instance.conductive && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && (double)Plugin.Instance.timeSinceLastDmg > 1.5)
			{
				Plugin.Instance.timeSinceLastDmg = 0f;
				if (!__instance.isInsideFactory && !__instance.isInHangarShipRoom)
				{
					GrabbableObject[] itemSlots = __instance.ItemSlots;
					foreach (GrabbableObject val in itemSlots)
					{
						if (!((Object)(object)val == (Object)null) && !((Object)(object)val.itemProperties == (Object)null) && val.itemProperties.isConductiveMetal && new Random().Next(0, 3) == 0)
						{
							Landmine.SpawnExplosion(((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up * 0.25f, false, 2.4f, 5f, 50, 0f, (GameObject)null);
							HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
							GameNetworkManager.Instance.localPlayerController.DamagePlayer(999, true, true, (CauseOfDeath)11, 0, false, default(Vector3));
							HUDManager.Instance.DisplayTip("Handicap Company", "You were too conductive!\nYou exploded due to too much electricity.\nSkill issue", true, false, "LC_Tip1");
						}
					}
				}
			}
			if (Plugin.Instance.weighty && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && __instance.carryWeight < 1.6f)
			{
				__instance.carryWeight = 1.6f;
			}
			if (Plugin.Instance.drunk && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				GameNetworkManager.Instance.localPlayerController.drunkness = 0.75f;
			}
			if (Plugin.Instance.talkative && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && IngamePlayerSettings.Instance.settings.micEnabled && !((Object)StartOfRound.Instance.voiceChatModule == (Object)null))
			{
				VoicePlayerState val2 = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName);
				if (val2.IsSpeaking)
				{
					float movementSpeed = Mathf.Clamp(val2.Amplitude * 140f, 0f, 4.6f);
					__instance.movementSpeed = movementSpeed;
				}
			}
			if (Plugin.Instance.weak && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && __instance.twoHanded && (double)Plugin.Instance.timeSinceLastDmg >= 0.5)
			{
				__instance.DamagePlayer(1, true, true, (CauseOfDeath)2, 0, false, default(Vector3));
				Plugin.Instance.timeSinceLastDmg = 0f;
			}
			if (Plugin.Instance.illiterate && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				HUDManager.Instance.HideHUD(true);
			}
			if (Plugin.Instance.crippled && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance))
			{
				if (__instance.health > 15)
				{
					__instance.health = 15;
				}
				__instance.MakeCriticallyInjured(true);
			}
			if (Plugin.Instance.paranoid && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && Plugin.Instance.timeSinceLastDmg >= 1f && StartOfRound.Instance.fearLevel >= 0.1f)
			{
				__instance.DamagePlayer(1, true, true, (CauseOfDeath)5, 0, false, default(Vector3));
				if (StartOfRound.Instance.fearLevel >= 0.4f)
				{
					__instance.DamagePlayer(2, true, true, (CauseOfDeath)5, 0, false, default(Vector3));
				}
				if (StartOfRound.Instance.fearLevel >= 0.74f)
				{
					__instance.DamagePlayer(3, true, true, (CauseOfDeath)5, 0, false, default(Vector3));
				}
				Plugin.Instance.timeSinceLastDmg = 0f;
			}
			if (Plugin.Instance.weak && ((object)GameNetworkManager.Instance.localPlayerController).Equals((object?)__instance) && __instance.health > 50)
			{
				__instance.health = 50;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch(typeof(RoundManager), "OnDestroy")]
		[HarmonyPostfix]
		private static void undo(RoundManager __instance)
		{
			Plugin.Instance.mute = false;
			Plugin.Instance.deaf = false;
			if (Plugin.Instance.palsy)
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "If you are still palsy, please go to the settings and\nreset your sensitivity manually.\nI don't know why this happens, thanks", false, false, "LC_Tip1");
				IngamePlayerSettings.Instance.settings.lookSensitivity = Plugin.Instance.ogSense;
			}
			Plugin.Instance.stopHandicapStacking = false;
			Plugin.Instance.palsy = false;
			Plugin.Instance.blind = false;
			Plugin.Instance.talkative = false;
			Plugin.Instance.drunk = false;
			Plugin.Instance.crippled = false;
			Plugin.Instance.introvert = false;
			Plugin.Instance.illiterate = false;
			Plugin.Instance.weak = false;
			Plugin.Instance.weighty = false;
			Plugin.Instance.extrovert = false;
			Plugin.Instance.paranoid = false;
			Plugin.Instance.hyperactive = false;
			Plugin.Instance.conductive = false;
			GameNetworkManager.Instance.localPlayerController.carryWeight = 1f;
			GameNetworkManager.Instance.localPlayerController.drunkness = 0f;
			HUDManager.Instance.HideHUD(false);
			IngamePlayerSettings.Instance.LoadSettingsFromPrefs();
			IngamePlayerSettings.Instance.UpdateGameToMatchSettings();
		}

		private static IEnumerator hyperTip()
		{
			yield return (object)new WaitForSeconds(4f);
			HUDManager.Instance.DisplayTip("Handicap Company", "You have a short grace period until the ship lands.\nGood luck!", false, false, "LC_Tip1");
		}

		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void gammaPatch(RoundManager __instance)
		{
			if (Plugin.Instance.palsy)
			{
				IngamePlayerSettings.Instance.settings.lookSensitivity = Plugin.Instance.ogSense;
			}
			if (Plugin.Instance.stopHandicapStacking)
			{
				return;
			}
			Plugin.Instance.reloadConfig();
			if ((StartOfRound.Instance.connectedPlayersAmount <= 0 && !Plugin.Instance.allowMuteWhileSolo.Value) || (!IngamePlayerSettings.Instance.settings.micEnabled && !Plugin.Instance.allowMuteWhileMuted.Value))
			{
				Plugin.Instance.available.Remove(1);
				Plugin.Instance.mls.LogWarning((object)"Removed Mute");
			}
			if (StartOfRound.Instance.connectedPlayersAmount <= 0 && !Plugin.Instance.allowIntroExtroWhileSolo.Value)
			{
				Plugin.Instance.available.Remove(6);
				Plugin.Instance.available.Remove(11);
				Plugin.Instance.mls.LogWarning((object)"Removed Intro/Extro");
			}
			Plugin.Instance.stopHandicapStacking = true;
			if (100 - Plugin.Instance.handicapChance.Value < new Random().Next(0, 101))
			{
				int num = Plugin.Instance.available[new Random().Next(0, Plugin.Instance.available.Count)];
				string text = "Lorem ipsum";
				switch (num)
				{
				case 0:
					IngamePlayerSettings.Instance.ChangeGamma(-85, -500f);
					Plugin.Instance.blind = true;
					text = "Blind";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're blind!\nYou can still see, but not that well... Good luck!", true, false, "LC_Tip1");
					break;
				case 1:
					IngamePlayerSettings.Instance.settings.micEnabled = false;
					Plugin.Instance.mute = true;
					text = "Mute";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're mute!\nYou watch on in silence.", true, false, "LC_Tip1");
					break;
				case 2:
					Plugin.Instance.ogSense = IngamePlayerSettings.Instance.settings.lookSensitivity;
					IngamePlayerSettings.Instance.settings.lookSensitivity = -IngamePlayerSettings.Instance.settings.lookSensitivity;
					Plugin.Instance.palsy = true;
					text = "Palsy";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're palsy!\n!yaw gnorW", true, false, "LC_Tip1");
					IngamePlayerSettings.Instance.LoadSettingsFromPrefs();
					break;
				case 3:
					IngamePlayerSettings.Instance.ChangeMasterVolume(0);
					Plugin.Instance.deaf = true;
					text = "Deaf";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're deaf!\nI would put text here, but you can't hear it.", true, false, "LC_Tip1");
					break;
				case 4:
					Plugin.Instance.crippled = true;
					text = "Broken Legs";
					HUDManager.Instance.DisplayTip("Handicap Company", "You have broken legs!\nYou're always at injured speeds, and are also at 15hp. Good luck.", true, false, "LC_Tip1");
					break;
				case 5:
					((MonoBehaviour)__instance).StartCoroutine(illwaiter());
					text = "Illiterate";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Illiterate!\nYou can't see UI or use Terminal..\nSay goodbye to this tip!", true, false, "LC_Tip1");
					break;
				case 6:
					Plugin.Instance.introvert = true;
					text = "Introverted";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're an Introvert!\nYou get more paranoid when you're with people..\nDon't get too paranoid or you'll take damage!", true, false, "LC_Tip1");
					break;
				case 7:
					Plugin.Instance.weighty = true;
					text = "Weighty";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Weighty!\nYou naturally gained some weight.", true, false, "LC_Tip1");
					break;
				case 8:
					Plugin.Instance.weak = true;
					text = "Weak";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Weak\nYou have less health and take 1hp/0.5s when holding 2-handed items.", true, false, "LC_Tip1");
					break;
				case 9:
					Plugin.Instance.paranoid = true;
					text = "Paranoid";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Paranoid\nFear damages you.\nYou also seem to get scared by seemingly nothing..?", true, false, "LC_Tip1");
					break;
				case 10:
					Plugin.Instance.conductive = true;
					text = "Conductive";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Conductive\nFor the love of god, don't take metal.", true, false, "LC_Tip1");
					break;
				case 11:
					Plugin.Instance.extrovert = true;
					text = "Extroverted";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're an Extrovert!\nYou get more paranoid when you're not with people..\nDon't get too paranoid or you'll take damage!", true, false, "LC_Tip1");
					break;
				case 12:
					GameNetworkManager.Instance.localPlayerController.Crouch(false);
					Plugin.Instance.hyperactive = true;
					text = "Hyperactive";
					((MonoBehaviour)__instance).StartCoroutine(hyperTip());
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Hyperactive!\nYou can't crouch and must keep moving.", true, false, "LC_Tip1");
					break;
				case 13:
					Plugin.Instance.talkative = true;
					GameNetworkManager.Instance.localPlayerController.drunkness = 0.2f;
					text = "Talkative";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Talkative!\nTalking controls your player speed!", true, false, "LC_Tip1");
					break;
				case 14:
					Plugin.Instance.drunk = true;
					text = "Drunk";
					HUDManager.Instance.DisplayTip("Handicap Company", "You're Drunk!\nYou're.. drunk. idk how else i'm supposed to explain that", true, false, "LC_Tip1");
					break;
				}
				if (Plugin.Instance.chatAnnouncement.Value == 0)
				{
					HUDManager.Instance.AddTextToChatOnServer("[HC] Got the handicap: " + text, (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				}
				if (Plugin.Instance.chatAnnouncement.Value == 1)
				{
					HUDManager.Instance.AddTextToChatOnServer("[HC] " + text, (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
				}
			}
			else
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "You're not handicapped!\nYou got lucky, atleast for now...", false, false, "LC_Tip1");
			}
		}

		private static IEnumerator illwaiter()
		{
			yield return (object)new WaitForSeconds(4f);
			Plugin.Instance.illiterate = true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
		[HarmonyPostfix]
		private static void undo(StartOfRound __instance)
		{
			Plugin.Instance.mute = false;
			Plugin.Instance.deaf = false;
			if (Plugin.Instance.palsy)
			{
				HUDManager.Instance.DisplayTip("Handicap Company", "If you are still palsy, please go to the settings and\nreset your sensitivity manually.\nI don't know why this happens, thanks", false, false, "LC_Tip1");
				IngamePlayerSettings.Instance.settings.lookSensitivity = Plugin.Instance.ogSense;
			}
			Plugin.Instance.palsy = false;
			Plugin.Instance.blind = false;
			Plugin.Instance.crippled = false;
			Plugin.Instance.illiterate = false;
			Plugin.Instance.introvert = false;
			Plugin.Instance.weak = false;
			Plugin.Instance.paranoid = false;
			Plugin.Instance.talkative = false;
			Plugin.Instance.drunk = false;
			GameNetworkManager.Instance.localPlayerController.drunkness = 0f;
			Plugin.Instance.extrovert = false;
			Plugin.Instance.stopHandicapStacking = false;
			Plugin.Instance.weighty = false;
			Plugin.Instance.hyperactive = false;
			Plugin.Instance.conductive = false;
			GameNetworkManager.Instance.localPlayerController.carryWeight = 1f;
			HUDManager.Instance.HideHUD(false);
			IngamePlayerSettings.Instance.LoadSettingsFromPrefs();
			IngamePlayerSettings.Instance.UpdateGameToMatchSettings();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPach
	{
		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		public static void ParsePlayerSentence(ref Terminal __instance)
		{
			if (Plugin.Instance.illiterate)
			{
				__instance.screenText.text = "";
			}
		}
	}
}